From af147e2c121a42aa530222fc5f8d4758c6ceeb00 Mon Sep 17 00:00:00 2001 From: Zacharon <113211893+Zacharon@users.noreply.github.com> Date: Sun, 18 Oct 2026 12:32:05 -0400 Subject: [PATCH 1/6] Add frozen multi-site infrastructure incident evaluation Co-Authored-By: GPT-6 Astra --- docs/LAST_30_DAYS.md | 11 ++- docs/MULTI_SITE_INCIDENT_EVALUATION.md | 98 +++++++++++++++++++ docs/NEXT_TASK_QUEUE.md | 6 ++ tests/fixtures/st-petersburg-20261018.mjs | 73 ++++++++++++++ .../multi-site-incident-evaluation.mjs | 44 +++++++++ .../multi-site-incident-evaluation-tests.mjs | 45 +++++++++ tests/run-tests.mjs | 2 + 7 files changed, 278 insertions(+), 1 deletion(-) create mode 100644 docs/MULTI_SITE_INCIDENT_EVALUATION.md create mode 100644 tests/fixtures/st-petersburg-20261018.mjs create mode 100644 tests/helpers/multi-site-incident-evaluation.mjs create mode 100644 tests/multi-site-incident-evaluation-tests.mjs diff --git a/docs/LAST_30_DAYS.md b/docs/LAST_30_DAYS.md index b965973..6811ba5 100644 --- a/docs/LAST_30_DAYS.md +++ b/docs/LAST_30_DAYS.md @@ -1,6 +1,15 @@ # Last 30 Days -Last updated: 2026-07-15. +Last updated: 2026-10-18. + +## 2026-10-18 - Frozen multi-site incident evaluation + +- Added one offline St. Petersburg four-site case and negative mutation tests in + `tests/multi-site-incident-evaluation-tests.mjs`, wired into the platform suite. +- AP/Reuters/RFE-RL search excerpts only; full-page retrieval failed. All claims + retain attribution and uncertainty; ceasefire terms remain brief-only. +- No runtime/API/provider changes. Operational-evidence/workbench and PortWatch + sample files are absent on this base. See `MULTI_SITE_INCIDENT_EVALUATION.md`. ## Merged Recently diff --git a/docs/MULTI_SITE_INCIDENT_EVALUATION.md b/docs/MULTI_SITE_INCIDENT_EVALUATION.md new file mode 100644 index 0000000..ce9f9b9 --- /dev/null +++ b/docs/MULTI_SITE_INCIDENT_EVALUATION.md @@ -0,0 +1,98 @@ +# Frozen St. Petersburg multi-site evaluation + +This is one **frozen evaluation fixture**, dated 2026-10-18, with partial source +retrieval and unverified claims. It is not live data, an operational assessment, +or a public feed feature. No provider, UI, or API imports it. + +## Source receipt and limitations + +Research on 2026-10-18 retrieved search-index excerpts, not complete article pages. +Direct page opens for AP, ITV's AP coverage, Reuters via Internazionale, +Devdiscourse and StreetInsider, and Local10 failed with `Internal Error` / +`URL ... is not accessible via this tool`. No access restrictions were bypassed. +Source timestamps below are publication metadata returned by search, not verified +event/observation times. Retrieval date has day precision. No raw articles retained. + +| Source | Publication metadata | Retained facts and attribution | +| --- | --- | --- | +| [AP](https://apnews.com/article/f813d3725b8b5f23958a68a95729fd0d) | 2026-10-18 09:49:17 UTC | Beglov: fires at two oil sites; city toll 1 killed, 5 injured. MoD: 1,015 drones intercepted. | +| [Reuters via Devdiscourse](https://www.devdiscourse.com/article/international/3994318-one-killed-five-injured-in-ukrainian-drone-attack-on-russias-st-petersburg-governor-says) | 2026-10-18 12:32 IST (07:02 UTC) | Ozon: logistics fire. VK: data center attacked, user services normal. | +| [Reuters via Yahoo Malaysia](https://malaysia.news.yahoo.com/one-killed-15-injured-ukrainian-104758436.html) | 2026-10-18 10:47 UTC | Authorities: 1 killed, 15 injured across city and Leningrad region. | +| [RFE/RL](https://www.rferl.org/a/ukraine-russia-drone-attacks-zelenskyy-airports/33878787.html) | 2026-10-18 12:07 CET, preserved as displayed | Zelenskyy: 76 energy/oil/gas attacks during prior week. Trump: energy pause announcement October 11. | +| Owner Daily Priority Brief | 2026-10-18; time unknown | No mutually confirmed ceasefire terms: **brief-only, unverified**. | + +The fixture never turns news repetition into independent physical confirmation. +Both Reuters hosts share one organization identity. The casualty reports cover +different geographic scopes: neither sum them nor allocate either to a site. +They remain unreconciled, not an inferred correction or a new city total. +No imagery was inspected, coordinates retrieved, operational closure established, +or restoration sourced. Facility operations and Ozon service impact stay unknown. +VK's service statement is a company claim, not proof of facility operability. +The interception count is not a launch total, site count, damage measure, or +independently verified observation. A ceasefire announcement does not establish +mutual terms or a violation finding. + +## Evaluation contract and use + +This local-main base lacks the operational-evidence code, workbench document, and +PortWatch frozen sample referenced by the brief. The minimal addition is an +evaluation-only schema v1 in `tests/fixtures/st-petersburg-20261018.mjs` and a +validator in `tests/helpers/multi-site-incident-evaluation.mjs`. Public +`/api/events`, its direct Netlify endpoint, and `/api/sources` are unchanged. +This is not integration proof for the absent workbench or future imports. + +Every evidence-bearing field carries source link/id, publisher, publication, +retrieval and event clocks, claimant/type, scope, confidence, verification and +evidence kind. Missing source/observation times are null; event dates are not +invented exact times. Site names and region labels identify the subjects described +by their attack records; geography has no geometry. `national-authority` and +`brief-author` avoid falsely classifying political statements as military or +independent journalism. Confidence describes establishment of the underlying +claim, not confidence that the excerpt exists. All remain unknown/unverified. + +Read-only capability `validateMultiSiteIncidentFixture/v1` accepts this frozen +case shape and returns `{valid, errors}`. It intentionally rejects new supported +facts too: a later source update needs a separately reviewed fixture revision, +not silent mutation of this snapshot. Humans and agents run the same command: + +```sh +node tests/multi-site-incident-evaluation-tests.mjs +npm test +``` + +Negative cases exercise claim-to-observation promotion, launch/damage substitution, +unsupported operations, site casualty allocation, fabricated geography, restoration, +live relabeling, provenance mismatch and collapsed assessment dimensions. Severity, +confidence, impact, corroboration, freshness and completeness remain separate. +The validator is a test utility, not an API ingestion security boundary. + +## Feature-standard scope + +This adds offline evaluation assets only. Seven product acceptance gates: + +- Shared capabilities: PASS for local evaluation; same read-only CLI test and + validator for humans/agents. +- Shared state: NOT APPLICABLE; no application state writes or new persistence. +- Scoped authority: NOT APPLICABLE; no accounts, grants or external effects. +- Human usability: PASS for CLI evaluation; readable fixture/docs and CLI errors. + No product UI introduced. +- Visible supervision: PASS for CLI evaluation; output reports failure and mutation + checks. Delegation/cancellation controls are NOT APPLICABLE to this sync test. +- Safe recovery: NOT APPLICABLE; read-only tests; Git versions assets. +- Receipts: PASS for local evaluation output; application transaction receipts + are NOT APPLICABLE because no application state changes. + +Product UI, hosted operation, live provider and real-user gates are NOT RUN. + +## Local verification, 2026-10-18 + +- `node tests/multi-site-incident-evaluation-tests.mjs`: PASS, valid case plus + 28 rejected unsafe mutations; fully offline. +- `npm.cmd test`: PASS (exit 0): platform suite, validator (10 checks, 0 failures; + 154 syntax files, 403 returned events, 20 reachable source URLs), E2E smoke and + Source Explorer smoke. Existing validator/smoke code calls provider routes; + these results do not independently verify the fixture's reporting. +- `npm.cmd run check:syntax`: PASS; Cloudflare exports valid. +- `git diff --check`: PASS. + +No push, PR, merge, production smoke or deployment performed. diff --git a/docs/NEXT_TASK_QUEUE.md b/docs/NEXT_TASK_QUEUE.md index 61503c0..a91027a 100644 --- a/docs/NEXT_TASK_QUEUE.md +++ b/docs/NEXT_TASK_QUEUE.md @@ -4,6 +4,12 @@ Small, agent-ready tasks only. Do not turn these into broad refactors. ## Context Updates +- Completed locally (2026-10-18): frozen multi-site incident evaluation and offline + semantic regression tests. See `MULTI_SITE_INCIDENT_EVALUATION.md`. Follow-up: + retrieve complete reporting/primary statements and reconcile regional casualty + scopes before any new fixture revision; integrate with a workbench only after + its absent model is available. No live activation or independent fact claim. + - In review: Strategic chokepoints v1 on `feature/strategic-chokepoints-event-intelligence-v1`. Keep follow-on provider work separate from the local registry and do not label a source live without the source-registry contract. - Completed: PR #37 created the ICM memory pack and made `AGENTS.md`, `docs/PROJECT_HANDOFF.md`, `docs/LAST_30_DAYS.md`, `docs/API_CONTRACTS.md`, `docs/SECURITY_INVARIANTS.md`, and this queue the first-read context for future agents. - In progress: Future feature structure and feature-flag documentation on branch `feature/future-feature-structure`. Keep it docs/structure-only: no runtime imports, no fake UI, no unfinished feature activation. diff --git a/tests/fixtures/st-petersburg-20261018.mjs b/tests/fixtures/st-petersburg-20261018.mjs new file mode 100644 index 0000000..c611cd5 --- /dev/null +++ b/tests/fixtures/st-petersburg-20261018.mjs @@ -0,0 +1,73 @@ +// Frozen evaluation input; never import into providers or the public event feed. +const retrievedAt = "2026-10-18"; // Date precision only; not an event/publication clock. +export const sources = { + ap: { + publisher: "Associated Press", publishedAt: "2026-10-18T09:49:17Z", + url: "https://apnews.com/article/f813d3725b8b5f23958a68a95729fd0d", + retrieval: "search-excerpt-only", retrievedAt, organization: "associated-press", + }, + reuters: { + publisher: "Reuters", host: "Devdiscourse", publishedAt: "2026-10-18T07:02:00Z", + url: "https://www.devdiscourse.com/article/international/3994318-one-killed-five-injured-in-ukrainian-drone-attack-on-russias-st-petersburg-governor-says", + retrieval: "search-excerpt-only", retrievedAt, organization: "reuters", + }, + reutersRegional: { + publisher: "Reuters", host: "Yahoo News Malaysia", publishedAt: "2026-10-18T10:47:00Z", + url: "https://malaysia.news.yahoo.com/one-killed-15-injured-ukrainian-104758436.html", + retrieval: "search-excerpt-only", retrievedAt, organization: "reuters", + }, + rferl: { + publisher: "RFE/RL", publishedAt: "2026-10-18 12:07 CET", + url: "https://www.rferl.org/a/ukraine-russia-drone-attacks-zelenskyy-airports/33878787.html", + retrieval: "search-excerpt-only", retrievedAt, organization: "rferl", + }, + brief: { + publisher: "Owner Daily Priority Brief", publishedAt: "2026-10-18", url: null, + retrieval: "brief-only", retrievedAt: null, organization: "owner-brief", + }, +}; + +function field(value, sourceId = null, claimantType = null, claimant = null, scope = null) { + return { + value, sourceId, source: sourceId ? sources[sourceId].url : null, + publisher: sourceId ? sources[sourceId].publisher : null, + publishedAt: sourceId ? sources[sourceId].publishedAt : null, + eventDate: "2026-10-18", observedAt: null, + retrievedAt: sourceId ? sources[sourceId].retrievedAt : null, + claimantType, claimant, scope, confidence: "unknown", + verification: "unverified", evidenceKind: sourceId ? "claim" : "unknown", + provenance: sourceId ? sources[sourceId].retrieval : "not-sourced", + }; +} +function site(id, name, region, sourceId, claimantType, claimant, damage) { + return { + id, name, geography: { label: region, precision: "region-label-only", geometry: null }, + reportedAttack: field("reported-targeted", sourceId, claimantType, claimant, id), + physicalDamageClaimed: damage ? field(damage, sourceId, claimantType, claimant, id) : field(null), + physicalDamageObserved: field(null), operationalStatus: field("unknown"), + casualties: field(null), commercialServiceEffects: field("unknown"), + restorationUpdates: [], restorationStatus: "pending", + dimensions: { severity: "unknown", confidence: "unknown", impact: "unknown", corroboration: 0, freshness: "frozen", completeness: "partial" }, + }; +} +const sites = [ + site("petersburg-terminal", "Petersburg Oil Terminal", "St. Petersburg", "ap", "regional-authority", "Alexander Beglov", "fire-reported"), + site("ruchi", "Ruchi oil depot", "St. Petersburg", "ap", "regional-authority", "Alexander Beglov", "fire-reported"), + site("ozon", "Ozon logistics facility", "St. Petersburg", "reuters", "company", "Ozon", "fire-reported"), + site("vk", "VK-associated data center", "Leningrad region", "reuters", "company", "VK", null), +]; +sites[3].commercialServiceEffects = field("normal-service-claimed", "reuters", "company", "VK", "VK user services; not facility operational status"); + +export const multiSiteIncidentFixture = { + schemaVersion: 1, id: "st-petersburg-multi-site-20261018", + label: "Frozen evaluation fixture - partial source retrieval, unverified claims", + mode: "frozen-evaluation", live: false, frozenOn: "2026-10-18", sources, sites, + nonSiteRecords: [ + { id: "city-casualties", kind: "casualties", evidence: field({ killed: 1, injured: 5 }, "ap", "regional-authority", "Alexander Beglov", "St. Petersburg attack; no site allocation") }, + { id: "regional-casualties", kind: "casualties", evidence: field({ killed: 1, injured: 15 }, "reutersRegional", "regional-authority", "Local authorities", "St. Petersburg and Leningrad region; no site allocation"), relationshipToCityTotal: "not-reconciled-do-not-add" }, + { id: "mod-interceptions", kind: "interception-claim", evidence: field(1015, "ap", "official-military", "Russian Ministry of Defence", "15 Russian regions, Crimea and Black Sea"), unit: "drones-claimed-intercepted", launchTotal: null, physicalDamage: null }, + { id: "ukraine-energy-attacks", kind: "attack-count-claim", evidence: field(76, "rferl", "national-authority", "Volodymyr Zelenskyy", "Ukraine energy/oil/gas; prior week"), unit: "attacks-claimed", period: "prior week as reported; exact interval unverified" }, + { id: "ceasefire-announcement", kind: "context", evidence: { ...field("energy-pause-announcement", "rferl", "national-authority", "Donald Trump", "Russia/Ukraine energy infrastructure"), eventDate: "2026-10-11" } }, + { id: "ceasefire-terms", kind: "context", evidence: field("no-mutually-confirmed-terms", "brief", "brief-author", "Owner brief", "Russia/Ukraine"), mutuallyConfirmedTerms: null }, + ], +}; diff --git a/tests/helpers/multi-site-incident-evaluation.mjs b/tests/helpers/multi-site-incident-evaluation.mjs new file mode 100644 index 0000000..b2dad7e --- /dev/null +++ b/tests/helpers/multi-site-incident-evaluation.mjs @@ -0,0 +1,44 @@ +// Evaluation-only contract: no production provider or API imports this module. +export function validateMultiSiteIncidentFixture(input) { + const errors = []; + const require = (condition, message) => { if (!condition) errors.push(message); }; + require(input?.mode === "frozen-evaluation" && input?.live === false, "fixture must remain frozen, never live"); + require(input?.label?.startsWith("Frozen evaluation fixture"), "frozen label required"); + const checkField = (field, path) => { + require(field && typeof field === "object", `${path}: evidence field required`); + if (!field) return; + for (const key of ["value", "source", "publisher", "publishedAt", "eventDate", "observedAt", "retrievedAt", "claimantType", "claimant", "scope", "confidence", "verification", "evidenceKind", "provenance"]) { + require(Object.hasOwn(field, key), `${path}: missing ${key}`); + } + const source = input.sources?.[field.sourceId]; + if (field.sourceId) { + require(Boolean(source), `${path}: missing source`); + require(field.source === source?.url && field.publisher === source?.publisher && field.publishedAt === source?.publishedAt && field.retrievedAt === source?.retrievedAt && field.provenance === source?.retrieval, `${path}: provenance mismatch`); + require(Boolean(field.claimantType && field.claimant && field.scope), `${path}: attribution required`); + require(field.evidenceKind === "claim", `${path}: sourced claim cannot become observation`); + } else { + require(field.evidenceKind === "unknown" && [null, "unknown"].includes(field.value), `${path}: unsourced value must remain unknown`); + require(field.source === null && field.publisher === null && field.claimant === null, `${path}: unsourced attribution must remain empty`); + } + // This frozen snapshot contains no independently established observations. + require(field.verification === "unverified" && field.confidence === "unknown" && field.observedAt === null, `${path}: no independent verification in this snapshot`); + }; + require(input?.sites?.length === 4, "four distinct sites required"); + require(new Set(input?.sites?.map(site => site.id)).size === 4, "site ids must be unique"); + for (const site of input?.sites || []) { + require(site.geography?.geometry === null && site.geography?.precision === "region-label-only", `${site.id}: no sourced geometry`); + for (const key of ["reportedAttack", "physicalDamageClaimed", "physicalDamageObserved", "operationalStatus", "casualties", "commercialServiceEffects"]) checkField(site[key], `${site.id}.${key}`); + require(site.physicalDamageObserved?.value === null, `${site.id}: claimed damage is not observed damage`); + require(site.operationalStatus?.value === "unknown", `${site.id}: facility operations unknown`); + require(site.casualties?.value === null, `${site.id}: aggregate casualties cannot be allocated`); + require(site.restorationUpdates?.length === 0 && site.restorationStatus === "pending", `${site.id}: restoration not sourced`); + const expected = { severity: "unknown", confidence: "unknown", impact: "unknown", corroboration: 0, freshness: "frozen", completeness: "partial" }; + require(Object.keys(site.dimensions || {}).length === 6 && Object.entries(expected).every(([key, value]) => site.dimensions?.[key] === value), `${site.id}: assessment dimensions must remain separate and unsupported values unknown`); + } + for (const record of input?.nonSiteRecords || []) checkField(record.evidence, record.id); + const interceptions = input?.nonSiteRecords?.find(record => record.id === "mod-interceptions"); + require(interceptions?.kind === "interception-claim" && interceptions?.evidence?.claimantType === "official-military" && interceptions?.unit === "drones-claimed-intercepted" && interceptions?.launchTotal === null && interceptions?.physicalDamage === null, "interceptions are military claims, not launches or damage"); + const terms = input?.nonSiteRecords?.find(record => record.id === "ceasefire-terms"); + require(terms?.mutuallyConfirmedTerms === null && terms?.evidence?.provenance === "brief-only", "ceasefire terms unconfirmed"); + return { valid: errors.length === 0, errors }; +} diff --git a/tests/multi-site-incident-evaluation-tests.mjs b/tests/multi-site-incident-evaluation-tests.mjs new file mode 100644 index 0000000..7b3ccf9 --- /dev/null +++ b/tests/multi-site-incident-evaluation-tests.mjs @@ -0,0 +1,45 @@ +import assert from "node:assert/strict"; +import { pathToFileURL } from "node:url"; +import { multiSiteIncidentFixture as fixture } from "./fixtures/st-petersburg-20261018.mjs"; +import { validateMultiSiteIncidentFixture as validate } from "./helpers/multi-site-incident-evaluation.mjs"; + +export function runMultiSiteIncidentEvaluationTests() { + assert.deepEqual(validate(fixture), { valid: true, errors: [] }); + let rejected = 0; + const rejects = (mutate, expected) => { + const candidate = structuredClone(fixture); + mutate(candidate); + const result = validate(candidate); + assert.equal(result.valid, false); + assert.match(result.errors.join("; "), expected); + rejected++; + }; + rejects(c => { c.live = true; c.mode = "live"; }, /never live/); + rejects(c => { c.label = "Live incident"; }, /frozen label/); + rejects(c => { c.nonSiteRecords[2].evidence.evidenceKind = "observation"; c.nonSiteRecords[2].evidence.verification = "independently-established"; }, /cannot become observation/); + rejects(c => { c.nonSiteRecords[2].launchTotal = 1015; }, /not launches or damage/); + rejects(c => { c.nonSiteRecords[2].physicalDamage = 1015; }, /not launches or damage/); + rejects(c => { c.nonSiteRecords[2].unit = "drones-launched"; }, /not launches or damage/); + for (let i = 0; i < 4; i++) { + rejects(c => { c.sites[i].operationalStatus.value = "closed"; }, /operations unknown/); + rejects(c => { c.sites[i].physicalDamageObserved = structuredClone(c.sites[0].physicalDamageClaimed); }, /not observed damage/); + rejects(c => { c.sites[i].casualties.value = { killed: 1, injured: 5 }; }, /cannot be allocated/); + } + rejects(c => { c.sites[3].operationalStatus = structuredClone(c.sites[3].commercialServiceEffects); }, /operations unknown/); + for (const key of ["severity", "confidence", "impact", "corroboration"]) { + rejects(c => { delete c.sites[0].dimensions[key]; c.sites[0].dimensions.score = 90; }, /dimensions must remain separate/); + } + rejects(c => { c.sites[0].dimensions.corroboration = 2; }, /dimensions must remain separate/); + rejects(c => { c.sites[0].reportedAttack.publisher = "Independent imagery"; }, /provenance mismatch/); + rejects(c => { c.sites[0].geography.geometry = { type: "Point", coordinates: [30, 60] }; }, /no sourced geometry/); + rejects(c => { c.sites[0].restorationUpdates.push("restored"); }, /restoration not sourced/); + rejects(c => { c.nonSiteRecords[5].mutuallyConfirmedTerms = "agreed"; }, /terms unconfirmed/); + assert.deepEqual(fixture.sites.map(site => site.casualties.value), [null, null, null, null]); + assert.notEqual(fixture.nonSiteRecords[0].evidence.scope, fixture.nonSiteRecords[1].evidence.scope); + assert.equal(fixture.sources.reuters.organization, fixture.sources.reutersRegional.organization); + assert.equal(fixture.sites[3].commercialServiceEffects.value, "normal-service-claimed"); + assert.equal(fixture.sites[3].physicalDamageClaimed.value, null); + console.log(`Multi-site frozen evaluation passed: valid fixture and ${rejected} rejected unsafe mutations.`); +} + +if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) runMultiSiteIncidentEvaluationTests(); diff --git a/tests/run-tests.mjs b/tests/run-tests.mjs index a38e3f8..0244fa1 100644 --- a/tests/run-tests.mjs +++ b/tests/run-tests.mjs @@ -1,4 +1,5 @@ import assert from "node:assert/strict"; +import { runMultiSiteIncidentEvaluationTests } from "./multi-site-incident-evaluation-tests.mjs"; import fs from "node:fs"; import { SEVERITIES } from "../src/config.js"; import { LAYER_CATALOG } from "../src/data/layers.js"; @@ -2087,5 +2088,6 @@ test("Chokepoint UI filtering, rendering, and event enrichment remain safe", () assert.deepEqual(enriched[0].affectedChokepoints, ["Suez Canal"]); }); +test("Frozen multi-site incident preserves claim and impact boundaries", runMultiSiteIncidentEvaluationTests); await runPendingTests(); console.log("All tests passed."); From 390b9a6b79bc89b03baf03f4fe4b1e02aed29384 Mon Sep 17 00:00:00 2001 From: Zacharon <113211893+Zacharon@users.noreply.github.com> Date: Tue, 20 Oct 2026 01:17:04 -0400 Subject: [PATCH 2/6] Make CLAUDE.md import AGENTS.md Replace the hand-synced copy with `@AGENTS.md` so the two files cannot drift; AGENTS.md is the single source. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 107 +----------------------------------------------------- 1 file changed, 1 insertion(+), 106 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 318a6ec..43c994c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,106 +1 @@ -# Live Map Agent Instructions - -These instructions apply to the whole repository. - -## ICM First-Read Pack - -Before broad repo exploration, read only this Interpretable Context Memory pack: - -1. `AGENTS.md` -2. `docs/PROJECT_HANDOFF.md` -3. `docs/LAST_30_DAYS.md` -4. `docs/API_CONTRACTS.md` -5. `docs/SECURITY_INVARIANTS.md` -6. `docs/NEXT_TASK_QUEUE.md` - -Then list the exact extra files needed for the task before reading more. Do not scan the whole repo unless the task truly requires it. - -Default agent workflow: - -- Work on one task only. -- Do not deploy. -- Do not push `main`. -- Do not refactor unrelated code. -- Run the smallest relevant tests. -- Update `docs/LAST_30_DAYS.md` and `docs/NEXT_TASK_QUEUE.md` when the work changes recent context or task priority. -- Use repo memory docs as source of truth over rediscovering architecture from scratch. - -Useful skill pipeline when available: `last30days-skill` for recent context, `Understand-Anything` for confusing code, `graphify` for architecture diagrams, `frontend-design` and `taste-skill` for UI, `stop-slop` for vague text, `gstack` for stack conventions, and `Remotion` only for later demo/marketing videos. - -## Deployment and API Compatibility - -- Never run Netlify deploy commands, build hooks, deployment APIs, manual deploy triggers, or production-publish actions unless the user explicitly asks for deployment. -- Never merge pull requests automatically. -- Do not push directly to `main`, `master`, or another production branch. -- Preserve Netlify static hosting compatibility: publish directory `.` and functions directory `netlify/functions`. -- Preserve `/api/events` and the direct `/.netlify/functions/events` endpoint. Do not rename, remove, or break either route. -- Preserve `/api/sources` and `/sources` when editing the master source registry or Source Explorer. -- Keep browser code static-host friendly. Do not require a build step unless `README.md`, `netlify.toml`, and GitHub Actions are updated together. - -## Secrets and Data Safety - -- Never expose secrets, access tokens, API keys, emails used for provider auth, or private credentials in browser code. -- Keep provider credentials in Netlify environment variables only. -- Do not place real API keys in `.env.example`, docs, tests, fixtures, screenshots, or source files. -- Never label fixtures, placeholder data, unavailable providers, or planned integrations as live. -- Never mark a master source registry entry `live` unless an adapter exists, terms are reviewed, attribution is implemented, and cache/retention policies are documented. -- Do not fabricate missing event data. -- Do not fabricate geography for non-geographic cyber, finance, or reference records. -- Do not present simplified country bounds as legal or precise boundaries. -- Keep detailed provider diagnostics on `/diagnostics`; the public dashboard should show only compact data-status summaries. -- Keep CII severity, confidence, impact, freshness, corroboration, and completeness separate. Do not collapse them into an unexplained number. -- Do not map SEC issuers to headquarters merely to create event markers. -- Do not claim causality between official economic, filing, energy, or market records and price movements unless verified by sources. -- Do not poll aircraft or vessel providers globally. Moving-object requests must be viewport-limited, server-side, cached, and capped. -- Do not expose OpenSky, Global Fishing Watch, AISHub, ADS-B, or AIS credentials in browser code. -- Do not claim complete global flight or vessel coverage. -- Do not identify private aircraft owners or infer vessel cargo/illegal behavior from position data. -- Sensitive humanitarian locations must be generalized or suppressed when precise display could increase risk. -- Do not mirror full copyrighted reports, PDFs, photos, exploit code, or malware samples. -- Do not add paid services without explicit approval. -- Keep public-information and risk claims explainable. -- Treat this application as informational, not emergency dispatch or operational guidance. - -## Source Quality - -### Open News and Social Signals - -- Never scrape restricted platforms or use access-control bypasses; registry-only means registry-only. -- Treat same organization, canonical URL, mirrors, and declared syndication as one source for corroboration. -- Never let reposts, cross-posts, likes, views, or social volume create verification. -- Keep social/video content metadata-only: no full text, comments, transcripts, chats, profiles, or raw payload retention without a documented review. -- Keep feed URLs allowlisted and server-side; preserve SSRF redirect and body limits. - -- Every live event source must include attribution, source URL, provider freshness, and source status. -- Every registry source must include access classification, implementation status, source tier, verification state, source URL, attribution, review dates, cache guidance, retention guidance, and limitations. -- Provider failures must be visible in `sourceStatus` and must not be hidden behind a successful-looking workflow result. -- If freshness, source status, or attribution changes, update the relevant docs and validator checks. -- Keep taxonomy, grouping, sorting, incident clustering, and provider-health behavior documented when changed. -- Keep non-geographic event behavior, request budgets, and provider scheduling documented when changed. -- Keep finance/commodity event classification, observation-vs-event rules, and provider-state behavior documented when changed. -- Keep country navigation, country-score methodology, diagnostics separation, provider capabilities, and opt-in provider gating documented when changed. -- Keep consumer UX, Standard/Advanced mode, moving-object API limits, tracking privacy disclosures, and aviation/maritime provider boundaries documented when changed. - -## Workflow - -- Use branches and pull requests for changes. Do not push directly to `main` unless the user explicitly asks for that. -- Keep changes scoped to the requested behavior. -- Update documentation whenever app behavior, deployment behavior, API shape, provider status, or validation behavior changes. - -## Required Checks - -Run the available syntax and validation checks before opening a PR: - -```bash -npm run check:syntax -npm run validate -``` - -For production or release changes, also run: - -```bash -npm run smoke:production -npm run security:scan -``` - -If a Windows Codex shell cannot find `npm` or resolves `node` to a blocked WindowsApps/Codex shim, follow `docs/LOCAL_VALIDATION.md` before treating GitHub Actions as the only source of validation. +@AGENTS.md From d7f31497d22e7d2e09d32e89a3e2203324312687 Mon Sep 17 00:00:00 2001 From: Zacharon <113211893+Zacharon@users.noreply.github.com> Date: Tue, 17 Nov 2026 01:11:41 -0500 Subject: [PATCH 3/6] Save in-progress work: Ukraine grid-region incident evaluation (schema v2) and hosted acceptance probe notes Extends the frozen multi-site incident evaluation with Reuters-attributed grid-region reports and focused query/negative tests, and records the 2026-10-19 PARTIAL hosted acceptance probe. Co-Authored-By: Claude Opus 5.5 --- docs/HOSTED_ACCEPTANCE_2026-10-19.md | 142 ++++++++++++++++++ docs/LAST_30_DAYS.md | 24 ++- docs/MULTI_SITE_INCIDENT_EVALUATION.md | 77 +++++++++- docs/NEXT_TASK_QUEUE.md | 11 ++ tests/fixtures/ukraine-grid-20261020.mjs | 78 ++++++++++ .../multi-site-incident-evaluation.mjs | 100 ++++++++++++ tests/run-tests.mjs | 2 + ...ukraine-grid-incident-evaluation-tests.mjs | 66 ++++++++ 8 files changed, 497 insertions(+), 3 deletions(-) create mode 100644 docs/HOSTED_ACCEPTANCE_2026-10-19.md create mode 100644 tests/fixtures/ukraine-grid-20261020.mjs create mode 100644 tests/ukraine-grid-incident-evaluation-tests.mjs diff --git a/docs/HOSTED_ACCEPTANCE_2026-10-19.md b/docs/HOSTED_ACCEPTANCE_2026-10-19.md new file mode 100644 index 0000000..c1a59fd --- /dev/null +++ b/docs/HOSTED_ACCEPTANCE_2026-10-19.md @@ -0,0 +1,142 @@ +# Hosted acceptance probe — October 19, 2026 + +Verdict: **PARTIAL; proposed hosted acceptance milestone remains open.** + +Observed 15:36–15:40 UTC using T3's collaborative browser. Desktop 1280×800 and +mobile layout 390×844 (desktop browser engine, not a physical mobile device). +No deployment, production configuration changes, provider activation, case import, +review approval or external publication was performed. + +## Revision and hosting identity + +Fetched `origin/main` read-only; it resolves to +`5aabf0f7903ecee7e10c12d05e7eea7113d2cf56`. This worktree stays on its separate +October 18 fixture branch. No rebase, merge or checkout was performed. + +GitHub's check-runs API reports success for validate, repo-secret-scan, +browser-secret-scan, CodeQL and Workers Builds on that revision. The Workers check +links build `cac3d61d-5a42-487b-b1bd-4543ec4f2555`. GitHub's deployments API returned +an empty array; that is not proof of no Cloudflare deployment. The serving Worker +version was not exposed by the sampled responses and was not independently bound +to the supplied `5ca83369-1dde-401a-8d72-f73f12a0ac96` version. + +- [Netlify homepage](https://liveworldmap.netlify.app/): HTTP 200, older operator + console visible; serving SHA unknown. +- [Netlify globe](https://liveworldmap.netlify.app/globe.html): fresh HTTP 404, + “Page not found.” This is a host/path observation, not a merged-code diagnosis. +- [Cloudflare homepage](https://live-map.zacharyfavaron.workers.dev/): HTTP 200, + Watch workspace visible; defaults to `mapMode=2d`. +- [Cloudflare globe](https://live-map.zacharyfavaron.workers.dev/globe.html): HTTP + 200. Normal 3D selection navigated to `/globe?...&mapMode=3d` and rendered Cesium. + +Five sampled frontend response bodies match `git show origin/main:` SHA-256: + +```text +index.html d898ffb47ec6b0a7b0288feb892f0a52d2bbdf0433b5159d3cfcbca8e21b55a6 +globe.html c56cb3ef9d835bcc853d10562db8663d2b6a77c6af785dfdc7c0ac504ac55dbd +src/app-controller.js 8dd8a724b9a050240f68b64f2a09250f0f1b25dbd6441a9915e8dd9287e65456 +src/map/cesium-adapter.js fcdec2879c94ac00e5b3b6938192aca532a383a86766d1b72205d394835f1ec2 +src/map/globe-controller.js 802e2f9cab8632cb3715f3fc2dd4a4c034688dea3b30f77bce81fbd35b96e72e +``` + +This establishes sampled frontend content parity. It does not prove the entire +deployed bundle, server code, serving version, or every asset matches that SHA. +One initial local hashing command failed due to PowerShell/native quoting; the +corrected stdin Node script produced the hashes above. No application change was +needed. + +## Genuine public-event journey + +Hosted `/api/events?hours=24` returned HTTP 200. Selected record: + +- ID `usgs:us6000u3ct`, M 5.3, 116 km WNW of Höfn, Iceland. +- [USGS source](https://earthquake.usgs.gov/earthquakes/eventpage/us6000u3ct). +- Occurred `2026-10-19T14:44:24.015Z`; source revision + `2026-10-19T14:59:53.040Z`; API `ingestedAt` `2026-10-19T15:37:10.607Z`. +- Latitude 64.5774, longitude -17.5136; provider `usgs`; reviewed in supplied + provider metadata. Source page itself was not independently opened in this run. +- Provider status reported healthy, not stale, with `stateStorageMode: memory`. + This is not evidence of durable collection or recovery. + +Clicked the ordinary report title, changed the native map-mode control to 3D, +opened the ordinary export disclosure, downloaded JSON, and used browser Back. +No synthetic event injection or demo mode was used for this journey. + +PASS observations: + +- The same ID/source/occurrence/revision appeared in list, inspector, globe + selection attribute and downloaded artifact. A selected marker and label were + visible on the desktop globe. +- Desktop 2D loaded 12 tile elements at the sampled moment. Globe loaded actual + same-origin Natural Earth JPEG tiles; network diagnostics show HTTP 200. +- Cloudflare homepage CSP has `script-src 'self' 'wasm-unsafe-eval'`; globe adds + `'unsafe-eval'`, retaining the other restrictions. No CSP refusal was found in + captured browser diagnostics. GPU ReadPixels warnings were present. +- The 2D→3D URL retained event ID, 24-hour window, filters, view, basemap, center + and zoom. Browser Back returned to the 2D homepage with those values retained. + Non-default as-of, different time windows and every filter combination were + NOT RUN. +- At 390×844, document scroll width remained 390. The globe rendered at mobile + layout and recovered after one Retry now action. Physical mobile testing and + owner visual acceptance remain NOT RUN. +- Existing `?failWebgl=1` hook explicitly disclosed forced unavailability and + retained the selected event and filters in the Leaflet fallback. This is a + forced renderer-failure probe, separate from the real API failure below. + +## Acceptance gaps and precise follow-up + +1. **Serving-version binding UNKNOWN.** Obtain read-only Cloudflare deployment + metadata linking the currently serving URL/version to the exact revision. + Sampled assets already match; no deployment is needed merely to investigate. +2. **USGS-to-case path not demonstrated.** Clicking Evidence ledger with the + USGS event selected opened `view=chokepoints`, Strait of Hormuz and + `case=portwatch-hormuz-2025-01`. The case selector exposed historical PortWatch, + synthetic Hormuz and Riyadh reporting. No USGS case entry was present. This + run therefore cannot accept the same event through Question → Evidence → + Assessment → Review → Export. Import is available, but was not used to invent + a native handoff or approval. Existing review gates were not exercised/closed. +3. **Mobile pane transition clears selection.** With the event selected in the + mobile Reports inspector, clicking Map removed `event=usgs:us6000u3ct` from + the URL and left `data-globe-selected-event` empty. This fails selection + preservation for that specific pane transition; it is distinct from the + successful desktop Back behavior. +4. **Export semantics differ.** API independentSourceCount/corroborationScore are + null and the inspector says “Independent sources: Not established.” The + snapshot card shows “Corroboration: 1”; JSON reports `distinctSourceCount: 1`, + `sourceKeys: ["usgs"]`, `display: "1 distinct source (related/co-cluster)"`. + Its caveat explicitly says this is not independent primary confirmation. + Record this as terminology/semantic parity ambiguity, not proof that JSON + claims independent verification. Inspector retrieval time also says “Not + supplied” despite API ingestedAt; document the intended clock mapping before + treating ingestion as publication or observation time. +5. **Observed API failure and recovery.** At 15:39:11 UTC console reported HTTP + 503 and `Error: API 503` in loadEvents. Mobile showed “Feed unavailable,” + “Event data temporarily unavailable,” and last successful refresh while + retaining the prior inspector. It also said “Next automatic retry + Future-dated.” This timestamp label is misleading for a scheduled future + retry. One manual Retry now later returned an Operational display with + 9/28 sources healthy; it does not explain the 503 or prove sustained recovery. + Root cause, broader host availability and stale-record export behavior remain + unverified. Do not generalize this single observed response into an outage. + +Next bounded work is version binding and these experience gaps using the merged +implementation. Native PostgreSQL concurrency/restore, hosted durable activation, +global tracking coverage and owner approval remain separate gates. No globe or +routing replacement was attempted. + +## Evidence retained locally + +Ignored directory `artifacts/hosted-acceptance-20261019/` contains: + +- `receipts.json`: browser results, source response sample, URLs, headers, sampled + hashes, globe attributes, ledger navigation, failure diagnostics and recovery. +- `usgs-export.json`: exact 12,676-byte downloaded artifact; not a case approval. +- `desktop-globe-selected.png`, `mobile-2d-selected.png`, + `mobile-feed-unavailable.png`, `mobile-map-after-retry.png`, + `forced-webgl-fallback.png`, `netlify-globe-404.png`. +- `manifest.json`: SHA-256 for those local files. These artifacts are not staged + or intended for static hosting. + +Docs-only follow-up: `git diff --check` and local receipt/export/manifest checks. +No product test suite rerun; no runtime files changed. Acceptance is bounded +browser evidence, not independent H3 or owner sign-off. diff --git a/docs/LAST_30_DAYS.md b/docs/LAST_30_DAYS.md index 6811ba5..7176d50 100644 --- a/docs/LAST_30_DAYS.md +++ b/docs/LAST_30_DAYS.md @@ -1,6 +1,28 @@ # Last 30 Days -Last updated: 2026-10-18. +Last updated: 2026-10-21. + +## 2026-10-21 - Frozen grid-region incident extension + +- Extended the existing offline multi-site evaluation container to schema v2 for + Reuters-attributed Ukrainian grid-region reports. Kept exact assets, physical + damage, outage start, restoration, and cessation verification unknown or false; + Odesa's 32,700 families is explicitly a report-time regional observation. +- Focused query/negative tests and feature-standard gates are documented in + `MULTI_SITE_INCIDENT_EVALUATION.md`. No provider, public API, or UI change. + +## 2026-10-19 - Hosted acceptance probe (PARTIAL) + +- Fetched remote main `5aabf0f` read-only; globe/workbench foundation is merged. + Older local-only/open-PR statements below remain historical. +- Cloudflare 2D/globe and real USGS source-snapshot journey worked; five frontend + assets match main. Serving Worker version remains unbound. Netlify globe 404 + was reproduced without a serving SHA. +- Mobile Map cleared selection; USGS Evidence ledger navigation opened Hormuz; + export source-count terminology differs from inspector independent evidence; + one API 503 exposed an incorrect future retry label before manual recovery. +- Details and locally retained receipts: `HOSTED_ACCEPTANCE_2026-10-19.md`. + No deployment or runtime edits. Hosted acceptance and owner review remain open. ## 2026-10-18 - Frozen multi-site incident evaluation diff --git a/docs/MULTI_SITE_INCIDENT_EVALUATION.md b/docs/MULTI_SITE_INCIDENT_EVALUATION.md index ce9f9b9..ac35f21 100644 --- a/docs/MULTI_SITE_INCIDENT_EVALUATION.md +++ b/docs/MULTI_SITE_INCIDENT_EVALUATION.md @@ -1,6 +1,6 @@ -# Frozen St. Petersburg multi-site evaluation +# Frozen multi-site incident evaluations -This is one **frozen evaluation fixture**, dated 2026-10-18, with partial source +The original St. Petersburg case is a **frozen evaluation fixture**, dated 2026-10-18, with partial source retrieval and unverified claims. It is not live data, an operational assessment, or a public feed feature. No provider, UI, or API imports it. @@ -96,3 +96,76 @@ Product UI, hosted operation, live provider and real-user gates are NOT RUN. - `git diff --check`: PASS. No push, PR, merge, production smoke or deployment performed. + +## 2026-10-21 grid-region extension (schema v2, offline) + +`tests/fixtures/ukraine-grid-20261020.mjs` extends the same multi-site +evaluation container (`sources`, `sites`, `nonSiteRecords`) and the same per-field +evidence envelope and separate assessment dimensions. The one validator +dispatches on `schemaVersion`. `sites` holds seven **regional reports**, not seven identified facilities +or map points. Five western regions are marked as newly targeted **according to +the reported statement**; Kirovohrad and Odesa are central/southern reports. +The Odesa regional record says DTEK reported **three facilities hit**. It does +not name any of them or allocate the 32,700 families among them. + +Each regional record stores `reportedTargetRegion`, `specificAsset`, +`physicalDamage`, `outageStart`, `customersAffected`, `restorationUpdate`, +`source`, and `observationTime` separately. Unknown asset, physical damage, +outage start, and restoration are explicit `null` evidence values. The Odesa +32,700 unit is **families**, with `point-in-time-at-report`, +`permanence: not-established`, and no per-incident or per-facility allocation. +The six regions without a count carry `null`, including no invented unit. The exact DTEK +observation clock is unavailable; `2026-10-20` is report-day precision, separate +from publication and retrieval. Ukrainian energy ministry officials and local +authorities reported the aggregate western expansion. Nekrasov named the +regions and central/western/southern labels; DTEK supplied the Odesa facility +count and family figure. The announced halt is context with Trump as announcer, +Zelenskiy as the speaker reporting it, unknown announcement date, an inferred +Sunday statement date (2026-10-18), and `cessationVerified: false`. It is not +a ceasefire finding. The earlier St. Petersburg fixture's October 11 halt +context is cross-referenced without treating it as a second independent source. +The Sunday Zelenskiy statement may also be the original fixture's weekly +attack-count statement; that possible match is referenced but not counted as +independent evidence. + +The [Reuters article](https://www.reuters.com/business/energy/russia-expands-attacks-energy-facilities-western-ukraine-2026-10-20/) +could not be opened directly in this environment. A +[Reuters syndication snapshot](https://uk.marketscreener.com/news/russia-expands-attacks-on-energy-facilities-to-western-ukraine-ce785cd8d88dfe2c) +was read on 2026-10-21. Its displayed publication/update times are 2026-10-20 +12:50/12:55 BST (11:50/11:55 UTC); the fixture stores a short factual snapshot, +not article text. This is one Reuters origin, not independent corroboration. + +Read-only capability `queryGridIncidentFixture/v2` takes the frozen fixture and +returns an allowlisted regional expansion, Odesa record and halt context after +`validateMultiSiteIncidentFixture` dispatches to the v2 validation branch and +rejects unsupported promotions and extra keys. Human and agent +use the same local command and validation: + +```sh +node tests/ukraine-grid-incident-evaluation-tests.mjs +``` + +Feature-standard gates 1–4 (local test environment): + +| Gate | Status | Evidence and limit | +| --- | --- | --- | +| 1 Shared capabilities | PASS for this read-only evaluation | The documented command calls the same `queryGridIncidentFixture/v2` and validator for a person or an agent. No product adapter was added. | +| 2 Shared state | NOT APPLICABLE | Query reads a versioned frozen fixture; it writes no application or user state. | +| 3 Scoped authority | NOT APPLICABLE | No user, role, grant, or external effect is involved; the fixture is local test data. This grants no ingestion permission. | +| 4 Human usability | PASS for this evaluation | A person can run the command without AI and read the JSON projection and explicit validation errors. Product UI and keyboard use are NOT RUN. | + +Gates 5–7 are NOT APPLICABLE because the capability writes no user data and +causes no external effect. This is candidate evaluation evidence only; live +provider, public API/UI, OSINT Forge storage, independently verified damage, +outage duration, and restoration remain NOT RUN or unknown. + +Local verification on 2026-10-21: `node tests/ukraine-grid-incident-evaluation-tests.mjs` +exited 0 and reported `7 regional reports, 32,700 families at report time, +25 rejected unsafe mutations`. The query JSON includes the five western names, +Odesa count 3, family count 32,700 with point-in-time and permanence caveats, +`null` asset/damage/outage/restoration values, and `cessationVerified: false`. +`npm.cmd run check:syntax` exited 0 (`Cloudflare exports are valid.`). +`npm.cmd test` exited 0: platform suite `All tests passed`; nested validator +`Result: PASS (10 checks, 0 failed)` with one `mode=partial-netlify-function` +warning; E2E and Source Explorer smoke tests passed. These are local tests, +not proof of live case data or hosted UI. diff --git a/docs/NEXT_TASK_QUEUE.md b/docs/NEXT_TASK_QUEUE.md index a91027a..1746d8d 100644 --- a/docs/NEXT_TASK_QUEUE.md +++ b/docs/NEXT_TASK_QUEUE.md @@ -4,6 +4,17 @@ Small, agent-ready tasks only. Do not turn these into broad refactors. ## Context Updates +- 2026-10-21: frozen multi-site schema v2 now has an offline Ukraine grid-region + case and report-time family impact query. Do not promote it into live ingestion; + exact assets, outage/restoration clocks, independent damage and ceasefire + verification need new source evidence. See `MULTI_SITE_INCIDENT_EVALUATION.md`. + +- 2026-10-19: foundation is merged in remote main `5aabf0f`; prioritize existing + hosted acceptance, not a globe rewrite. `HOSTED_ACCEPTANCE_2026-10-19.md` records + working Cloudflare 2D/3D/public-USGS snapshots and remaining version binding, + USGS-to-case handoff, mobile selection and failure/semantic presentation gaps. + Netlify `/globe.html` returned 404, serving SHA unknown. No deployment authorized. + - Completed locally (2026-10-18): frozen multi-site incident evaluation and offline semantic regression tests. See `MULTI_SITE_INCIDENT_EVALUATION.md`. Follow-up: retrieve complete reporting/primary statements and reconcile regional casualty diff --git a/tests/fixtures/ukraine-grid-20261020.mjs b/tests/fixtures/ukraine-grid-20261020.mjs new file mode 100644 index 0000000..27e9e55 --- /dev/null +++ b/tests/fixtures/ukraine-grid-20261020.mjs @@ -0,0 +1,78 @@ +// Frozen v2 extension of the existing multi-site evidence-envelope fixture. No provider imports. +const source = { + publisher: "Reuters", organization: "reuters", + url: "https://www.reuters.com/business/energy/russia-expands-attacks-energy-facilities-western-ukraine-2026-10-20/", + snapshotUrl: "https://uk.marketscreener.com/news/russia-expands-attacks-on-energy-facilities-to-western-ukraine-ce785cd8d88dfe2c", + retrieval: "Reuters-syndication-snapshot; direct Reuters page unavailable", + publishedAt: "2026-10-20T11:50:00Z", updatedAt: "2026-10-20T11:55:00Z", + retrievedAt: "2026-10-21T18:00:55Z", + snapshotFacts: [ + "Ukrainian energy ministry officials and local authorities reported expansion into previously untargeted western regions", + "Nekrasov named Zhytomyr, Lviv, Rivne, Ternopil, Khmelnytskyi, Kirovohrad and Odesa as struck regions", + "DTEK reported three Odesa-region energy facilities hit and 32,700 families remaining without power", + "Zelenskiy described attacks after Trump's announced energy-attack halt; cessation was not independently verified in this snapshot", + ], +}; +export const sources = { reuters: source }; + +function field(value, claimantType = null, claimant = null, scope = null, eventDate = "2026-10-20") { + const sourced = claimant !== null; + return { + value, sourceId: sourced ? "reuters" : null, + source: sourced ? source.url : null, + publisher: sourced ? source.publisher : null, + publishedAt: sourced ? source.publishedAt : null, + eventDate, observedAt: null, + retrievedAt: sourced ? source.retrievedAt : null, + claimantType, claimant, scope, confidence: "unknown", + verification: "unverified", evidenceKind: sourced ? "claim" : "unknown", + provenance: sourced ? source.retrieval : "not-sourced", + }; +} + +function region(name, area, western) { + const scope = `${name} region, Ukraine`; + return { + id: `grid-${name.toLowerCase()}`, name: `${name} regional energy report`, + siteScope: "regional-report; physical sites unidentified", + geography: { label: scope, precision: "region-label-only", geometry: null }, + reportedAttack: field("reported-targeted", "national-authority", "Artem Nekrasov", scope), + physicalDamageClaimed: field(null), physicalDamageObserved: field(null), + operationalStatus: field("unknown"), casualties: field(null), + commercialServiceEffects: field("unknown"), + restorationUpdates: [], restorationStatus: "unknown", + dimensions: { severity: "unknown", confidence: "unknown", impact: "unknown", corroboration: 0, freshness: "frozen", completeness: "partial" }, + reportedTargetRegion: field({ name, area }, "national-authority", "Artem Nekrasov", scope), + reportedExpansion: western ? field("previously-untargeted-reported", "official-sources", "Ukrainian energy ministry officials and local authorities", "western regions (aggregate); Ukraine") : field(null), + reportedFacilityCount: field(null), specificAsset: field(null), + physicalDamage: field(null), outageStart: field(null), + customersAffected: field(null), restorationUpdate: field(null), + source: { sourceId: "reuters", url: source.url }, + observationTime: { exact: null, reportedAsOfDate: "2026-10-20", precision: "day", basis: "report-day; exact source observation clock unknown" }, + }; +} + +const sites = [ + ...["Zhytomyr", "Lviv", "Rivne", "Ternopil", "Khmelnytskyi"].map(name => region(name, "western", true)), + region("Kirovohrad", "central", false), region("Odesa", "southern", false), +]; +const odesa = sites.at(-1); +odesa.reportedFacilityCount = field(3, "company", "DTEK", "Odesa region; unidentified facilities"); +odesa.customersAffected = field({ count: 32700, unit: "families", temporalScope: "point-in-time-at-report", permanence: "not-established", incidentAllocation: "not-established" }, "company", "DTEK", "Odesa regional count; no per-facility allocation"); + +export const ukraineGridIncidentFixture = { + schemaVersion: 2, id: "ukraine-grid-regional-strikes-20261020", + label: "Frozen evaluation fixture - Reuters-attributed regional grid reports", + mode: "frozen-evaluation", live: false, frozenOn: "2026-10-21", + sources, sites, + nonSiteRecords: [{ + id: "energy-attack-halt", kind: "context", + evidence: field("announced-energy-attack-halt", "national-authority", "Volodymyr Zelenskiy", "Zelenskiy's account of Donald Trump's announcement; Russia/Ukraine energy infrastructure", "2026-10-18"), + announcer: "Donald Trump", announcementDate: null, + reportedStatementDate: "2026-10-18", statementDateBasis: "Sunday inferred from Reuters Tuesday 2026-10-20 publication", + cessationVerified: false, + priorFixtureContextId: "st-petersburg-multi-site-20261018:ceasefire-announcement", + possiblePriorStatementContextId: "st-petersburg-multi-site-20261018:ukraine-energy-attacks", + observationTime: { exact: null, reportedAsOfDate: "2026-10-18", precision: "day", basis: "statement-day inferred; announcement clock unknown" }, + }], +}; diff --git a/tests/helpers/multi-site-incident-evaluation.mjs b/tests/helpers/multi-site-incident-evaluation.mjs index b2dad7e..733ec63 100644 --- a/tests/helpers/multi-site-incident-evaluation.mjs +++ b/tests/helpers/multi-site-incident-evaluation.mjs @@ -1,7 +1,11 @@ // Evaluation-only contract: no production provider or API imports this module. +import { isDeepStrictEqual } from "node:util"; + export function validateMultiSiteIncidentFixture(input) { + if (input?.schemaVersion === 2) return validateGridIncidentFixture(input); const errors = []; const require = (condition, message) => { if (!condition) errors.push(message); }; + require(input?.schemaVersion === 1, "unsupported multi-site schema version"); require(input?.mode === "frozen-evaluation" && input?.live === false, "fixture must remain frozen, never live"); require(input?.label?.startsWith("Frozen evaluation fixture"), "frozen label required"); const checkField = (field, path) => { @@ -42,3 +46,99 @@ export function validateMultiSiteIncidentFixture(input) { require(terms?.mutuallyConfirmedTerms === null && terms?.evidence?.provenance === "brief-only", "ceasefire terms unconfirmed"); return { valid: errors.length === 0, errors }; } + +const FIELD_KEYS = ["value", "sourceId", "source", "publisher", "publishedAt", "eventDate", "observedAt", "retrievedAt", "claimantType", "claimant", "scope", "confidence", "verification", "evidenceKind", "provenance"]; +const SITE_KEYS = ["id", "name", "siteScope", "geography", "reportedAttack", "physicalDamageClaimed", "physicalDamageObserved", "operationalStatus", "casualties", "commercialServiceEffects", "restorationUpdates", "restorationStatus", "dimensions", "reportedTargetRegion", "reportedExpansion", "reportedFacilityCount", "specificAsset", "physicalDamage", "outageStart", "customersAffected", "restorationUpdate", "source", "observationTime"]; +const SOURCE_FACTS = [ + "Ukrainian energy ministry officials and local authorities reported expansion into previously untargeted western regions", + "Nekrasov named Zhytomyr, Lviv, Rivne, Ternopil, Khmelnytskyi, Kirovohrad and Odesa as struck regions", + "DTEK reported three Odesa-region energy facilities hit and 32,700 families remaining without power", + "Zelenskiy described attacks after Trump's announced energy-attack halt; cessation was not independently verified in this snapshot", +]; + +function validateGridIncidentFixture(input) { + const errors = []; + const need = (condition, message) => { if (!condition) errors.push(message); }; + const keys = (object, expected, path) => need(object && typeof object === "object" && !Array.isArray(object) && Object.keys(object).length === expected.length && expected.every(key => Object.hasOwn(object, key)), `${path}: unexpected or missing keys`); + const sameArray = (actual, expected) => Array.isArray(actual) && actual.length === expected.length && actual.every((value, index) => value === expected[index]); + keys(input, ["schemaVersion", "id", "label", "mode", "live", "frozenOn", "sources", "sites", "nonSiteRecords"], "fixture"); + need(input?.schemaVersion === 2 && input?.id === "ukraine-grid-regional-strikes-20261020" && input?.label === "Frozen evaluation fixture - Reuters-attributed regional grid reports" && input?.mode === "frozen-evaluation" && input?.live === false && input?.frozenOn === "2026-10-21", "fixture identity/frozen label mismatch"); + keys(input?.sources, ["reuters"], "sources"); + const origin = input?.sources?.reuters; + keys(origin, ["publisher", "organization", "url", "snapshotUrl", "retrieval", "publishedAt", "updatedAt", "retrievedAt", "snapshotFacts"], "Reuters source"); + need(origin?.publisher === "Reuters" && origin?.organization === "reuters" && origin?.url === "https://www.reuters.com/business/energy/russia-expands-attacks-energy-facilities-western-ukraine-2026-10-20/" && origin?.snapshotUrl === "https://uk.marketscreener.com/news/russia-expands-attacks-on-energy-facilities-to-western-ukraine-ce785cd8d88dfe2c" && origin?.retrieval === "Reuters-syndication-snapshot; direct Reuters page unavailable" && origin?.publishedAt === "2026-10-20T11:50:00Z" && origin?.updatedAt === "2026-10-20T11:55:00Z" && origin?.retrievedAt === "2026-10-21T18:00:55Z" && sameArray(origin?.snapshotFacts, SOURCE_FACTS), "Reuters source snapshot mismatch"); + const checkField = (field, path, value, claimantType = null, claimant = null, scope = null, eventDate = "2026-10-20") => { + keys(field, FIELD_KEYS, path); + if (!field) return; + const sourced = claimant !== null; + need(isDeepStrictEqual(field.value, value), `${path}: unsupported value`); + need(field.sourceId === (sourced ? "reuters" : null) && field.source === (sourced ? origin?.url : null) && field.publisher === (sourced ? "Reuters" : null) && field.publishedAt === (sourced ? origin?.publishedAt : null) && field.retrievedAt === (sourced ? origin?.retrievedAt : null) && field.provenance === (sourced ? origin?.retrieval : "not-sourced") && field.evidenceKind === (sourced ? "claim" : "unknown"), `${path}: provenance/evidence mismatch`); + need(field.claimantType === claimantType && field.claimant === claimant && field.scope === scope && field.eventDate === eventDate && field.observedAt === null && field.confidence === "unknown" && field.verification === "unverified", `${path}: attribution/time/verification mismatch`); + }; + const west = ["Zhytomyr", "Lviv", "Rivne", "Ternopil", "Khmelnytskyi"]; + const expectedRegions = [...west, "Kirovohrad", "Odesa"]; + need(input?.sites?.length === 7, "seven regional reports required"); + need(sameArray(input?.sites?.map(site => site.reportedTargetRegion?.value?.name), expectedRegions), "regional expansion missing or reordered"); + for (const [index, site] of (input?.sites || []).entries()) { + const name = expectedRegions[index]; + const area = west.includes(name) ? "western" : name === "Odesa" ? "southern" : "central"; + const scope = `${name} region, Ukraine`; + const path = site?.id || `site-${index}`; + keys(site, SITE_KEYS, path); + need(site?.id === `grid-${name.toLowerCase()}` && site?.name === `${name} regional energy report` && site?.siteScope === "regional-report; physical sites unidentified", `${path}: site identity mismatch`); + keys(site?.geography, ["label", "precision", "geometry"], `${path}.geography`); + need(site?.geography?.label === scope && site?.geography?.precision === "region-label-only" && site?.geography?.geometry === null, `${path}: precise site/geometry unsupported`); + checkField(site?.reportedAttack, `${path}.reportedAttack`, "reported-targeted", "national-authority", "Artem Nekrasov", scope); + for (const key of ["physicalDamageClaimed", "physicalDamageObserved", "casualties", "specificAsset", "physicalDamage", "outageStart", "restorationUpdate"]) checkField(site?.[key], `${path}.${key}`, null); + checkField(site?.operationalStatus, `${path}.operationalStatus`, "unknown"); + checkField(site?.commercialServiceEffects, `${path}.commercialServiceEffects`, "unknown"); + need(Array.isArray(site?.restorationUpdates) && site.restorationUpdates.length === 0 && site.restorationStatus === "unknown", `${path}: restoration unknown`); + keys(site?.dimensions, ["severity", "confidence", "impact", "corroboration", "freshness", "completeness"], `${path}.dimensions`); + need(site?.dimensions?.severity === "unknown" && site?.dimensions?.confidence === "unknown" && site?.dimensions?.impact === "unknown" && site?.dimensions?.corroboration === 0 && site?.dimensions?.freshness === "frozen" && site?.dimensions?.completeness === "partial", `${path}: assessment dimensions must remain separate`); + checkField(site?.reportedTargetRegion, `${path}.reportedTargetRegion`, { name, area }, "national-authority", "Artem Nekrasov", scope); + keys(site?.reportedTargetRegion?.value, ["name", "area"], `${path}.reportedTargetRegion.value`); + if (west.includes(name)) checkField(site?.reportedExpansion, `${path}.reportedExpansion`, "previously-untargeted-reported", "official-sources", "Ukrainian energy ministry officials and local authorities", "western regions (aggregate); Ukraine"); + else checkField(site?.reportedExpansion, `${path}.reportedExpansion`, null); + if (name === "Odesa") { + checkField(site?.reportedFacilityCount, `${path}.reportedFacilityCount`, 3, "company", "DTEK", "Odesa region; unidentified facilities"); + checkField(site?.customersAffected, `${path}.customersAffected`, { count: 32700, unit: "families", temporalScope: "point-in-time-at-report", permanence: "not-established", incidentAllocation: "not-established" }, "company", "DTEK", "Odesa regional count; no per-facility allocation"); + keys(site?.customersAffected?.value, ["count", "unit", "temporalScope", "permanence", "incidentAllocation"], `${path}.customersAffected.value`); + } else { + checkField(site?.reportedFacilityCount, `${path}.reportedFacilityCount`, null); + checkField(site?.customersAffected, `${path}.customersAffected`, null); + } + keys(site?.source, ["sourceId", "url"], `${path}.source`); + need(site?.source?.sourceId === "reuters" && site?.source?.url === origin?.url, `${path}: source reference mismatch`); + keys(site?.observationTime, ["exact", "reportedAsOfDate", "precision", "basis"], `${path}.observationTime`); + need(site?.observationTime?.exact === null && site?.observationTime?.reportedAsOfDate === "2026-10-20" && site?.observationTime?.precision === "day" && site?.observationTime?.basis === "report-day; exact source observation clock unknown", `${path}: observation clock unsupported`); + } + need(input?.nonSiteRecords?.length === 1, "one halt context record required"); + const halt = input?.nonSiteRecords?.[0]; + keys(halt, ["id", "kind", "evidence", "announcer", "announcementDate", "reportedStatementDate", "statementDateBasis", "cessationVerified", "priorFixtureContextId", "possiblePriorStatementContextId", "observationTime"], "halt"); + need(halt?.id === "energy-attack-halt" && halt?.kind === "context" && halt?.announcer === "Donald Trump" && halt?.announcementDate === null && halt?.reportedStatementDate === "2026-10-18" && halt?.statementDateBasis === "Sunday inferred from Reuters Tuesday 2026-10-20 publication" && halt?.cessationVerified === false && halt?.priorFixtureContextId === "st-petersburg-multi-site-20261018:ceasefire-announcement" && halt?.possiblePriorStatementContextId === "st-petersburg-multi-site-20261018:ukraine-energy-attacks", "announced halt is not verified cessation"); + checkField(halt?.evidence, "halt.evidence", "announced-energy-attack-halt", "national-authority", "Volodymyr Zelenskiy", "Zelenskiy's account of Donald Trump's announcement; Russia/Ukraine energy infrastructure", "2026-10-18"); + keys(halt?.observationTime, ["exact", "reportedAsOfDate", "precision", "basis"], "halt.observationTime"); + need(halt?.observationTime?.exact === null && halt?.observationTime?.reportedAsOfDate === "2026-10-18" && halt?.observationTime?.precision === "day" && halt?.observationTime?.basis === "statement-day inferred; announcement clock unknown", "halt statement time mismatch"); + return { valid: errors.length === 0, errors }; +} + +export function queryGridIncidentFixture(input) { + if (input?.schemaVersion !== 2) throw new Error("grid query requires multi-site schema v2"); + const result = validateMultiSiteIncidentFixture(input); + if (!result.valid) throw new Error(result.errors.join("; ")); + const odesa = input.sites.find(site => site.reportedTargetRegion.value.name === "Odesa"); + return { + newlyReportedWesternRegions: input.sites.filter(site => site.reportedExpansion.value !== null).map(site => site.reportedTargetRegion.value.name), + odesa: { + reportedFacilityCount: odesa.reportedFacilityCount.value, + customersAffected: odesa.customersAffected.value, + specificAsset: odesa.specificAsset.value, + physicalDamage: odesa.physicalDamage.value, + outageStart: odesa.outageStart.value, + restorationUpdate: odesa.restorationUpdate.value, + source: odesa.source, + observationTime: odesa.observationTime, + }, + energyAttackHalt: { announcer: input.nonSiteRecords[0].announcer, announcementDate: input.nonSiteRecords[0].announcementDate, reportedStatementDate: input.nonSiteRecords[0].reportedStatementDate, cessationVerified: input.nonSiteRecords[0].cessationVerified }, + }; +} diff --git a/tests/run-tests.mjs b/tests/run-tests.mjs index 0244fa1..2306184 100644 --- a/tests/run-tests.mjs +++ b/tests/run-tests.mjs @@ -1,5 +1,6 @@ import assert from "node:assert/strict"; import { runMultiSiteIncidentEvaluationTests } from "./multi-site-incident-evaluation-tests.mjs"; +import { runUkraineGridIncidentEvaluationTests } from "./ukraine-grid-incident-evaluation-tests.mjs"; import fs from "node:fs"; import { SEVERITIES } from "../src/config.js"; import { LAYER_CATALOG } from "../src/data/layers.js"; @@ -2089,5 +2090,6 @@ test("Chokepoint UI filtering, rendering, and event enrichment remain safe", () }); test("Frozen multi-site incident preserves claim and impact boundaries", runMultiSiteIncidentEvaluationTests); +test("Frozen grid multi-site incident keeps regions and report-time impact separate", runUkraineGridIncidentEvaluationTests); await runPendingTests(); console.log("All tests passed."); diff --git a/tests/ukraine-grid-incident-evaluation-tests.mjs b/tests/ukraine-grid-incident-evaluation-tests.mjs new file mode 100644 index 0000000..1cc6fcb --- /dev/null +++ b/tests/ukraine-grid-incident-evaluation-tests.mjs @@ -0,0 +1,66 @@ +import assert from "node:assert/strict"; +import { pathToFileURL } from "node:url"; +import { ukraineGridIncidentFixture as fixture } from "./fixtures/ukraine-grid-20261020.mjs"; +import { queryGridIncidentFixture, validateMultiSiteIncidentFixture } from "./helpers/multi-site-incident-evaluation.mjs"; + +export function runUkraineGridIncidentEvaluationTests() { + assert.deepEqual(validateMultiSiteIncidentFixture(fixture), { valid: true, errors: [] }); + const answer = queryGridIncidentFixture(fixture); + assert.deepEqual(Object.keys(answer), ["newlyReportedWesternRegions", "odesa", "energyAttackHalt"]); + assert.deepEqual(Object.keys(answer.odesa), ["reportedFacilityCount", "customersAffected", "specificAsset", "physicalDamage", "outageStart", "restorationUpdate", "source", "observationTime"]); + assert.deepEqual(answer.newlyReportedWesternRegions, ["Zhytomyr", "Lviv", "Rivne", "Ternopil", "Khmelnytskyi"]); + assert.equal(answer.odesa.reportedFacilityCount, 3); + assert.deepEqual(answer.odesa.customersAffected, { count: 32700, unit: "families", temporalScope: "point-in-time-at-report", permanence: "not-established", incidentAllocation: "not-established" }); + assert.equal(answer.odesa.observationTime.exact, null); + assert.equal(answer.odesa.observationTime.reportedAsOfDate, "2026-10-20"); + assert.equal(answer.odesa.outageStart, null); + assert.equal(answer.odesa.restorationUpdate, null); + assert.equal(answer.odesa.specificAsset, null); + assert.equal(answer.odesa.physicalDamage, null); + assert.equal(answer.energyAttackHalt.cessationVerified, false); + assert.equal(answer.energyAttackHalt.announcer, "Donald Trump"); + assert.equal(answer.energyAttackHalt.announcementDate, null); + assert.equal(fixture.nonSiteRecords[0].evidence.eventDate, "2026-10-18"); + assert.equal(fixture.sites[6].customersAffected.evidenceKind, "claim"); + assert.deepEqual(Object.keys(fixture.sites[6].dimensions), ["severity", "confidence", "impact", "corroboration", "freshness", "completeness"]); + let rejected = 0; + const rejects = (mutate, message) => { + const changed = structuredClone(fixture); + mutate(changed); + const result = validateMultiSiteIncidentFixture(changed); + assert.equal(result.valid, false); + assert.match(result.errors.join("; "), message); + assert.throws(() => queryGridIncidentFixture(changed)); + rejected++; + }; + rejects(c => { c.sites[0].reportedTargetRegion.value.name = "Unknown"; }, /regional expansion|unsupported value/); + rejects(c => { c.sites[6].customersAffected.value.temporalScope = "permanent"; }, /unsupported value/); + rejects(c => { c.sites[6].customersAffected.value.permanence = "permanent"; }, /unsupported value/); + rejects(c => { c.sites[6].customersAffected.value.count = 32700 * 3; }, /unsupported value/); + rejects(c => { c.sites[6].specificAsset.value = "Odesa substation A"; }, /unsupported value/); + rejects(c => { c.sites[6].physicalDamage.value = "confirmed"; }, /unsupported value/); + rejects(c => { c.sites[6].outageStart.value = "2026-10-20T00:00:00Z"; }, /unsupported value/); + rejects(c => { c.sites[6].restorationUpdate.value = "restored"; }, /unsupported value/); + rejects(c => { c.sites[6].observationTime.exact = "2026-10-20T11:50:00Z"; }, /observation clock/); + rejects(c => { c.nonSiteRecords[0].cessationVerified = true; }, /not verified cessation/); + rejects(c => { c.sites[6].geography.geometry = { type: "Point", coordinates: [30, 46] }; }, /precise site/); + rejects(c => { c.sources.reuters.organization = "independent-second-source"; }, /source snapshot/); + // Independent adversarial paths found in H3 round 1: extra keys must fail closed. + rejects(c => { c.sites[6].permanentOutage = true; }, /unexpected or missing keys/); + rejects(c => { c.nonSiteRecords[0].ceasefire = "verified"; }, /unexpected or missing keys/); + rejects(c => { c.sites[6].geography.coordinates = [30.7, 46.4]; }, /unexpected or missing keys/); + rejects(c => { c.sites[6].geography.label = "Odesa TPP-2, Ukraine"; }, /precise site/); + rejects(c => { c.label = "Live grid feed"; }, /frozen label/); + rejects(c => { c.corroboration = 2; }, /unexpected or missing keys/); + rejects(c => { c.sources.ap = {}; }, /unexpected or missing keys/); + rejects(c => { c.sources.reuters.snapshotFacts[3] = "Ceasefire verified"; }, /source snapshot/); + rejects(c => { c.sites[6].customersAffected.claimant = "independent observer"; }, /attribution/); + rejects(c => { c.nonSiteRecords[0].evidence.evidenceKind = "observation"; }, /provenance/); + rejects(c => { c.sources.reuters.updatedAt = "2026-10-20T12:00:00Z"; }, /source snapshot/); + rejects(c => { c.sites[0].reportedExpansion.claimant = "Reuters"; }, /attribution/); + rejects(c => { c.sites[6].reportedTargetRegion.value.toJSON = () => ({ name: "Odesa", area: "southern" }); c.sites[6].reportedTargetRegion.value.preciseAsset = "Odesa TPP-2"; }, /unexpected or missing keys|unsupported value/); + console.log(`Ukraine grid multi-site evaluation passed: 7 regional reports, 32,700 families at report time, ${rejected} rejected unsafe mutations.`); + console.log(JSON.stringify(answer)); +} + +if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) runUkraineGridIncidentEvaluationTests(); From 5a479a431b9b726e02529d57abebbc8f1cb454bd Mon Sep 17 00:00:00 2001 From: Zacharon <113211893+Zacharon@users.noreply.github.com> Date: Tue, 17 Nov 2026 01:22:09 -0500 Subject: [PATCH 4/6] Save in-progress work: honest manual-refresh feedback and safe NWS source URLs The refresh button now reports the actual outcome (refreshed, partial, no provider data, public snapshots, failed) instead of always saying 'Refreshed'; Watch reset also clears the verification filter; NWS alert links go through safeSourceUrl. Adds audit-repair regressions. Co-Authored-By: Claude Opus 5.5 --- docs/LAST_30_DAYS.md | 12 + docs/NEXT_TASK_QUEUE.md | 10 + src/app-controller.js | 21 +- src/data/providers/nws.js | 7 +- .../osint-dashboard-v2/event-detail-drawer.js | 9 +- tests/audit-repair-tests.mjs | 239 +++++++++++++++++- 6 files changed, 288 insertions(+), 10 deletions(-) diff --git a/docs/LAST_30_DAYS.md b/docs/LAST_30_DAYS.md index 0a8e6bf..9e596a2 100644 --- a/docs/LAST_30_DAYS.md +++ b/docs/LAST_30_DAYS.md @@ -1,3 +1,15 @@ +## 2026-10-31 - Event-to-original-source journey (same isolated candidate) + +Extended the existing refresh candidate within the selected journey: Clear report filters resets verification too; the inspector places source revision and supplied retrieval time beside Open original source; NWS keeps a supplied alert-specific web/GeoJSON identity instead of substituting the active-feed collection or homepage. Missing original links and clocks remain unavailable. Invalid supplied web links still fail validation. No URL is invented from a URN. + +An unrelated render keeps the in-flight refresh label, and a delayed manual feedback reset leaves demo mode's reload label intact. The original refresh patch/evidence remains separate. Local synthetic regressions cover the source/filter/detail path and failure/retry; browser/keyboard/mobile acceptance and independent coordinator review remain separate. No providers, globe layers, deployment or canonical installation changed. + +## 2026-10-31 - Truthful manual refresh feedback (isolated local fix) + +Manual refresh now reserves success copy for an accepted response, qualifies partial/empty/saved-read results, and reports failure after timeout, network or malformed responses. Intentional offline previews retain their Public snapshots outcome. Generation guards prevent an old completion timer from replacing feedback during a newer request. Existing source timestamps, cached reports, request scheduling and provider settings remain unchanged. + +Local regression checks execute the actual controller request lifecycle and error renderer with synthetic responses, including failed refresh followed by successful retry. This isolated branch is not installed into the canonical checkout or deployed; browser/screen-reader acceptance and independent H3 are separate evidence. See the task's refresh verification report for commands, results and limits. + ## 2026-10-17 - Candidate committed, main merged, globe visual pass The 53-path candidate and inherited foundation are committed on `feature/evidence-semantic-globe` (draft PR #75 to `main`). Current `main` (33d426f) is merged in. Main's audit-repair suite is reconciled with candidate semantics: undated records stay visible as "Time unknown", unknown exact clocks read "Not supplied", the browser direct-USGS fallback stays removed, and source URLs use the shared `safeSourceUrl` helper. The inherited registry cache-policy assertion is fixed. The validator now skips gitignored root evidence folders. The 3D globe gained a night-atlas restyle, atmosphere/terminator, stars, graticule, optional local borders, severity-styled clustered markers and smooth fly-to ([record and CSP implications](GLOBE_VISUAL_2026-10-17.md)). The repository ruleset requires PRs for updates to every branch, so follow-ups go out as a new stacked branch and PR. No deployment. diff --git a/docs/NEXT_TASK_QUEUE.md b/docs/NEXT_TASK_QUEUE.md index 4d01659..c3bc25b 100644 --- a/docs/NEXT_TASK_QUEUE.md +++ b/docs/NEXT_TASK_QUEUE.md @@ -1,3 +1,13 @@ +## 2026-10-31 - Bounded event-source journey continuation + +- Review the cumulative isolated candidate for find/filter/inspect/original-source behavior, NWS identity fallback and adjacent source/retrieval clocks. Preserve unavailable links/times; do not activate new providers or infer source freshness from retrieval. +- Current desktop/narrow keyboard, loading/error/empty-state and globe acceptance remain queued for the GUI owner. Coordinator review must use the cumulative journey patch, not the older refresh-only patch. Netlify publication is paused; no candidate combination or release follows from this record. + +## 2026-10-31 - Refresh feedback local candidate + +- The isolated refresh-feedback fix preserves cached report clocks and makes failed attempts distinct from successful, partial, empty and saved-read responses. Regression coverage includes failure/retry and superseded-request feedback. +- Keep full browser/assistive-technology acceptance and any canonical installation separate. No provider, hosting or deployment change accompanies this fix; existing queue priorities and gates remain unchanged. + ## 2026-10-17 - Globe visual pass awaiting owner review - Owner visual acceptance of the globe pass (`docs/GLOBE_VISUAL_2026-10-17.md`, screenshots in `artifacts/globe-visual-2026-10-17/`). diff --git a/src/app-controller.js b/src/app-controller.js index 9c175c2..b9bdaaa 100644 --- a/src/app-controller.js +++ b/src/app-controller.js @@ -933,7 +933,7 @@ export function bootLiveMap() { document.body.dataset.liveMapChokepoint = state.selectedChokepointId || ""; document.body.dataset.liveMapDataMode = state.demo ? "mixed" : (state.dataMode || "public"); if (els.dataMode) els.dataMode.value = state.demo ? "mixed" : (state.dataMode || "public"); - if (els.refreshNow) els.refreshNow.textContent = state.demo ? "Reload demo" : "Refresh reports"; + if (els.refreshNow) els.refreshNow.textContent = state.demo ? "Reload demo" : state.apiStatus === "loading" ? "Refreshing reports…" : "Refresh reports"; if (els.baseMap && state.mapView.basemap) els.baseMap.value = state.mapView.basemap; } catch (error) { console.error(error); @@ -1225,8 +1225,10 @@ export function bootLiveMap() { render(); els.systemStatus.innerHTML = " Updating"; els.refreshNow.disabled = true; + els.refreshNow.textContent = "Refreshing reports…"; const controller = eventRequestController = new AbortController(); const timeout = setTimeout(() => controller.abort(), CONFIG.requestTimeoutMs); + let refreshOutcome = "Refresh failed"; try { const response = await fetch(`${CONFIG.endpoint}?hours=${state.hours}&t=${Date.now()}`, { cache: "no-store", signal: controller.signal }); if (!response.ok) { @@ -1255,6 +1257,9 @@ export function bootLiveMap() { renderSourceHealth(els.sourceHealth, result, state.errors); render(); scheduleNextLoad(CONFIG.refreshSeconds * 1000); + refreshOutcome = result.localPreview + ? (result.localPreview.cacheOnly ? "Saved public reads reloaded" : "Local public data refreshed") + : noData ? "No provider data" : isPartial ? "Partial data refreshed" : "Reports refreshed"; } catch (error) { if(generation!==eventRequestGeneration)return; state.apiStatus='error'; @@ -1278,6 +1283,7 @@ export function bootLiveMap() { if (els.sourceHealth) els.sourceHealth.textContent = "Loaded local public snapshots. Preview /api remains JSON 503 by design — this is not live coverage."; if (els.publicDataStatus) els.publicDataStatus.innerHTML = "Public snapshots

