GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Electricity markets and data pipelines / pipelinenews / archive/202608261547-pipelinenews/objects/js/sha256

Objects — Sha256 and 6 more files

A JavaScript module in PipelineNews that validates metadata observation (`validateMetadataObservation`) and builds discovery ledger (`buildDiscoveryLedger`) (units: MW), using SHA-256. It validates metadata observation (`validateMetadataObservation`) and builds discovery ledger (`buildDiscoveryLedger`).

564 lines of JavaScript from pipelinenews, in 7 files. Topic: Electricity markets and data pipelines. Section 992 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. Objects — Sha256 transform · pipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/60ebe5b31cdb881e61c7275fd3f696b33a4f134c5c0a6e6cd8f1474545156acc.mjs lines 1–124
  2. Objects — Sha256 transform · pipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/8e4a229d0e059a498cafb70648f2bcb5d44c7bc4d114cf98ddcf97d108731b04.mjs lines 1–147
  3. Objects — Sha256 render · pipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/9bce91d7bde247265bdf369416ff4771c4866d3369c22d3b3d9c96aef4a95272.mjs lines 1–37
  4. Objects — Sha256 transform · pipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/bf8b87533cda64fa145de9ca28998b29bf7f863f483a26a78e34fc3272fe9f7d.mjs lines 1–26
  5. Objects — Sha256 transform · pipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/d7c0164d2d767996c45e86d27c4754d4388e4493a00a33e2429c6759cfe9b328.mjs lines 1–138
  6. Objects — Sha256 render · pipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/dca6a33a559496cfb7f0e6141f81e37a25513b1af7976d712dc9e23cf5cc2ee6.mjs lines 1–38
  7. Objects — Sha256 render · pipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/e57f8ead800893c351e9dfac7294b0995b14e9c20fdc5042773f451acfa98136.mjs lines 1–54

Objects — Sha256

A JavaScript module in PipelineNews that works with the Renewable Energy Planning Database (REPD) register. It records references (`recordReferences`), resolves planning binding (`resolvePlanningBinding`) and builds frontier contract (`buildFrontierContract`).

transformpipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/60ebe5b31cdb881e61c7275fd3f696b33a4f134c5c0a6e6cd8f1474545156acc.mjs · lines 1–124 of 124 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review) · pattern resolvePlanningBinding (shared by 2 files)

What it does
It calculates the REPD register. Defines 11 functions or classes, including text, compact, projectRef, projectName, canonicalPlanningAuthority.
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. Domain terms in the code: the REPD register.
What it achieves
Defines `text`, `compact`, `projectRef` and 8 more.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · archive/202608261547-pipelinenews/objects/js/sha256 · JavaScript module
Uses
Objects — Sha256 (import)
Used by
none found
Produces
POLICY_ID, SOURCE_SCORES, normalisePlanningReference, buildReferenceGroups, selectFrontier, sourceHealth, resolvePlanningBinding, buildFrontierContract
Defines here
text, compact, projectRef, projectName, canonicalPlanningAuthority, recordReferences, projectNameMatches, planningAuthorityMatches, primaryMatch, resolvePlanningBinding, buildFrontierContract
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/objects/js/sha256/60ebe5b31cdb881e61c7275fd3f696b33a4f134c5c0a6e6cd8f1474545156acc.mjs:1-124 · blob b0fcf51ec9485ff387b9b6c9db74f523987b4a44 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
import * as previous from "./bf8b87533cda64fa145de9ca28998b29bf7f863f483a26a78e34fc3272fe9f7d.mjs";

export const POLICY_ID = "PN-OFFICIAL-FRONTIER-V3-AUTHORITY-SAFE";
export const SOURCE_SCORES = previous.SOURCE_SCORES;
export const normalisePlanningReference = previous.normalisePlanningReference;
export const buildReferenceGroups = previous.buildReferenceGroups;
export const selectFrontier = previous.selectFrontier;
export const sourceHealth = previous.sourceHealth;

const text = (value) => String(value ?? "").normalize("NFKC").trim();
const compact = (value) => text(value).toUpperCase().replace(/[^A-Z0-9]/g, "");
const projectRef = (project) => text(project.repd_ref || project.Ref_ID || project.ref_id);
const projectName = (project) => text(project.name || project.project_name || project.site_name);

// PlanIt uses a small number of documented service-area labels rather than the
// exact REPD authority label. Keep those mappings explicit and reviewable; do
// not replace this list with substring or fuzzy matching.
const authorityAliases = new Map([
  ["ARGYLL", "ARGYLLANDBUTE"],
  ["BABERGHMIDSUFFOLK", "MIDSUFFOLK"],
  ["DUMFRIES", "DUMFRIESANDGALLOWAY"],
  ["SOUTHWESTDEVON", "WESTDEVON"],
]);

function canonicalPlanningAuthority(value) {
  const normalised = compact(value);
  return authorityAliases.get(normalised) || normalised;
}

