In this section
- Register Ingest energy-data · pipelinenews / archive/202608261547-pipelinenews/attributionv1/modules/register-ingest.mjs lines 1–96
- Build Charge Fixture Proof storage · pipelinenews / archive/202608261547-pipelinenews/attributionv1/scripts/build-charge-fixture-proof.mjs lines 1–17
- Build Discrepancy Fixture Proof storage · pipelinenews / archive/202608261547-pipelinenews/attributionv1/scripts/build-discrepancy-fixture-proof.mjs lines 1–17
- Build Register Fixture Proof energy-data · pipelinenews / archive/202608261547-pipelinenews/attributionv1/scripts/build-register-fixture-proof.mjs lines 1–17
- SQL Attribution Discrepancy other · pipelinenews / archive/202608261547-pipelinenews/attributionv1/sql/attribution-discrepancy.sql lines 1–25
- Check Batch5 Attribution test · pipelinenews / archive/202608261547-pipelinenews/attributionv1/tests/check_batch5_attribution.mjs lines 1–28
- Check Batch6 Registers test · pipelinenews / archive/202608261547-pipelinenews/attributionv1/tests/check_batch6_registers.mjs lines 1–26
- Check Batch7 Product test · pipelinenews / archive/202608261547-pipelinenews/attributionv1/tests/check_batch7_product.mjs lines 1–26
- Build Consumer storage · pipelinenews / archive/202608261547-pipelinenews/consumer_v1/scripts/build_consumer.py lines 1–158
- SQL Projections storage · pipelinenews / archive/202608261547-pipelinenews/consumer_v1/sql/projections.sql lines 1–17
- Run Consumer test · pipelinenews / archive/202608261547-pipelinenews/consumer_v1/tests/run_consumer.sh lines 1–5
- Verify Consumer test · pipelinenews / archive/202608261547-pipelinenews/consumer_v1/tests/verify_consumer.py lines 1–74
- Capture Recapture transform · pipelinenews / archive/202608261547-pipelinenews/discoveryv1/modules/capture-recapture.mjs lines 1–39
- Credibility transform · pipelinenews / archive/202608261547-pipelinenews/discoveryv1/modules/credibility.mjs lines 1–58
- Discovery Ledger transform · pipelinenews / archive/202608261547-pipelinenews/discoveryv1/modules/discovery-ledger.mjs lines 1–57
Register Ingest
A JavaScript module in PipelineNews that normalises organisation (`normaliseOrganisationEvent`) and builds register fixture proof (`buildRegisterFixtureProof`), using SHA-256. It normalises organisation event (`normaliseOrganisationEvent`) and builds register fixture proof (`buildRegisterFixtureProof`).
energy-datapipelinenews / archive/202608261547-pipelinenews/attributionv1/modules/register-ingest.mjs · lines 1–96 of 96 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)
- What it does
- It calculates its inputs. Defines sha256, sourceDetails, normaliseOrganisationEvent, ingestRegisterRecords, buildRegisterFixtureProof. Uses libraries node:crypto.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Downstream impact
- Used directly by 2 files: Build Register Fixture Proof (pipelinenews); Check Batch6 Registers (pipelinenews).
- What it achieves
- Defines `sha256`, `sourceDetails`, `normaliseOrganisationEvent` and 2 more.
- Why it matters
- Imported by Build Register Fixture Proof. Checked by Check Batch6 Registers.
- Application
- pipelinenews · archive/202608261547-pipelinenews/attributionv1/modules · JavaScript module
- Uses
- Attribution Ledger (import), node:crypto
- Used by
- imported by Build Register Fixture Proof (import), imported by Check Batch6 Registers (import)
- Produces
- ingestRegisterRecords, buildRegisterFixtureProof
- Defines here
- sha256, sourceDetails, normaliseOrganisationEvent, ingestRegisterRecords, buildRegisterFixtureProof
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/attributionv1/modules/register-ingest.mjs:1-96 · blob c48cb5602521734cde5715b2a19110681cf35c87 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
import { createHash } from "node:crypto";
import { appendAttributions, normaliseAttribution } from "./attribution-ledger.mjs";
const sourcePolicy = Object.freeze({
planit: ["planit.org.uk", "OFFICIAL_PLANNING_AGGREGATOR"],
planning_data: ["planning.data.gov.uk", "OFFICIAL_PLANNING_DATA"],
neso: ["neso.energy", "OFFICIAL_CONNECTION_REGISTER"],
lccc: ["lowcarboncontracts.uk", "OFFICIAL_CFD_REGISTER"],
gazette: ["thegazette.co.uk", "OFFICIAL_STATUTORY_NOTICE"]
});
const sha256 = (value) => createHash("sha256").update(value).digest("hex");
function sourceDetails(record) {
const policy = sourcePolicy[record.source_type];
if (!policy) throw new Error(`unsupported register source: ${record.source_type}`);
const url = new URL(record.evidence_url);
if (url.protocol !== "https:" || !(url.hostname === policy[0] || url.hostname.endsWith(`.${policy[0]}`))) throw new Error(`source URL does not match ${record.source_type} policy`);
return { url, evidenceKind: policy[1] };
}
function normaliseOrganisationEvent(record, details) {
if (!String(record.organisation ?? "").trim()) throw new Error("organisation event requires organisation");
const identity = `${record.gg_project_id}\n${record.organisation}\n${record.event_type}\n${record.source_ref}\n${record.observed_at}`;
return {
organisation_event_id: `PN-ORG-EVENT-${sha256(identity).slice(0, 20).toUpperCase()}`,
repd_ref: String(record.repd_ref),
gg_project_id: record.gg_project_id,
organisation: String(record.organisation).trim(),
company_number: record.company_number ?? null,
event_type: record.event_type,
event_date: record.event_date ?? null,
evidence_url: details.url.toString(),
evidence_domain: details.url.hostname,
evidence_kind: details.evidenceKind,
credibility: 1,
observed_at: record.observed_at
};
}
export function ingestRegisterRecords(records) {
if (!Array.isArray(records)) throw new Error("register records must be an array");
const roles = [];
const organisationEvents = [];
const abstentions = [];
for (const record of records) {
const details = sourceDetails(record);
if (record.source_type === "gazette") {
organisationEvents.push(normaliseOrganisationEvent(record, details));
continue;
}
if (!record.organisation) {
abstentions.push({
source_type: record.source_type,
source_ref: record.source_ref,
gg_project_id: record.gg_project_id,
decision: "ABSTAIN",
reason: "NO_EXPLICIT_ORGANISATION",
observed_at: record.observed_at
});
continue;
}
roles.push(normaliseAttribution({
repd_ref: record.repd_ref,
gg_project_id: record.gg_project_id,
role: record.role,
organisation: record.organisation,
company_number: record.company_number ?? null,
effective_from: record.effective_from ?? null,
effective_to: record.effective_to ?? null,
evidence_url: details.url.toString(),
evidence_kind: details.evidenceKind,
credibility: 1,
observed_at: record.observed_at,
claim_status: "CONFIRMED"
}));
}
return {
roles: appendAttributions([], roles),
organisation_events: organisationEvents.sort((left, right) => left.organisation_event_id.localeCompare(right.organisation_event_id)),
abstentions: abstentions.sort((left, right) => left.source_ref.localeCompare(right.source_ref))
};
}
export function buildRegisterFixtureProof(fixture) {
if (fixture.schema !== "pipelinenews.attribution-register-fixture.v1" || fixture.fixture_only !== true) throw new Error("fixture marker required");
const output = ingestRegisterRecords(fixture.records);
return {
schema: "pipelinenews.attribution-register-fixture-proof.v1",
fixture_only: true,
counts: { roles: output.roles.length, confirmed: output.roles.filter((row) => row.claim_status === "CONFIRMED").length, organisation_events: output.organisation_events.length, abstentions: output.abstentions.length },
...output,
publication_law: { source_role_must_be_explicit: true, contradictions_overwritten: false, gazette_event_inferred_as_delivery_role: false }
};
}
export { sourcePolicy };Build Charge Fixture Proof
A JavaScript module in the scripts folder of PipelineNews that reads charges.
storagepipelinenews / archive/202608261547-pipelinenews/attributionv1/scripts/build-charge-fixture-proof.mjs · lines 1–17 of 17 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)
- What it does
- It loads charges. Uses libraries node:fs/promises. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Inputs & outputs
- In: JSON file charges.v1.json; JSON file charge-fixture-proof.json.
- What it achieves
- Its name says it builds charge fixture proof. It reads `attributionv1/fixtures/charges.v1.json`.
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · archive/202608261547-pipelinenews/attributionv1/scripts · JavaScript module
- Uses
- Attribution Ledger (import), node:fs/promises
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/attributionv1/scripts/build-charge-fixture-proof.mjs:1-17 · blob ba8d7bf782057f9ec533e77ca7d00c2b86bd47d3 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: filesystem · domain stage: experimental · users: none · canonical: unreached_review
import { open, readFile, rename } from "node:fs/promises";
import { buildChargeFixtureProof } from "../modules/attribution-ledger.mjs";
const root = new URL("../../", import.meta.url);
const input = JSON.parse(await readFile(new URL("attributionv1/fixtures/charges.v1.json", root)));
const output = `${JSON.stringify(buildChargeFixtureProof(input), null, 2)}\n`;
const target = new URL("attributionv1/data/charge-fixture-proof.json", root);
const temporary = new URL("attributionv1/data/.charge-fixture-proof.json.tmp", root);
const handle = await open(temporary, "w");
try {
await handle.writeFile(output);
await handle.sync();
} finally {
await handle.close();
}
JSON.parse(await readFile(temporary, "utf8"));
await rename(temporary, target);Build Discrepancy Fixture Proof
A JavaScript module in the scripts folder of PipelineNews.
storagepipelinenews / archive/202608261547-pipelinenews/attributionv1/scripts/build-discrepancy-fixture-proof.mjs · lines 1–17 of 17 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)
- What it does
- It loads data. Uses libraries node:fs/promises. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Inputs & outputs
- In: JSON file discrepancy.v1.json; JSON file discrepancy-fixture-proof.json.
- What it achieves
- Its name says it builds discrepancy fixture proof. It reads `attributionv1/fixtures/discrepancy.v1.json`.
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · archive/202608261547-pipelinenews/attributionv1/scripts · JavaScript module
- Uses
- Discrepancy View (import), node:fs/promises
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/attributionv1/scripts/build-discrepancy-fixture-proof.mjs:1-17 · blob 10a2027aea495cbcf1b32c6e12b45d4fa92b88d5 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: filesystem · domain stage: experimental · users: none · canonical: unreached_review
import { open, readFile, rename } from "node:fs/promises";
import { buildDiscrepancyFixtureProof } from "../modules/discrepancy-view.mjs";
const root = new URL("../../", import.meta.url);
const input = JSON.parse(await readFile(new URL("attributionv1/fixtures/discrepancy.v1.json", root)));
const output = `${JSON.stringify(buildDiscrepancyFixtureProof(input), null, 2)}\n`;
const target = new URL("attributionv1/data/discrepancy-fixture-proof.json", root);
const temporary = new URL("attributionv1/data/.discrepancy-fixture-proof.json.tmp", root);
const handle = await open(temporary, "w");
try {
await handle.writeFile(output);
await handle.sync();
} finally {
await handle.close();
}
JSON.parse(await readFile(temporary, "utf8"));
await rename(temporary, target);Build Register Fixture Proof
A JavaScript module in the scripts folder of PipelineNews that reads register sources.
energy-datapipelinenews / archive/202608261547-pipelinenews/attributionv1/scripts/build-register-fixture-proof.mjs · lines 1–17 of 17 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)
- What it does
- It loads register sources. Uses libraries node:fs/promises. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Inputs & outputs
- In: JSON file register-sources.v1.json; JSON file register-fixture-proof.json.
- What it achieves
- Its name says it builds register fixture proof. It reads `attributionv1/fixtures/register-sources.v1.json`.
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · archive/202608261547-pipelinenews/attributionv1/scripts · JavaScript module
- Uses
- Register Ingest (import), node:fs/promises
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/attributionv1/scripts/build-register-fixture-proof.mjs:1-17 · blob 6a9b6d592601d95fc7bc5b516981f8c918ae4841 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: filesystem · domain stage: experimental · users: none · canonical: unreached_review
import { open, readFile, rename } from "node:fs/promises";
import { buildRegisterFixtureProof } from "../modules/register-ingest.mjs";
const root = new URL("../../", import.meta.url);
const input = JSON.parse(await readFile(new URL("attributionv1/fixtures/register-sources.v1.json", root)));
const output = `${JSON.stringify(buildRegisterFixtureProof(input), null, 2)}\n`;
const target = new URL("attributionv1/data/register-fixture-proof.json", root);
const temporary = new URL("attributionv1/data/.register-fixture-proof.json.tmp", root);
const handle = await open(temporary, "w");
try {
await handle.writeFile(output);
await handle.sync();
} finally {
await handle.close();
}
JSON.parse(await readFile(temporary, "utf8"));
await rename(temporary, target);SQL Attribution Discrepancy
An SQL query in PipelineNews.
otherpipelinenews / archive/202608261547-pipelinenews/attributionv1/sql/attribution-discrepancy.sql · lines 1–25 of 25 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- What it achieves
- No statement of purpose was found in the file, a README line naming it, or its name. Described from its file name only (a candidate, not yet checked against the code).
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · archive/202608261547-pipelinenews/attributionv1/sql · SQL query
- Uses
- none found
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/attributionv1/sql/attribution-discrepancy.sql:1-25 · blob 8c6394b9f82922108608597505065563cd632a4b · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: unknown · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
-- Neutral read model: reported organisation-role claims beside confirmed records.
-- It states the evidence gap and makes no assessment of any person.
select
reported.gg_project_id,
projects.name as project_name,
reported.role,
reported.organisation as reported_organisation,
reported.evidence_url as reported_source,
reported.observed_at as reported_at,
confirmed.organisation as confirmed_organisation,
confirmed.evidence_url as confirmed_source,
projects.lifecycle as project_state_at_claim,
case
when confirmed.organisation is null then 'NO_CONFIRMED_RECORD'
when confirmed.organisation <> reported.organisation then 'CONFLICTS_WITH_CONFIRMED'
else 'CONSISTENT'
end as status
from attribution_roles as reported
left join attribution_roles as confirmed
on confirmed.repd_ref = reported.repd_ref
and confirmed.role = reported.role
and confirmed.claim_status = 'CONFIRMED'
join projects
on projects.repd_ref = reported.repd_ref
where reported.claim_status = 'REPORTED';Check Batch5 Attribution
A JavaScript module in the tests folder of PipelineNews that tests charges and release attributionv1.
testpipelinenews / archive/202608261547-pipelinenews/attributionv1/tests/check_batch5_attribution.mjs · lines 1–28 of 28 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)
- What it does
- It tests charges and release attributionv1. Uses libraries node:assert/strict, node:fs/promises. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Inputs & outputs
- In: JSON file charges.v1.json; JSON file release.attributionv1.json.
- What it achieves
- Its name says it checks Batch5 attribution. It reads `../fixtures/charges.v1.json`.
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · archive/202608261547-pipelinenews/attributionv1/tests · JavaScript module
- Uses
- Attribution Ledger (import), node:assert/strict, node:fs/promises
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/attributionv1/tests/check_batch5_attribution.mjs:1-28 · blob 8f3b86b399972c3ef17a5bf77985b54626df99ed · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem · domain stage: experimental · users: none · canonical: unreached_review
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { appendAttributions, buildChargeFixtureProof, normaliseAttribution } from "../modules/attribution-ledger.mjs";
const fixture = JSON.parse(await readFile(new URL("../fixtures/charges.v1.json", import.meta.url)));
const contract = JSON.parse(await readFile(new URL("../contracts/release.attributionv1.json", import.meta.url)));
const proof = buildChargeFixtureProof(fixture);
assert.equal(contract.feature, "organisational delivery attribution for UK renewable infrastructure");
assert.equal(contract.acceptance.person_key_allowed, false);
assert.equal(contract.acceptance.contradicting_claims_coexist, true);
assert.equal(contract.acceptance.financial_close_inferred_from_charge_alone, false);
assert.equal(proof.fixture_only, true);
assert.equal(proof.counts.roles, 1);
assert.equal(proof.roles[0].role, "LENDER");
assert.equal(proof.roles[0].claim_status, "CONFIRMED");
assert.equal(proof.roles[0].gg_project_id, "GG2050-REPD-17494");
assert.equal(proof.interpretation.financial_close_inferred_from_charge_alone, false);
const reported = normaliseAttribution({ ...proof.roles[0], attribution_id: undefined, organisation: "Fixture Alternative Finance Limited", credibility: 0.3, claim_status: "REPORTED", evidence_url: "https://publisher.example/report", evidence_kind: "INDEXED_SNIPPET" });
const together = appendAttributions(proof.roles, [reported]);
assert.equal(together.length, 2, "contradicting organisations must coexist");
assert.equal(new Set(together.map((row) => row.organisation)).size, 2);
assert.throws(() => normaliseAttribution({ ...reported, person_name: "forbidden" }), /person-keyed field forbidden/);
assert.throws(() => normaliseAttribution({ ...reported, credibility: 0.3, claim_status: "CONFIRMED" }), /tier-one or tier-two/);
assert.equal(Object.keys(proof.roles[0]).some((key) => /person|individual/iu.test(key)), false);
console.log("PASS AttributionV1 batch 5: organisation-only roles; official charge evidence; contradictions coexist; no financial-close overreach");Check Batch6 Registers
A JavaScript module in the tests folder of PipelineNews that tests register sources and register ingest.
testpipelinenews / archive/202608261547-pipelinenews/attributionv1/tests/check_batch6_registers.mjs · lines 1–26 of 26 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)
- What it does
- It tests register sources and register ingest. Uses libraries node:assert/strict, node:fs/promises. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Inputs & outputs
- In: JSON file register-sources.v1.json; JSON file register-ingest.v1.json.
- What it achieves
- Its name says it checks Batch6 registers. It reads `../fixtures/register-sources.v1.json`.
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · archive/202608261547-pipelinenews/attributionv1/tests · JavaScript module
- Uses
- Register Ingest (import), node:assert/strict, node:fs/promises
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/attributionv1/tests/check_batch6_registers.mjs:1-26 · blob b71f2cd87f74a48c213e6f014da985039bc5d3ea · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem · domain stage: experimental · users: none · canonical: unreached_review
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { buildRegisterFixtureProof, ingestRegisterRecords } from "../modules/register-ingest.mjs";
const fixture = JSON.parse(await readFile(new URL("../fixtures/register-sources.v1.json", import.meta.url)));
const contract = JSON.parse(await readFile(new URL("../contracts/register-ingest.v1.json", import.meta.url)));
const proof = buildRegisterFixtureProof(fixture);
assert.equal(contract.source_law.official_register_credibility, 1);
assert.equal(contract.source_law.role_must_be_explicit_in_source_record, true);
assert.equal(proof.fixture_only, true);
assert.equal(proof.counts.roles, 4);
assert.equal(proof.counts.confirmed, 4);
assert.equal(proof.counts.organisation_events, 1);
assert.equal(proof.counts.abstentions, 1);
assert.equal(proof.roles.every((row) => row.gg_project_id === "GG2050-REPD-17494"), true);
assert.equal(proof.roles.every((row) => row.claim_status === "CONFIRMED" && row.credibility === 1), true);
const owners = proof.roles.filter((row) => row.role === "OWNER");
assert.equal(owners.length, 2);
assert.equal(new Set(owners.map((row) => row.organisation)).size, 2, "officially conflicting owner records must coexist");
assert.equal(proof.organisation_events[0].event_type, "STATUTORY_NOTICE");
assert.equal(proof.roles.some((row) => row.evidence_kind === "OFFICIAL_STATUTORY_NOTICE"), false, "statutory notice must not invent a delivery role");
assert.equal(proof.publication_law.contradictions_overwritten, false);
assert.throws(() => ingestRegisterRecords([{ ...fixture.records[0], evidence_url: "https://publisher.example/item" }]), /source URL does not match/);
console.log("PASS AttributionV1 batch 6: explicit official-register roles confirmed; gaps abstain; contradictions and statutory events retained without inference");Check Batch7 Product
A JavaScript module in the tests folder of PipelineNews that tests discrepancy.
testpipelinenews / archive/202608261547-pipelinenews/attributionv1/tests/check_batch7_product.mjs · lines 1–26 of 26 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)
- What it does
- It tests discrepancy. Uses libraries node:assert/strict, node:fs/promises. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Inputs & outputs
- In: JSON file discrepancy.v1.json.
- What it achieves
- Its name says it checks Batch7 product. It reads `../fixtures/discrepancy.v1.json`.
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · archive/202608261547-pipelinenews/attributionv1/tests · JavaScript module
- Uses
- Discrepancy View (import), Capture Recapture (import), node:assert/strict, node:fs/promises
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/attributionv1/tests/check_batch7_product.mjs:1-26 · blob f810a86e293eef37793afc2614e5f22a1d1e28eb · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem · domain stage: experimental · users: none · canonical: unreached_review
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { buildDiscrepancyFixtureProof } from "../modules/discrepancy-view.mjs";
import { lincolnPetersen, publicationReadiness, weeklyCoverageReport } from "../../discoveryv1/modules/capture-recapture.mjs";
const fixture = JSON.parse(await readFile(new URL("../fixtures/discrepancy.v1.json", import.meta.url)));
const proof = buildDiscrepancyFixtureProof(fixture);
assert.deepEqual(proof.counts, { rows: 3, consistent: 1, conflicts_with_confirmed: 1, no_confirmed_record: 1 });
assert.equal(proof.rows.every((row) => row.gg_project_id === "GG2050-REPD-17494"), true);
assert.equal(proof.rows.every((row) => row.reported_source.startsWith("https://")), true);
assert.equal(proof.publication_law.allegation_or_person_assessment, false);
assert.deepEqual(lincolnPetersen(10, 12, 8), { estimated_total: 15, recall_a: 0.667, recall_b: 0.8, note: "optimistic two-channel estimate; source dependence requires three-channel log-linear review" });
assert.equal(lincolnPetersen(1, 1, 0).estimated_total, null);
const coverage = weeklyCoverageReport({ week_ending: "2026-08-30", search_index_events: 10, register_events: 12, overlap: 8 });
assert.equal(coverage.alert_threshold, 0.8);
assert.equal(coverage.estimate.estimated_total, 15);
const notCurrent = publicationReadiness({ evaluated_at: "2026-08-25T17:01:00Z", latest_discovered_at: "2026-08-25T16:01:00Z", provider_statuses: [{ provider: "brave", status: "NOT_RUN" }] });
assert.equal(notCurrent.status, "CANDIDATE_NOT_CURRENT");
assert.deepEqual(notCurrent.unavailable_providers, ["brave"]);
assert.equal(notCurrent.empty_result_means_no_mentions, false);
const current = publicationReadiness({ evaluated_at: "2026-08-25T17:01:00Z", latest_discovered_at: "2026-08-25T16:01:00Z", provider_statuses: [{ provider: "brave", status: "LIVE" }] });
assert.equal(current.status, "CURRENT");
console.log("PASS batch 7 product logic: neutral discrepancy states; capture-recapture report; freshness fails closed");Build Consumer
A Python module in the scripts folder of PipelineNews that reads release consumer, major project news, regional news and regional decisions, using SHA-256.
storagepipelinenews / archive/202608261547-pipelinenews/consumer_v1/scripts/build_consumer.py · lines 1–158 of 158 · version 2026-08-26 15:47 · Entry point · pattern write_json (shared by 33 files)
- What it does
- It loads release consumer, major project news, regional news and regional decisions. Defines 6 functions or classes, including raw, load, sha_bytes, sha_path, write_json. Uses libraries hashlib, json, re, pathlib, duckdb. Side effects: reads or writes files; uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Inputs & outputs
- In: JSON file release.consumer-v1.json; JSON file major_project_news_v9_5_1.json; JSON file regional_news.json; JSON file regional_decisions.json; JSON file regional_manifest.json; JSON file release.newsv1.json; Parquet file newsv5_reason_decisions.parquet; Parquet file newsv6_dc_sources.parquet.
- Downstream impact
- It is itself an entry point (Python module); no other file was found loading it.
- What it achieves
- It writes JSON (`write_json`) and is built from the sha path helper (`sha_path`) and the URL order hash helper (`url_order_hash`). Its name says it builds consumer. Defines `raw`, `load`, `sha_bytes` and 3 more. It writes `intelligence_overlay.json`.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- pipelinenews · archive/202608261547-pipelinenews/consumer_v1/scripts · Python module
- Uses
- hashlib, json, re, pathlib, duckdb
- Used by
- none found
- Produces
- raw, load, sha_bytes, sha_path, write_json, url_order_hash
- Defines here
- raw, load, sha_bytes, sha_path, write_json, url_order_hash
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/consumer_v1/scripts/build_consumer.py:1-158 · blob 1ba92d4909d463f9fb6f82c3bae9fb0096cc9494 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: filesystem, storage · domain stage: experimental · users: none · canonical: production_core
#!/usr/bin/env python3
import hashlib
import json
import re
from pathlib import Path
import duckdb
ROOT = Path(__file__).resolve().parents[2]
BASE = ROOT / "consumer_v1"
CONTRACT_PATH = BASE / "contracts/release.consumer-v1.json"
OUT = BASE / "data"
def raw(path):
return path.read_bytes()
def load(path):
return json.loads(raw(path))
def sha_bytes(value):
return hashlib.sha256(value).hexdigest()
def sha_path(path):
return sha_bytes(raw(path))
def write_json(path, value):
path.write_text(json.dumps(value, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
def url_order_hash(rows):
return sha_bytes(("\n".join(row["url"] for row in rows)).encode())
contract = load(CONTRACT_PATH)
expected = contract["expected"]
paths = {
"feed": ROOT / "newsv1/dist/major_project_news_v9_5_1.json",
"regional_news": ROOT / "newsv1/data/v9.7/regional_news.json",
"regional_decisions": ROOT / "newsv1/data/v9.7/regional_decisions.json",
"regional_manifest": ROOT / "newsv1/data/v9.7/regional_manifest.json",
"index": ROOT / "newsv1/index.html",
"mobile_css": ROOT / "newsv1/styles/v9-6-1.css",
"release_contract": ROOT / "newsv1/contracts/release.newsv1.json",
}
for name, path in paths.items():
if sha_path(path) != contract["source"]["newsv1_hashes"][name]:
raise SystemExit(f"frozen NewsV1 hash mismatch: {name}")
manifest = load(ROOT / contract["source"]["parquet_manifest"])
artifact_map = {Path(item["path"]).name: item for item in manifest["artifacts"]}
for filename, digest in contract["source"]["required_parquet_artifacts"].items():
parquet = ROOT / "analytics_v1/parquet" / filename
if artifact_map.get(filename, {}).get("sha256") != digest or sha_path(parquet) != digest:
raise SystemExit(f"Parquet provenance mismatch: {filename}")
queries = {
"reasons_to_research": """SELECT payload_json FROM read_parquet(?) WHERE decision = 'PUBLISH_REASON_TO_RESEARCH' ORDER BY source_display_order, reason_decision_id""",
"data_centre_sources": "SELECT payload_json FROM read_parquet(?) ORDER BY source_id",
"data_centre_observations": "SELECT payload_json FROM read_parquet(?) ORDER BY evidence_id",
"data_centre_link_decisions": "SELECT payload_json FROM read_parquet(?) ORDER BY link_decision_id",
}
files = {
"reasons_to_research": "newsv5_reason_decisions.parquet",
"data_centre_sources": "newsv6_dc_sources.parquet",
"data_centre_observations": "newsv6_dc_observations.parquet",
"data_centre_link_decisions": "newsv6_dc_link_decisions.parquet",
}
connection = duckdb.connect(":memory:")
collections = {}
for name, query in queries.items():
parquet = str(ROOT / "analytics_v1/parquet" / files[name])
collections[name] = [json.loads(row[0]) for row in connection.execute(query, [parquet]).fetchall()]
connection.close()
feed = load(paths["feed"])
regional = load(paths["regional_news"])
regional_manifest = load(paths["regional_manifest"])
html = paths["index"].read_text(encoding="utf-8")
css = paths["mobile_css"].read_text(encoding="utf-8")
all_items = feed["all_items"]
uk_items = feed["canonical_items"]
regional_items = regional["articles"]
beacon = [item for item in uk_items if "Beacon Fen" in item.get("project", "")]
guard = {
"schema": "pipelinenews.consumer-interface-guard.v1",
"release": "consumer_v1",
"status": "PASS",
"generated_at": contract["generated_at"],
"newsv1_action": "NO_CHANGE",
"counts": {
"all_headlines": len(all_items),
"uk_headlines": len(uk_items),
"international_headlines": len(regional_items),
"us": regional_manifest["telemetry"]["by_region"]["US"],
"europe": regional_manifest["telemetry"]["by_region"]["EUROPE"],
"international_other": regional_manifest["telemetry"]["by_region"]["INTERNATIONAL_OTHER"],
},
"url_order_hashes": {
"all": url_order_hash(all_items),
"uk": url_order_hash(uk_items),
"regional": url_order_hash(regional_items),
},
"beacon_fen": {
"matches": len(beacon),
"repd_ref": beacon[0]["repd_ref"] if len(beacon) == 1 else None,
"gg_project_id": beacon[0]["gg_project_id"] if len(beacon) == 1 else None,
},
"interface": {
"project_table_columns": len(re.findall(r"<th(?:\s|>)", html)),
"mobile_horizontal_scroll": bool(re.search(r"\.tablewrap\s*\{[^}]*overflow-x:\s*auto", css, re.S)),
"mobile_columns_preserved": bool(re.search(r"\.tablewrap \.hide-mobile\s*\{[^}]*display:\s*table-cell", css, re.S)),
},
"source_hashes": {name: sha_path(path) for name, path in paths.items()},
}
overlay = {
"schema": "pipelinenews.consumer-intelligence-overlay.v1",
"release": "consumer_v1",
"status": "CANDIDATE",
"generated_at": contract["generated_at"],
"project_signal_action": "NO_CHANGE",
"ordering": "Every collection is produced by the declared DuckDB query and its explicit ORDER BY.",
"counts": {name: len(rows) for name, rows in collections.items()},
**collections,
}
OUT.mkdir(parents=True, exist_ok=True)
write_json(OUT / "intelligence_overlay.json", overlay)
write_json(OUT / "interface_guard.json", guard)
artifacts = []
for name in ("intelligence_overlay.json", "interface_guard.json"):
path = OUT / name
artifacts.append({"path": f"consumer_v1/data/{name}", "sha256": sha_path(path), "bytes": path.stat().st_size})
build_manifest = {
"schema": "pipelinenews.consumer-build-manifest.v1",
"release": "consumer_v1",
"status": "CANDIDATE",
"generated_at": contract["generated_at"],
"contract_sha256": sha_path(CONTRACT_PATH),
"analytics_audit_sha256": sha_path(ROOT / "analytics_v1/reports/parquet_audit.json"),
"artifacts": artifacts,
"checks": {
"explicit_order_queries": 4,
"publishable_reasons": len(collections["reasons_to_research"]),
"data_centre_project_signal_links": 0,
"newsv1_interface_changed": False,
},
}
write_json(OUT / "build_manifest.json", build_manifest)
print("PASS ConsumerV1 build: 4 ordered projections / NewsV1 protected / data-centre namespace isolated")SQL Projections
An SQL query in PipelineNews that reads newsv5 reason decisions, newsv6 DC sources, newsv6 DC observations and newsv6 DC link decisions.
storagepipelinenews / archive/202608261547-pipelinenews/consumer_v1/sql/projections.sql · lines 1–17 of 17 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)
- What it does
- It loads newsv5 reason decisions, newsv6 DC sources, newsv6 DC observations and newsv6 DC link decisions. Side effects: uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Inputs & outputs
- In: Parquet file newsv5_reason_decisions.parquet; Parquet file newsv6_dc_sources.parquet; Parquet file newsv6_dc_observations.parquet; Parquet file newsv6_dc_link_decisions.parquet.
- What it achieves
- It reads `analytics_v1/parquet/newsv5_reason_decisions.parquet`.
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · archive/202608261547-pipelinenews/consumer_v1/sql · SQL query
- Uses
- none found
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/consumer_v1/sql/projections.sql:1-17 · blob b6d64573fbd63aa616aff44fe2a72b207d6085a5 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: storage · domain stage: experimental · users: none · canonical: unreached_review
-- ConsumerV1 publication queries. Physical Parquet scan order is never a display contract.
SELECT payload_json
FROM read_parquet('analytics_v1/parquet/newsv5_reason_decisions.parquet')
WHERE decision = 'PUBLISH_REASON_TO_RESEARCH'
ORDER BY source_display_order, reason_decision_id;
SELECT payload_json
FROM read_parquet('analytics_v1/parquet/newsv6_dc_sources.parquet')
ORDER BY source_id;
SELECT payload_json
FROM read_parquet('analytics_v1/parquet/newsv6_dc_observations.parquet')
ORDER BY evidence_id;
SELECT payload_json
FROM read_parquet('analytics_v1/parquet/newsv6_dc_link_decisions.parquet')
ORDER BY link_decision_id;Run Consumer
A shell script in the tests folder of PipelineNews.
testpipelinenews / archive/202608261547-pipelinenews/consumer_v1/tests/run_consumer.sh · lines 1–5 of 5 · version 2026-08-26 15:47 · Entry point
- What it does
- It tests its inputs. Side effects: starts processes.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Downstream impact
- It is itself an entry point (shell script); no other file was found loading it.
- What it achieves
- No statement of purpose was found in the file, a README line naming it, or its name.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- pipelinenews · archive/202608261547-pipelinenews/consumer_v1/tests · shell script
- Uses
- none found
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/consumer_v1/tests/run_consumer.sh:1-5 · blob 616738272453f0dca460e16725580f7a1a39c00f · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: unknown · effects: process · domain stage: experimental · users: none · canonical: production_core
#!/usr/bin/env bash
set -euo pipefail
python consumer_v1/scripts/build_consumer.py
python consumer_v1/tests/verify_consumer.py
bash newsv1/tests/run_newsv1.shVerify Consumer
A Python module in the tests folder of PipelineNews that tests release consumer, intelligence overlay and interface guard, using SHA-256.
testpipelinenews / archive/202608261547-pipelinenews/consumer_v1/tests/verify_consumer.py · lines 1–74 of 74 · version 2026-08-26 15:47 · Entry point
- What it does
- It tests release consumer, intelligence overlay and interface guard. Defines load, sha. Uses libraries hashlib, json, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Inputs & outputs
- In: JSON file release.consumer-v1.json; JSON file intelligence_overlay.json; JSON file interface_guard.json; JSON file build_manifest.json.
- Downstream impact
- It is itself an entry point (Python module); no other file was found loading it.
- What it achieves
- Its name says it verifies consumer. Defines `load` and `sha`.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- pipelinenews · archive/202608261547-pipelinenews/consumer_v1/tests · Python module
- Uses
- hashlib, json, pathlib
- Used by
- none found
- Produces
- load, sha
- Defines here
- load, sha
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/consumer_v1/tests/verify_consumer.py:1-74 · blob afbe8df87f91cc429667d0ac5a0ae41075f1f8e4 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem · domain stage: experimental · users: none · canonical: production_core
#!/usr/bin/env python3
import hashlib
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
BASE = ROOT / "consumer_v1"
def load(path):
return json.loads(path.read_bytes())
def sha(path):
return hashlib.sha256(path.read_bytes()).hexdigest()
contract = load(BASE / "contracts/release.consumer-v1.json")
expected = contract["expected"]
overlay = load(BASE / "data/intelligence_overlay.json")
guard = load(BASE / "data/interface_guard.json")
manifest = load(BASE / "data/build_manifest.json")
assert contract["status"] == overlay["status"] == manifest["status"] == "CANDIDATE"
assert guard["status"] == "PASS"
assert guard["counts"] == {
"all_headlines": expected["all_headlines"],
"uk_headlines": expected["uk_headlines"],
"international_headlines": expected["international_headlines"],
"us": expected["us"],
"europe": expected["europe"],
"international_other": expected["international_other"],
}
assert guard["url_order_hashes"] == expected["url_order_hashes"]
assert guard["beacon_fen"]["matches"] == 1
assert guard["beacon_fen"]["repd_ref"] == expected["beacon_fen_repd_ref"]
assert guard["beacon_fen"]["gg_project_id"] == "GG2050-REPD-13599"
assert guard["interface"] == {
"project_table_columns": expected["project_table_columns"],
"mobile_horizontal_scroll": True,
"mobile_columns_preserved": True,
}
assert overlay["project_signal_action"] == "NO_CHANGE"
assert overlay["counts"] == {
"reasons_to_research": expected["publishable_reasons"],
"data_centre_sources": expected["data_centre_sources"],
"data_centre_observations": expected["data_centre_observations"],
"data_centre_link_decisions": expected["data_centre_link_decisions"],
}
assert overlay["reasons_to_research"] == []
assert all(row["decision"].startswith("ABSTAIN") for row in overlay["data_centre_link_decisions"])
assert [row["source_id"] for row in overlay["data_centre_sources"]] == sorted(row["source_id"] for row in overlay["data_centre_sources"])
assert [row["evidence_id"] for row in overlay["data_centre_observations"]] == sorted(row["evidence_id"] for row in overlay["data_centre_observations"])
assert [row["link_decision_id"] for row in overlay["data_centre_link_decisions"]] == sorted(row["link_decision_id"] for row in overlay["data_centre_link_decisions"])
forbidden = {"repd_ref", "gg_project_id", "project_id", "project_signal_eligible", "eligible_for_news_signal"}
for collection in ("data_centre_sources", "data_centre_observations", "data_centre_link_decisions"):
assert not any(forbidden.intersection(row) for row in overlay[collection]), f"renewable identity leaked into {collection}"
sql = (BASE / "sql/projections.sql").read_text(encoding="utf-8")
assert sql.upper().count("ORDER BY") == 4
assert "PUBLISH_REASON_TO_RESEARCH" in sql
artifact_map = {item["path"]: item for item in manifest["artifacts"]}
for name in ("intelligence_overlay.json", "interface_guard.json"):
path = BASE / "data" / name
assert artifact_map[f"consumer_v1/data/{name}"]["sha256"] == sha(path)
assert manifest["checks"] == {
"explicit_order_queries": 4,
"publishable_reasons": 0,
"data_centre_project_signal_links": 0,
"newsv1_interface_changed": False,
}
print("PASS ConsumerV1 verifier: 133/45/19/4/9/6, Beacon Fen 13599, 11 columns, mobile scroll, zero domain leakage")Capture Recapture
A JavaScript module in PipelineNews that works with lincoln petersen (`lincolnPetersen`) and weekly coverage report (`weeklyCoverageReport`).
transformpipelinenews / archive/202608261547-pipelinenews/discoveryv1/modules/capture-recapture.mjs · lines 1–39 of 39 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)
- What it does
- It calculates its inputs. Defines lincolnPetersen, weeklyCoverageReport, publicationReadiness.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Downstream impact
- Used directly by 1 file: Check Batch7 Product (pipelinenews).
- What it achieves
- It is built from the lincoln petersen helper (`lincolnPetersen`), the weekly coverage report helper (`weeklyCoverageReport`) and the publication readiness helper (`publicationReadiness`). Defines `lincolnPetersen`, `weeklyCoverageReport` and `publicationReadiness`.
- Why it matters
- Checked by Check Batch7 Product.
- Application
- pipelinenews · archive/202608261547-pipelinenews/discoveryv1/modules · JavaScript module
- Uses
- none found
- Used by
- imported by Check Batch7 Product (import)
- Produces
- lincolnPetersen, weeklyCoverageReport, publicationReadiness
- Defines here
- lincolnPetersen, weeklyCoverageReport, publicationReadiness
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/discoveryv1/modules/capture-recapture.mjs:1-39 · blob 11fdf28c6ba70484f87f44a1e2bbffa1ad566a32 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
export function lincolnPetersen(nA, nB, overlap) {
for (const [name, value] of Object.entries({ nA, nB, overlap })) if (!Number.isInteger(value) || value < 0) throw new Error(`${name} must be a non-negative integer`);
if (overlap > Math.min(nA, nB)) throw new Error("overlap cannot exceed either channel");
if (overlap === 0) return { estimated_total: null, recall_a: null, recall_b: null, note: "no overlap — channels not comparable" };
return {
estimated_total: Math.round((nA * nB) / overlap),
recall_a: Number((overlap / nB).toFixed(3)),
recall_b: Number((overlap / nA).toFixed(3)),
note: "optimistic two-channel estimate; source dependence requires three-channel log-linear review"
};
}
export function weeklyCoverageReport({ week_ending, search_index_events, register_events, overlap }) {
return {
schema: "pipelinenews.discovery-coverage.v1",
week_ending,
channels: { search_index_events, register_events, overlap },
estimate: lincolnPetersen(search_index_events, register_events, overlap),
alert_threshold: 0.8
};
}
export function publicationReadiness({ evaluated_at, latest_discovered_at, maximum_age_hours = 24, provider_statuses = [] }) {
const evaluated = Date.parse(evaluated_at);
const latest = Date.parse(latest_discovered_at);
if (!Number.isFinite(evaluated) || !Number.isFinite(latest)) throw new Error("valid freshness timestamps required");
const ageHours = (evaluated - latest) / 3_600_000;
const unavailable = provider_statuses.filter((row) => row.status !== "LIVE").map((row) => row.provider);
const current = ageHours >= 0 && ageHours <= maximum_age_hours;
return {
status: current && unavailable.length === 0 ? "CURRENT" : "CANDIDATE_NOT_CURRENT",
evaluated_at,
latest_discovered_at,
age_hours: Number(ageHours.toFixed(3)),
maximum_age_hours,
unavailable_providers: unavailable,
empty_result_means_no_mentions: false
};
}Credibility
A JavaScript module in PipelineNews that normalises domain (`normaliseDomain`), using SHA-256.
transformpipelinenews / archive/202608261547-pipelinenews/discoveryv1/modules/credibility.mjs · lines 1–58 of 58 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)
- What it does
- It calculates its inputs. Defines sha256, normaliseDomain, credibilityForDomain, eventConfidence. Uses libraries node:crypto.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Downstream impact
- Used directly by 2 files: Discovery Ledger (pipelinenews); Check Batch3 Normalize Credibility (pipelinenews).
- What it achieves
- It normalises domain (`normaliseDomain`) and is built from the credibility for domain helper (`credibilityForDomain`) and the event confidence helper (`eventConfidence`). Defines `sha256`, `normaliseDomain`, `credibilityForDomain` and 1 more.
- Why it matters
- Imported by Discovery Ledger. Checked by Check Batch3 Normalize Credibility.
- Application
- pipelinenews · archive/202608261547-pipelinenews/discoveryv1/modules · JavaScript module
- Uses
- node:crypto
- Used by
- imported by Discovery Ledger (import), imported by Check Batch3 Normalize Credibility (import)
- Produces
- credibilityForDomain, eventConfidence
- Defines here
- sha256, normaliseDomain, credibilityForDomain, eventConfidence
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/discoveryv1/modules/credibility.mjs:1-58 · blob db0187954a450ec3e418fa984ae26344e5968c1e · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
import { createHash } from "node:crypto";
const scores = new Map(Object.entries({
"gov.uk": 1,
"planninginspectorate.gov.uk": 1,
"planning.data.gov.uk": 1,
"planit.org.uk": 1,
"neso.energy": 1,
"nationalgrideso.com": 1,
"find-and-update.company-information.service.gov.uk": 1,
"thegazette.co.uk": 1,
"lowcarboncontracts.uk": 1,
"ofgem.gov.uk": 1,
"solarpowerportal.co.uk": 0.7,
"energy-storage.news": 0.7,
"current-news.co.uk": 0.7,
"renews.biz": 0.7,
"constructionenquirer.com": 0.7,
"theconstructionindex.co.uk": 0.7,
"pv-magazine.com": 0.7,
"businessgreen.com": 0.7,
"bbc.co.uk": 0.6,
"bbc.com": 0.6,
"theguardian.com": 0.6,
"ft.com": 0.6,
"thetimes.co.uk": 0.6,
"x.com": 0.3,
"medium.com": 0.3
}));
const restrictedApexDigests = new Set([
"68c1e55b7e7549913f34030a5f0d49a94613b05469ac21f5eea1e6cb32cd5eb7"
]);
const sha256 = (value) => createHash("sha256").update(value).digest("hex");
const normaliseDomain = (value) => String(value ?? "").toLowerCase().replace(/^www\./u, "").replace(/\.$/u, "");
export function credibilityForDomain(value) {
const domain = normaliseDomain(value);
const labels = domain.split(".");
const apex = labels.slice(-2).join(".");
if (restrictedApexDigests.has(sha256(apex))) return 0.3;
const matches = [...scores.entries()].filter(([known]) => domain === known || domain.endsWith(`.${known}`));
if (!matches.length) return 0.3;
matches.sort((left, right) => right[0].length - left[0].length);
return matches[0][1];
}
export function eventConfidence(mentions) {
if (!Array.isArray(mentions) || mentions.length === 0) throw new Error("event confidence requires mentions");
const values = mentions.map((mention) => Number(mention.credibility));
if (values.some((value) => !Number.isFinite(value) || value <= 0 || value > 1)) throw new Error("credibility must be in (0, 1]");
const best = Math.max(...values);
const distinct = new Set(mentions.map((mention) => normaliseDomain(mention.source_domain))).size;
const corroboration = Math.min(0.2, 0.05 * Math.max(0, distinct - 1));
return Number(Math.min(1, best + corroboration).toFixed(2));
}
export { scores as credibilityScores };Discovery Ledger
A JavaScript module in PipelineNews.
transformpipelinenews / archive/202608261547-pipelinenews/discoveryv1/modules/discovery-ledger.mjs · lines 1–57 of 57 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review) · pattern buildDiscoveryLedger (shared by 2 files)
- What it does
- It calculates its inputs. Defines buildDiscoveryLedger.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'archive'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Downstream impact
- Used directly by 2 files: Build Discovery Ledger (pipelinenews); Check Batch4 Binding (pipelinenews).
- What it achieves
- Defines `buildDiscoveryLedger`.
- Why it matters
- Imported by Build Discovery Ledger. Checked by Check Batch4 Binding.
- Application
- pipelinenews · archive/202608261547-pipelinenews/discoveryv1/modules · JavaScript module
- Uses
- Credibility (import), Mention Normalizer (import), Matcher Bridge (import)
- Used by
- imported by Build Discovery Ledger (import), imported by Check Batch4 Binding (import)
- Produces
- buildDiscoveryLedger
- Defines here
- buildDiscoveryLedger
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 archive/202608261547-pipelinenews/discoveryv1/modules/discovery-ledger.mjs:1-57 · blob 1b4af97dbd308b4d1f5c3eeb03f7a26f48b381ba · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
import { credibilityForDomain } from "./credibility.mjs";
import { canonicalUrl, clusterMentions, mentionId } from "./mention-normalizer.mjs";
import { matchDiscoveryMention } from "./matcher-bridge.mjs";
export function buildDiscoveryLedger(input) {
if (input.schema !== "pipelinenews.discovery-fixture.v1") throw new Error("unexpected discovery input schema");
if (input.fixture_only !== true) throw new Error("fixture marker required for candidate ledger build");
const rows = input.observations.map((observation) => {
if (Object.hasOwn(observation, "body")) throw new Error("article body storage is forbidden");
const url = canonicalUrl(observation.url);
const sourceDomain = new URL(url).hostname.toLowerCase();
const snippet = String(observation.snippet ?? "").slice(0, 300);
const binding = matchDiscoveryMention({ ...observation, snippet }, input.projects);
const row = {
mention_id: null,
repd_ref: binding.repd_ref,
gg_project_id: binding.gg_project_id,
candidate_gg_project_ids: binding.candidate_gg_project_ids,
canonical_url: url,
source_domain: sourceDomain,
credibility: credibilityForDomain(sourceDomain),
title: observation.title,
snippet,
published_at: observation.published_at ?? null,
discovered_at: observation.discovered_at,
discovery_method: observation.discovery_method,
query_used: observation.query_used,
binding_evidence: { reason: binding.reason, ...binding.binding_evidence },
binding_status: binding.binding_status,
cluster_id: null
};
row.mention_id = mentionId(row);
return row;
});
const clustered = clusterMentions(rows);
if (new Set(clustered.map((row) => row.mention_id)).size !== clustered.length) throw new Error("duplicate mention IDs");
return {
schema: "pipelinenews.discovery-mentions.v1",
release_id: input.release_id,
fixture_only: true,
publication_status: "REGRESSION_FIXTURE_ONLY",
counts: {
observations: clustered.length,
primary_match: clustered.filter((row) => row.binding_status === "PRIMARY_MATCH").length,
abstain: clustered.filter((row) => row.binding_status === "ABSTAIN").length,
rejected: clustered.filter((row) => row.binding_status === "REJECTED").length
},
mentions: clustered,
publication_law: {
repd_mutated: false,
credibility_gates_binding: false,
outbound_result_pages_fetched: false,
article_bodies_stored: false,
abstentions_retained: true
}
};
}