Genuine saved records only. Capture time and observation period are on each card. Not a live feed.

"; state.dataMode = "public"; + refreshOutcome = "Public snapshots"; } else if (!state.events.length) { els.eventList.innerHTML = '
Event data temporarily unavailable. Filters and the map remain usable; use Retry when connectivity returns.
'; } @@ -1286,9 +1292,14 @@ export function bootLiveMap() { } finally { clearTimeout(timeout); if(generation!==eventRequestGeneration)return; - if(generation===eventRequestGeneration)els.refreshNow.disabled = false; - if (manual) els.refreshNow.textContent = "Refreshed"; - setTimeout(() => (els.refreshNow.textContent = "Refresh"), 1200); + els.refreshNow.disabled = false; + if (manual) { + // A completed attempt is not necessarily a successful retrieval. + els.refreshNow.textContent = refreshOutcome; + setTimeout(() => { + if (generation === eventRequestGeneration && state.apiStatus !== "loading" && !state.demo) els.refreshNow.textContent = "Refresh reports"; + }, 1200); + } } } @@ -1358,7 +1369,7 @@ export function bootLiveMap() { if (event.target.closest("a")) return; const watchSource=event.target.closest('[data-watch-source]'),watchChanges=event.target.closest('[data-watch-changes]'); if(watchSource||watchChanges){if(watchSource)state.watchSource=watchSource.dataset.watchSource;else state.watchChangeFilter=watchChanges.dataset.watchChanges;state.listPage=0;syncUrlState();render();return;} - if(event.target.closest('[data-watch-reset]')){clearInspectorSelection();state.mobilePane='feed';state.rightDrawerOpen=true;state.watchSource='';state.watchChangeFilter='all';state.selectedCountryIso3=null;state.mapView.viewportOnly=false;state.mapView.asOf=null;resetDashboardFilters();els.search.value='';els.globalSearch.value='';els.globalSearchResults.hidden=true;state.listPage=0;syncUrlState();render();els.search.focus();return;} + if(event.target.closest('[data-watch-reset]')){clearInspectorSelection();state.mobilePane='feed';state.rightDrawerOpen=true;state.watchSource='';state.watchChangeFilter='all';state.selectedCountryIso3=null;state.mapView.viewportOnly=false;state.mapView.asOf=null;state.mapView.verification='all';resetDashboardFilters();els.search.value='';els.globalSearch.value='';els.globalSearchResults.hidden=true;state.listPage=0;syncUrlState();render();els.search.focus();return;} const mobileButton = event.target.closest('[data-mobile-pane]'); if (mobileButton) { if (state.selectedEventId) clearInspectorSelection(); diff --git a/src/data/providers/nws.js b/src/data/providers/nws.js index 8b295e3..cb395bc 100644 --- a/src/data/providers/nws.js +++ b/src/data/providers/nws.js @@ -1,4 +1,5 @@ import { createNormalizedEvent } from "../../events/normalized-event.js"; +import { safeSourceUrl } from "../../sources/source-url.js"; export const NWS_ACTIVE_ALERTS_URL = "https://api.weather.gov/alerts/active"; @@ -90,7 +91,11 @@ export function normalizeNwsAlert(feature, now = new Date()) { const geometry = feature?.geometry || null; const point = representativeNwsPoint(geometry); const eventName = properties.event || "Weather alert"; - const sourceUrl = properties.web || properties.id || "https://api.weather.gov/alerts/active"; + // NWS properties.id can be a URN; the GeoJSON feature id can carry the + // specific alert's API URL. A collection feed or homepage is not that alert. + const sourceUrl = properties.web && !safeSourceUrl(properties.web) ? properties.web + : [properties.web, feature?.id, properties.id].map(safeSourceUrl).find(url => + url && !["/", "/alerts", "/alerts/active"].includes(new URL(url).pathname.replace(/\/$/, "") || "/")) || null; const severity = nwsSeverityScore(properties); const instruction = summarizeText(properties.instruction, 260); const description = summarizeText(properties.description, 520); diff --git a/src/ui/osint-dashboard-v2/event-detail-drawer.js b/src/ui/osint-dashboard-v2/event-detail-drawer.js index 613c11b..fa46480 100644 --- a/src/ui/osint-dashboard-v2/event-detail-drawer.js +++ b/src/ui/osint-dashboard-v2/event-detail-drawer.js @@ -1,4 +1,4 @@ -import { sourceLink } from "../../sources/source-url.js"; +import { sourceLink, safeSourceUrl } from "../../sources/source-url.js"; import { confidenceText, timestampMs } from "../../events/event-values.js"; import { CATEGORIES, SEVERITIES } from "../../config.js"; import { escapeHtml, exactTime, relativeTime } from "../../events/event-normalizer.js"; @@ -110,7 +110,10 @@ export function renderEventDetailDrawer(event, { changeStatus = null, allEvents const location = event.geographic === false ? "No map location" : event.place || event.country || "Location pending"; const confidence = confidenceText(event.confidence); const sourceBadge = event.sourceName || event.provider || "Unknown source"; - const sourceAction = sourceLink(event.sourceUrl, "Open source", "v2-detail-link"); + const sourceUrl = safeSourceUrl(event.sourceUrl); + // Older cached NWS records may still contain the collection/homepage fallback. + const nwsCollection = event.provider === "nws-alerts" && sourceUrl && ["/", "/alerts", "/alerts/active"].includes(new URL(sourceUrl).pathname.replace(/\/$/, "") || "/"); + const sourceAction = sourceLink(nwsCollection ? null : sourceUrl, "Open original source", "v2-detail-link"); const providerLink = sourceLink(event.providerUrl, "Provider info", "v2-detail-link secondary"); const mapLink = Number.isFinite(event.lat) && Number.isFinite(event.lon) ? `Coordinates` @@ -138,7 +141,7 @@ export function renderEventDetailDrawer(event, { changeStatus = null, allEvents

${escapeHtml(event.title)}

${escapeHtml(event.summary || "No summary available.")}

-

Supporting source

${escapeHtml(event.sourceName || 'Unknown source')} · ${escapeHtml(event.verificationStatus || 'unverified')}

${sourceAction}${providerLink}

Occurrence: ${escapeHtml(exactTime(event.occurredAt))}
Source revision: ${escapeHtml(exactTime(event.updatedAt))}

+

Supporting source

${escapeHtml(event.sourceName || 'Unknown source')} · ${escapeHtml(event.verificationStatus || 'unverified')}

${sourceAction}${providerLink}

Occurrence: ${escapeHtml(exactTime(event.occurredAt))}
Source revision: ${escapeHtml(exactTime(event.updatedAt))}
Retrieved: ${escapeHtml(exactTime(event.fetchedAt ?? event.retrievedAt ?? event.metadata?.retrievedAt))}

Retrieval time does not establish when the event occurred. Missing source times remain unknown.

Source coverage
${escapeHtml(event.coverage || event.metadata?.coverage || "Not supplied; do not infer complete coverage")}
Limits of this evidence
${escapeHtml(limitationText)}
diff --git a/tests/audit-repair-tests.mjs b/tests/audit-repair-tests.mjs index 21410b1..50c7336 100644 --- a/tests/audit-repair-tests.mjs +++ b/tests/audit-repair-tests.mjs @@ -1,10 +1,11 @@ import assert from "node:assert/strict"; import test from "node:test"; import fs from "node:fs"; +import vm from "node:vm"; import { safeSourceUrl, sourceLink } from "../src/sources/source-url.js"; import { timestampMs, confidenceValue } from "../src/events/event-values.js"; import { createNormalizedEvent, toLegacyEvent, validateNormalizedEvent } from "../src/events/normalized-event.js"; -import { normalizeEvent, relativeTime, exactTime } from "../src/events/event-normalizer.js"; +import { normalizeEvent, relativeTime, exactTime, escapeHtml } from "../src/events/event-normalizer.js"; import { normalizeFeedItem, observationFromFeedItem } from "../src/data/providers/rss-feed.js"; import { canonicalizeObservationUrl } from "../src/intelligence/source-observations.js"; import { renderEventDetailDrawer } from "../src/ui/osint-dashboard-v2/event-detail-drawer.js"; @@ -252,3 +253,239 @@ test("CI enforces focused regressions and CodeQL failure without activating smok assert.doesNotMatch(fs.readFileSync(".github/workflows/security.yml", "utf8"), /continue-on-error:\s*true/); assert.match(fs.readFileSync(".github/workflows/validate.yml", "utf8"), /npm run test:platform && npm run test:audit-repair/); }); + +// Execute the controller's actual request lifecycle without starting maps, +// reading browser storage, or making provider requests. Only its I/O is faked. +function refreshHarness({ cacheAvailable = true } = {}) { + const source = fs.readFileSync("src/app-controller.js", "utf8"); + const start = source.indexOf(" async function loadEvents(manual = false) {"); + const end = source.indexOf(" let movingAbort =", start); + assert.ok(start >= 0 && end > start, "Controller request lifecycle must be available"); + const errorStart = source.indexOf("function renderFeedError(element) {"); + const errorEnd = source.indexOf("function updateCountDebug(", errorStart); + assert.ok(errorStart >= 0 && errorEnd > errorStart, "Controller recovery feedback must be available"); + const timers = new Map(); + const requests = []; + const scheduledLoads = []; + let nextTimer = 0; + const element = () => ({ textContent: "", innerHTML: "", disabled: false, classList: { add() {}, toggle() {} } }); + const els = Object.fromEntries(["refreshNow", "systemStatus", "sourceHealth", "publicDataStatus", "eventList", "feedError"].map(key => [key, element()])); + const cached = { events: [{ id: "synthetic-cached", occurredAt: 1000, updatedAt: 2000 }], generatedAt: 3000 }; + const state = { demo: false, hours: 168, events: cacheAvailable ? structuredClone(cached.events) : [], lastLoaded: cacheAvailable ? cached.generatedAt : null, errors: [], apiFailure: null }; + let renderError; + const context = { + state, els, eventRequestGeneration: 0, eventRequestController: null, changeTimer: null, retryAttempts: 0, + RETRY_BASE_MS: 30000, RETRY_CAP_MS: 300000, + CONFIG: { endpoint: "/synthetic/events", requestTimeoutMs: 100, refreshSeconds: 60 }, + AbortController, escapeHtml, relativeTime, console: { error() {} }, + setTimeout(callback, delay) { const id = ++nextTimer; timers.set(id, { callback, delay }); return id; }, + clearTimeout(id) { timers.delete(id); }, + fetch(url, { signal }) { + return new Promise((resolve, reject) => { + signal.addEventListener("abort", () => reject(Object.assign(new Error("Synthetic timeout"), { name: "AbortError" })), { once: true }); + requests.push({ resolve, reject }); + }); + }, + render() { els.refreshNow.textContent = state.demo ? "Reload demo" : state.apiStatus === "loading" ? "Refreshing reports…" : "Refresh reports"; renderError(els.feedError); }, + applyResult(result) { state.events = result.events; state.lastLoaded = result.generatedAt; state.errors = result.errors || []; }, + writeEventCache() {}, scheduleChangePoll() {}, renderSourceHealth() {}, + scheduleNextLoad(delay) { scheduledLoads.push(delay); }, + readEventCache() { return cacheAvailable ? structuredClone(cached) : null; }, + classifyFetchError(error) { return error.name === "AbortError" ? "timeout" : "network"; }, + safeFailureMessage(kind) { return `Synthetic ${kind} failure; retained reports are cached.`; }, + async hydrateSnapshotRecords() {}, async loadPublicSnapshots() {}, + }; + context.window = { clearTimeout: context.clearTimeout }; + const lifecycle = vm.runInNewContext(`${source.slice(errorStart, errorEnd)}\n${source.slice(start, end)}\n({loadEvents, renderFeedError})`, context); + const load = lifecycle.loadEvents; + renderError = lifecycle.renderFeedError; + const respond = (requestIndex, payload = {}, { ok = true, status = 200, contentType = "application/json" } = {}) => { + requests[requestIndex].resolve({ ok, status, headers: { get: () => contentType }, async json() { return payload; } }); + }; + const fire = delay => { + for (const [id, timer] of [...timers]) if (timer.delay === delay) { timers.delete(id); timer.callback(); } + }; + return { load, state, els, requests, scheduledLoads, respond, fire }; +} + +for (const failure of ["503", "timeout", "network", "non-json", "invalid-json"]) { + test(`Manual refresh ${failure} retains clocks and permits a successful retry`, async () => { + const h = refreshHarness(); + const before = structuredClone(h.state.events); + const pending = h.load(true); + assert.equal(h.els.refreshNow.disabled, true); + if (failure === "timeout") h.fire(100); + else if (failure === "network") h.requests[0].reject(new TypeError("Synthetic network failure")); + else if (failure === "invalid-json") h.requests[0].resolve({ ok: true, headers: { get: () => "application/json" }, async json() { throw new SyntaxError("Synthetic malformed JSON"); } }); + else h.respond(0, {}, failure === "503" ? { ok: false, status: 503 } : { contentType: "text/html" }); + await pending; + assert.equal(h.els.refreshNow.textContent, "Refresh failed"); + assert.match(h.els.systemStatus.innerHTML, /Feed unavailable/); + assert.equal(h.els.feedError.hidden, false); + assert.match(h.els.feedError.innerHTML, /data-provider-retry>Retry now/); + assert.equal(h.els.refreshNow.disabled, false); + assert.deepEqual(h.state.events, before); + assert.equal(h.state.lastLoaded, 3000); + assert.ok(h.state.apiFailure); + assert.equal(h.scheduledLoads.at(-1), 30000); + + const retry = h.load(true); + const updated = [{ ...before[0], updatedAt: 4000 }]; + h.respond(1, { events: updated, generatedAt: 5000 }); + await retry; + assert.equal(h.els.refreshNow.textContent, "Reports refreshed"); + assert.equal(h.els.refreshNow.disabled, false); + assert.equal(h.state.apiFailure, null); + assert.equal(h.els.feedError.hidden, true); + assert.equal(h.els.feedError.innerHTML, ""); + assert.equal(h.state.events[0].occurredAt, 1000); + assert.equal(h.state.events[0].updatedAt, 4000); + assert.equal(h.state.lastLoaded, 5000); + assert.equal(h.scheduledLoads.at(-1), 60000); + }); +} + +test("Failed first refresh restores cached reports without inventing new clocks", async () => { + const h = refreshHarness(); + h.state.events = []; + const pending = h.load(true); + h.respond(0, {}, { ok: false, status: 503 }); + await pending; + assert.equal(h.state.events[0].id, "synthetic-cached"); + assert.equal(h.state.events[0].occurredAt, 1000); + assert.equal(h.state.events[0].updatedAt, 2000); + assert.equal(h.state.lastLoaded, 3000); + assert.equal(h.els.refreshNow.textContent, "Refresh failed"); + assert.match(h.els.sourceHealth.textContent, /cached data/); +}); + +test("Failure without cached reports keeps an empty recoverable state", async () => { + const h = refreshHarness({ cacheAvailable: false }); + const pending = h.load(true); + h.respond(0, {}, { ok: false, status: 503 }); + await pending; + assert.equal(h.state.events.length, 0); + assert.equal(h.state.lastLoaded, null); + assert.equal(h.els.refreshNow.textContent, "Refresh failed"); + assert.equal(h.els.refreshNow.disabled, false); + assert.match(h.els.feedError.innerHTML, /No cached refresh is available yet/); + assert.match(h.els.feedError.innerHTML, /data-provider-retry>Retry now/); +}); + +for (const [payload, button, status] of [ + [{ events: [{ id: "synthetic" }], systemStatus: "partial-data" }, "Partial data refreshed", "Partial data"], + [{ events: [] }, "No provider data", "No provider data"], + [{ events: [{ id: "synthetic" }], localPreview: { cacheOnly: true } }, "Saved public reads reloaded", "Saved public reads"], +]) { + test(`Manual refresh qualifies success: ${button}`, async () => { + const h = refreshHarness(); + const pending = h.load(true); + h.respond(0, { ...payload, generatedAt: 5000 }); + await pending; + assert.equal(h.els.refreshNow.textContent, button); + assert.ok(h.els.systemStatus.innerHTML.includes(status)); + assert.equal(h.state.apiFailure, null); + }); +} + +test("Intentional preview 503 loads snapshots without a live refresh success or retry loop", async () => { + const h = refreshHarness(); + const pending = h.load(true); + h.respond(0, { error: "offline-preview" }, { ok: false, status: 503 }); + await pending; + assert.equal(h.els.refreshNow.textContent, "Public snapshots"); + assert.match(h.els.systemStatus.innerHTML, /Public snapshots/); + assert.equal(h.state.apiFailure.kind, "offline-preview"); + assert.equal(h.els.refreshNow.disabled, false); + assert.equal(h.scheduledLoads.length, 0); +}); + +test("Superseded requests and old feedback timers cannot overwrite the newest refresh", async () => { + const h = refreshHarness(); + const first = h.load(true); + h.respond(0, { events: [{ id: "first" }], generatedAt: 4000 }); + await first; + const second = h.load(true); + h.fire(1200); + assert.equal(h.els.refreshNow.textContent, "Refreshing reports…"); + assert.equal(h.els.refreshNow.disabled, true); + const third = h.load(true); + await second; // Starting the third request aborts the second. + assert.equal(h.els.refreshNow.disabled, true); + h.respond(2, { events: [{ id: "latest" }], generatedAt: 6000 }); + await third; + assert.equal(h.state.events[0].id, "latest"); + assert.equal(h.els.refreshNow.textContent, "Reports refreshed"); + h.fire(1200); + assert.equal(h.els.refreshNow.textContent, "Refresh reports"); +}); + +test("Old manual feedback timer preserves the demo reload action", async () => { + const h = refreshHarness(); + const pending = h.load(true); + h.respond(0, { events: [{ id: "synthetic" }], generatedAt: 4000 }); + await pending; + h.state.demo = true; + h.els.refreshNow.textContent = "Reload demo"; + h.fire(1200); + assert.equal(h.els.refreshNow.textContent, "Reload demo"); +}); + +test("NWS uses supplied alert identity rather than the feed or provider homepage", () => { + const id = "https://api.weather.gov/alerts/synthetic-alert"; + for (const web of [undefined, "https://www.weather.gov/", "https://api.weather.gov/alerts/active"]) { + const result = normalizeNwsAlert({ id, properties: { id: "urn:oid:synthetic-alert", web, event: "Tornado Warning" } }, now); + assert.ok(result.event); + assert.equal(result.event.sourceUrl, id); + } + const original = "https://www.weather.gov/alert/synthetic"; + assert.equal(normalizeNwsAlert({ id, properties: { web: original } }, now).event.sourceUrl, original); + assert.equal(normalizeNwsAlert({ properties: { id: "urn:oid:synthetic" } }, now).event.sourceUrl, null); + assert.equal(normalizeNwsAlert({ id, properties: { web: "javascript:bad" } }, now).event, null); +}); + +test("Filter, inspect and original source preserve distinct source and retrieval clocks", () => { + const sourceUrl = "https://api.weather.gov/alerts/synthetic-alert"; + const canonical = normalizeNwsAlert({ id: sourceUrl, properties: { id: "urn:synthetic", event: "Tornado Warning", sent: "2026-10-12T10:00:00Z", onset: "2026-10-12T09:00:00Z" } }, now).event; + const event = normalizeEvent({ ...toLegacyEvent(canonical), retrievedAt: "2026-10-12T11:00:00Z" }); + const filters = { categories: new Set([event.category]), severities: new Set([event.severity]), query: "tornado" }; + const found = filteredEvents([event], filters, 24, "newest", now.getTime()); + assert.equal(found.length, 1); + const html = renderEventDetailDrawer(found[0]); + const supporting = html.split('
")[0]; + assert.ok(supporting.includes(`href="${sourceUrl}"`)); + assert.match(supporting, />Open original source<\/a>/); + assert.ok(supporting.includes(`Source revision: ${exactTime(event.updatedAt)}`)); + assert.ok(supporting.includes(`Retrieved: ${exactTime(event.retrievedAt)}`)); + filters.query = "no-such-synthetic-event"; + assert.equal(filteredEvents([event], filters, 24, "newest", now.getTime()).length, 0); + const missing = renderEventDetailDrawer(normalizeEvent(toLegacyEvent(normalizeNwsAlert({ properties: { id: "urn:synthetic" } }, now).event))); + const missingSource = missing.split('
")[0]; + assert.match(missingSource, /Open original source unavailable/); + assert.ok(missingSource.includes(`Source revision: ${exactTime(null)}`)); + assert.ok(missingSource.includes(`Retrieved: ${exactTime(null)}`)); + const legacy = renderEventDetailDrawer({ ...event, sourceUrl: "https://api.weather.gov/alerts/active" }); + assert.match(legacy, /Open original source unavailable/); + assert.doesNotMatch(legacy, /href="https:\/\/api.weather.gov\/alerts\/active"/); +}); + +test("Clear report filters removes the verification constraint without changing provider settings", () => { + const source = fs.readFileSync("src/app-controller.js", "utf8"); + const handler = source.split("\n").find(line => line.includes("if(event.target.closest('[data-watch-reset]'))")); + assert.ok(handler); + const state = { mapView: { verification: "supported", viewportOnly: true, asOf: "2026-10-12" } }; + const providerSettings = { enabled: false }; + let focused = false; + const input = { value: "synthetic", focus() { focused = true; } }; + vm.runInNewContext(`(function(){${handler}})()`, { + state, providerSettings, event: { target: { closest() { return {}; } } }, + els: { search: input, globalSearch: { value: "synthetic" }, globalSearchResults: { hidden: false } }, + clearInspectorSelection() {}, resetDashboardFilters() {}, syncUrlState() {}, render() {}, + }); + assert.equal(state.mapView.verification, "all"); + assert.equal(state.mapView.viewportOnly, false); + assert.equal(state.mapView.asOf, null); + assert.equal(input.value, ""); + assert.equal(focused, true); + assert.deepEqual(providerSettings, { enabled: false }); +}); From d44473e0b784e47729460fbd1509d4f5a297ff7c Mon Sep 17 00:00:00 2001 From: Zacharon <113211893+Zacharon@users.noreply.github.com> Date: Tue, 17 Nov 2026 01:22:36 -0500 Subject: [PATCH 5/6] Skip repeat WebGL probes while a Cesium viewer is live setGlobeMode reused webglAvailable() on every render, creating and releasing a temporary GPU context each time. A live viewer already proves capability; context loss and forced-failure flags still take precedence and teardown re-probes. Adds a local measurement script and record. Co-Authored-By: Claude Opus 5.5 --- docs/GLOBE_PERFORMANCE_LOCAL_2026-10-30.md | 42 ++++++++++++++++++++++ docs/LAST_30_DAYS.md | 4 +++ docs/NEXT_TASK_QUEUE.md | 2 ++ scripts/measure-globe-local.mjs | 32 +++++++++++++++++ src/map/globe-controller.js | 5 ++- 5 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 docs/GLOBE_PERFORMANCE_LOCAL_2026-10-30.md create mode 100644 scripts/measure-globe-local.mjs diff --git a/docs/GLOBE_PERFORMANCE_LOCAL_2026-10-30.md b/docs/GLOBE_PERFORMANCE_LOCAL_2026-10-30.md new file mode 100644 index 0000000..2dc859d --- /dev/null +++ b/docs/GLOBE_PERFORMANCE_LOCAL_2026-10-30.md @@ -0,0 +1,42 @@ +# Local globe repeat-work measurement + +Baseline: `390b9a6b79bc89b03baf03f4fe4b1e02aed29384`, origin `https://github.com/Zacharon/live-map.git`. Candidate exists only in orchestrator-bound `perf/globe-local-20261030`; no canonical application, push or deployment. + +## OBSERVED + +- `src/map/globe-controller.js:setGlobeMode` called `webglAvailable()` on every render. `src/map/cesium-adapter.js:19-30` creates a temporary canvas/context and releases it. Twenty synthetic chokepoint toggles produced 24 and 22 WebGL getContext calls, consuming 182.0 and 133.2 ms inside getContext alone. +- The focused change reuses `globeHandle.ok` while a viewer exists. Forced failure and context-loss guards take precedence; teardown clears the handle so a new probe occurs. +- Same scenario after the change produced zero repeat probes in both initial and verification runs. Rotation and viewer identity passed. No overall latency speedup is established: repeat elapsed times varied. +- Startup source path: index.html loads Leaflet and markercluster before app.js; app.js statically imports app-controller.js and its dependency graph. Cesium loads dynamically from cesium-adapter.js:118 onward, with an IIFE fallback. Resource durations do not isolate JS parse/evaluation time. +- Initial baseline Cesium module resource duration was 5245.6 ms for 4,754,611 transferred bytes, versus 151.7 ms on reload. The later cold-cache sample was 137.1 ms. OS/filesystem/antivirus/process warmup are uncontrolled; this is not evidence of an optimization to Cesium transfer or parsing. + +| Sample | First renderer-ready ms | 20 toggles elapsed ms | Repeat probes | +| --- | ---: | ---: | ---: | +| Before, cold browser cache | 6776.3 | 1755.8 | 24 | +| Before, warm process reload | 1117.8 | 1459.6 | 22 | +| After, cold browser cache | 1667.2 | 1646.1 | 0 | +| After, warm process reload | 1119.3 | 1173.6 | 0 | +| Verification, cold browser cache | 1936.3 | 1826.8 | 0 | +| Verification, warm process reload | 1210.1 | 1617.0 | 0 | + +Readiness is a 10 ms sampled renderer signal, followed by an explicit camera rotation assertion, not a user-input-to-photon metric. The loopback server sends no-store, so warm means process reload, not an HTTP asset-cache hit. + +## Reproduce and correctness + +Raw local evidence: [before](../artifacts/globe-performance/before.json), [after](../artifacts/globe-performance/after.json), [verification and regressions](../artifacts/globe-performance/after-verified.json). These generated artifacts are ignored by Git and remain in this local checkout. + +`node scripts/measure-globe-local.mjs