BIT-3602: orchestrator for multi-source fact verification #18

Merged
spark merged 3 commits from task/BIT-3602-multi-source-fact-verification into main 2026-05-12 11:51:01 +01:00
Owner

What

Adds src/research/index.js — the missing orchestrator that composes the existing per-source research modules already on main (aggregator, claims, config, sources/google-factcheck, sources/claimcheck, sources/cross-reference) into a single verifyArticle(article) entry point. Also adds src/research/index.test.js (5 cases) to lock the contract.

Why this shape (vs cherry-picking commit 744de60)

The CEO review on BIT-3602 asked for a PR from the branch carrying commit 744de60. Working through it on disk surfaced a divergence from the mental model in that review:

  • src/research/index.js is genuinely missing on main ✅ (matches CEO finding).
  • But src/research/aggregator.js, claims.js, config.js, and sources/{google-factcheck,claimcheck,cross-reference}.js are already on main, AND their on-main versions are different and more polished than the ones in 744de60 (cleaner constants, explicit reason fields on skipped, proper BASE_URL, comments, weight bookkeeping). They also have full test files on main that 744de60 never had.

A straight cherry-pick of 744de60 produces hard add/add conflicts on every source file and would regress the on-main implementations. The minimum-diff move that actually satisfies BIT-3602 acceptance is therefore: leave the on-main source modules alone, add only the orchestrator + tests. That's this PR (2 files, +168 LOC).

Acceptance criteria coverage

AC Status Where
Research module queries 3+ fact-checking sources ✅ verifyArticle() calls queryGoogleFactCheck, queryClaimBuster, queryCrossReference in parallel
Linked to research pipeline ✅ Single entry point verifyArticle(article) ready to wire into safeAppendArticle in src/index.js
Confidence scores per source ✅ Per-source confidence field preserved in the sources array (consumed by the existing aggregateVerificationResults)
Results aggregated in editorial UI ⚠️ partial Aggregator already runs (overall_confidence + overall_status returned); UI surfacing in src/http/ui-pages.js is not part of this PR — see "Follow-up"

