Daily News Digest
Live demonstration of the complete integration of all four engineering conventions from conventions/:
- state-file-pattern — STATE.md for cross-run state
- control-flow-separation — Use code for fetching / LLM for summarization
- maker-checker — Checker performs five-dimensional verification of summary quality
- error-compact-pattern — Errors don't explode the context
Workflow
Step 1: Read State (Deterministic) ✅
Read the last run state and idempotency keys from STATE.md.
Step 2: Fetch RSS (Deterministic) ✅
# Zero LLM cost. Only process articles added since the last run.
import feedparser
for url in RSS_SOURCES:
feed = feedparser.parse(url)
new = [entry for entry in feed.entries
if entry.id not in state.get("idempotency_keys", [])]
Step 3: LLM Summary (Probabilistic) ❌
# Limited to 5 articles per day to control token overhead.
for article in new[:5]:
summary = await llm.complete(
f"Summarize in three points, each no more than 20 words:\nTitle: {article.title}\n{article.description}"
)
Step 4: Checker Verification (Probabilistic) ❌
An independent Agent performs five-dimensional scoring of the summaries. Score ≥ 40/50 is PASS.
Step 5: Update State (Deterministic) ✅
state["progress"]["articles_summarized"] += len(passed)
state["idempotency_keys"].extend([a.id for a in processed])
atomic_write("STATE.md", state) # Atomic write + file lock
Error Handling
# Compress errors according to error-compact-pattern
try:
feed = feedparser.parse(url)
except Exception as e:
compact = f"[STEP_FAILED] fetch_rss@{now}\n Error: {type(e).__name__} - {str(e)[:80]}\n Recoverable: YES (retry with backoff)"
context.append(compact)
Output Format
# News Digest {YYYY-MM-DD}
## 📰 {article.title}
- {point 1}
- {point 2}
- {point 3}