diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cdd0106..70812cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,10 @@ env: ROOT_WHEEL: "ace_domain_world_intelligence-0.9.0-py3-none-any.whl" ROOT_SDIST: "ace_domain_world_intelligence-0.9.0.tar.gz" ACE_CORE_VERSION: "0.5.0" + # P2E consumes the monitoring API merged after the public 0.5.0 artifact. + # Keep source acceptance on the exact reviewed commit until a versioned Core + # release carries the same tree; the isolated wheel gate below stays public. + ACE_CORE_CANDIDATE_SHA: "f0d2191ba7cf2d33ccfc3c821422786929be8349" RELEASE_CONTRACT_TEST: "tests/test_release_contract.py" ADAPTER_TEST_SUITE: "adapters/federal_register_source/tests" # Keep the repository's proof scripts and separately packaged connector ahead @@ -53,6 +57,18 @@ jobs: # checks. The wheel is installed separately below in a clean venv. run: uv sync --frozen --no-install-project + - name: Install the exact merged Core monitoring candidate + run: | + set -euo pipefail + uv pip install --python .venv/bin/python --reinstall \ + "ace-core @ git+https://github.com/augmented-cognition-engine/core.git@${ACE_CORE_CANDIDATE_SHA}" + uv run --no-sync python - <<'PY' + from ace.application import MonitoringLifecycleService, SensingWindowService + + assert MonitoringLifecycleService is not None + assert SensingWindowService is not None + PY + - name: Confirm the synced interpreter is Python 3.12 run: | set -euo pipefail @@ -190,6 +206,10 @@ jobs: planetary + "modules/synthesis.json", planetary + "conformance/p2d_live_conflict_correction_input.json", planetary + "conformance/p2d_live_expected.json", + planetary + "conformance/p2e_contract_requests.json", + planetary + "conformance/p2e_negative_cases.json", + planetary + "conformance/p2e_user_owned_live_orientation_expected.json", + planetary + "conformance/p2e_user_owned_live_orientation_input.json", federal + "manifest.json", federal + "modules/ontology.json", federal + "modules/source_mapping.json", diff --git a/CHANGELOG.md b/CHANGELOG.md index c5b02eb..da49b81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,19 @@ noted here only where the boundary between them changes. ### Added +- **P2E user-owned LIVE-orientation consumer packet.** Public ACE 0.5.0 Monitor, + PersonaBinding, and record-only Subscription contracts now bind the accepted planetary-defense + pack, exact activation, one fixture principal, and the pack persona with pinned identities. +- **Repeated-window ownership and suppression runtime.** Six explicit owner-requested windows append + and exactly replay initial orientation, exact no-change suppression, two always-visible + corrections, zero acquisition while paused, resume, and zero acquisition after Subscription + revocation. Eleven negative mutations fail closed. +- **Closed narrow platform requests.** Merged Core #94 closes `WI-CR-007` with owner-authorized + append-only lifecycle and closes `WI-CR-008` with bounded sensing-window route-or-suppression + receipts. World consumes the generic public seams and adds no private implementation. +- **Composed captured LIVE lineage.** The four NASA/ESA Observations remain linked through three + Shifts, three Signals, two Cases, and the original 2-citation and 4-citation Reality Briefs. + - **P2D LIVE conflict and correction.** Four exact NASA/ESA planetary-defense publications become LIVE Observations, one dated cross-source divergence and two same-source downward-revision Shifts, three routed Signals, immutable historical and corrected Cases, and cited Reality Briefs with @@ -25,6 +38,9 @@ noted here only where the boundary between them changes. ### Boundaries +- P2E appends five lifecycle transitions and six sensing receipts without a network request, + scheduler, autonomous loop, delivery, publication, or external action. Its P2D prerequisite + remains 44 LIVE records; the composed ledger is 62 LIVE records and zero PREPARED records. - The new six-module pack is inert JSON only. The P2D proof contains 44 LIVE records and zero PREPARED records, performs no network request, and creates no action, delivery, publication, persuasion, monitor, or schedule. diff --git a/README.md b/README.md index f69c133..41a49e4 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,19 @@ The accepted P2D identities are `pack_ir:bb400cc0652622b43c01504e651110e0`, hist contains 44 LIVE records and zero PREPARED records. Separate official publication roots do not prove independent measurements: both agencies describe a shared international observation ecosystem. +P2E materializes the next user-owned LIVE-orientation boundary without claiming a scheduler or +autonomous sensing runtime. Public ACE 0.5.0 contracts construct one exact Monitor +(`monitor:bbb0e5ab246c6d1f08f7669226db6873`), principal/persona binding +(`persona_binding:1349e5c7f78270dd5c8e267b582a1399`), and record-only Subscription +(`subscription:3bb149effa91c5fdd224780ae0a455ee`) over the accepted planetary-defense activation. Six +explicitly requested windows append and exactly replay initial orientation, no-change suppression, +both visible corrections, owner pause/resume, and terminal revocation through the generic services +merged in Core #94. `WI-CR-007` and `WI-CR-008` are closed for merged-source acceptance. The +composed path preserves four captured NASA/ESA Observations through three Shifts, three Signals, two +Cases, and the original cited Reality Briefs: 62 LIVE records and zero PREPARED records. World adds +no private substitute, network request, delivery, schedule, or action. Public-index reproduction of +the new Core contracts remains pending a versioned Core release. + P2C2 completes that sensing path across the Core + Intelligence + Domain boundaries. A new declarative monitor pack admits two exact FCC records — document `2026-15932` published August 6 and document `2026-16197` published August 7 — as successive LIVE snapshots of one stable monitor @@ -337,9 +350,14 @@ suite and `26 passed` for the connector. With the AI command-center candidate in baseline, the same environment passes `87` domain and `62` connector tests. The public demo reproduces `case:412426eee708d56f6bda931ccf9e5d8b` and `brief:25d8232c9bfa27050bdcb160fb75f06c`, and its two artifacts are byte-identical across runs. -With P2D integrated, the source-tree candidate passes `90` domain tests, `80` connector tests, and -all `7` release-contract tests. Its locally built wheel contains exactly 55 JSON resources, nine -from the planetary-defense pack, and no executable code. +The merged P2D baseline passed `90` domain tests, `80` connector tests, and all `7` +release-contract tests. Its wheel contained exactly 55 JSON resources, nine from the +planetary-defense pack, and no executable code. The verified P2E runtime candidate passes `102` domain, +`80` connector, and all `7` release-contract tests. Its wheel contains exactly 59 JSON resources, +13 from the planetary-defense pack, including exactly four P2E conformance resources and no +executable payload. A checkout-free install of the Core #94 candidate wheel reproduces the pinned +Monitor, PersonaBinding, Subscription, five lifecycle transitions, six sensing receipts, and full +captured LIVE lineage from `site-packages` without importing the Core checkout. The exact identities, negative cases, and artifact proofs are recorded in [`docs/audits/world-intelligence-p2a-2026-08-06.md`](docs/audits/world-intelligence-p2a-2026-08-06.md) @@ -363,6 +381,8 @@ The two-lineage LIVE Shift → Signal → Case → cited Brief proof is recorded [`docs/audits/world-intelligence-ai-command-center-live-2026-08-10.md`](docs/audits/world-intelligence-ai-command-center-live-2026-08-10.md). The LIVE conflict, correction, supersession, and per-claim status proof is recorded in [`docs/audits/world-intelligence-p2d-live-conflict-correction-2026-08-11.md`](docs/audits/world-intelligence-p2d-live-conflict-correction-2026-08-11.md). +The user-owned static intent and repeated-window contract boundary is recorded in +[`docs/audits/world-intelligence-p2e-user-owned-live-orientation-2026-08-11.md`](docs/audits/world-intelligence-p2e-user-owned-live-orientation-2026-08-11.md). Release-level scope and evidence are recorded in [`docs/releases/world-intelligence-p2c2-v0.9.0.md`](docs/releases/world-intelligence-p2c2-v0.9.0.md), diff --git a/ROADMAP.md b/ROADMAP.md index e06f351..e5c92d8 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -29,8 +29,18 @@ See the [0.9.0 release record](docs/releases/world-intelligence-p2c2-v0.9.0.md). See the [P2D audit](docs/audits/world-intelligence-p2d-live-conflict-correction-2026-08-11.md). -## Next — user-owned live orientation - +## Candidate — user-owned live orientation + +- The P2E consumer packet constructs exact public Monitor, PersonaBinding, and record-only + Subscription contracts over the accepted P2D activation and consumes the generic owner lifecycle + and sensing-window services merged in Core #94. +- Six explicit owner-requested windows now append and exactly replay no-change suppression, + always-visible corrections, pause/resume, terminal revocation, and zero-acquisition guards. This + grants no scheduler or autonomous sensing authority. +- `WI-CR-007` (owner-authorized lifecycle) and `WI-CR-008` (bounded sensing-window disposition) are + closed for merged-source acceptance. Public-index Core reproduction remains open. +- The composed evidence preserves four captured official-source Observations through three Shifts, + three Signals, two Cases, and the original cited Reality Briefs: 62 LIVE records, zero PREPARED. - Add a separately reviewed, opt-in production transport without bundling it into the Domain Pack. - Turn one-shot governed sensing into explicit user-owned monitors and subscriptions. - Preserve source independence, correction visibility, attention ownership, suppression, and diff --git a/docs/audits/world-intelligence-p2e-user-owned-live-orientation-2026-08-11.md b/docs/audits/world-intelligence-p2e-user-owned-live-orientation-2026-08-11.md new file mode 100644 index 0000000..ab60d26 --- /dev/null +++ b/docs/audits/world-intelligence-p2e-user-owned-live-orientation-2026-08-11.md @@ -0,0 +1,118 @@ +# World Intelligence P2E user-owned LIVE orientation audit — 2026-08-11 + +## Result + +P2E materializes the next consumer boundary over the accepted P2D NASA/ESA packet. Public +`ace-core==0.5.0` supplies the exact inert Monitor, PersonaBinding, and Subscription contracts. Core +PR [#94](https://github.com/augmented-cognition-engine/core/pull/94), merged as +`f0d2191ba7cf2d33ccfc3c821422786929be8349`, adds the domain-neutral owner lifecycle and bounded +sensing-window services. World consumes those public seams without adding a domain-private runtime. + +`WI-CR-007` and `WI-CR-008` are closed for merged-source consumer acceptance. Five owner lifecycle +transitions and six sensing-window dispositions append immutably and replay through newly +constructed services. There is still no scheduler, autonomous source loop, delivery, publication, +or external action. Public-index Core reproduction remains pending a versioned Core release. + +## Exact static intent + +| Resource | Accepted identity | +|---|---| +| Planetary-defense pack | `pack_ir:bb400cc0652622b43c01504e651110e0` | +| Activation revision | `activation_revision:385d00a35e8bf7a39ec07c630ac36eec` | +| Monitor | `monitor:bbb0e5ab246c6d1f08f7669226db6873` | +| Principal/persona binding | `persona_binding:1349e5c7f78270dd5c8e267b582a1399` | +| Record-only Subscription | `subscription:3bb149effa91c5fdd224780ae0a455ee` | +| P2E packet | `sha256:e35f892af752db6dc4e6bf0cd6f6c5e9f7f4b74749f952ccb7effee701ad9d9e` | + +The binding names one fixture principal and the `planetary_defense_researcher` pack persona. The +Subscription selects both accepted planetary-defense Signal types and the existing Reality Brief +template. Its delivery disposition is `record_only`; no delivery adapter or effect is present. + +## Six frozen sensing windows + +| Window | State | Material | Disposition | Acquisition requests | +|---|---|---|---|---:| +| `w1` | active | earlier NASA/ESA divergence | routed | 2 | +| `w2` | active | exact replay, no new material | `no_material_change` | 2 | +| `w3` | active | NASA same-lineage correction | routed and visible | 1 | +| `w4` | owner paused | none | `owner_paused` | 0 | +| `w5` | resumed | ESA same-lineage correction | routed and visible | 1 | +| `w6` | subscription revoked | none | `subscription_revoked` | 0 | + +These windows are now executed as explicit requests over immutable completed evaluations. Every +request and interval is bounded and replayed exactly. The cadence preference still grants no +scheduler or autonomous execution. + +## Captured LIVE lineage + +The same recorded, network-free official-source adapters capture four dated publications under two +claimant roots. The resulting LIVE path is preserved exactly: + +```text +4 source-linked Observations +→ 3 Shifts +→ 3 Signals +→ historical + corrected Cases +→ cited Reality Briefs (2 and 4 citations) +``` + +The Briefs remain `brief:c3549af0262b100ca65024ee19cbae6e` and +`brief:806d69d8e41f83f93ee3dc10f58f0d16`; P2E does not rewrite the P2D record graph. + +## Fail-closed evidence + +Eleven mutations fail with pinned first violations: + +- missing owner and changed owner; +- PREPARED/LIVE mixing; +- acquisition while paused and after revocation; +- correction hidden as no material change; +- publication roots misrepresented as independent measurements; +- hidden delivery and autonomous scheduling; +- historical Brief rewriting; and +- divergent replay identity. + +## Boundary + +- The accepted P2D prerequisite remains 44 LIVE records and zero PREPARED records. +- P2E adds 18 LIVE monitoring records—five lifecycle transitions with their append-only anchor and + revision material plus six sensing receipts—for 62 composed LIVE records and zero PREPARED + records. +- NASA and ESA remain independent claimant publication roots only. +- Corrections are always material and visible; same-lineage revisions add no corroboration family. +- The Domain Pack remains JSON-only and requests only source-read authority. +- The packet performs no network access, scheduling, delivery, publication, persuasion, Decision, + Outcome, or external action. + +## Verification + +| Check | Result | +|---|---:| +| P2E acceptance projection | zero violations; exact packet replay | +| P2E negative vectors | 11/11 fail closed with pinned first violations | +| Focused P2E + pack-pin suite | `14 passed` | +| Complete World domain suite | `102 passed` | +| Complete connector suite | `80 passed` | +| Release-contract suite | `7 passed` | +| Changed-file Ruff lint and format | passed | +| Candidate wheel JSON payload | exactly 59 resources | +| Planetary-defense wheel payload | exactly 13 resources, including four P2E conformance files | +| Executable wheel payload | none | +| Checkout-free merged-tree probe | World candidate + local Core wheel from the exact Core #94 tree; all lifecycle/window and LIVE lineage identities reproduced from `site-packages` | + +Build artifacts from this working-tree verification: + +- Core candidate wheel SHA-256: + `82a0b365b83a79672685f6c2e71370a7f7218cf56e8c872064961e6e38985d7a`; +- World wheel SHA-256: + `d256293ee16d9a641fa02b52a36322b85eb5c48960667649335ce313c5be2100`; +- World source-distribution SHA-256: + `1005516d8d09e6b10720049b5da1e46d5ac6973483385ab38223d2912050e2e6`. + +The World wheel reproduced byte-for-byte in two builds under the frozen source epoch. It contains +59 JSON resources, 13 under the planetary-defense pack, and zero Python payloads. The Core wheel's +source tree `9690d1e75f07b75d1e0bc1aab73b4d9ee145f2e1` is byte-identical to merged commit +`f0d2191ba7cf2d33ccfc3c821422786929be8349`. A checkout-free import loaded both Core and World from +`site-packages` and exposed both monitoring services. + +These are local candidate hashes, not published release identities. diff --git a/docs/design/world-intelligence-p2e-user-owned-live-orientation-work-packet-v1.md b/docs/design/world-intelligence-p2e-user-owned-live-orientation-work-packet-v1.md new file mode 100644 index 0000000..9becb30 --- /dev/null +++ b/docs/design/world-intelligence-p2e-user-owned-live-orientation-work-packet-v1.md @@ -0,0 +1,108 @@ +# P2E work packet — user-owned LIVE orientation + +**Status:** merged-platform consumer candidate; public Core artifact replay pending + +**Mode:** LIVE only; PREPARED material is excluded + +**Runtime status:** six lifecycle-governed sensing windows materialized and exactly replayed + +## Purpose + +P2E turns the P2D one-shot planetary-defense proof into an explicit user-owned sensing intent +without moving universal lifecycle or sensing-window semantics into the World domain. The packet +now consumes the generic implementation merged in Core +[#94](https://github.com/augmented-cognition-engine/core/pull/94) at +`f0d2191ba7cf2d33ccfc3c821422786929be8349`. + +Released `ace-core==0.5.0` exposes inert, domain-neutral `MonitorV1Alpha1`, +`PersonaBindingV1Alpha1`, and `SubscriptionV1Alpha1` contracts. Merged Core source adds the public +owner lifecycle and bounded sensing-window contracts and application services. P2E constructs, +materializes, and pins those resources against a checkout-free wheel whose source tree is identical +to the merged commit. The Subscription remains `record_only`, so the new receipts grant no delivery +effect. Public-index Core installation remains a later release receipt rather than a claim here. + +The scenario reuses the exact P2D NASA/ESA publication lineages, pack activation, historical Brief, +corrected Brief, and correction semantics. It adds no new factual claim and performs no network +request. Six owner-requested sensing windows exercise active sensing, exact no-change suppression, +visible correction, pause, resume, and revocation. + +## Frozen sequence + +1. The owner creates one inert LIVE Monitor, one principal-to-persona binding, and one record-only + Subscription bound to the accepted P2D pack through public ACE 0.5.0 contracts. +2. Window `w1` admits the two earlier NASA/ESA publications and surfaces the historical divergence. +3. Window `w2` sees the exact same admitted material and records `no_material_change`; it creates no + new Shift, Signal, Case, Brief, or source record. +4. Window `w3` surfaces the NASA revision and its same-lineage supersession. A correction may never + be hidden by duplicate or fatigue suppression. +5. The owner pauses the monitor. Window `w4` performs zero acquisition and records `owner_paused`. +6. The owner resumes the monitor. Window `w5` surfaces the ESA revision and the accepted corrected + Reality Brief. +7. The owner revokes the subscription. Window `w6` performs zero acquisition and records + `subscription_revoked`. + +Every window is explicitly requested. The packet declares cadence preferences but grants no +scheduler, timer, daemon, delivery channel, publication, or external-action authority. + +## Ownership boundary + +- One stable `owner_ref` must bind the monitor, subscription, lifecycle events, and attention + policy. Ownership cannot be inferred from a device, API credential, source, persona, or publisher. +- Only that owner may pause, resume, or revoke the intent in this packet. +- Paused or revoked state blocks acquisition before a source adapter or transport is invoked. +- Subscription revocation is terminal for later windows; replay may reopen the revocation but may + not silently reactivate it. +- Attention remains an internal route-or-suppression disposition. P2E authorizes no delivery. + +## Correction and independence boundary + +- `no_material_change` applies only when the exact admitted source identities are unchanged. +- A newly admitted correction or supersession is material and must remain visible. +- NASA and ESA count as two claimant publication roots. The packet does not claim independent + measurements, observation campaigns, models, or truth. +- Same-lineage before/after publications never manufacture corroboration. +- P2D historical artifacts remain immutable and reopen with the accepted identities. + +## Closed public-platform contract requests + +### WI-CR-007 — owner-enforced Monitor and Subscription lifecycle + +Closed by Core #94. ACE Intelligence now has append-only lifecycle transitions for create, pause, +resume, and revoke. The application service authorizes transitions against the bound principal, +preserves a stable logical intent and append-once sequence, enforces terminal revocation, and +provides exact restart replay. World contributes only the subject, source requirements, persona, +and policy references. + +### WI-CR-008 — bounded sensing-window disposition + +Closed by Core #94. ACE Intelligence now has a domain-neutral, append-only sensing-window receipt +that records the authorizing Monitor/Subscription revisions, requested interval, source transaction +references, accepted new resources, and exactly one routed-or-suppressed disposition. P2E proves +paused and revoked windows contain zero acquisition and correction material cannot collapse into +`no_material_change`. + +Neither implementation lives in the Domain Pack. World imports the generic contracts and services +without adding World vocabulary to Core. `WI-CR-007` and `WI-CR-008` are closed for merged-source +consumer acceptance; public-artifact reproduction remains explicitly pending. + +## Fail-closed vectors + +The conformance validator rejects missing or changed ownership, PREPARED/LIVE mixing, acquisition +while paused, acquisition after revocation, correction suppression, false measurement independence, +hidden delivery, autonomous scheduling, historical rewriting, and replay divergence. + +## Acceptance + +- The positive packet validates with zero violations and an exact replay identity. +- All ten negative vectors fail with their pinned first violation. +- The accepted P2D pack and Brief identities remain unchanged. +- The three static public contracts construct with exact pinned identities; five lifecycle + transitions and six sensing-window receipts append exactly and replay after fresh service + construction. +- Captured NASA/ESA LIVE Observations remain source-linked through three Shifts, three Signals, two + Cases, and the original cited Reality Brief identities. +- The composed ledger contains 62 LIVE records—44 P2D records plus 18 monitoring records—and zero + PREPARED records. +- The Domain Pack stays JSON-only and gains no authority request beyond source read. +- No network, scheduler, delivery, publication, persuasion, Decision, Outcome, or external action is + executed or implied. diff --git a/domain_packs/tests/test_world_intelligence_p2e_user_owned_live_orientation.py b/domain_packs/tests/test_world_intelligence_p2e_user_owned_live_orientation.py new file mode 100644 index 0000000..226fce4 --- /dev/null +++ b/domain_packs/tests/test_world_intelligence_p2e_user_owned_live_orientation.py @@ -0,0 +1,170 @@ +from __future__ import annotations + +import json +from pathlib import Path + +import ace.application +import ace.intelligence +from ace.intelligence import SubscriptionDeliveryDisposition + +from scripts.p2d_live_conflict_correction import compile_planetary_defense_pack +from scripts.p2e_user_owned_live_orientation_acceptance import ( + EXPECTED_PATH, + INPUT_PATH, + NEGATIVE_PATH, + REQUESTS_PATH, + build_static_intent_contracts, + packet_identity, + run_negative_cases, + run_positive, + run_runtime_positive, +) + +REPO_ROOT = Path(__file__).resolve().parents[2] +PACK_ROOT = REPO_ROOT / "domain_packs" / "world_intelligence_planetary_defense" + + +def _load(path: Path): + return json.loads(path.read_text(encoding="utf-8")) + + +def test_p2e_positive_projection_is_exact_and_runtime_materialized() -> None: + expected = _load(EXPECTED_PATH) + assert run_positive() == expected["expected_projection"] + assert expected["expected_projection"]["runtime_materialization_claimed"] is True + assert expected["expected_projection"]["open_contract_requests"] == [] + + +async def test_p2e_materializes_exact_live_lineage_through_cited_reality_briefs() -> None: + expected = _load(EXPECTED_PATH)["expected_runtime"] + result = await run_runtime_positive() + + assert result == expected + assert result["official_publication_roots"] == ["ESA", "NASA"] + assert len(result["source_observation_ids"]) == 4 + assert len(result["shift_ids"]) == len(result["signal_ids"]) == 3 + assert len(result["case_ids"]) == len(result["reality_brief_ids"]) == 2 + assert result["reality_brief_citation_counts"] == [2, 4] + assert result["all_lineage_records_persisted"] is True + assert result["prepared_record_count"] == 0 + assert result["prepared_live_separated"] is True + + +def test_p2e_packet_identity_replays_exactly() -> None: + packet = _load(INPUT_PATH) + expected = _load(EXPECTED_PATH) + first = packet_identity(packet, expected) + second = packet_identity(packet, expected) + assert first == second == expected["packet_identity"] + + +def test_p2e_negative_vectors_fail_closed_with_pinned_first_violations() -> None: + expected = {item["case_id"]: item["expected_violation"] for item in _load(NEGATIVE_PATH)["cases"]} + assert len(expected) == 11 + assert run_negative_cases() == expected + + +def test_p2e_owner_state_blocks_acquisition_before_source_access() -> None: + packet = _load(INPUT_PATH) + guarded = { + window["suppression_reason"]: window + for window in packet["sensing_windows"] + if window["suppression_reason"] in {"owner_paused", "subscription_revoked"} + } + assert set(guarded) == {"owner_paused", "subscription_revoked"} + for window in guarded.values(): + assert window["acquisition_request_count"] == 0 + assert window["candidate_source_keys"] == [] + assert window["accepted_new_source_keys"] == [] + assert window["replayed_source_keys"] == [] + + +def test_p2e_constructs_exact_public_monitor_binding_and_record_only_subscription() -> None: + packet = _load(INPUT_PATH) + ownership = packet["ownership"] + monitor, persona_binding, subscription = build_static_intent_contracts(packet) + + assert monitor.monitor_ref == ownership["monitor_ref"] + assert monitor.monitor_digest == ownership["monitor_digest"] + assert persona_binding.principal_ref == ownership["owner_ref"] + assert persona_binding.binding_ref == ownership["persona_binding_ref"] + assert persona_binding.binding_digest == ownership["persona_binding_digest"] + assert subscription.persona_binding_ref == persona_binding.binding_ref + assert subscription.monitor_refs == (monitor.monitor_ref,) + assert subscription.subscription_ref == ownership["subscription_ref"] + assert subscription.subscription_digest == ownership["subscription_digest"] + assert subscription.delivery is SubscriptionDeliveryDisposition.RECORD_ONLY + + +def test_p2e_corrections_are_never_suppressed_as_duplicate_or_fatigue() -> None: + packet = _load(INPUT_PATH) + corrections = [ + window for window in packet["sensing_windows"] if window["material_kind"] == "same_lineage_correction" + ] + assert [window["window_id"] for window in corrections] == [ + "sensing_window:w3-nasa-correction", + "sensing_window:w5-esa-correction-after-resume", + ] + for window in corrections: + assert window["correction_visible"] is True + assert window["disposition"] == "routed" + assert window["suppression_reason"] is None + + +def test_p2e_preserves_publication_family_boundary_without_measurement_claim() -> None: + policy = _load(INPUT_PATH)["source_policy"] + assert sorted(policy["publication_roots"]) == ["ESA", "NASA"] + assert policy["publication_root_independence_only"] is True + assert policy["independent_measurements_claimed"] is False + assert policy["same_lineage_revisions_count_as_new_families"] is False + + +def test_p2e_keeps_p2d_pack_and_brief_identities_unchanged() -> None: + packet = _load(INPUT_PATH) + pack = compile_planetary_defense_pack() + assert pack.compiled_pack_id == packet["prerequisites"]["compiled_pack_id"] + assert packet["prerequisites"]["historical_brief_id"] == ("brief:c3549af0262b100ca65024ee19cbae6e") + assert packet["prerequisites"]["corrected_brief_id"] == ("brief:806d69d8e41f83f93ee3dc10f58f0d16") + + +def test_p2e_domain_pack_remains_inert_and_grants_no_new_authority() -> None: + manifest = _load(PACK_ROOT / "manifest.json") + assert {item["authority"] for item in manifest["authority_requests"]} == {"source_read"} + assert all(path.suffix == ".json" for path in PACK_ROOT.rglob("*") if path.is_file()) + assert not tuple(PACK_ROOT.rglob("*.py")) + packet = _load(INPUT_PATH) + assert packet["source_policy"]["network_access"] is False + assert packet["cadence_preference"]["scheduler_authorized"] is False + assert packet["ownership"]["delivery_authorized"] is False + assert packet["safety"]["external_action"] is False + + +def _public_intelligence_source() -> str: + root = Path(ace.intelligence.__file__).resolve().parent + return "\n".join(path.read_text(encoding="utf-8") for path in root.rglob("*.py")) + + +def test_wi_cr_007_platform_gap_user_owned_monitor_subscription() -> None: + requests = {item["request_id"]: item for item in _load(REQUESTS_PATH)["requests"]} + assert requests["WI-CR-007"]["status"] == "closed" + assert hasattr(ace.intelligence, "MonitorV1Alpha1") + assert hasattr(ace.intelligence, "PersonaBindingV1Alpha1") + assert hasattr(ace.intelligence, "SubscriptionV1Alpha1") + assert hasattr(ace.application, "MonitoringLifecycleService") + assert hasattr(ace.intelligence, "MonitoringLifecycleRequestV1Alpha1") + assert hasattr(ace.intelligence, "MonitoringLifecycleReceiptV1Alpha1") + source = _public_intelligence_source() + assert "ace.intelligence.monitor/v1alpha1" in source + assert "ace.intelligence.subscription/v1alpha1" in source + assert "ace.intelligence.monitoring-lifecycle-receipt/v1alpha1" in source + assert "MonitoringLifecycleState.REVOKED" in source + + +def test_wi_cr_008_platform_gap_sensing_window_disposition() -> None: + requests = {item["request_id"]: item for item in _load(REQUESTS_PATH)["requests"]} + assert requests["WI-CR-008"]["status"] == "closed" + assert hasattr(ace.application, "SensingWindowService") + assert hasattr(ace.intelligence, "SensingWindowReceiptV1Alpha1") + source = _public_intelligence_source() + assert "ace.intelligence.sensing-window-receipt/v1alpha1" in source + assert "subscription_revoked" in source diff --git a/domain_packs/world_intelligence_planetary_defense/conformance/p2e_contract_requests.json b/domain_packs/world_intelligence_planetary_defense/conformance/p2e_contract_requests.json new file mode 100644 index 0000000..de74fe6 --- /dev/null +++ b/domain_packs/world_intelligence_planetary_defense/conformance/p2e_contract_requests.json @@ -0,0 +1,39 @@ +{ + "consumer": "world_intelligence", + "contract": "ace.world-intelligence.p2e-consumer-contract-requests/v1alpha1", + "requests": [ + { + "request_id": "WI-CR-007", + "title": "Owner-enforced Monitor and Subscription lifecycle", + "status": "closed", + "resolution": "Merged Core PR #94 adds the public owner-authorized append-only lifecycle service and immutable transition receipts. P2E materializes create, pause, resume, and terminal subscription revocation with exact restart replay.", + "motivation": "Released ACE Intelligence already exposes inert Monitor, PersonaBinding, and Subscription resources, which P2E consumes exactly. It has no public lifecycle service that authorizes pause, resume, and terminal revocation against the bound principal while preserving one stable logical intent.", + "requested_contract_shape": "Append-only create, pause, resume, and revoke transitions over the existing domain-neutral Monitor, PersonaBinding, and Subscription contracts. Enforce the bound principal, product/mode/activation scope, stable logical intent, terminal revocation, exact authorization, and idempotent replay without World vocabulary.", + "acceptance_probe": "ace.intelligence publicly exports an owner-authorized Monitor/Subscription lifecycle service and immutable transition receipt over the existing v1alpha1 contracts.", + "blocked_expectations": [ + "owner-enforced pause/resume/revoke", + "terminal revocation replay" + ], + "compatibility_requirement": "Existing one-shot PREPARED and LIVE derivation, routing, Brief, Decision, and action paths remain byte-identical when no Monitor or Subscription is declared.", + "quarantined_test": "test_wi_cr_007_platform_gap_user_owned_monitor_subscription" + }, + { + "request_id": "WI-CR-008", + "title": "Bounded sensing-window disposition and suppression", + "status": "closed", + "resolution": "Merged Core PR #94 adds the public bounded sensing-window service and typed routed/suppressed receipts. P2E materializes all six windows, including replay-only no-change and zero-acquisition paused/revoked guards.", + "motivation": "Released ACE Intelligence has no public receipt that binds one requested sensing window to Monitor/Subscription revisions, source transactions, accepted new resources, and exactly one routed-or-suppressed disposition. World must not implement hidden scheduling, duplicate suppression, or correction visibility privately.", + "requested_contract_shape": "A domain-neutral append-only sensing-window receipt with requested interval, authorizing Monitor and Subscription revisions, source transaction refs, accepted/replayed resources, and a routed material-change or explicit suppression disposition. Paused/revoked windows prove zero acquisition; correction material cannot be classified as no_material_change.", + "acceptance_probe": "ace.intelligence publicly exports a sensing-window receipt and service with typed routed/suppressed dispositions, explicit suppression reasons, zero-acquisition guards, and exact replay.", + "blocked_expectations": [ + "runtime sensing-window materialization", + "no-material-change suppression receipt", + "owner-paused zero-acquisition receipt", + "revoked-subscription zero-acquisition receipt", + "correction-always-visible invariant" + ], + "compatibility_requirement": "Routing without a sensing window behaves exactly as today; the new receipt is additive and grants no scheduler, delivery, publication, or external-action authority.", + "quarantined_test": "test_wi_cr_008_platform_gap_sensing_window_disposition" + } + ] +} diff --git a/domain_packs/world_intelligence_planetary_defense/conformance/p2e_negative_cases.json b/domain_packs/world_intelligence_planetary_defense/conformance/p2e_negative_cases.json new file mode 100644 index 0000000..1770f99 --- /dev/null +++ b/domain_packs/world_intelligence_planetary_defense/conformance/p2e_negative_cases.json @@ -0,0 +1,60 @@ +{ + "contract": "ace.world-intelligence.p2e-negative-cases/v1alpha1", + "cases": [ + { + "case_id": "missing_owner", + "mutation": "Remove the stable owner reference from the monitor intent.", + "expected_violation": "missing_attention_owner" + }, + { + "case_id": "owner_changed", + "mutation": "Attribute the resume event to a different principal.", + "expected_violation": "attention_owner_changed" + }, + { + "case_id": "prepared_live_mix", + "mutation": "Mark one PREPARED record as reused inside the LIVE packet.", + "expected_violation": "prepared_live_mixed" + }, + { + "case_id": "acquisition_while_paused", + "mutation": "Issue one source acquisition request in the owner-paused window.", + "expected_violation": "acquisition_not_authorized" + }, + { + "case_id": "acquisition_after_revocation", + "mutation": "Issue one source acquisition request after subscription revocation.", + "expected_violation": "acquisition_not_authorized" + }, + { + "case_id": "correction_suppressed", + "mutation": "Suppress the NASA correction as no material change.", + "expected_violation": "correction_visibility_lost" + }, + { + "case_id": "false_measurement_independence", + "mutation": "Claim the NASA and ESA publication roots prove independent measurements.", + "expected_violation": "false_independence_claim" + }, + { + "case_id": "hidden_delivery", + "mutation": "Authorize delivery through the subscription attention policy.", + "expected_violation": "external_authority_smuggled" + }, + { + "case_id": "autonomous_schedule", + "mutation": "Authorize autonomous scheduler execution from a cadence preference.", + "expected_violation": "external_authority_smuggled" + }, + { + "case_id": "history_rewrite", + "mutation": "Replace the accepted P2D historical Brief identity with a rewritten artifact.", + "expected_violation": "historical_artifact_rewritten" + }, + { + "case_id": "divergent_replay", + "mutation": "Move one sensing-window request time by one second without changing the pinned packet identity.", + "expected_violation": "divergent_replay_identity" + } + ] +} diff --git a/domain_packs/world_intelligence_planetary_defense/conformance/p2e_user_owned_live_orientation_expected.json b/domain_packs/world_intelligence_planetary_defense/conformance/p2e_user_owned_live_orientation_expected.json new file mode 100644 index 0000000..1b0e302 --- /dev/null +++ b/domain_packs/world_intelligence_planetary_defense/conformance/p2e_user_owned_live_orientation_expected.json @@ -0,0 +1,88 @@ +{ + "contract": "ace.world-intelligence.p2e-user-owned-live-orientation-expected/v1alpha1", + "packet_identity": "sha256:e35f892af752db6dc4e6bf0cd6f6c5e9f7f4b74749f952ccb7effee701ad9d9e", + "expected_projection": { + "mode": "LIVE", + "window_count": 6, + "routed_window_count": 3, + "suppressed_window_count": 3, + "suppression_reasons": [ + "no_material_change", + "owner_paused", + "subscription_revoked" + ], + "owner_guarded_zero_acquisition_windows": 2, + "correction_window_count": 2, + "visible_correction_window_count": 2, + "publication_family_count": 2, + "p2d_live_record_count": 44, + "prepared_record_count": 0, + "static_intent_contracts_constructed": true, + "runtime_materialization_claimed": true, + "open_contract_requests": [], + "negative_vector_count": 11, + "network_access": false, + "scheduler_authorized": false, + "delivery_authorized": false, + "external_action": false, + "violations": [] + }, + "expected_runtime": { + "contract": "ace.world-intelligence.p2e-user-owned-live-orientation-runtime/v1alpha1", + "mode": "LIVE", + "lifecycle_receipt_ids": [ + "monitoring_lifecycle:eef2dbd9e85996690c38b8c74edf4fc8", + "monitoring_lifecycle:d225aa0d2f906562eb17851ec05f3b30", + "monitoring_lifecycle:81c8c122cc5235ab2b84cfb3c7b22019", + "monitoring_lifecycle:6a0cd45354dd0cf2e0e15cb08691d17f", + "monitoring_lifecycle:93594a7ca00a197dd80ab7d54351321d" + ], + "sensing_window_receipt_ids": [ + "sensing_window:8635dbae2c7bd7e64e143c342a99b6a9", + "sensing_window:695409908d2f3277bd0ad8fdf4cb73c7", + "sensing_window:0cf4c37c45703d64363687664cf3db4e", + "sensing_window:e6a89b0f366b16de38b39fedf9cf459b", + "sensing_window:dbc36f77ce5117ef0e0e5cbefb3e7e95", + "sensing_window:909f717e822d2b5e3d2b414b462a2086" + ], + "all_lifecycle_replays_exact": true, + "all_window_replays_exact": true, + "monitoring_record_count": 18, + "p2d_live_record_count": 44, + "composed_live_record_count": 62, + "prepared_record_count": 0, + "official_publication_roots": ["ESA", "NASA"], + "source_observation_ids": [ + "observation:af15bd030df7010eb7228ea155ab9cb8", + "observation:b833f0a930c3503c7ca8b61a748ef942", + "observation:dc110cf23f3fd4e50e9a3a7c94e0660e", + "observation:828d0fb5e6e1560847e2b61560aa0d71" + ], + "shift_ids": [ + "shift:5de2922c755b0878673074d1ac6eedc8", + "shift:aa3e085039db29ce564f2c4a11a78386", + "shift:d94f3e62487cdaef3b904761d76260b8" + ], + "signal_ids": [ + "signal:8798d2ceff3a293a5edb4acf59376627", + "signal:b898c5fc7f3751a84e2b68b788100234", + "signal:1b1c88646144cc8a0c637850ccd769b2" + ], + "case_ids": [ + "case:9f2a90fa065e26aba4792c8cdd24647d", + "case:7298a4c57828df679d03b2ed6493b437" + ], + "reality_brief_ids": [ + "brief:c3549af0262b100ca65024ee19cbae6e", + "brief:806d69d8e41f83f93ee3dc10f58f0d16" + ], + "reality_brief_citation_counts": [2, 4], + "correction_windows_visible": true, + "owner_guarded_zero_acquisition_windows": 2, + "scheduler_authority": false, + "delivery_authority": false, + "external_action_authority": false, + "all_lineage_records_persisted": true, + "prepared_live_separated": true + } +} diff --git a/domain_packs/world_intelligence_planetary_defense/conformance/p2e_user_owned_live_orientation_input.json b/domain_packs/world_intelligence_planetary_defense/conformance/p2e_user_owned_live_orientation_input.json new file mode 100644 index 0000000..a04db94 --- /dev/null +++ b/domain_packs/world_intelligence_planetary_defense/conformance/p2e_user_owned_live_orientation_input.json @@ -0,0 +1,213 @@ +{ + "contract": "ace.world-intelligence.p2e-user-owned-live-orientation-input/v1alpha1", + "packet_id": "world_intelligence_p2e_user_owned_live_orientation", + "mode": "LIVE", + "product_id": "product:world-planetary-defense", + "static_intent_contracts_constructed": true, + "runtime_materialization_claimed": true, + "prepared_material_reused": false, + "prerequisites": { + "compiled_pack_id": "pack_ir:bb400cc0652622b43c01504e651110e0", + "pack_digest": "sha256:bb400cc0652622b43c01504e651110e09bc651d5003bbbfebe00afca213dbb29", + "activation_revision_ref": "activation_revision:385d00a35e8bf7a39ec07c630ac36eec", + "historical_brief_id": "brief:c3549af0262b100ca65024ee19cbae6e", + "corrected_brief_id": "brief:806d69d8e41f83f93ee3dc10f58f0d16", + "p2d_live_record_count": 44, + "p2d_prepared_record_count": 0 + }, + "ownership": { + "owner_ref": "principal:world-analyst-001", + "monitor_id": "planetary_defense_2024_yr4_impact_risk", + "monitor_ref": "monitor:bbb0e5ab246c6d1f08f7669226db6873", + "monitor_digest": "sha256:bbb0e5ab246c6d1f08f7669226db6873d3bdd39aa4a2719c4425c044b1e22761", + "monitor_owner_ref": "principal:world-analyst-001", + "subscription_id": "planetary_defense_2024_yr4_impact_risk", + "subscription_ref": "subscription:3bb149effa91c5fdd224780ae0a455ee", + "subscription_digest": "sha256:3bb149effa91c5fdd224780ae0a455eef3b47ec6fc948cbec9301675b488461e", + "subscription_owner_ref": "principal:world-analyst-001", + "persona_binding_ref": "persona_binding:1349e5c7f78270dd5c8e267b582a1399", + "persona_binding_digest": "sha256:1349e5c7f78270dd5c8e267b582a1399e7e63d445b4c1cf63ac517bf527f5980", + "subject_ref": "entity:planetary-defense/2024-yr4-earth-impact-2032", + "activation_revision": "activation_revision:385d00a35e8bf7a39ec07c630ac36eec", + "persona_ids": ["planetary_defense_researcher"], + "brief_template_id": "planetary_defense_reality_brief", + "delivery_disposition": "record_only", + "delivery_authorized": false + }, + "lifecycle": [ + { + "event_id": "monitor_event:create", + "target_kind": "monitor", + "event_type": "created", + "actor_ref": "principal:world-analyst-001", + "effective_at": "2026-08-11T17:57:00+00:00" + }, + { + "event_id": "subscription_event:create", + "target_kind": "subscription", + "event_type": "created", + "actor_ref": "principal:world-analyst-001", + "effective_at": "2026-08-11T17:57:01+00:00" + }, + { + "event_id": "monitor_event:pause", + "target_kind": "monitor", + "event_type": "paused", + "actor_ref": "principal:world-analyst-001", + "effective_at": "2026-08-11T18:10:10+00:00" + }, + { + "event_id": "monitor_event:resume", + "target_kind": "monitor", + "event_type": "resumed", + "actor_ref": "principal:world-analyst-001", + "effective_at": "2026-08-11T18:10:40+00:00" + }, + { + "event_id": "subscription_event:revoke", + "target_kind": "subscription", + "event_type": "revoked", + "actor_ref": "principal:world-analyst-001", + "effective_at": "2026-08-11T18:17:10+00:00" + } + ], + "source_policy": { + "transport_kind": "separately_installed_opt_in_connector", + "transport_enabled_in_packet": false, + "network_access": false, + "publication_roots": ["ESA", "NASA"], + "publication_root_independence_only": true, + "independent_measurements_claimed": false, + "same_lineage_revisions_count_as_new_families": false + }, + "cadence_preference": { + "declared_only": true, + "scheduler_authorized": false, + "autonomous_execution": false + }, + "sensing_windows": [ + { + "window_id": "sensing_window:w1-initial-orientation", + "requested_by": "principal:world-analyst-001", + "requested_at": "2026-08-11T17:59:00+00:00", + "window_started_at": "2026-08-11T18:00:00+00:00", + "window_ended_at": "2026-08-11T18:05:00+00:00", + "evaluated_at": "2026-08-11T18:05:01+00:00", + "monitor_state": "active", + "subscription_state": "active", + "candidate_source_keys": ["esa_initial", "nasa_initial"], + "acquisition_request_count": 2, + "accepted_new_source_keys": ["esa_initial", "nasa_initial"], + "replayed_source_keys": [], + "material_kind": "initial_divergence", + "correction_visible": false, + "disposition": "routed", + "suppression_reason": null, + "result_brief_id": "brief:c3549af0262b100ca65024ee19cbae6e" + }, + { + "window_id": "sensing_window:w2-no-material-change", + "requested_by": "principal:world-analyst-001", + "requested_at": "2026-08-11T18:06:00+00:00", + "window_started_at": "2026-08-11T18:06:01+00:00", + "window_ended_at": "2026-08-11T18:07:00+00:00", + "evaluated_at": "2026-08-11T18:07:01+00:00", + "monitor_state": "active", + "subscription_state": "active", + "candidate_source_keys": ["esa_initial", "nasa_initial"], + "acquisition_request_count": 2, + "accepted_new_source_keys": [], + "replayed_source_keys": ["esa_initial", "nasa_initial"], + "material_kind": "none", + "correction_visible": false, + "disposition": "suppressed", + "suppression_reason": "no_material_change", + "result_brief_id": null + }, + { + "window_id": "sensing_window:w3-nasa-correction", + "requested_by": "principal:world-analyst-001", + "requested_at": "2026-08-11T18:09:00+00:00", + "window_started_at": "2026-08-11T18:10:00+00:00", + "window_ended_at": "2026-08-11T18:10:06+00:00", + "evaluated_at": "2026-08-11T18:10:07+00:00", + "monitor_state": "active", + "subscription_state": "active", + "candidate_source_keys": ["nasa_revised"], + "acquisition_request_count": 1, + "accepted_new_source_keys": ["nasa_revised"], + "replayed_source_keys": [], + "material_kind": "same_lineage_correction", + "correction_visible": true, + "disposition": "routed", + "suppression_reason": null, + "result_brief_id": null + }, + { + "window_id": "sensing_window:w4-owner-paused", + "requested_by": "principal:world-analyst-001", + "requested_at": "2026-08-11T18:10:20+00:00", + "window_started_at": "2026-08-11T18:10:21+00:00", + "window_ended_at": "2026-08-11T18:10:30+00:00", + "evaluated_at": "2026-08-11T18:10:31+00:00", + "monitor_state": "paused", + "subscription_state": "active", + "candidate_source_keys": [], + "acquisition_request_count": 0, + "accepted_new_source_keys": [], + "replayed_source_keys": [], + "material_kind": "none", + "correction_visible": false, + "disposition": "suppressed", + "suppression_reason": "owner_paused", + "result_brief_id": null + }, + { + "window_id": "sensing_window:w5-esa-correction-after-resume", + "requested_by": "principal:world-analyst-001", + "requested_at": "2026-08-11T18:10:50+00:00", + "window_started_at": "2026-08-11T18:11:00+00:00", + "window_ended_at": "2026-08-11T18:17:02+00:00", + "evaluated_at": "2026-08-11T18:17:03+00:00", + "monitor_state": "active", + "subscription_state": "active", + "candidate_source_keys": ["esa_revised"], + "acquisition_request_count": 1, + "accepted_new_source_keys": ["esa_revised"], + "replayed_source_keys": [], + "material_kind": "same_lineage_correction", + "correction_visible": true, + "disposition": "routed", + "suppression_reason": null, + "result_brief_id": "brief:806d69d8e41f83f93ee3dc10f58f0d16" + }, + { + "window_id": "sensing_window:w6-subscription-revoked", + "requested_by": "principal:world-analyst-001", + "requested_at": "2026-08-11T18:17:20+00:00", + "window_started_at": "2026-08-11T18:17:21+00:00", + "window_ended_at": "2026-08-11T18:17:30+00:00", + "evaluated_at": "2026-08-11T18:17:31+00:00", + "monitor_state": "active", + "subscription_state": "revoked", + "candidate_source_keys": [], + "acquisition_request_count": 0, + "accepted_new_source_keys": [], + "replayed_source_keys": [], + "material_kind": "none", + "correction_visible": false, + "disposition": "suppressed", + "suppression_reason": "subscription_revoked", + "result_brief_id": null + } + ], + "safety": { + "prepared_record_count": 0, + "delivery": false, + "publication": false, + "persuasion": false, + "decision": false, + "outcome": false, + "external_action": false + } +} diff --git a/scripts/p2d_live_conflict_correction.py b/scripts/p2d_live_conflict_correction.py index 2e94c10..4b487aa 100644 --- a/scripts/p2d_live_conflict_correction.py +++ b/scripts/p2d_live_conflict_correction.py @@ -193,6 +193,22 @@ def ingress(self, clock: SequenceClock) -> LiveSourceIngressService: ) +@dataclass(frozen=True, slots=True) +class P2DExecution: + """Exact P2D projection plus the LIVE material used by later consumer proofs.""" + + projection: dict[str, Any] + environment: P2DEnvironment + admissions: dict[str, Any] + divergence: Any + nasa_revision: Any + esa_revision: Any + historical_case: CaseV1Alpha1 + historical_brief: Any + corrected_case: CaseV1Alpha1 + corrected_brief: Any + + def _artifact(claimant: dict[str, Any]) -> CapabilityArtifactIdentityV1Alpha1: implementation_id = { "NASA": NASA_PLANETARY_DEFENSE_IMPLEMENTATION_ID, @@ -1135,7 +1151,9 @@ def _negative_vectors(*, nasa_assertion, nasa_revised, nasa_initial, esa_initial return results -async def run_acceptance() -> dict[str, Any]: +async def execute_acceptance() -> P2DExecution: + """Execute P2D and retain its exact LIVE objects for composed acceptance.""" + environment = await build_environment() authorizer = ExactAppendAuthorizer() binding = bind_committed_activation( @@ -1446,7 +1464,7 @@ async def run_acceptance() -> dict[str, Any]: prepared_records = tuple( record for record in environment.store.records.values() if record.record_space == "prepared" ) - return { + projection = { "contract": "ace.world-intelligence.p2d-live-conflict-correction-proof/v1alpha1", "pack": { "compiled_pack_id": environment.pack.compiled_pack_id, @@ -1550,6 +1568,24 @@ async def run_acceptance() -> dict[str, Any]: "external_action": False, }, } + return P2DExecution( + projection=projection, + environment=environment, + admissions=admissions, + divergence=divergence, + nasa_revision=nasa_revision, + esa_revision=esa_revision, + historical_case=historical_case, + historical_brief=historical_brief, + corrected_case=corrected_case, + corrected_brief=corrected_brief, + ) + + +async def run_acceptance() -> dict[str, Any]: + """Return the stable public P2D acceptance projection.""" + + return (await execute_acceptance()).projection def main() -> None: diff --git a/scripts/p2e_user_owned_live_orientation_acceptance.py b/scripts/p2e_user_owned_live_orientation_acceptance.py new file mode 100755 index 0000000..1271ee9 --- /dev/null +++ b/scripts/p2e_user_owned_live_orientation_acceptance.py @@ -0,0 +1,659 @@ +#!/usr/bin/env python3 +"""Validate the frozen P2E user-owned LIVE-orientation consumer packet. + +This is conformance tooling, not a Monitor, Subscription, scheduler, source +transport, or delivery runtime. It freezes the consumer boundary and keeps the +missing generic platform contracts visible instead of simulating them in World. +""" + +from __future__ import annotations + +import asyncio +import copy +import hashlib +import json +from datetime import datetime +from pathlib import Path +from typing import Any + +from ace.application import ( + LIVE_MONITORING_RECORD_SPACE, + MonitoringLifecycleService, + SensingWindowService, +) +from ace.core import AuthenticatedRuntimeContextV1Alpha1 +from ace.intelligence import ( + CompiledPackRefV1, + ExactMaterialReferenceV1Alpha1, + MonitorDisposition, + MonitoringLifecycleAction, + MonitoringLifecycleRequestV1Alpha1, + MonitoringTargetKind, + MonitorV1Alpha1, + PersonaBindingV1Alpha1, + SensingWindowDisposition, + SensingWindowEvaluationV1Alpha1, + SensingWindowMaterialKind, + SensingWindowRequestV1Alpha1, + SensingWindowSuppressionReason, + SubscriptionDeliveryDisposition, + SubscriptionV1Alpha1, +) + +from scripts.p2d_live_conflict_correction import execute_acceptance + +REPO_ROOT = Path(__file__).resolve().parents[1] +PACK_ROOT = REPO_ROOT / "domain_packs" / "world_intelligence_planetary_defense" +CONFORMANCE = PACK_ROOT / "conformance" + +INPUT_PATH = CONFORMANCE / "p2e_user_owned_live_orientation_input.json" +EXPECTED_PATH = CONFORMANCE / "p2e_user_owned_live_orientation_expected.json" +REQUESTS_PATH = CONFORMANCE / "p2e_contract_requests.json" +NEGATIVE_PATH = CONFORMANCE / "p2e_negative_cases.json" + +P2D_PACK_ID = "pack_ir:bb400cc0652622b43c01504e651110e0" +P2D_HISTORICAL_BRIEF_ID = "brief:c3549af0262b100ca65024ee19cbae6e" +P2D_CORRECTED_BRIEF_ID = "brief:806d69d8e41f83f93ee3dc10f58f0d16" +CORRECTION_KIND = "same_lineage_correction" +OWNER_GUARD_REASONS = {"owner_paused", "subscription_revoked"} + + +def _load(path: Path) -> dict[str, Any]: + return json.loads(path.read_text(encoding="utf-8")) + + +def _canonical(value: Any) -> bytes: + return json.dumps(value, ensure_ascii=False, separators=(",", ":"), sort_keys=True).encode() + + +def _time(value: str) -> datetime: + parsed = datetime.fromisoformat(value) + if parsed.tzinfo is None or parsed.utcoffset() is None: + raise ValueError("P2E times must be timezone-aware") + return parsed + + +def packet_identity(packet: dict[str, Any], expected: dict[str, Any]) -> str: + identity_free_expected = copy.deepcopy(expected) + identity_free_expected.pop("packet_identity", None) + material = {"input": packet, "expected": identity_free_expected} + return f"sha256:{hashlib.sha256(_canonical(material)).hexdigest()}" + + +def build_static_intent_contracts( + packet: dict[str, Any] | None = None, +) -> tuple[MonitorV1Alpha1, PersonaBindingV1Alpha1, SubscriptionV1Alpha1]: + """Construct the public ACE 0.5.0 intent contracts with exact identity.""" + + packet = copy.deepcopy(packet) if packet is not None else _load(INPUT_PATH) + ownership = packet["ownership"] + prerequisites = packet["prerequisites"] + compiled_pack = CompiledPackRefV1( + pack_id="world_intelligence_planetary_defense", + pack_version="0.1.0", + compiled_pack_id=prerequisites["compiled_pack_id"], + pack_digest=prerequisites["pack_digest"], + ) + monitor = MonitorV1Alpha1( + monitor_id=ownership["monitor_id"], + product_id=packet["product_id"], + subject_entity_type_ids=("planetary_defense_risk_estimate",), + subject_refs=(ownership["subject_ref"],), + detection_rule_ids=( + "cross_source_impact_estimate_divergence", + "same_source_impact_estimate_revision", + ), + compiled_pack=compiled_pack, + activation_revision_ref=prerequisites["activation_revision_ref"], + disposition=MonitorDisposition.ENABLED, + ) + persona_binding = PersonaBindingV1Alpha1( + product_id=packet["product_id"], + principal_ref=ownership["owner_ref"], + persona_id=ownership["persona_ids"][0], + compiled_pack=compiled_pack, + activation_revision_ref=prerequisites["activation_revision_ref"], + ) + subscription = SubscriptionV1Alpha1( + subscription_id=ownership["subscription_id"], + product_id=packet["product_id"], + persona_binding_ref=str(persona_binding.binding_ref), + monitor_refs=(str(monitor.monitor_ref),), + signal_types=( + "planetary_defense_estimate_divergence", + "planetary_defense_estimate_revision", + ), + brief_template_ids=(ownership["brief_template_id"],), + minimum_confidence=0.8, + delivery=SubscriptionDeliveryDisposition.RECORD_ONLY, + ) + return monitor, persona_binding, subscription + + +def _lifecycle_state(packet: dict[str, Any], requested_at: datetime) -> tuple[str, str]: + monitor_state = "absent" + subscription_state = "absent" + for event in sorted(packet["lifecycle"], key=lambda item: _time(item["effective_at"])): + if _time(event["effective_at"]) > requested_at: + break + target = event["target_kind"] + if target == "monitor": + if event["event_type"] in {"created", "resumed"}: + monitor_state = "active" + elif event["event_type"] == "paused": + monitor_state = "paused" + elif event["event_type"] == "revoked": + monitor_state = "revoked" + elif target == "subscription": + if event["event_type"] in {"created", "resumed"}: + subscription_state = "active" + elif event["event_type"] == "paused": + subscription_state = "paused" + elif event["event_type"] == "revoked": + subscription_state = "revoked" + return monitor_state, subscription_state + + +def validate_packet( + packet: dict[str, Any], + expected: dict[str, Any], + *, + pinned_identity: str | None = None, +) -> list[str]: + """Return deterministic fail-closed violations.""" + + violations: list[str] = [] + ownership = packet["ownership"] + owner_ref = ownership.get("owner_ref") + + if not owner_ref: + violations.append("missing_attention_owner") + elif ( + ownership.get("monitor_owner_ref") != owner_ref + or ownership.get("subscription_owner_ref") != owner_ref + or any(event.get("actor_ref") != owner_ref for event in packet["lifecycle"]) + or any(window.get("requested_by") != owner_ref for window in packet["sensing_windows"]) + ): + violations.append("attention_owner_changed") + + if ( + packet.get("mode") != "LIVE" + or packet.get("prepared_material_reused") is not False + or packet["safety"].get("prepared_record_count") != 0 + or packet["prerequisites"].get("p2d_prepared_record_count") != 0 + ): + violations.append("prepared_live_mixed") + + if packet.get("static_intent_contracts_constructed") is not True: + violations.append("static_intent_contract_invalid") + else: + try: + monitor, persona_binding, subscription = build_static_intent_contracts(packet) + except (KeyError, TypeError, ValueError): + violations.append("static_intent_contract_invalid") + else: + if ( + monitor.monitor_ref != ownership.get("monitor_ref") + or monitor.monitor_digest != ownership.get("monitor_digest") + or persona_binding.binding_ref != ownership.get("persona_binding_ref") + or persona_binding.binding_digest != ownership.get("persona_binding_digest") + or subscription.subscription_ref != ownership.get("subscription_ref") + or subscription.subscription_digest != ownership.get("subscription_digest") + or subscription.delivery is not SubscriptionDeliveryDisposition.RECORD_ONLY + ): + violations.append("static_intent_contract_invalid") + + lifecycle_times = [_time(event["effective_at"]) for event in packet["lifecycle"]] + window_times = [_time(window["requested_at"]) for window in packet["sensing_windows"]] + if ( + lifecycle_times != sorted(lifecycle_times) + or window_times != sorted(window_times) + or any( + not ( + _time(window["requested_at"]) + <= _time(window["window_started_at"]) + < _time(window["window_ended_at"]) + <= _time(window["evaluated_at"]) + ) + for window in packet["sensing_windows"] + ) + ): + violations.append("temporal_incoherence") + + for window in packet["sensing_windows"]: + monitor_state, subscription_state = _lifecycle_state(packet, _time(window["requested_at"])) + if window["monitor_state"] != monitor_state or window["subscription_state"] != subscription_state: + violations.append("lifecycle_state_mismatch") + break + if (monitor_state == "paused" or subscription_state == "revoked") and ( + window["acquisition_request_count"] != 0 + or window["candidate_source_keys"] + or window["accepted_new_source_keys"] + or window["replayed_source_keys"] + ): + violations.append("acquisition_not_authorized") + break + + for window in packet["sensing_windows"]: + if window["material_kind"] == CORRECTION_KIND and ( + window["disposition"] != "routed" + or window["suppression_reason"] is not None + or window["correction_visible"] is not True + or not window["accepted_new_source_keys"] + ): + violations.append("correction_visibility_lost") + break + if window["suppression_reason"] == "no_material_change" and ( + window["material_kind"] != "none" + or window["accepted_new_source_keys"] + or not window["replayed_source_keys"] + or window["correction_visible"] is not False + ): + violations.append("invalid_no_material_change_suppression") + break + + source_policy = packet["source_policy"] + if ( + sorted(source_policy["publication_roots"]) != ["ESA", "NASA"] + or source_policy["publication_root_independence_only"] is not True + or source_policy["independent_measurements_claimed"] is not False + or source_policy["same_lineage_revisions_count_as_new_families"] is not False + ): + violations.append("false_independence_claim") + + safety = packet["safety"] + if ( + ownership["delivery_authorized"] is not False + or packet["cadence_preference"]["scheduler_authorized"] is not False + or packet["cadence_preference"]["autonomous_execution"] is not False + or source_policy["transport_enabled_in_packet"] is not False + or source_policy["network_access"] is not False + or any( + safety[key] is not False + for key in ( + "delivery", + "publication", + "persuasion", + "decision", + "outcome", + "external_action", + ) + ) + ): + violations.append("external_authority_smuggled") + + prerequisites = packet["prerequisites"] + if ( + prerequisites["compiled_pack_id"] != P2D_PACK_ID + or prerequisites["historical_brief_id"] != P2D_HISTORICAL_BRIEF_ID + or prerequisites["corrected_brief_id"] != P2D_CORRECTED_BRIEF_ID + or ownership["activation_revision"] != prerequisites["activation_revision_ref"] + ): + violations.append("historical_artifact_rewritten") + + if pinned_identity is not None and packet_identity(packet, expected) != pinned_identity: + violations.append("divergent_replay_identity") + return violations + + +def projection(packet: dict[str, Any], expected: dict[str, Any]) -> dict[str, Any]: + windows = packet["sensing_windows"] + requests = _load(REQUESTS_PATH)["requests"] + negatives = _load(NEGATIVE_PATH)["cases"] + suppressions = [window["suppression_reason"] for window in windows if window["suppression_reason"] is not None] + correction_windows = [window for window in windows if window["material_kind"] == CORRECTION_KIND] + return { + "mode": packet["mode"], + "window_count": len(windows), + "routed_window_count": sum(window["disposition"] == "routed" for window in windows), + "suppressed_window_count": sum(window["disposition"] == "suppressed" for window in windows), + "suppression_reasons": suppressions, + "owner_guarded_zero_acquisition_windows": sum( + window["suppression_reason"] in OWNER_GUARD_REASONS and window["acquisition_request_count"] == 0 + for window in windows + ), + "correction_window_count": len(correction_windows), + "visible_correction_window_count": sum(window["correction_visible"] is True for window in correction_windows), + "publication_family_count": len(packet["source_policy"]["publication_roots"]), + "p2d_live_record_count": packet["prerequisites"]["p2d_live_record_count"], + "prepared_record_count": packet["safety"]["prepared_record_count"], + "static_intent_contracts_constructed": packet["static_intent_contracts_constructed"], + "runtime_materialization_claimed": packet["runtime_materialization_claimed"], + "open_contract_requests": [request["request_id"] for request in requests if request["status"] == "open"], + "negative_vector_count": len(negatives), + "network_access": packet["source_policy"]["network_access"], + "scheduler_authorized": packet["cadence_preference"]["scheduler_authorized"], + "delivery_authorized": packet["ownership"]["delivery_authorized"], + "external_action": packet["safety"]["external_action"], + "violations": validate_packet( + packet, + expected, + pinned_identity=expected["packet_identity"], + ), + } + + +def run_positive() -> dict[str, Any]: + packet = _load(INPUT_PATH) + expected = _load(EXPECTED_PATH) + return projection(packet, expected) + + +def _exact(reference: str | None, digest: str | None) -> ExactMaterialReferenceV1Alpha1: + return ExactMaterialReferenceV1Alpha1(reference=str(reference), digest=str(digest)) + + +def _resource_exact(resource: Any) -> ExactMaterialReferenceV1Alpha1: + return _exact(resource.resource_id, resource.resource_digest) + + +def _source_request_exact(request: Any) -> ExactMaterialReferenceV1Alpha1: + return _exact(request.request_id, request.request_digest) + + +def _source_transaction_exact(admission: Any) -> ExactMaterialReferenceV1Alpha1: + return _exact(admission.admission_receipt.receipt_id, admission.admission_receipt.receipt_digest) + + +async def run_runtime_positive() -> dict[str, Any]: + """Materialize P2E over the exact captured P2D LIVE record graph.""" + + packet = _load(INPUT_PATH) + p2d = await execute_acceptance() + monitor, persona_binding, subscription = build_static_intent_contracts(packet) + owner_ref = packet["ownership"]["owner_ref"] + context = AuthenticatedRuntimeContextV1Alpha1( + product_id=packet["product_id"], + actor_ref=owner_ref, + authentication_receipt_ref="authentication_receipt:world-planetary-defense-p2e-owner", + authentication_receipt_digest="sha256:" + "e" * 64, + authenticated_at=p2d.environment.context.authenticated_at, + expires_at=p2d.environment.context.expires_at, + ) + targets = {"monitor": monitor, "subscription": subscription} + target_kinds = { + "monitor": MonitoringTargetKind.MONITOR, + "subscription": MonitoringTargetKind.SUBSCRIPTION, + } + target_references = { + "monitor": _exact(monitor.monitor_ref, monitor.monitor_digest), + "subscription": _exact(subscription.subscription_ref, subscription.subscription_digest), + } + binding_reference = _exact(persona_binding.binding_ref, persona_binding.binding_digest) + action_by_event = { + "created": MonitoringLifecycleAction.CREATE, + "paused": MonitoringLifecycleAction.PAUSE, + "resumed": MonitoringLifecycleAction.RESUME, + "revoked": MonitoringLifecycleAction.REVOKE, + } + lifecycle_service = MonitoringLifecycleService(store=p2d.environment.store) + lifecycle_heads: dict[str, Any] = {} + lifecycle_sequences = {"monitor": 0, "subscription": 0} + lifecycle_receipts = [] + lifecycle_replays = [] + for event in packet["lifecycle"]: + target_name = event["target_kind"] + lifecycle_sequences[target_name] += 1 + prior = lifecycle_heads.get(target_name) + request = MonitoringLifecycleRequestV1Alpha1( + transition_key=event["event_id"], + product_id=packet["product_id"], + authenticated_context=context, + target_kind=target_kinds[target_name], + target=target_references[target_name], + persona_binding=binding_reference, + action=action_by_event[event["event_type"]], + sequence=lifecycle_sequences[target_name], + prior_receipt=prior.reference() if prior is not None else None, + requested_at=_time(event["effective_at"]), + ) + admission = await lifecycle_service.transition( + request=request, + persona_binding=persona_binding, + target=targets[target_name], + applied_at=_time(event["effective_at"]), + ) + replay = await MonitoringLifecycleService(store=p2d.environment.store).transition( + request=request, + persona_binding=persona_binding, + target=targets[target_name], + applied_at=_time(event["effective_at"]), + ) + lifecycle_heads[target_name] = admission.receipt + lifecycle_receipts.append(admission.receipt) + lifecycle_replays.append(replay.replayed and replay.receipt == admission.receipt) + + def lifecycle_at( + target_kind: MonitoringTargetKind, + available_at: datetime, + ) -> ExactMaterialReferenceV1Alpha1: + candidates = [ + receipt + for receipt in lifecycle_receipts + if receipt.target_kind is target_kind and receipt.applied_at <= available_at + ] + return max(candidates, key=lambda item: item.sequence).reference() + + routed_by_window = { + "sensing_window:w1-initial-orientation": ( + p2d.admissions["esa_initial"].observation, + p2d.admissions["nasa_initial"].observation, + p2d.divergence.shift, + p2d.divergence.signal, + p2d.historical_case, + p2d.historical_brief, + ), + "sensing_window:w3-nasa-correction": (p2d.admissions["nasa_revised"].observation,), + "sensing_window:w5-esa-correction-after-resume": ( + p2d.admissions["esa_revised"].observation, + p2d.nasa_revision.shift, + p2d.nasa_revision.signal, + p2d.esa_revision.shift, + p2d.esa_revision.signal, + p2d.corrected_case, + p2d.corrected_brief, + ), + } + material_kinds = { + "none": SensingWindowMaterialKind.NONE, + "initial_divergence": SensingWindowMaterialKind.MATERIAL_CHANGE, + CORRECTION_KIND: SensingWindowMaterialKind.CORRECTION, + } + dispositions = { + "routed": SensingWindowDisposition.ROUTED, + "suppressed": SensingWindowDisposition.SUPPRESSED, + } + suppression_reasons = {item.value: item for item in SensingWindowSuppressionReason} + sensing_service = SensingWindowService(store=p2d.environment.store) + window_receipts = [] + window_replays = [] + for window in packet["sensing_windows"]: + window_started_at = _time(window["window_started_at"]) + request = SensingWindowRequestV1Alpha1( + window_key=window["window_id"], + product_id=packet["product_id"], + authenticated_context=context, + monitor_lifecycle=lifecycle_at(MonitoringTargetKind.MONITOR, window_started_at), + subscription_lifecycle=lifecycle_at(MonitoringTargetKind.SUBSCRIPTION, window_started_at), + requested_at=_time(window["requested_at"]), + window_started_at=window_started_at, + window_ended_at=_time(window["window_ended_at"]), + ) + candidate_keys = tuple(window["candidate_source_keys"]) + accepted_keys = tuple(window["accepted_new_source_keys"]) + replayed_keys = tuple(window["replayed_source_keys"]) + if len(candidate_keys) != window["acquisition_request_count"]: + raise AssertionError("frozen sensing-window acquisition count crossed its candidate requests") + evaluation = SensingWindowEvaluationV1Alpha1( + request=request.reference(), + acquisition_requests=tuple(_source_request_exact(p2d.environment.requests[key]) for key in candidate_keys), + source_transactions=tuple(_source_transaction_exact(p2d.admissions[key]) for key in candidate_keys), + accepted_resources=tuple(_resource_exact(p2d.admissions[key].observation) for key in accepted_keys), + replayed_resources=tuple(_resource_exact(p2d.admissions[key].observation) for key in replayed_keys), + routed_resources=tuple(_resource_exact(item) for item in routed_by_window.get(window["window_id"], ())), + material_kind=material_kinds[window["material_kind"]], + disposition=dispositions[window["disposition"]], + suppression_reason=( + suppression_reasons[window["suppression_reason"]] if window["suppression_reason"] is not None else None + ), + correction_visible=window["correction_visible"], + evaluated_at=_time(window["evaluated_at"]), + ) + admission = await sensing_service.record(request=request, evaluation=evaluation) + replay = await SensingWindowService(store=p2d.environment.store).record( + request=request, + evaluation=evaluation, + ) + window_receipts.append(admission.receipt) + window_replays.append(replay.replayed and replay.receipt == admission.receipt) + + live_records = tuple( + record + for record in p2d.environment.store.records.values() + if record.record_space in {"live", LIVE_MONITORING_RECORD_SPACE} + ) + prepared_records = tuple( + record for record in p2d.environment.store.records.values() if record.record_space == "prepared" + ) + monitoring_records = tuple( + record + for record in p2d.environment.store.records.values() + if record.record_space == LIVE_MONITORING_RECORD_SPACE + ) + lineage_resources = ( + *(p2d.admissions[key].observation for key in ("esa_initial", "nasa_initial", "nasa_revised", "esa_revised")), + p2d.divergence.shift, + p2d.nasa_revision.shift, + p2d.esa_revision.shift, + p2d.divergence.signal, + p2d.nasa_revision.signal, + p2d.esa_revision.signal, + p2d.historical_case, + p2d.corrected_case, + p2d.historical_brief, + p2d.corrected_brief, + ) + p2d_record_keys = { + record.record_key for record in p2d.environment.store.records.values() if record.record_space == "live" + } + return { + "contract": "ace.world-intelligence.p2e-user-owned-live-orientation-runtime/v1alpha1", + "mode": "LIVE", + "lifecycle_receipt_ids": [str(item.receipt_id) for item in lifecycle_receipts], + "sensing_window_receipt_ids": [str(item.receipt_id) for item in window_receipts], + "all_lifecycle_replays_exact": all(lifecycle_replays), + "all_window_replays_exact": all(window_replays), + "monitoring_record_count": len(monitoring_records), + "p2d_live_record_count": p2d.projection["separation"]["live_record_count"], + "composed_live_record_count": len(live_records), + "prepared_record_count": len(prepared_records), + "official_publication_roots": p2d.projection["source"]["independent_claimant_roots"], + "source_observation_ids": [ + str(p2d.admissions[key].observation.resource_id) + for key in ("esa_initial", "nasa_initial", "nasa_revised", "esa_revised") + ], + "shift_ids": [ + str(item.resource_id) for item in (p2d.divergence.shift, p2d.nasa_revision.shift, p2d.esa_revision.shift) + ], + "signal_ids": [ + str(item.resource_id) for item in (p2d.divergence.signal, p2d.nasa_revision.signal, p2d.esa_revision.signal) + ], + "case_ids": [str(p2d.historical_case.resource_id), str(p2d.corrected_case.resource_id)], + "reality_brief_ids": [ + str(p2d.historical_brief.resource_id), + str(p2d.corrected_brief.resource_id), + ], + "reality_brief_citation_counts": [ + len(p2d.historical_brief.citations), + len(p2d.corrected_brief.citations), + ], + "correction_windows_visible": all( + receipt.correction_visible + for receipt in window_receipts + if receipt.material_kind is SensingWindowMaterialKind.CORRECTION + ), + "owner_guarded_zero_acquisition_windows": sum( + receipt.suppression_reason + in { + SensingWindowSuppressionReason.OWNER_PAUSED, + SensingWindowSuppressionReason.SUBSCRIPTION_REVOKED, + } + and not receipt.acquisition_requests + and not receipt.source_transactions + for receipt in window_receipts + ), + "scheduler_authority": any(receipt.scheduler_authority for receipt in window_receipts), + "delivery_authority": any(receipt.delivery_authority for receipt in window_receipts), + "external_action_authority": any(receipt.external_action_authority for receipt in window_receipts), + "all_lineage_records_persisted": all(str(item.resource_id) in p2d_record_keys for item in lineage_resources), + "prepared_live_separated": len(prepared_records) == 0, + } + + +def _mutated_packet(case_id: str) -> dict[str, Any]: + packet = copy.deepcopy(_load(INPUT_PATH)) + windows = packet["sensing_windows"] + if case_id == "missing_owner": + packet["ownership"]["owner_ref"] = "" + elif case_id == "owner_changed": + packet["lifecycle"][2]["actor_ref"] = "principal:other-user" + elif case_id == "prepared_live_mix": + packet["prepared_material_reused"] = True + elif case_id == "acquisition_while_paused": + windows[3]["acquisition_request_count"] = 1 + elif case_id == "acquisition_after_revocation": + windows[5]["acquisition_request_count"] = 1 + elif case_id == "correction_suppressed": + windows[2]["disposition"] = "suppressed" + windows[2]["suppression_reason"] = "no_material_change" + windows[2]["correction_visible"] = False + elif case_id == "false_measurement_independence": + packet["source_policy"]["independent_measurements_claimed"] = True + elif case_id == "hidden_delivery": + packet["ownership"]["delivery_authorized"] = True + elif case_id == "autonomous_schedule": + packet["cadence_preference"]["scheduler_authorized"] = True + packet["cadence_preference"]["autonomous_execution"] = True + elif case_id == "history_rewrite": + packet["prerequisites"]["historical_brief_id"] = "brief:rewritten" + elif case_id == "divergent_replay": + windows[1]["requested_at"] = "2026-08-11T18:06:01+00:00" + else: + raise KeyError(case_id) + return packet + + +def run_negative_cases() -> dict[str, str]: + expected = _load(EXPECTED_PATH) + pinned_identity = expected["packet_identity"] + results: dict[str, str] = {} + for item in _load(NEGATIVE_PATH)["cases"]: + violations = validate_packet( + _mutated_packet(item["case_id"]), + expected, + pinned_identity=pinned_identity, + ) + results[item["case_id"]] = violations[0] if violations else "accepted" + return results + + +def main() -> None: + packet = _load(INPUT_PATH) + expected = _load(EXPECTED_PATH) + print( + json.dumps( + { + "contract": "ace.world-intelligence.p2e-user-owned-live-orientation-proof/v1alpha1", + "packet_identity": packet_identity(packet, expected), + "projection": projection(packet, expected), + "runtime": asyncio.run(run_runtime_positive()), + "negative_vectors": run_negative_cases(), + }, + indent=2, + sort_keys=True, + ) + ) + + +if __name__ == "__main__": + main()