Add Record and SAPO RSS, Guardian world and BBC handball; cap noisy RSS via maxItems. Document Lusa/wire and ToS notes in AGGREGATOR_OPERATIONS. Paperclip-Agent: José Alves (urlKey jos-alves; id 11179220-3cec-4f0f-880d-2771ff64fce8) Paperclip-Issue: BIT-741 Paperclip-Run: ce6e2b51-1a3f-46f5-b479-2500427a0327 Made-with: Cursor
4.1 KiB
4.1 KiB
Writer pipeline — andebol.net (aggregator-first)
Scope: writer-pipeline/ in this repo. Parent: aggregator epic (Paperclip BIT-709); delivery tracked under BIT-713.
Editorial Standards
All content must follow the Editorial Brief. Key rules:
- Language: European Portuguese (PT-PT) only — no English
- Real news only: verify facts, cite sources, no speculation
- No plagiarism: rewrite from scratch, never copy-paste
- Quality checks: headlines must match content; images must have clear rights
See docs/ANDEBOL_EDITORIAL_BRIEF.md for detailed publication criteria, writing templates, and common pitfalls.
What it does
- Ingest — Pulls configured sources (RSS + optional sitemap/HTML) from
writer-pipeline/config/andebol.net.sources.jsoninto a local JSON store (writer-pipeline/var/aggregated-items.json, gitignored). Portuguese highlights (e.g. Record, SAPO) and international feeds (e.g. Guardian world, BBC handball) extend the shortlist; Lusa and other wires are covered under usage notes indocs/AGGREGATOR_OPERATIONS.md§ Sources, copyright, and wire services (Lusa). - Shortlist — Newest items that are not yet drafted in WordPress and not skipped.
- Editorial filter — Each shortlisted item is evaluated against the Editorial Brief (language, fact-checking, source attribution) before writing. Skip items that do not meet criteria.
- Read path (aggregator-first) — Before any LLM reading step, the writer uses only structured fields from the store (
title,summary,url,sourceFeedId). No full-page fetch is required for the primary path. - Metrics — Each cycle appends one JSON line to
writer-pipeline/var/metrics.jsonlwith estimated read-phase tokens for:- Aggregator path:
aggregatorReadContext()(title + summary + URL + instruction block). - Legacy path: full HTML text fetch per shortlisted URL (for comparison only). If a fetch fails, that item falls back to summary-sized estimate so the cycle still completes.
- Aggregator path:
- Publish — Optional: creates WordPress drafts from the shortlist using Application Passwords (never required for metrics-only runs).
Fallback behaviour
- Per feed: a failing RSS URL is logged in
metrics.errors; other feeds still run. - Per URL (legacy comparison): failed HTML fetch does not block the cycle; aggregator metrics still apply for production reads.
- WP publish: if credentials are missing, the cycle completes with a clear error string and no draft creation.
Commands
cd writer-pipeline
npm install
npm run build
# Ingest + metrics + optional legacy comparison (no WP)
node dist/run-cycle.js --site andebol.net --dry-run --shortlist 10
# Create up to N drafts (needs ANDEBOL_WP_* env)
node dist/run-cycle.js --site andebol.net --publish-max 1 --shortlist 10
Aggregator HTTP API (optional, for cron or external tools):
npm run aggregator
# GET /health
# GET /shortlist?site=andebol.net&limit=10
# GET /search?site=andebol.net&limit=20&q=benfica&max_age_hours=168
# GET /stats
# POST /ingest?site=andebol.net
Set AGGREGATOR_URL on the bridge (e.g. http://127.0.0.1:3310) so writer candidates use this API first; see docs/AGGREGATOR_OPERATIONS.md.
Sample outcome (2026-04-02, dry-run, 5-item shortlist)
| Metric | Value |
|---|---|
tokensReadAggregatorPath |
~675 |
tokensReadLegacyPath |
~6.2k |
| Ratio (legacy ÷ aggregator) | ~9× |
Pricing reference in code uses USD 0.15 / 1M input tokens (token-metrics.ts) for read-phase estimates only — adjust when the production model changes.
Next steps
- Add more
sources[]entries (competition sites, press rooms) and tune dedup via canonical URLs; use per-feedmaxItemson noisy RSS feeds. - Plug a real LLM generation step that receives only
aggregatorReadContext(item)— no full HTML in the prompt unless a human toggles a break-glass flag. - Run
npm run aggregatorunder systemd on the LXC with periodicPOST /ingestand a singlerun-cyclecron for drafts.