function recordReferences(record) {
  return [record.uid, record.reference, record.altid]
    .map(normalisePlanningReference)
    .filter(Boolean);
}

function projectNameMatches(record, project) {
  const name = compact(projectName(project));
  if (name.length < 8) return false;
  const body = compact([record.name, record.description, record.applicant].filter(Boolean).join(" "));
  return body.includes(name);
}

function planningAuthorityMatches(record, project) {
  const observed = canonicalPlanningAuthority(record.area_name);
  const expected = canonicalPlanningAuthority(project.planning_authority);
  if (observed.length < 4 || expected.length < 4) return false;
  return observed === expected;
}

function primaryMatch(project, method) {
  return {
    role: "PRIMARY_MATCH",
    method,
    repd_ref: projectRef(project),
    gg_project_id: text(project.gg_project_id) || `GG2050-REPD-${projectRef(project)}`,
    project_name: projectName(project),
    planning_application_reference: text(project.planning_application_reference),
    planning_authority: text(project.planning_authority) || null,
    news_may_overwrite_official_facts: false,
  };
}

export function resolvePlanningBinding(record, referenceGroup) {
  const recordRefs = new Set(recordReferences(record));
  if (!recordRefs.has(referenceGroup.normalised_reference)) {
    return { role: "ABSTAIN", reason: "PLANNING_REFERENCE_NOT_EXACT" };
  }

  const nameMatches = referenceGroup.projects.filter((project) => projectNameMatches(record, project));
  if (nameMatches.length === 1) return primaryMatch(nameMatches[0], "EXACT_REFERENCE_PLUS_EXACT_PROJECT_NAME");
  if (nameMatches.length > 1) {
    return {
      role: "ABSTAIN",
      reason: "AMBIGUOUS_EXACT_PROJECT_NAME",
      candidate_repd_refs: nameMatches.map(projectRef),
    };
  }

  const authorityMatches = referenceGroup.projects.filter((project) => planningAuthorityMatches(record, project));
  if (authorityMatches.length === 1) return primaryMatch(authorityMatches[0], "EXACT_REFERENCE_PLUS_PLANNING_AUTHORITY");

  return {
    role: "ABSTAIN",
    reason: authorityMatches.length > 1
      ? "AMBIGUOUS_PLANNING_AUTHORITY"
      : "PLANNING_AUTHORITY_OR_PROJECT_NAME_NOT_CONFIRMED",
    candidate_repd_refs: referenceGroup.projects.map(projectRef),
  };
}

export function buildFrontierContract(input) {
  const contract = previous.buildFrontierContract(input);
  const groups = buildReferenceGroups(input.fixture.projects);
  const eastPyeGroup = groups.find((group) => group.normalised_reference === normalisePlanningReference("EN0110014"));
  const duplicateGroup = groups.find((group) => group.projects.length > 1);
  if (!eastPyeGroup || !duplicateGroup) throw new Error("authority-safe binding fixtures incomplete");
  const eastPyeBinding = resolvePlanningBinding(input.fixture.planit_unique, eastPyeGroup);
  const duplicateBinding = resolvePlanningBinding(input.fixture.planit_duplicate, duplicateGroup);
  if (eastPyeBinding.repd_ref !== "17494") throw new Error("East Pye authority-safe regression failed");
  if (duplicateBinding.role !== "ABSTAIN") throw new Error("duplicate planning reference must abstain");

  return {
    ...contract,
    policy_id: POLICY_ID,
    fixture_proof: {
      ...contract.fixture_proof,
      east_pye_binding: eastPyeBinding,
      duplicate_reference_decision: duplicateBinding,
    },
    binding_gate: {
      exact_reference_required: true,
      exact_project_name_or_planning_authority_required: true,
      planning_authority_matching: "EXACT_AFTER_EXPLICIT_ALIAS_MAP",
      planning_authority_aliases: Object.fromEntries(authorityAliases),
      reference_unique_inside_repd_is_not_globally_unique: true,
      capacity_used_for_identity: false,
      ambiguous_action: "ABSTAIN",
    },
    publication_law: {
      ...contract.publication_law,
      cached_bindings_require_current_policy_reclassification: true,
    },
  };
}

Objects — Sha256

A JavaScript module in PipelineNews that validates metadata observation (`validateMetadataObservation`) and builds discovery ledger (`buildDiscoveryLedger`) (units: MW), using SHA-256. It validates metadata observation (`validateMetadataObservation`) and builds discovery ledger (`buildDiscoveryLedger`).

transformpipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/8e4a229d0e059a498cafb70648f2bcb5d44c7bc4d114cf98ddcf97d108731b04.mjs · lines 1–147 of 147 · 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 6 functions or classes, including sha256, invariant, canonicaliseSourceUrl, validateMetadataObservation, discoverSource. 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.
What it achieves
Defines `sha256`, `invariant`, `canonicaliseSourceUrl` and 3 more.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · archive/202608261547-pipelinenews/objects/js/sha256 · JavaScript module
Uses
node:crypto
Used by
mentioned in Standalone (comment link)
Produces
DISCOVERY_POLICY_ID, canonicaliseSourceUrl, discoverSource, buildDiscoveryLedger
Defines here
sha256, invariant, canonicaliseSourceUrl, validateMetadataObservation, discoverSource, 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/objects/js/sha256/8e4a229d0e059a498cafb70648f2bcb5d44c7bc4d114cf98ddcf97d108731b04.mjs:1-147 · blob 49352f07c2729f5e19b53000f8dd29ae1aa833be · 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";

export const DISCOVERY_POLICY_ID = "PN-DISCOVERY-RECALL-FIRST-STRICT-PROMOTION";

const TRACKING_PARAMETERS = new Set([
  "utm_campaign",
  "utm_content",
  "utm_medium",
  "utm_source",
  "utm_term",
]);

const sha256 = (value) => createHash("sha256").update(value).digest("hex");

const requiredNullFields = [
  "headline",
  "summary",
  "body",
  "author",
  "image_url",
  "article_id",
  "project_id",
  "repd_ref",
  "development_id",
  "data_centre_evidence_id",
  "event_type",
  "capacity_mw",
];

const invariant = (condition, message) => {
  if (!condition) throw new Error(message);
};

export function canonicaliseSourceUrl(rawUrl, allowedHosts, canonicalHost) {
  const url = new URL(rawUrl);
  invariant(["http:", "https:"].includes(url.protocol), "source URL must use HTTP(S)");
  invariant(!url.username && !url.password, "source URL credentials are forbidden");
  const hosts = new Set(allowedHosts.map((host) => host.toLowerCase()));
  invariant(hosts.has(url.hostname.toLowerCase()), "source host is not allow-listed");
  invariant(hosts.has(canonicalHost.toLowerCase()), "canonical host is not allow-listed");

  url.protocol = "https:";
  url.hostname = canonicalHost.toLowerCase();
  url.port = "";
  url.hash = "";
  for (const key of [...url.searchParams.keys()]) {
    if (TRACKING_PARAMETERS.has(key.toLowerCase())) url.searchParams.delete(key);
  }
  url.searchParams.sort();
  if (url.pathname.length > 1) url.pathname = url.pathname.replace(/\/+$/, "");
  invariant(/^\/news\/articles\/[a-z0-9]+$/.test(url.pathname), "source URL is not a BBC article path");
  return url.toString();
}

function validateMetadataObservation(observation) {
  invariant(["AGGREGATOR_METADATA", "SYNDICATION_METADATA"].includes(observation.evidence_class), "invalid metadata evidence class");
  invariant(observation.permitted_use === "DISCOVERY_METADATA_ONLY", "metadata observation cannot be promoted");
  invariant(observation.claim_eligible === false, "metadata observation cannot be claim-eligible");
  invariant(new URL(observation.observation_url).protocol === "https:", "metadata observation URL must use HTTPS");
  invariant(typeof observation.observed_title === "string" && observation.observed_title.length > 0, "metadata observation requires a title");
  invariant(Number.isFinite(Date.parse(observation.observed_published_at)), "metadata observation requires an ISO timestamp");
  return { ...observation };
}

export function discoverSource(seed) {
  invariant(seed.input_basis === "USER_PROVIDED_URL", "unsupported discovery input basis");
  invariant(seed.evidence_class === "PUBLISHER_DISCOVERY_SENTINEL", "unsupported source evidence class");
  invariant(seed.permitted_use === "CREDITED_OUTBOUND_LINK_ONLY", "publisher source must remain outbound-only");
  invariant(seed.identity_authority === "NONE", "publisher source cannot establish identity");
  for (const field of requiredNullFields) invariant(seed[field] === null, `${field} must remain null at URL-only discovery`);

  const canonicalUrl = canonicaliseSourceUrl(seed.url, seed.allowed_hosts, seed.canonical_host);
  const digest = sha256(canonicalUrl);
  const metadataObservations = (seed.metadata_observations || []).map(validateMetadataObservation);

  return {
    discovery_id: `PN-DISCOVERY-${digest.slice(0, 20).toUpperCase()}`,
    source_fingerprint: `sha256:${digest}`,
    canonical_url: canonicalUrl,
    publisher_label: seed.publisher_label,
    input_basis: seed.input_basis,
    evidence_class: seed.evidence_class,
    permitted_use: seed.permitted_use,
    identity_authority: seed.identity_authority,
    discovered_at: seed.discovered_at,
    discovery_status: "DISCOVERED_URL_ONLY",
    direct_source_metadata_status: "UNVERIFIED",
    content_retrieved: false,
    headline: null,
    summary: null,
    body: null,
    author: null,
    image_url: null,
    article_id: null,
    project_id: null,
    repd_ref: null,
    development_id: null,
    data_centre_evidence_id: null,
    event_type: null,
    capacity_mw: null,
    claim_eligible: false,
    metadata_observations: metadataObservations,
    decisions: {
      candidate_collection: "ACCEPT_RECALL_FIRST_URL",
      article_promotion: "HOLD_NO_DIRECT_SOURCE_METADATA",
      claim_extraction: "ABSTAIN_NO_DIRECT_ARTICLE_EVIDENCE",
      project_binding: "ABSTAIN_NO_IDENTITY_EVIDENCE",
      data_centre_binding: "ABSTAIN_NO_IDENTITY_EVIDENCE",
    },
  };
}

