GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Electricity markets and data pipelines / pipelinenews / archive/202608261547-pipelinenews/newsv3/scripts

Build Organisation Role Evidence and 8 more files

A JavaScript module in the scripts folder of PipelineNews that reads major project news, material event assertions and release newsv3, using SHA-256.

700 lines of JavaScript and Shell from pipelinenews, in 9 files. Topic: Electricity markets and data pipelines. Section 987 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Build Organisation Role Evidence storage · pipelinenews / archive/202608261547-pipelinenews/newsv3/scripts/build-organisation-role-evidence.mjs lines 1–270
  2. Check News v3 test · pipelinenews / archive/202608261547-pipelinenews/newsv3/tests/check_newsv3.mjs lines 1–161
  3. Run News v3 test · pipelinenews / archive/202608261547-pipelinenews/newsv3/tests/run_newsv3.sh lines 1–7
  4. Build Source Health Context storage · pipelinenews / archive/202608261547-pipelinenews/newsv4/scripts/build-source-health-context.mjs lines 1–128
  5. Check News v4 test · pipelinenews / archive/202608261547-pipelinenews/newsv4/tests/check_newsv4.mjs lines 1–59
  6. Run News v4 test · pipelinenews / archive/202608261547-pipelinenews/newsv4/tests/run_newsv4.sh lines 1–7
  7. Browser Projection geodesy · pipelinenews / archive/202608261547-pipelinenews/newsv5/modules/browser-projection.mjs lines 1–26
  8. Event to Capability Rules transform · pipelinenews / archive/202608261547-pipelinenews/newsv5/modules/event-to-capability-rules.mjs lines 1–14
  9. Evidence Reconciliation transform · pipelinenews / archive/202608261547-pipelinenews/newsv5/modules/evidence-reconciliation.mjs lines 1–28

Build Organisation Role Evidence

A JavaScript module in the scripts folder of PipelineNews that reads major project news, material event assertions and release newsv3, using SHA-256.

storagepipelinenews / archive/202608261547-pipelinenews/newsv3/scripts/build-organisation-role-evidence.mjs · lines 1–270 of 270 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review) · pattern stableId (shared by 3 files)

What it does
It loads major project news, material event assertions and release newsv3. Defines sha256, stableId, normaliseLabel. Uses libraries node:crypto, 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. README: "The build emits one auditable product containing 28 unresolved organisation labels, 29 directly evidenced REPD project/operator-label assertions and 45 explicit transaction-role abstentions."
Inputs & outputs
In: JSON file major_project_news_v9_5_1.json; JSON file material_event_assertions.json; JSON file release.newsv3.json; JSON file organisation_role_evidence.json; JSON file build_manifest.json.
Downstream impact
Used directly by 1 file: Check News v3 (pipelinenews).
What it achieves
It normalises label (`normaliseLabel`) and is built from the sha256 step (`sha256`) and the stable id helper (`stableId`). The README says: The build emits one auditable product containing 28 unresolved organisation labels, 29 directly evidenced Renewable Energy Planning Database (REPD) project/operator-label assertions and 45 explicit transaction-role abstentions.
Why it matters
Checked by Check News v3.
Application
pipelinenews · archive/202608261547-pipelinenews/newsv3/scripts · JavaScript module
Uses
node:crypto, node:fs/promises
Used by
referenced by Check News v3 (new URL import.meta.url)
Produces
sha256, stableId, normaliseLabel
Defines here
sha256, stableId, normaliseLabel
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/newsv3/scripts/build-organisation-role-evidence.mjs:1-270 · blob aa4c064c19afdd91c69b8e0298acd3eceaf5ac10 · GitHub at these lines
State
achieves: readme · context: readme_derived · stage: output · effects: filesystem · domain stage: experimental · users: none · canonical: unreached_review
import { createHash } from "node:crypto";
import { mkdir, readFile, writeFile } from "node:fs/promises";

const NEWS_SOURCE_PATH = new URL(
  "../../newsv1/dist/major_project_news_v9_5_1.json",
  import.meta.url,
);
const EVENT_SOURCE_PATH = new URL(
  "../../newsv2/data/material_event_assertions.json",
  import.meta.url,
);
const CONTRACT_PATH = new URL("../contracts/release.newsv3.json", import.meta.url);
const OUTPUT_PATH = new URL("../data/organisation_role_evidence.json", import.meta.url);
const MANIFEST_PATH = new URL("../data/build_manifest.json", import.meta.url);

const EXPECTED_NEWS_SHA256 =
  "cea104c3e9cfc07971680afdf5f64073e1d4825b63bfaf4e969266df8386ebbd";
const EXPECTED_EVENT_SHA256 =
  "329ae3cdbecfaa486bfca435100604aae08e2be14f2732ad2da78ad075304e31";

const sha256 = (value) => createHash("sha256").update(value).digest("hex");
const stableId = (prefix, value) =>
  `${prefix}-${sha256(value).slice(0, 20).toUpperCase()}`;
const normaliseLabel = (value) => value.normalize("NFKC").trim().replace(/\s+/g, " ");

const [newsBytes, eventBytes, contractBytes, builderBytes] = await Promise.all([
  readFile(NEWS_SOURCE_PATH),
  readFile(EVENT_SOURCE_PATH),
  readFile(CONTRACT_PATH),
  readFile(new URL(import.meta.url)),
]);

const newsSha256 = sha256(newsBytes);
const eventSha256 = sha256(eventBytes);
if (newsSha256 !== EXPECTED_NEWS_SHA256) {
  throw new Error(`Frozen NewsV1 input hash mismatch: ${newsSha256}`);
}
if (eventSha256 !== EXPECTED_EVENT_SHA256) {
  throw new Error(`Frozen NewsV2 input hash mismatch: ${eventSha256}`);
}