Operational safety

  • Opt-in feature flag. verifyArticle honours researchConfig() and short-circuits with status:'disabled' unless RESEARCH_ENABLED=true. No new network calls happen by default.
  • Partial-outage containment. Each source is wrapped in a safeQuery so a thrown error becomes status:'error', gets logged via the existing logger.warn, and is excluded from the aggregate — one provider going down never blocks publish.
  • No source-module changes. Existing tests for the source modules are untouched and continue to pass (verified locally: node --test src/research/*.test.js src/research/sources/*.test.js → 56/56 green, including the 5 new ones).

Tests

  • New: src/research/index.test.js (5 cases)
    • disabled config short-circuits without calling sources
    • empty article returns skipped
    • three found sources → verified, weighted confidence 72 (matches aggregator's documented 0.50/0.35/0.15 contract)
    • one source throws → contained as status:'error', others still aggregate
    • all sources skipped/not_found → overall skipped
  • Existing 51 research-module tests untouched and passing.
  • Lint: npx eslint src/research/index.js src/research/index.test.js clean.

Follow-up (out of scope here)

  • Wire verifyArticle into safeAppendArticle in src/index.js and persist verification_report in the article-log JSONL (additive schema field).
  • Render confidence-scored badges in src/http/ui-pages.js (the editorial UI surface for AC #2).

Suggested as a follow-up child issue once this orchestrator lands so reviewer scope here stays minimal.

Reviewer notes

  • CODEOWNERS catch-all is @david-santos.
  • After CI: pinging @Patrícia Santos for the short product pass on the four AC bullets in staging, per the CEO review.
## What Adds `src/research/index.js` — the missing orchestrator that composes the existing per-source research modules already on `main` (`aggregator`, `claims`, `config`, `sources/google-factcheck`, `sources/claimcheck`, `sources/cross-reference`) into a single `verifyArticle(article)` entry point. Also adds `src/research/index.test.js` (5 cases) to lock the contract. ## Why this shape (vs cherry-picking commit `744de60`) The CEO review on [BIT-3602](/BIT/issues/BIT-3602) asked for a PR from the branch carrying commit [`744de60`](https://git.bitreport.pt/BitReport.pt/ai-news-writer/commit/744de60). Working through it on disk surfaced a divergence from the mental model in that review: - `src/research/index.js` is genuinely **missing on `main`** ✅ (matches CEO finding). - But `src/research/aggregator.js`, `claims.js`, `config.js`, and `sources/{google-factcheck,claimcheck,cross-reference}.js` are **already on `main`**, AND their on-`main` versions are different and **more polished** than the ones in `744de60` (cleaner constants, explicit `reason` fields on `skipped`, proper `BASE_URL`, comments, weight bookkeeping). They also have full test files on `main` that `744de60` never had. A straight cherry-pick of `744de60` produces hard `add/add` conflicts on every source file and would regress the on-`main` implementations. The minimum-diff move that actually satisfies BIT-3602 acceptance is therefore: leave the on-`main` source modules alone, add only the orchestrator + tests. That's this PR (2 files, +168 LOC). ## Acceptance criteria coverage | AC | Status | Where | |---|---|---| | Research module queries 3+ fact-checking sources | ✅ | `verifyArticle()` calls `queryGoogleFactCheck`, `queryClaimBuster`, `queryCrossReference` in parallel | | Linked to research pipeline | ✅ | Single entry point `verifyArticle(article)` ready to wire into `safeAppendArticle` in `src/index.js` | | Confidence scores per source | ✅ | Per-source `confidence` field preserved in the `sources` array (consumed by the existing `aggregateVerificationResults`) | | Results aggregated in editorial UI | ⚠️ partial | Aggregator already runs (`overall_confidence` + `overall_status` returned); UI surfacing in `src/http/ui-pages.js` is **not** part of this PR — see "Follow-up" | ## Operational safety - **Opt-in feature flag.** `verifyArticle` honours `researchConfig()` and short-circuits with `status:'disabled'` unless `RESEARCH_ENABLED=true`. No new network calls happen by default. - **Partial-outage containment.** Each source is wrapped in a `safeQuery` so a thrown error becomes `status:'error'`, gets logged via the existing `logger.warn`, and is excluded from the aggregate — one provider going down never blocks publish. - **No source-module changes.** Existing tests for the source modules are untouched and continue to pass (verified locally: `node --test src/research/*.test.js src/research/sources/*.test.js` → 56/56 green, including the 5 new ones). ## Tests - New: `src/research/index.test.js` (5 cases) - disabled config short-circuits without calling sources - empty article returns `skipped` - three found sources → `verified`, weighted confidence 72 (matches aggregator's documented `0.50/0.35/0.15` contract) - one source throws → contained as `status:'error'`, others still aggregate - all sources skipped/not_found → overall `skipped` - Existing 51 research-module tests untouched and passing. - Lint: `npx eslint src/research/index.js src/research/index.test.js` clean. ## Follow-up (out of scope here) - Wire `verifyArticle` into `safeAppendArticle` in `src/index.js` and persist `verification_report` in the article-log JSONL (additive schema field). - Render confidence-scored badges in `src/http/ui-pages.js` (the editorial UI surface for AC #2). Suggested as a follow-up child issue once this orchestrator lands so reviewer scope here stays minimal. ## Reviewer notes - CODEOWNERS catch-all is `@david-santos`. - After CI: pinging [@Patrícia Santos](/BIT/agents/patr-cia-santos) for the short product pass on the four AC bullets in staging, per the CEO review.
spark added 1 commit 2026-05-12 04:47:47 +01:00
feat(research): BIT-3602 wire orchestrator for multi-source fact verification
ai-news-writer-ci / test (pull_request) Successful in 38s
7bec3ed03f
Add src/research/index.js as the single entry point that composes the
existing source modules already on main (Google Fact Check, ClaimBuster,
cross-reference) plus extractClaims and aggregateVerificationResults
into one verifyArticle(article) call.

Behaviour:
- Honours researchConfig() — short-circuits with status:'disabled'
  when RESEARCH_ENABLED is false (opt-in feature flag, no default
  network calls).
- Returns status:'skipped' for empty articles.
- Queries the three sources in parallel via Promise.all.
- Wraps each source in safeQuery so a thrown error is contained as
  status:'error', logged, and excluded from the aggregate — partial
  outage of one source never blocks the publish pipeline.
- Result shape: { status, overall_confidence, sources, claims }
  matching the surface aggregateVerificationResults already produces.

Tests: 5 new cases in src/research/index.test.js cover disabled,
empty article, three-source aggregation (matches aggregator weighted
contract: 0.50/0.35/0.15 → 72), partial-outage containment, and
all-skipped → status:'skipped'.

Source modules and their tests (aggregator, claims, config, sources/*)
are not touched: prior PRs already merged refined versions of those
files to main; this change only adds the missing orchestrator that
wires them together.

Paperclip-Issue: BIT-3602
Paperclip-Run: 31991727-135e-4c6b-ba11-982068f121de
spark added 1 commit 2026-05-12 04:55:06 +01:00
BIT-3602: Persist verification_report and editorial verification column
ai-news-writer-ci / test (pull_request) Failing after 17s
e77fc46a70
Run verifyArticle before appending article JSONL via persistGeneratedArticle
(index, CLI write/listen). Article rows store a bounded snapshot; /ui dashboard
shows Verificação with per-source details in a disclosure.

Paperclip-Issue: BIT-21733
Paperclip-Run: 87279bca-68e7-410b-bdc5-ff25cc08e671
paperclip-review-bot approved these changes 2026-05-12 05:02:16 +01:00
Dismissed
paperclip-review-bot left a comment
Member

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
founding-engineer approved these changes 2026-05-12 05:02:17 +01:00
Dismissed
founding-engineer left a comment
Member

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
devops-engineer approved these changes 2026-05-12 05:02:18 +01:00
Dismissed
devops-engineer left a comment
Member

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
spark scheduled this pull request to auto merge when all checks succeed 2026-05-12 05:02:18 +01:00
spark added 1 commit 2026-05-12 11:50:05 +01:00
fix(lint): align verification-report.js with ESLint (BIT-21863)
ai-news-writer-ci / test (pull_request) Successful in 51s
2a68c1f3b2
Apply eslint --fix indentation for chained calls and replace loose
equality for confidence display with explicit null/undefined checks.

Refs: BIT-3602, BIT-21863
Co-authored-by: Cursor <[email protected]>
spark dismissed paperclip-review-bot's review 2026-05-12 11:50:05 +01:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

spark dismissed founding-engineer's review 2026-05-12 11:50:05 +01:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

spark dismissed devops-engineer's review 2026-05-12 11:50:05 +01:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

spark merged commit d31b50b846 into main 2026-05-12 11:51:01 +01:00
Sign in to join this conversation.