export function buildDiscoveryLedger(input) {
  invariant(input.schema === "pipelinenews.source-discovery-input.v1", "unexpected input schema");
  invariant(/^\d{12}-PipelineNews$/.test(input.release_id), "invalid timestamp release ID");
  invariant(input.app_title === "PipelineNews", "app title must remain PipelineNews");
  invariant(Number.isFinite(Date.parse(input.incepted_at)), "invalid inception timestamp");

  const candidates = input.candidates.map(discoverSource);
  invariant(new Set(candidates.map((row) => row.canonical_url)).size === candidates.length, "duplicate canonical source URL");
  invariant(new Set(candidates.map((row) => row.discovery_id)).size === candidates.length, "duplicate discovery ID");

  return {
    schema: "pipelinenews.source-discovery-ledger.v1",
    release_id: input.release_id,
    app_title: input.app_title,
    incepted_at: input.incepted_at,
    policy_id: DISCOVERY_POLICY_ID,
    status: "CANDIDATE",
    counts: {
      source_candidates: candidates.length,
      url_only_candidates: candidates.filter((row) => row.discovery_status === "DISCOVERED_URL_ONLY").length,
      promoted_articles: candidates.filter((row) => row.article_id !== null).length,
      project_bindings: candidates.filter((row) => row.project_id !== null).length,
      data_centre_bindings: candidates.filter((row) => row.data_centre_evidence_id !== null).length,
      claim_eligible: candidates.filter((row) => row.claim_eligible).length,
    },
    candidates,
    publication_law: {
      recall_first_candidate_collection: true,
      direct_source_verification_required_for_article_promotion: true,
      aggregator_metadata_may_create_claims: false,
      publisher_context_may_create_identity: false,
      url_discovery_may_change_official_repd_facts: false,
    },
  };
}

Objects — Sha256

A JavaScript module in PipelineNews. It gets JSON (`getJson`) and is built from the by id helper (`byId`).

renderpipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/9bce91d7bde247265bdf369416ff4771c4866d3369c22d3b3d9c96aef4a95272.mjs · lines 1–37 of 37 · version 2026-08-26 15:47 · Entry point · pattern getJson (shared by 15 files)

What it does
It draws its content. Defines byId, getJson, start. Side effects: changes the web page (DOM); makes network requests.
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.json.
Downstream impact
Used directly by 1 file: PipelineNews — PipelineNews Page (pipelinenews, https://ventusltd.github.io/pipelinenews/archive/202608261547-pipelinenews/202608251651-PipelineNews/).
What it achieves
Defines `byId`, `getJson` and `start`.
Why it matters
Loaded by the PipelineNews page at https://ventusltd.github.io/pipelinenews/archive/202608261547-pipelinenews/202608251651-PipelineNews/.
Application
pipelinenews · archive/202608261547-pipelinenews/objects/js/sha256 · JavaScript module
Uses
none found
Used by
loaded by PipelineNews — PipelineNews Page (script src)
Produces
byId, getJson, start
Defines here
byId, getJson, start
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/objects/js/sha256/9bce91d7bde247265bdf369416ff4771c4866d3369c22d3b3d9c96aef4a95272.mjs:1-37 · blob 6fdccc82f5292c88ef76d21e2563471022935636 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, network · domain stage: experimental · users: none · canonical: production_core
const byId = (id) => document.getElementById(id);
const getJson = async (url) => { const response = await fetch(url); if (!response.ok) throw new Error(`${response.status}: ${url}`); return response.json(); };

async function start() {
  const folderUrl = new URL("release.json", document.baseURI);
  const folder = await getJson(folderUrl);
  const manifestUrl = new URL(folder.manifest, folderUrl);
  const manifest = await getJson(manifestUrl);
  const root = new URL(folder.repository_root, folderUrl);
  const contractObject = manifest.objects.artifacts.find((item) => item.role === "official_frontier_contract");
  const contractUrl = new URL(contractObject.path, root);
  const contract = await getJson(contractUrl);

  document.title = `${manifest.display_title} — ${manifest.release_id}`;
  byId("releaseId").textContent = manifest.release_id;
  byId("projects").textContent = contract.spine.total_projects.toLocaleString("en-GB");
  byId("references").textContent = contract.spine.with_planning_reference.toLocaleString("en-GB");
  byId("fallback").textContent = contract.spine.without_planning_reference.toLocaleString("en-GB");
  byId("batch").textContent = contract.scheduler.reference_budget_per_run;
  byId("match").textContent = `${contract.fixture_proof.east_pye_binding.project_name} · ${contract.fixture_proof.east_pye_binding.gg_project_id}`;
  byId("abstention").textContent = `${contract.fixture_proof.duplicate_reference_decision.reason}: ${contract.fixture_proof.duplicate_reference_decision.candidate_repd_refs.join(", ")}`;

  const ladder = byId("ladder");
  for (const source of contract.source_order) {
    const li = document.createElement("li");
    li.textContent = `${source.score}/100 · ${source.source_class}`;
    ladder.append(li);
  }
  byId("manifest").href = manifestUrl;
  byId("contract").href = contractUrl;
  byId("state").textContent = "Full-spine scheduler verified; official adapters bounded and fail-closed; Google discovery retained.";
}

start().catch((error) => {
  byId("state").textContent = `Release failed closed: ${error.message}`;
  byId("state").classList.add("error");
});

Objects — Sha256

A JavaScript module in PipelineNews that builds frontier contract (`buildFrontierContract`). It builds frontier contract (`buildFrontierContract`).

transformpipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/bf8b87533cda64fa145de9ca28998b29bf7f863f483a26a78e34fc3272fe9f7d.mjs · lines 1–26 of 26 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review) · pattern buildFrontierContract (shared by 3 files)