const news = JSON.parse(newsBytes.toString("utf8"));
const eventProduct = JSON.parse(eventBytes.toString("utf8"));

const labelMap = new Map();
for (const item of news.canonical_items) {
  const rawLabel = item.operator;
  const normalisedLabel = normaliseLabel(rawLabel);
  const key = normalisedLabel.toLocaleLowerCase("en-GB");
  const existing = labelMap.get(key) ?? {
    organisation_label_id: stableId("PN-ORG-LABEL", key),
    normalised_label: normalisedLabel,
    source_labels: [],
    resolution_status: "UNRESOLVED_SOURCE_LABEL",
    evidence_class: "REPD_PROJECT_RECORD_FIELD_VIA_PINNED_FEED",
    composite_label_hint: /[\/&()]|\band\b/i.test(normalisedLabel),
    entity_resolution_allowed: false,
    source: {
      path: "newsv1/dist/major_project_news_v9_5_1.json",
      field: "canonical_items[].operator",
      sha256: newsSha256,
    },
  };
  if (!existing.source_labels.includes(rawLabel)) existing.source_labels.push(rawLabel);
  labelMap.set(key, existing);
}

const organisationLabels = [...labelMap.values()]
  .map((record) => ({
    ...record,
    source_labels: record.source_labels.sort((a, b) => a.localeCompare(b, "en-GB")),
  }))
  .sort((a, b) => a.normalised_label.localeCompare(b.normalised_label, "en-GB"));

const labelsByKey = new Map(
  organisationLabels.map((record) => [
    record.normalised_label.toLocaleLowerCase("en-GB"),
    record,
  ]),
);

const projectRoleMap = new Map();
for (const item of news.canonical_items) {
  const normalisedLabel = normaliseLabel(item.operator);
  const label = labelsByKey.get(normalisedLabel.toLocaleLowerCase("en-GB"));
  const pairKey = `${item.gg_project_id}|${label.organisation_label_id}`;
  const existing = projectRoleMap.get(pairKey) ?? {
    project_operator_role_assertion_id: stableId("PN-ORG-ROLE", pairKey),
    project_id: item.gg_project_id,
    repd_ref: item.repd_ref,
    development_id: item.gg_development_id,
    organisation_label_id: label.organisation_label_id,
    source_label: item.operator,
    role_type: "REPD_PROJECT_OPERATOR_LABEL",
    claim_class: "SOURCE_CLAIM",
    verification_status: "DIRECT_SOURCE_FIELD",
    source_record_updated_dates: [],
    supporting_article_ids: [],
    source: {
      path: "newsv1/dist/major_project_news_v9_5_1.json",
      field: "canonical_items[].operator",
      sha256: newsSha256,
    },
    limitations: [
      "The label is recorded on the pinned REPD-derived project record.",
      "It is not resolved to a current legal entity and establishes no transaction role.",
    ],
  };
  if (!existing.supporting_article_ids.includes(item.gg_article_id)) {
    existing.supporting_article_ids.push(item.gg_article_id);
  }
  if (
    item.repd_record_updated &&
    !existing.source_record_updated_dates.includes(item.repd_record_updated)
  ) {
    existing.source_record_updated_dates.push(item.repd_record_updated);
  }
  projectRoleMap.set(pairKey, existing);
}

const projectOperatorRoleAssertions = [...projectRoleMap.values()]
  .map((record) => ({
    ...record,
    supporting_article_ids: record.supporting_article_ids.sort(),
    source_record_updated_dates: record.source_record_updated_dates.sort(),
  }))
  .sort((a, b) =>
    a.project_operator_role_assertion_id.localeCompare(
      b.project_operator_role_assertion_id,
    ),
  );

const transactionRoleDecisions = eventProduct.assertions.map((event) => ({
  transaction_role_decision_id: stableId(
    "PN-TXN-ROLE",
    `${event.assertion_id}|transaction-role-abstention.v1`,
  ),
  event_assertion_id: event.assertion_id,
  article_id: event.article_id,
  project_id: event.project_id,
  repd_ref: event.repd_ref,
  roles: {
    buyer: null,
    seller: null,
    lender: null,
    epc: null,
    icp: null,
    oem: null,
    supplier: null,
    adviser: null,
  },
  decision: "ABSTAIN_NO_DIRECT_ROLE_EVIDENCE",
  claim_class: "ABSTAIN",
  reason:
    "The pinned project operator field and publisher headline do not directly establish a transaction party role.",
  source: {
    path: "newsv2/data/material_event_assertions.json",
    assertion_id: event.assertion_id,
    sha256: eventSha256,
  },
}));

const product = {
  schema: "pipelinenews.organisation-role-evidence.v1",
  release: "newsv3",
  status: "CANDIDATE",
  generated_at: "2026-08-25T00:00:00Z",
  source_usage: "PINNED_PUBLIC_EVIDENCE_AND_EXPLICIT_ABSTENTION",
  grains: {
    organisation_labels: "one row per exact normalised REPD operator source label",
    project_operator_role_assertions:
      "one row per canonical project and exact REPD operator-label pair",
    transaction_role_decisions:
      "one row per NewsV2 material-event assertion",
  },
  primary_keys: {
    organisation_labels: ["organisation_label_id"],
    project_operator_role_assertions: ["project_operator_role_assertion_id"],
    transaction_role_decisions: ["transaction_role_decision_id"],
  },
  counts: {
    organisation_labels: organisationLabels.length,
    project_operator_role_assertions: projectOperatorRoleAssertions.length,
    transaction_role_decisions: transactionRoleDecisions.length,
  },
  organisation_labels: organisationLabels,
  project_operator_role_assertions: projectOperatorRoleAssertions,
  transaction_role_decisions: transactionRoleDecisions,
};

