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.
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.
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
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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
Adds
src/research/index.js— the missing orchestrator that composes the existing per-source research modules already onmain(aggregator,claims,config,sources/google-factcheck,sources/claimcheck,sources/cross-reference) into a singleverifyArticle(article)entry point. Also addssrc/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.jsis genuinely missing onmain✅ (matches CEO finding).src/research/aggregator.js,claims.js,config.js, andsources/{google-factcheck,claimcheck,cross-reference}.jsare already onmain, AND their on-mainversions are different and more polished than the ones in744de60(cleaner constants, explicitreasonfields onskipped, properBASE_URL, comments, weight bookkeeping). They also have full test files onmainthat744de60never had.A straight cherry-pick of
744de60produces hardadd/addconflicts on every source file and would regress the on-mainimplementations. The minimum-diff move that actually satisfies BIT-3602 acceptance is therefore: leave the on-mainsource modules alone, add only the orchestrator + tests. That's this PR (2 files, +168 LOC).Acceptance criteria coverage
verifyArticle()callsqueryGoogleFactCheck,queryClaimBuster,queryCrossReferencein parallelverifyArticle(article)ready to wire intosafeAppendArticleinsrc/index.jsconfidencefield preserved in thesourcesarray (consumed by the existingaggregateVerificationResults)overall_confidence+overall_statusreturned); UI surfacing insrc/http/ui-pages.jsis not part of this PR — see "Follow-up"Operational safety
verifyArticlehonoursresearchConfig()and short-circuits withstatus:'disabled'unlessRESEARCH_ENABLED=true. No new network calls happen by default.safeQueryso a thrown error becomesstatus:'error', gets logged via the existinglogger.warn, and is excluded from the aggregate — one provider going down never blocks publish.node --test src/research/*.test.js src/research/sources/*.test.js→ 56/56 green, including the 5 new ones).Tests
src/research/index.test.js(5 cases)skippedverified, weighted confidence 72 (matches aggregator's documented0.50/0.35/0.15contract)status:'error', others still aggregateskippednpx eslint src/research/index.js src/research/index.test.jsclean.Follow-up (out of scope here)
verifyArticleintosafeAppendArticleinsrc/index.jsand persistverification_reportin the article-log JSONL (additive schema field).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
@david-santos.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-982068f121deauto-approve: CI success (gitea_auto_approve_open_prs_once.py)
auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
New commits pushed, approval review dismissed automatically according to repository settings
New commits pushed, approval review dismissed automatically according to repository settings
New commits pushed, approval review dismissed automatically according to repository settings