What it does
It calculates its inputs. Defines buildFrontierContract.
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: Objects — Sha256 (pipelinenews).
What it achieves
Defines `buildFrontierContract`.
Why it matters
Imported by a file of the same name.
Application
pipelinenews · archive/202608261547-pipelinenews/objects/js/sha256 · JavaScript module
Uses
Objects — Sha256 (import)
Used by
imported by Objects — Sha256 (import)
Produces
POLICY_ID, SOURCE_SCORES, normalisePlanningReference, buildReferenceGroups, selectFrontier, resolvePlanningBinding, sourceHealth, buildFrontierContract
Defines here
buildFrontierContract
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/objects/js/sha256/bf8b87533cda64fa145de9ca28998b29bf7f863f483a26a78e34fc3272fe9f7d.mjs:1-26 · blob 309b0e38773dd55d9a4f84ef493b6a832cc3fe7f · GitHub at these lines
State
achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
import * as previous from "./0f0adf842d22158b882f168d6c131480afd81bce6609b8453a073f15d201d18c.mjs";

export const POLICY_ID = "PN-OFFICIAL-FRONTIER-V2-LOWERCASE-SLUG";
export const SOURCE_SCORES = previous.SOURCE_SCORES;
export const normalisePlanningReference = previous.normalisePlanningReference;
export const buildReferenceGroups = previous.buildReferenceGroups;
export const selectFrontier = previous.selectFrontier;
export const resolvePlanningBinding = previous.resolvePlanningBinding;
export const sourceHealth = previous.sourceHealth;

export function buildFrontierContract(input) {
  if (!/^\d{12}-pipelinenews$/.test(input.release_id)) throw new Error("release ID must use the lowercase pipelinenews slug");
  const legacyInput = { ...input, release_id: input.release_id.replace(/-pipelinenews$/, "-PipelineNews") };
  const contract = previous.buildFrontierContract(legacyInput);
  return {
    ...contract,
    release_id: input.release_id,
    policy_id: POLICY_ID,
    naming: {
      format: "YYYYMMDDHHmm-pipelinenews",
      path_slug: "pipelinenews",
      visible_title: "Pipeline News",
      lowercase_paths_required: true
    }
  };
}

Objects — Sha256

A JavaScript module in PipelineNews that works with the Renewable Energy Planning Database (REPD) register, using SHA-256. It normalises evidence (`normaliseEvidence`), binds project (`bindProject`) and builds evidence ledger (`buildEvidenceLedger`).

transformpipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/d7c0164d2d767996c45e86d27c4754d4388e4493a00a33e2429c6759cfe9b328.mjs · lines 1–138 of 138 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review) · pattern invariant (shared by 75 files)

What it does
It calculates the REPD register. Defines 6 functions or classes, including invariant, sha256, canonicaliseUrl, normaliseEvidence, bindProject. 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. Domain terms in the code: the REPD register.
What it achieves
Defines `invariant`, `sha256`, `canonicaliseUrl` and 3 more.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · archive/202608261547-pipelinenews/objects/js/sha256 · JavaScript module
Uses
node:crypto
Used by
none found
Produces
POLICY_ID, canonicaliseUrl, buildEvidenceLedger
Defines here
invariant, sha256, canonicaliseUrl, normaliseEvidence, bindProject, buildEvidenceLedger
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/objects/js/sha256/d7c0164d2d767996c45e86d27c4754d4388e4493a00a33e2429c6759cfe9b328.mjs:1-138 · blob c12115954d8e620c3e08d70b6e6f61df3693b36a · 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";