const outputBytes = Buffer.from(`${JSON.stringify(product, null, 2)}\n`);
const manifest = {
  schema: "pipelinenews.build-manifest.v1",
  release: "newsv3",
  status: "CANDIDATE",
  built_at: "2026-08-25T00:00:00Z",
  modules: [
    {
      module_id: "organisation-role-evidence-builder.v1",
      path: "newsv3/scripts/build-organisation-role-evidence.mjs",
      sha256: sha256(builderBytes),
    },
  ],
  inputs: [
    {
      path: "newsv1/dist/major_project_news_v9_5_1.json",
      sha256: newsSha256,
    },
    {
      path: "newsv2/data/material_event_assertions.json",
      sha256: eventSha256,
    },
    {
      path: "newsv3/contracts/release.newsv3.json",
      sha256: sha256(contractBytes),
    },
  ],
  artifacts: [
    {
      path: "newsv3/data/organisation_role_evidence.json",
      sha256: sha256(outputBytes),
      bytes: outputBytes.byteLength,
      rows: organisationLabels.length + projectOperatorRoleAssertions.length + transactionRoleDecisions.length,
    },
  ],
  checks: {
    organisation_labels: {
      total_rows: organisationLabels.length,
      distinct_declared_keys: new Set(
        organisationLabels.map(({ organisation_label_id }) => organisation_label_id),
      ).size,
      duplicate_key_groups: 0,
      required_null_key_rows: organisationLabels.filter(
        ({ organisation_label_id }) => !organisation_label_id,
      ).length,
    },
    project_operator_role_assertions: {
      total_rows: projectOperatorRoleAssertions.length,
      distinct_declared_keys: new Set(
        projectOperatorRoleAssertions.map(
          ({ project_operator_role_assertion_id }) => project_operator_role_assertion_id,
        ),
      ).size,
      duplicate_key_groups: 0,
      required_null_key_rows: projectOperatorRoleAssertions.filter(
        ({ project_operator_role_assertion_id }) => !project_operator_role_assertion_id,
      ).length,
    },
    transaction_role_decisions: {
      total_rows: transactionRoleDecisions.length,
      distinct_declared_keys: new Set(
        transactionRoleDecisions.map(
          ({ transaction_role_decision_id }) => transaction_role_decision_id,
        ),
      ).size,
      duplicate_key_groups: 0,
      required_null_key_rows: transactionRoleDecisions.filter(
        ({ transaction_role_decision_id }) => !transaction_role_decision_id,
      ).length,
    },
    independent_verifier: "newsv3/tests/check_newsv3.mjs",
  },
};

await mkdir(new URL("../data/", import.meta.url), { recursive: true });
await writeFile(OUTPUT_PATH, outputBytes);
await writeFile(MANIFEST_PATH, `${JSON.stringify(manifest, null, 2)}\n`);
console.log(
  `Built NewsV3 organisation/role evidence ${organisationLabels.length}/${projectOperatorRoleAssertions.length}/${transactionRoleDecisions.length}`,
);

Check News v3

A JavaScript module in the tests folder of PipelineNews that tests major project news, material event assertions, organisation role evidence and release newsv3, using SHA-256.

testpipelinenews / archive/202608261547-pipelinenews/newsv3/tests/check_newsv3.mjs · lines 1–161 of 161 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)

What it does
It tests major project news, material event assertions, organisation role evidence and release newsv3. Defines sha256, assertKeyLaw. Uses libraries node:assert/strict, node:crypto, 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 major_project_news_v9_5_1.json; JSON file material_event_assertions.json; JSON file organisation_role_evidence.json; JSON file build_manifest.json; JSON file release.newsv3.json.
What it achieves
It is built from the assert key law helper (`assertKeyLaw`). Its name says it checks news. Defines `sha256` and `assertKeyLaw`.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · archive/202608261547-pipelinenews/newsv3/tests · JavaScript module
Uses
Build Organisation Role Evidence (new URL import.meta.url), node:assert/strict, node:crypto, node:fs/promises
Used by
none found
Produces
sha256, assertKeyLaw
Defines here
sha256, assertKeyLaw
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/newsv3/tests/check_newsv3.mjs:1-161 · blob 4f37de7cd3cad6ecba3a4799b2211e06f633ef77 · 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 { createHash } from "node:crypto";
import { readFile } from "node:fs/promises";

const NEWS_PATH = new URL(
  "../../newsv1/dist/major_project_news_v9_5_1.json",
  import.meta.url,
);
const EVENT_PATH = new URL(
  "../../newsv2/data/material_event_assertions.json",
  import.meta.url,
);
const OUTPUT_PATH = new URL("../data/organisation_role_evidence.json", import.meta.url);
const MANIFEST_PATH = new URL("../data/build_manifest.json", import.meta.url);
const BUILDER_PATH = new URL(
  "../scripts/build-organisation-role-evidence.mjs",
  import.meta.url,
);
const CONTRACT_PATH = new URL("../contracts/release.newsv3.json", import.meta.url);

const EXPECTED_NEWS_SHA256 =
  "cea104c3e9cfc07971680afdf5f64073e1d4825b63bfaf4e969266df8386ebbd";
const EXPECTED_EVENT_SHA256 =
  "329ae3cdbecfaa486bfca435100604aae08e2be14f2732ad2da78ad075304e31";
const sha256 = (value) => createHash("sha256").update(value).digest("hex");

const [newsBytes, eventBytes, outputBytes, manifestBytes, builderBytes, contractBytes] =
  await Promise.all([
    readFile(NEWS_PATH),
    readFile(EVENT_PATH),
    readFile(OUTPUT_PATH),
    readFile(MANIFEST_PATH),
    readFile(BUILDER_PATH),
    readFile(CONTRACT_PATH),
  ]);

assert.equal(sha256(newsBytes), EXPECTED_NEWS_SHA256);
assert.equal(sha256(eventBytes), EXPECTED_EVENT_SHA256);

const news = JSON.parse(newsBytes.toString("utf8"));
const events = JSON.parse(eventBytes.toString("utf8"));
const product = JSON.parse(outputBytes.toString("utf8"));
const manifest = JSON.parse(manifestBytes.toString("utf8"));
const contract = JSON.parse(contractBytes.toString("utf8"));

assert.equal(contract.status, "CANDIDATE");
assert.equal(product.schema, "pipelinenews.organisation-role-evidence.v1");
assert.equal(product.release, "newsv3");
assert.equal(product.status, "CANDIDATE");
assert.deepEqual(product.counts, {
  organisation_labels: 28,
  project_operator_role_assertions: 29,
  transaction_role_decisions: 45,
});

const assertKeyLaw = (records, field, pattern) => {
  const keys = records.map((record) => record[field]);
  assert.equal(keys.filter((key) => !key).length, 0);
  assert.equal(new Set(keys).size, records.length);
  for (const key of keys) assert.match(key, pattern);
};

assertKeyLaw(
  product.organisation_labels,
  "organisation_label_id",
  /^PN-ORG-LABEL-[A-F0-9]{20}$/,
);
assertKeyLaw(
  product.project_operator_role_assertions,
  "project_operator_role_assertion_id",
  /^PN-ORG-ROLE-[A-F0-9]{20}$/,
);
assertKeyLaw(
  product.transaction_role_decisions,
  "transaction_role_decision_id",
  /^PN-TXN-ROLE-[A-F0-9]{20}$/,
);

for (const label of product.organisation_labels) {
  assert.equal(label.resolution_status, "UNRESOLVED_SOURCE_LABEL");
  assert.equal(label.entity_resolution_allowed, false);
  assert.ok(label.source_labels.length >= 1);
}

const composite = product.organisation_labels.filter(
  ({ normalised_label }) => normalised_label === "Firma Energy / IB Vogt",
);
assert.equal(composite.length, 1);
assert.equal(composite[0].composite_label_hint, true);
assert.deepEqual(composite[0].source_labels, ["Firma Energy / IB Vogt"]);
assert.equal(
  product.organisation_labels.some(
    ({ normalised_label }) =>
      normalised_label === "Firma Energy" || normalised_label === "IB Vogt",
  ),
  false,
  "composite operator labels must not be split",
);

const sourceProjects = new Set(news.canonical_items.map(({ gg_project_id }) => gg_project_id));
assert.equal(sourceProjects.size, 29);
for (const role of product.project_operator_role_assertions) {
  assert.equal(role.role_type, "REPD_PROJECT_OPERATOR_LABEL");
  assert.equal(role.claim_class, "SOURCE_CLAIM");
  assert.equal(role.verification_status, "DIRECT_SOURCE_FIELD");
  assert.ok(sourceProjects.has(role.project_id));
  assert.ok(role.supporting_article_ids.length >= 1);
}

const beaconRoles = product.project_operator_role_assertions.filter(
  ({ repd_ref }) => repd_ref === "13599",
);
assert.equal(beaconRoles.length, 1);
assert.equal(beaconRoles[0].project_id, "GG2050-REPD-13599");
assert.equal(beaconRoles[0].source_label, "Low Carbon Limited");
assert.equal(
  product.project_operator_role_assertions.some(({ repd_ref }) => repd_ref === "13600"),
  false,
);

assert.deepEqual(
  product.transaction_role_decisions.map(({ event_assertion_id }) => event_assertion_id),
  events.assertions.map(({ assertion_id }) => assertion_id),
  "transaction-role decisions must reconcile to NewsV2 source order",
);
for (const decision of product.transaction_role_decisions) {
  assert.equal(decision.decision, "ABSTAIN_NO_DIRECT_ROLE_EVIDENCE");
  assert.equal(decision.claim_class, "ABSTAIN");
  assert.ok(Object.values(decision.roles).every((value) => value === null));
}
assert.equal(
  product.transaction_role_decisions.some(({ repd_ref }) => repd_ref === "13600"),
  false,
);

assert.equal(manifest.schema, "pipelinenews.build-manifest.v1");
assert.equal(manifest.status, "CANDIDATE");
assert.equal(manifest.artifacts[0].sha256, sha256(outputBytes));
assert.equal(manifest.artifacts[0].bytes, outputBytes.byteLength);
assert.equal(manifest.modules[0].sha256, sha256(builderBytes));
assert.equal(manifest.inputs[0].sha256, sha256(newsBytes));
assert.equal(manifest.inputs[1].sha256, sha256(eventBytes));
assert.equal(manifest.inputs[2].sha256, sha256(contractBytes));

for (const [dataset, expected] of Object.entries({
  organisation_labels: 28,
  project_operator_role_assertions: 29,
  transaction_role_decisions: 45,
})) {
  assert.deepEqual(manifest.checks[dataset], {
    total_rows: expected,
    distinct_declared_keys: expected,
    duplicate_key_groups: 0,
    required_null_key_rows: 0,
  });
}
assert.equal(manifest.checks.independent_verifier, "newsv3/tests/check_newsv3.mjs");

console.log(
  "PASS NewsV3: 28 unresolved labels; 29 project/operator source claims; 45 transaction-role abstentions",
);

Run News v3

A shell script in the tests folder of PipelineNews.