export const POLICY_ID = "PN-EVIDENCE-CREDIBILITY-V1";

const CREDIBILITY = Object.freeze({
  OFFICIAL_REPD_REGISTER: 100,
  OFFICIAL_PLANNING_AUTHORITY: 95,
  OFFICIAL_AGGREGATOR: 90,
  ORIGINAL_PUBLISHER: 65,
  NEWS_AGGREGATOR: 30,
  SYNDICATION: 25,
});

const IDENTITY_AUTHORITIES = new Set(["OFFICIAL_REPD_REGISTER", "OFFICIAL_PLANNING_AUTHORITY"]);
const TRACKING_PARAMETERS = new Set(["utm_campaign", "utm_content", "utm_medium", "utm_source", "utm_term"]);
const invariant = (condition, message) => { if (!condition) throw new Error(message); };
const sha256 = (value) => createHash("sha256").update(value).digest("hex");

export function canonicaliseUrl(rawUrl) {
  const url = new URL(rawUrl);
  invariant(["http:", "https:"].includes(url.protocol), "evidence URL must use HTTP(S)");
  invariant(!url.username && !url.password, "URL credentials are forbidden");
  url.protocol = "https:";
  url.hash = "";
  for (const key of [...url.searchParams.keys()]) {
    if (TRACKING_PARAMETERS.has(key.toLowerCase())) url.searchParams.delete(key);
  }
  url.searchParams.sort();
  if (url.pathname.length > 1) url.pathname = url.pathname.replace(/\/+$/, "");
  return url.toString();
}

function normaliseEvidence(observation) {
  invariant(Object.hasOwn(CREDIBILITY, observation.source_class), `unknown source class: ${observation.source_class}`);
  invariant(typeof observation.publisher_label === "string" && observation.publisher_label.length > 0, "publisher label required");
  invariant(typeof observation.source_ref === "string" && observation.source_ref.length > 0, "source reference required");
  const canonicalUrl = canonicaliseUrl(observation.url);
  const credibilityScore = CREDIBILITY[observation.source_class];
  const identityAuthority = IDENTITY_AUTHORITIES.has(observation.source_class);
  invariant(!observation.claims?.body, "third-party article bodies must not be stored");
  if (!identityAuthority) {
    invariant(!observation.claims?.repd_ref, "non-official evidence cannot assert a REPD reference");
    invariant(!observation.claims?.planning_application_reference, "non-official evidence cannot assert a planning reference");
  }
  const digest = sha256(`${observation.source_class}\n${observation.source_ref}\n${canonicalUrl}`);
  return {
    evidence_id: `PN-EVIDENCE-${digest.slice(0, 20).toUpperCase()}`,
    source_class: observation.source_class,
    credibility_score: credibilityScore,
    credibility_label: credibilityScore >= 90 ? "OFFICIAL" : credibilityScore >= 60 ? "PUBLISHER" : "DISCOVERY",
    identity_authority: identityAuthority,
    publisher_label: observation.publisher_label,
    source_ref: observation.source_ref,
    canonical_url: canonicalUrl,
    observed_at: observation.observed_at,
    permitted_use: observation.permitted_use,
    claims: observation.claims || {},
  };
}

function bindProject(projects, evidence) {
  const official = evidence.filter((row) => row.identity_authority);
  const assertedRefs = new Set(official.map((row) => row.claims.repd_ref).filter(Boolean));
  const planningRefs = new Set(official.map((row) => row.claims.planning_application_reference).filter(Boolean));
  const candidates = projects.filter((project) => assertedRefs.has(project.repd_ref) || planningRefs.has(project.planning_application_reference));
  invariant(candidates.length === 1, `official identity evidence must resolve exactly one project; got ${candidates.length}`);
  const project = candidates[0];
  invariant(!project.related_repd_refs.includes(project.repd_ref), "project cannot relate to itself");
  return {
    role: "PRIMARY_MATCH",
    method: assertedRefs.has(project.repd_ref) ? "EXACT_REPD_REF" : "EXACT_PLANNING_REFERENCE",
    repd_ref: project.repd_ref,
    gg_project_id: `GG2050-REPD-${project.repd_ref}`,
    project_name: project.project_name,
    technology: project.technology,
    official_capacity_mw: project.official_capacity_mw,
    planning_application_reference: project.planning_application_reference,
    related_repd_refs: project.related_repd_refs,
    news_may_overwrite_official_facts: false,
  };
}