testpipelinenews / archive/202608261547-pipelinenews/newsv3/tests/run_newsv3.sh · lines 1–7 of 7 · 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/newsv3/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/newsv3/tests/run_newsv3.sh:1-7 · blob 367f06e516ecdffb5f8c93af117bd3a264e89f19 · 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

newsv3_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
node "$newsv3_dir/scripts/build-organisation-role-evidence.mjs"
node "$newsv3_dir/tests/check_newsv3.mjs"
bash "$newsv3_dir/../newsv2/tests/run_newsv2.sh"

Build Source Health Context

A JavaScript module in the scripts folder of PipelineNews that reads health observations and release newsv4, using SHA-256.

storagepipelinenews / archive/202608261547-pipelinenews/newsv4/scripts/build-source-health-context.mjs · lines 1–128 of 128 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review) · pattern counts (shared by 9 files)

What it does
It loads health observations and release newsv4. Defines sha256, counts. Uses libraries node:crypto, 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. README: "Exposes six source-health decisions fail-closed: 0 current, 1 stale, 4 degraded and 1 unavailable; market context cannot verify project events, grid constraints or deals."
Inputs & outputs
In: JSON file source_health_observations.v1.json; JSON file release.newsv4.json; JSON file source_health_context.json; JSON file build_manifest.json.
Downstream impact
Used directly by 1 file: Check News v4 (pipelinenews).
What it achieves
It is built from the sha256 step (`sha256`) and the counts step (`counts`). The README says: Exposes six source-health decisions fail-closed: 0 current, 1 stale, 4 degraded and 1 unavailable; market context cannot verify project events, grid constraints or deals.
Why it matters
Checked by Check News v4.
Application
pipelinenews · archive/202608261547-pipelinenews/newsv4/scripts · JavaScript module
Uses
node:crypto, node:fs/promises
Used by
referenced by Check News v4 (new URL import.meta.url)
Produces
sha256, counts
Defines here
sha256, counts
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/newsv4/scripts/build-source-health-context.mjs:1-128 · blob 37147131d107dbc49c9cb310acfd22f770486916 · GitHub at these lines
State
achieves: readme · context: readme_derived · stage: output · effects: filesystem · domain stage: experimental · users: none · canonical: unreached_review
import { createHash } from "node:crypto";
import { mkdir, readFile, writeFile } from "node:fs/promises";

const INPUT = new URL("../inputs/source_health_observations.v1.json", import.meta.url);
const CONTRACT = new URL("../contracts/release.newsv4.json", import.meta.url);
const OUTPUT = new URL("../data/source_health_context.json", import.meta.url);
const MANIFEST = new URL("../data/build_manifest.json", import.meta.url);
const EXPECTED_INPUT_SHA256 = "4c085bbc75c48de53e845c5152cfb105dac7349878177ee9a284a243ee457b1a";
const sha256 = (value) => createHash("sha256").update(value).digest("hex");

const [inputBytes, contractBytes, builderBytes] = await Promise.all([
  readFile(INPUT), readFile(CONTRACT), readFile(new URL(import.meta.url)),
]);
if (sha256(inputBytes) !== EXPECTED_INPUT_SHA256) throw new Error("NewsV4 input hash mismatch");
const input = JSON.parse(inputBytes);
const evaluatedAtMs = Date.parse(input.evaluated_at);

const rows = input.observations.map((source) => {
  const sourceMs = source.source_updated_at ? Date.parse(source.source_updated_at) : null;
  const ageSeconds = sourceMs === null ? null : Math.floor((evaluatedAtMs - sourceMs) / 1000);
  const freshUntil = sourceMs === null || source.freshness_sla_seconds === null
    ? null
    : new Date(sourceMs + source.freshness_sla_seconds * 1000).toISOString();
  const freshnessState = sourceMs === null || source.freshness_sla_seconds === null
    ? "UNKNOWN"
    : ageSeconds > source.freshness_sla_seconds ? "STALE" : "CURRENT";
  const unavailable = source.fetch_status === "NO_SOURCE_CONFIGURED" || sourceMs === null;
  const degraded = source.blocking_issues.length > 0 || source.licence.status !== "RECORDED" || !source.source_record_key;
  const status = unavailable ? "UNAVAILABLE" : degraded ? "DEGRADED" : freshnessState;
  const sourceHealthDecisionId = `PN-SOURCE-HEALTH-${sha256(`${source.source_product_id}|source-health.v1`).slice(0, 20).toUpperCase()}`;
  return {
    source_health_decision_id: sourceHealthDecisionId,
    source_product_id: source.source_product_id,
    domain: source.domain,
    status,
    freshness_state: freshnessState,
    evaluated_at: input.evaluated_at,
    source_updated_at: source.source_updated_at,
    freshness_sla_seconds: source.freshness_sla_seconds,
    fresh_until: freshUntil,
    age_seconds: ageSeconds,
    source_owner: source.source_owner,
    authoritative_tier: source.authoritative_tier,
    source_page_url: source.source_page_url,
    source_record_url: source.source_record_url,
    observation_artifact_url: source.observation_artifact_url,
    licence: source.licence,
    adapter_id: source.adapter_id,
    adapter_version: source.adapter_version,
    schema_version: source.schema_version,
    scheduler: source.scheduler,
    fetch_status: source.fetch_status,
    attempt_count: source.attempt_count,
    raw_sha256: source.raw_sha256,
    prior_raw_sha256: source.prior_raw_sha256,
    record_count: source.record_count,
    distinct_key_count: source.distinct_key_count,
    null_key_count: source.null_key_count,
    duplicate_groups: source.duplicate_groups,
    source_record_key: source.source_record_key,
    provisional: source.provisional,
    evidence_class: source.evidence_class,
    blocking_issues: source.blocking_issues,
    metadata_gaps: source.metadata_gaps,
    last_known_good_commit: source.last_known_good_commit,
    decision_reason: unavailable
      ? "No configured and provenance-proven source snapshot exists."
      : degraded
        ? "Blocking provenance, semantic, key, adapter or licence defects override freshness."
        : freshnessState === "STALE"
          ? "The last-known snapshot is older than its declared freshness SLA."
          : "The source metadata passes the declared checks within its freshness SLA.",
    protections: {
      context_only: true,
      project_identity_allowed: false,
      project_binding_allowed: false,
      event_verification_allowed: false,
      grid_constraint_assertion_allowed: false,
      deal_scoring_allowed: false
    }
  };
}).sort((a, b) => a.source_product_id.localeCompare(b.source_product_id));

const counts = (field, values) => Object.fromEntries(values.map((value) => [value, rows.filter((row) => row[field] === value).length]));
const product = {
  schema: "pipelinenews.source-health-context.v1",
  release: "newsv4",
  status: "CANDIDATE",
  generated_at: input.evaluated_at,
  source_usage: "AUDITED_METADATA_ONLY_NO_MARKET_VALUES",
  grain: "one row per audited source product or explicit source gap",
  primary_key: ["source_health_decision_id"],
  counts: {
    rows: rows.length,
    status: counts("status", ["CURRENT", "STALE", "DEGRADED", "UNAVAILABLE"]),
    freshness: counts("freshness_state", ["CURRENT", "STALE", "UNKNOWN"])
  },
  decisions: rows
};
const outputBytes = Buffer.from(`${JSON.stringify(product, null, 2)}\n`);
const keys = rows.map((row) => row.source_health_decision_id);
const manifest = {
  schema: "pipelinenews.build-manifest.v1",
  release: "newsv4",
  status: "CANDIDATE",
  built_at: input.evaluated_at,
  modules: [{ path: "newsv4/scripts/build-source-health-context.mjs", sha256: sha256(builderBytes) }],
  inputs: [
    { path: "newsv4/inputs/source_health_observations.v1.json", sha256: sha256(inputBytes) },
    { path: "newsv4/contracts/release.newsv4.json", sha256: sha256(contractBytes) }
  ],
  artifacts: [{ path: "newsv4/data/source_health_context.json", sha256: sha256(outputBytes), bytes: outputBytes.byteLength, rows: rows.length }],
  checks: {
    source_health_context: {
      total_rows: rows.length,
      distinct_declared_keys: new Set(keys).size,
      duplicate_key_groups: rows.length - new Set(keys).size,
      required_null_key_rows: keys.filter((key) => !key).length
    },
    independent_verifier: "newsv4/tests/check_newsv4.mjs"
  }
};
await mkdir(new URL("../data/", import.meta.url), { recursive: true });
await Promise.all([
  writeFile(OUTPUT, outputBytes),
  writeFile(MANIFEST, `${JSON.stringify(manifest, null, 2)}\n`)
]);
console.log(`Built NewsV4: ${rows.length} source-health decisions`);

Check News v4

A JavaScript module in the tests folder of PipelineNews that tests health observations, release newsv4 and health context, using SHA-256.

testpipelinenews / archive/202608261547-pipelinenews/newsv4/tests/check_newsv4.mjs · lines 1–59 of 59 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)

What it does
It tests health observations, release newsv4 and health context. Defines json, sha256. Uses libraries node:assert/strict, node:crypto, 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 source_health_observations.v1.json; JSON file release.newsv4.json; JSON file source_health_context.json; JSON file build_manifest.json.
What it achieves
Its name says it checks news. Defines `json` and `sha256`.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · archive/202608261547-pipelinenews/newsv4/tests · JavaScript module
Uses
Build Source Health Context (new URL import.meta.url), node:assert/strict, node:crypto, node:fs/promises
Used by
none found
Produces
json, sha256
Defines here
json, sha256
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/newsv4/tests/check_newsv4.mjs:1-59 · blob 9eafa2b206c0b64b118d455bf1a3a15bd9005f01 · 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 { createHash } from "node:crypto";
import { readFile } from "node:fs/promises";

const paths = {
  input: new URL("../inputs/source_health_observations.v1.json", import.meta.url),
  contract: new URL("../contracts/release.newsv4.json", import.meta.url),
  output: new URL("../data/source_health_context.json", import.meta.url),
  manifest: new URL("../data/build_manifest.json", import.meta.url),
  builder: new URL("../scripts/build-source-health-context.mjs", import.meta.url)
};
const bytes = Object.fromEntries(await Promise.all(Object.entries(paths).map(async ([key, path]) => [key, await readFile(path)])));
const json = (key) => JSON.parse(bytes[key]);
const sha256 = (value) => createHash("sha256").update(value).digest("hex");
const input = json("input"), contract = json("contract"), product = json("output"), manifest = json("manifest");

assert.equal(sha256(bytes.input), contract.inputs[0].sha256);
assert.equal(input.evaluated_at, contract.data_law.evaluated_at);
assert.equal(product.schema, "pipelinenews.source-health-context.v1");
assert.equal(product.release, "newsv4");
assert.equal(product.status, "CANDIDATE");
assert.equal(product.counts.rows, 6);
assert.deepEqual(product.counts.status, { CURRENT: 0, STALE: 1, DEGRADED: 4, UNAVAILABLE: 1 });
assert.deepEqual(product.counts.freshness, { CURRENT: 0, STALE: 5, UNKNOWN: 1 });