export function buildEvidenceLedger(input) {
  invariant(input.schema === "pipelinenews.evidence-input.v1", "unexpected evidence input schema");
  invariant(/^\d{12}-PipelineNews$/.test(input.release_id), "invalid release ID");
  invariant(input.app_title === "PipelineNews", "app title must remain PipelineNews");
  invariant(Array.isArray(input.v1_v5_mission_invariants) && input.v1_v5_mission_invariants.length >= 5, "V1-V5 mission baseline missing");

  const evidence = input.observations.map(normaliseEvidence).sort((a, b) => b.credibility_score - a.credibility_score || a.evidence_id.localeCompare(b.evidence_id));
  invariant(new Set(evidence.map((row) => row.evidence_id)).size === evidence.length, "duplicate evidence ID");
  invariant(evidence.some((row) => row.source_class === "NEWS_AGGREGATOR"), "noisy news discovery must remain enabled");
  invariant(evidence.some((row) => row.credibility_score >= 90), "official evidence required");

  const binding = bindProject(input.projects, evidence);
  const publisher = evidence.find((row) => row.source_class === "ORIGINAL_PUBLISHER");
  invariant(publisher, "original publisher evidence required");
  const official = evidence.filter((row) => row.identity_authority);
  const eventDigest = sha256(`${binding.gg_project_id}\n${publisher.canonical_url}`);

  return {
    schema: "pipelinenews.evidence-ledger.v1",
    release_id: input.release_id,
    app_title: input.app_title,
    incepted_at: input.incepted_at,
    policy_id: POLICY_ID,
    counts: {
      observations: evidence.length,
      official_observations: evidence.filter((row) => row.credibility_score >= 90).length,
      publisher_observations: evidence.filter((row) => row.credibility_label === "PUBLISHER").length,
      discovery_observations: evidence.filter((row) => row.credibility_label === "DISCOVERY").length,
      primary_matches: 1,
    },
    event: {
      event_id: `PN-EVENT-${eventDigest.slice(0, 20).toUpperCase()}`,
      headline: publisher.claims.headline,
      direct_outbound_url: publisher.canonical_url,
      publisher_label: publisher.publisher_label,
      published_at: publisher.claims.published_at,
      publisher_reported_claim: publisher.claims.publisher_reported_claim,
      publisher_claim_credibility_score: publisher.credibility_score,
      official_status: official.map((row) => row.claims.official_status).find(Boolean),
      highest_credibility_score: Math.max(...evidence.map((row) => row.credibility_score)),
      binding,
    },
    evidence,
    source_adapters: input.source_adapters,
    mission_invariants: input.v1_v5_mission_invariants,
    publication_law: {
      official_sources_rank_above_news: true,
      google_discovery_retained: true,
      original_outlet_credited_and_linked: true,
      article_body_stored: false,
      non_official_sources_may_establish_identity: false,
      news_may_overwrite_repd: false,
      default_ambiguous_binding: "ABSTAIN",
    },
  };
}

Objects — Sha256

A JavaScript module in PipelineNews. It fetches JSON (`fetchJson`) and is built from the by id helper (`byId`).

renderpipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/dca6a33a559496cfb7f0e6141f81e37a25513b1af7976d712dc9e23cf5cc2ee6.mjs · lines 1–38 of 38 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review) · pattern fetchJson (shared by 14 files)

What it does
It draws its content. Defines byId, fetchJson, start. Side effects: changes the web page (DOM); makes network requests.
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.json.
What it achieves
Defines `byId`, `fetchJson` and `start`.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · archive/202608261547-pipelinenews/objects/js/sha256 · JavaScript module
Uses
none found
Used by
none found
Produces
byId, fetchJson, start
Defines here
byId, fetchJson, start
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/objects/js/sha256/dca6a33a559496cfb7f0e6141f81e37a25513b1af7976d712dc9e23cf5cc2ee6.mjs:1-38 · blob e8ed3014464a15d35651c72d8184cd3d974e9813 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, network · domain stage: experimental · users: none · canonical: unreached_review
const byId = (id) => document.getElementById(id);
const fetchJson = async (url) => { const response = await fetch(url); if (!response.ok) throw new Error(`${response.status}: ${url}`); return response.json(); };

async function start() {
  const folderUrl = new URL("release.json", document.baseURI);
  const folder = await fetchJson(folderUrl);
  const manifestUrl = new URL(folder.manifest, folderUrl);
  const manifest = await fetchJson(manifestUrl);
  const root = new URL(folder.repository_root, folderUrl);
  const descriptor = manifest.objects.artifacts.find((row) => row.role === "evidence_credibility_ledger");
  const ledgerUrl = new URL(descriptor.path, root);
  const ledger = await fetchJson(ledgerUrl);
  const event = ledger.event;

  document.title = `${manifest.display_title} — ${manifest.release_id}`;
  byId("releaseId").textContent = manifest.release_id;
  byId("officialCount").textContent = ledger.counts.official_observations;
  byId("newsCount").textContent = ledger.counts.publisher_observations + ledger.counts.discovery_observations;
  byId("matchCount").textContent = ledger.counts.primary_matches;
  byId("headline").textContent = event.headline;
  byId("project").textContent = `${event.binding.project_name} · ${event.binding.gg_project_id} · ${event.binding.official_capacity_mw} MW`;
  byId("status").textContent = event.official_status;
  byId("claim").textContent = `${event.publisher_reported_claim} — publisher-reported, credibility ${event.publisher_claim_credibility_score}/100`;
  const source = byId("source"); source.href = event.direct_outbound_url; source.textContent = `Read at ${event.publisher_label}`;

  const evidenceList = byId("evidence");
  for (const item of ledger.evidence) {
    const li = document.createElement("li");
    const link = document.createElement("a"); link.href = item.canonical_url; link.textContent = item.publisher_label;
    li.append(document.createTextNode(`${item.credibility_score}/100 ${item.credibility_label} · `), link, document.createTextNode(` · ${item.source_ref}`));
    evidenceList.append(li);
  }
  byId("manifest").href = manifestUrl;
  byId("ledger").href = ledgerUrl;
  byId("loadState").textContent = "Evidence ordered by deterministic credibility policy.";
}