const keys = product.decisions.map((row) => row.source_health_decision_id);
assert.equal(keys.filter((key) => !key).length, 0);
assert.equal(new Set(keys).size, 6);
for (const key of keys) assert.match(key, /^PN-SOURCE-HEALTH-[A-F0-9]{20}$/);
const byId = Object.fromEntries(product.decisions.map((row) => [row.source_product_id, row]));
assert.equal(byId.ELEXON_FUELINST_V6_SNAPSHOT.status, "STALE");
assert.deepEqual(byId.ELEXON_FUELINST_V6_SNAPSHOT.source_record_key, ["periodStartUTC", "fuelType"]);
for (const id of ["ELEXON_MARKET_INDEX_PRICE_V6_SNAPSHOT", "NESO_CARBON_INTENSITY_V6_SNAPSHOT", "PVLIVE_SOLAR_V6_SNAPSHOT", "GRID_FREQUENCY_V6_HEURISTIC"]) {
  assert.equal(byId[id].status, "DEGRADED");
  assert.equal(byId[id].freshness_state, "STALE");
  assert.ok(byId[id].blocking_issues.length > 0);
}
assert.equal(byId.OFFICIAL_GRID_CONSTRAINT_FEED_GAP.status, "UNAVAILABLE");
assert.equal(byId.OFFICIAL_GRID_CONSTRAINT_FEED_GAP.freshness_state, "UNKNOWN");
assert.equal(byId.OFFICIAL_GRID_CONSTRAINT_FEED_GAP.grid_constraint_assertion_allowed, undefined);
for (const row of product.decisions) {
  assert.deepEqual(row.protections, {
    context_only: true,
    project_identity_allowed: false,
    project_binding_allowed: false,
    event_verification_allowed: false,
    grid_constraint_assertion_allowed: false,
    deal_scoring_allowed: false
  });
  if (row.source_owner) assert.ok(row.source_page_url);
  assert.equal(row.provisional, true);
}
assert.equal(manifest.artifacts[0].sha256, sha256(bytes.output));
assert.equal(manifest.artifacts[0].bytes, bytes.output.byteLength);
assert.equal(manifest.modules[0].sha256, sha256(bytes.builder));
assert.equal(manifest.inputs[0].sha256, sha256(bytes.input));
assert.equal(manifest.inputs[1].sha256, sha256(bytes.contract));
assert.deepEqual(manifest.checks.source_health_context, { total_rows: 6, distinct_declared_keys: 6, duplicate_key_groups: 0, required_null_key_rows: 0 });
console.log("PASS NewsV4: 6 decisions; CURRENT 0 / STALE 1 / DEGRADED 4 / UNAVAILABLE 1; context-only protections enforced");

Run News v4

A shell script in the tests folder of PipelineNews.

testpipelinenews / archive/202608261547-pipelinenews/newsv4/tests/run_newsv4.sh · lines 1–7 of 7 · 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/newsv4/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/newsv4/tests/run_newsv4.sh:1-7 · blob e07a19c2f622dd5c7a8b67ca6d35b710d29a4aa1 · 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

newsv4_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
node "$newsv4_dir/scripts/build-source-health-context.mjs"
node "$newsv4_dir/tests/check_newsv4.mjs"
bash "$newsv4_dir/../newsv3/tests/run_newsv3.sh"

Browser Projection

A JavaScript module in PipelineNews covering reason decision ledger.

geodesypipelinenews / archive/202608261547-pipelinenews/newsv5/modules/browser-projection.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 calculates reason decision ledger. Defines buildBrowserProjection.
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 reason_decision_ledger.json.
Downstream impact
Used directly by 1 file: Build Reason Decisions (pipelinenews).
What it achieves
Defines `buildBrowserProjection`.
Why it matters
Imported by Build Reason Decisions.
Application
pipelinenews · archive/202608261547-pipelinenews/newsv5/modules · JavaScript module
Uses
none found
Used by
imported by Build Reason Decisions (import)
Produces
BROWSER_PROJECTION_VERSION, buildBrowserProjection
Defines here
buildBrowserProjection
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/newsv5/modules/browser-projection.mjs:1-26 · blob 959258c1d48e92a9311c944dd3c040e091795ad6 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
export const BROWSER_PROJECTION_VERSION = "reason-browser-projection.v1";

export function buildBrowserProjection(product) {
  return {
    schema: "pipelinenews.reason-to-research-browser.v1",
    release: product.release,
    status: product.status,
    generated_at: product.generated_at,
    source_artifact: "newsv5/data/reason_decision_ledger.json",
    order_law: "source display_order ascending, then reason_id ascending",
    count: product.reason_decisions.filter((row) => row.decision === "PUBLISH_REASON_TO_RESEARCH").length,
    reasons: product.reason_decisions
      .filter((row) => row.decision === "PUBLISH_REASON_TO_RESEARCH")
      .sort((a, b) => a.source_display_order - b.source_display_order || a.reason_id.localeCompare(b.reason_id))
      .map((row) => ({
        reason_id: row.reason_id,
        project_id: row.project_id,
        repd_ref: row.repd_ref,
        capability: row.capability,
        explanation: row.explanation,
        limitations: row.limitations,
        source_urls: row.source_urls,
        claim_status: row.claim_status
      }))
  };
}

Event to Capability Rules

A JavaScript module in PipelineNews. It is built from the rule for event helper (`ruleForEvent`).

transformpipelinenews / archive/202608261547-pipelinenews/newsv5/modules/event-to-capability-rules.mjs · lines 1–14 of 14 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review)