start().catch((error) => { byId("loadState").textContent = `Release failed closed: ${error.message}`; byId("loadState").classList.add("error"); });

Objects — Sha256

A JavaScript module in PipelineNews that sets link (`setLink`). It fetches JSON (`fetchJson`) and sets link (`setLink`).

renderpipelinenews / archive/202608261547-pipelinenews/objects/js/sha256/e57f8ead800893c351e9dfac7294b0995b14e9c20fdc5042773f451acfa98136.mjs · lines 1–54 of 54 · version 2026-08-26 15:47 · Not reached from any entry point (candidate for review) · pattern fetchJson (shared by 14 files)

What it does
It draws its content. Defines byId, fetchJson, setLink, start. Side effects: changes the web page (DOM); makes network requests.
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.json.
What it achieves
Defines `byId`, `fetchJson`, `setLink` and 1 more.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · archive/202608261547-pipelinenews/objects/js/sha256 · JavaScript module
Uses
none found
Used by
none found
Produces
byId, fetchJson, setLink, start
Defines here
byId, fetchJson, setLink, start
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/objects/js/sha256/e57f8ead800893c351e9dfac7294b0995b14e9c20fdc5042773f451acfa98136.mjs:1-54 · blob 120a05e6e9ce1095e731f2d1a51218b85c2b3368 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, network · domain stage: experimental · users: none · canonical: unreached_review
const byId = (id) => document.getElementById(id);

async function fetchJson(url) {
  const response = await fetch(url, { cache: "default" });
  if (!response.ok) throw new Error(`${response.status} ${response.statusText}: ${url}`);
  return response.json();
}

function setLink(element, href, label) {
  element.href = href;
  element.textContent = label;
}

async function start() {
  const folderPointerUrl = new URL("release.json", document.baseURI);
  const folder = await fetchJson(folderPointerUrl);
  const manifestUrl = new URL(folder.manifest, folderPointerUrl);
  const manifest = await fetchJson(manifestUrl);
  if (folder.release_id !== manifest.release_id) throw new Error("Folder and manifest release IDs differ");

  const repositoryRoot = new URL(folder.repository_root, folderPointerUrl);
  const artifactDescriptor = manifest.objects.artifacts.find((row) => row.role === "source_discovery_ledger");
  const artifactUrl = new URL(artifactDescriptor.path, repositoryRoot);
  const ledger = await fetchJson(artifactUrl);
  const candidate = ledger.candidates[0];

  document.title = `${manifest.display_title} — ${manifest.release_id}`;
  byId("appTitle").textContent = manifest.display_title;
  byId("releaseId").textContent = manifest.release_id;
  byId("releaseStatus").textContent = `${manifest.status} · ${manifest.feature}`;
  byId("candidateCount").textContent = ledger.counts.source_candidates;
  byId("articleCount").textContent = ledger.counts.promoted_articles;
  byId("bindingCount").textContent = ledger.counts.project_bindings + ledger.counts.data_centre_bindings;
  byId("discoveryId").textContent = candidate.discovery_id;
  byId("sourceStatus").textContent = `${candidate.discovery_status}; direct-source metadata ${candidate.direct_source_metadata_status.toLowerCase()}`;
  setLink(byId("sourceLink"), candidate.canonical_url, `${candidate.publisher_label}: ${candidate.canonical_url}`);
  setLink(byId("manifestLink"), manifestUrl, "Immutable release manifest");
  setLink(byId("artifactLink"), artifactUrl, "Hash-addressed discovery ledger");
  setLink(byId("fullAppLink"), new URL(folder.ui_parent, folderPointerUrl), "Open the unchanged NewsV7 interface");

  const observations = byId("metadataObservations");
  for (const observation of candidate.metadata_observations) {
    const item = document.createElement("li");
    const link = document.createElement("a");
    setLink(link, observation.observation_url, observation.observed_title);
    item.append(link, document.createTextNode(` — ${observation.evidence_class}; discovery metadata only`));
    observations.append(item);
  }
}

start().catch((error) => {
  byId("loadState").textContent = `Release could not be resolved: ${error.message}`;
  byId("loadState").classList.add("error");
});