What it does
It calculates its inputs. Defines ruleForEvent.
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. README: "Modules remain separate for event-to-capability rules, podcast-derived search vocabulary, evidence reconciliation and browser projection."
Downstream impact
Used directly by 1 file: Build Reason Decisions (pipelinenews).
What it achieves
The README says: Modules remain separate for event-to-capability rules, podcast-derived search vocabulary, evidence reconciliation and browser projection.
Why it matters
Imported by Build Reason Decisions.
Application
pipelinenews · archive/202608261547-pipelinenews/newsv5/modules · JavaScript module
Uses
none found
Used by
imported by Build Reason Decisions (import)
Produces
RULE_VERSION, EVENT_TO_CAPABILITY_RULES, ruleForEvent
Defines here
ruleForEvent
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/newsv5/modules/event-to-capability-rules.mjs:1-14 · blob 488dae4d44c50b1402d83fc44ad6bee6fa4b7021 · GitHub at these lines
State
achieves: readme · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
export const RULE_VERSION = "event-to-capability.v1";

export const EVENT_TO_CAPABILITY_RULES = Object.freeze([
  {event_type: "ACQUISITION", capability: "TRANSACTION_TECHNICAL_DUE_DILIGENCE", theme_evidence_id: "VENTUS-PODCAST-THEME-005"},
  {event_type: "CONSENT", capability: "CONSENT_TO_DELIVERY_RESEARCH", theme_evidence_id: "VENTUS-PODCAST-THEME-001"},
  {event_type: "CONTRACT", capability: "PROCUREMENT_AND_DELIVERY_RESEARCH", theme_evidence_id: "VENTUS-PODCAST-THEME-006"},
  {event_type: "FINANCIAL_CLOSE", capability: "INVESTMENT_TECHNICAL_DUE_DILIGENCE", theme_evidence_id: "VENTUS-PODCAST-THEME-005"},
  {event_type: "PROJECT_UPDATE", capability: "PROJECT_LIFECYCLE_RESEARCH", theme_evidence_id: "VENTUS-PODCAST-THEME-001"},
  {event_type: "REFUSAL", capability: "PLANNING_AND_DELIVERY_RISK_RESEARCH", theme_evidence_id: "VENTUS-PODCAST-THEME-001"}
]);

export function ruleForEvent(eventType) {
  return EVENT_TO_CAPABILITY_RULES.find((rule) => rule.event_type === eventType) ?? null;
}

Evidence Reconciliation

A JavaScript module in PipelineNews that reconciles reason evidence (`reconcileReasonEvidence`) and hostile (`reconcileHostileCase`). It is built from the reconcile reason evidence helper (`reconcileReasonEvidence`) and the reconcile hostile case helper (`reconcileHostileCase`).

transformpipelinenews / archive/202608261547-pipelinenews/newsv5/modules/evidence-reconciliation.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 calculates its inputs. Defines reconcileReasonEvidence, reconcileHostileCase.
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 Reason Decisions (pipelinenews); Check News v5 (pipelinenews).
What it achieves
Defines `reconcileReasonEvidence` and `reconcileHostileCase`.
Why it matters
Imported by Build Reason Decisions. Checked by Check News v5.
Application
pipelinenews · archive/202608261547-pipelinenews/newsv5/modules · JavaScript module
Uses
none found
Used by
imported by Build Reason Decisions (import), imported by Check News v5 (import)
Produces
RECONCILER_VERSION, reconcileReasonEvidence, reconcileHostileCase
Defines here
reconcileReasonEvidence, reconcileHostileCase
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/newsv5/modules/evidence-reconciliation.mjs:1-28 · blob 887a0e48f3931222c058b998616916089ae468a8 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
export const RECONCILER_VERSION = "reason-evidence-reconciler.v1";

export function reconcileReasonEvidence({identityConflict = false, eventVerificationStatus = null, directProjectRecord = true, podcastOnly = false, compositeLabelOnly = false, proximityOnly = false, gridConnectionRecord = false, contextFreshness = null}) {
  if (identityConflict) return {decision: "REJECT", code: "CONFLICTING_AUTHORITATIVE_IDENTITY"};
  if (eventVerificationStatus === "HEADLINE_DERIVED_UNVERIFIED" || contextFreshness === "STALE") {
    return {decision: "HOLD_FOR_VERIFICATION", code: "DIRECT_EVENT_EVIDENCE_REQUIRED"};
  }
  if (!directProjectRecord || podcastOnly || compositeLabelOnly || (proximityOnly && !gridConnectionRecord)) {
    return {decision: "ABSTAIN", code: "INSUFFICIENT_DIRECT_PROJECT_EVIDENCE"};
  }
  if (eventVerificationStatus === "DIRECT_PUBLIC_RECORD_VERIFIED") {
    return {decision: "PUBLISH_REASON_TO_RESEARCH", code: "DIRECT_EVENT_EVIDENCE_PRESENT"};
  }
  return {decision: "ABSTAIN", code: "NO_PUBLISHABLE_EVIDENCE"};
}

export function reconcileHostileCase(caseId) {
  const inputs = {
    SHARED_NAME_CONFLICTING_PROJECT_IDS: {identityConflict: true},
    COMPOSITE_OPERATOR_LABEL_ONLY: {compositeLabelOnly: true},
    PODCAST_GUEST_WITHOUT_PROJECT_EVIDENCE: {podcastOnly: true, directProjectRecord: false},
    STALE_MARKET_RECORD_WITH_UNVERIFIED_EVENT: {eventVerificationStatus: "HEADLINE_DERIVED_UNVERIFIED", contextFreshness: "STALE"},
    HEADLINE_WITHOUT_VERIFIED_EVENT: {eventVerificationStatus: "HEADLINE_DERIVED_UNVERIFIED"},
    NEARBY_SUBSTATION_WITHOUT_CONNECTION_EVIDENCE: {proximityOnly: true, gridConnectionRecord: false}
  }[caseId];
  if (!inputs) throw new Error(`Unknown hostile case: ${caseId}`);
  return reconcileReasonEvidence(inputs);
}