Skip to content

fix(selection-monitoring): bind post-issuance validation and export to one snapshot #273

Description

@seonghobae

Finding

Selection Monitoring had two distinct post-issuance integrity gaps in the same canonical-export boundary.

The first was representation-preserving runtime aliasing: after issuance, low-level mutation could replace an exact built-in trust field with a behavior-bearing subtype carrying the same serialized value. That gap was repaired on PR #42 before this update by re-establishing exact built-in runtime types before canonical rendering.

A second checked-versus-used gap remained. At 155c9cdc9586ac29bdc4ace8a718fba3ab6304a5, _assert_canonical_runtime_evidence(plan) read and validated live object fields, then _canonical_plan_json_unchecked(plan) reread those fields for rendering. Another thread could therefore mutate monitoring_start after validation but before .isoformat(), substituting caller-controlled subtype behavior into the export that had just passed the type gate.

Reality RED

Test-only exact a08e12cb246a31f7ec6f9026b3f1fc5bade07930 adds a deterministic barrier after runtime validation, then replaces monitoring_start with an executable date subtype before rendering resumes.

Foundation CI 34355327114, job 102478423049, materialized the real RED on that exact head: the Selection Monitoring package ran 123 tests and finished 1 failed, 122 passed because test_canonical_export_uses_the_same_runtime_snapshot_it_validated observed AssertionError("caller-controlled date method executed"). The RED head still reported 100% owned statement and branch coverage, so this is a behavioral integrity failure rather than an uncovered path.

Causal repair

Exact source repair e5a53ca440ac7ed38049095afdf39bef34591078 introduces one captured canonical runtime-evidence dictionary. Canonical export now:

  1. reads each serialized trust-bearing field exactly once;
  2. exact-type validates that captured snapshot;
  3. renders date/timestamp/JSON exclusively from the same snapshot;
  4. compares those canonical bytes with the original process-local issuance seal.

A subtype present at capture fails closed before caller-controlled rendering. A mutation after validation cannot alter the already-captured value used by that export. A subsequent export sees the new live value and fails the exact-type boundary. Valid canonical JSON/schema and the public builder contract are unchanged.

Foundation CI 34355550242, job 102479182632, completed SUCCESS on exact e5a53ca440ac7ed38049095afdf39bef34591078, including Foundation dependency hygiene, owned unit/service contracts, isolated PostgreSQL contracts, and read-only validation.

Documentation successor 6749ea11063c091a1aa8af1714af5e088cb4a3db updates ADR 0016, Selection Monitoring traceability, README, and package CHANGELOG so the one-snapshot invariant is code-current. Its exact-head workflows are fresh and must be judged independently; predecessor GREEN does not transfer.

Canonical owner / acceptance

PR #42 remains the sole Selection Monitoring writer, based on protected develop@eb9757f8649aaad026a9865508d9aad50c1a7a4f. Preserve aggregate-only scope, human-only consequential authority, exact 100% statement/branch coverage, privacy/issuance regressions, and current Foundation dependency order. Do not restore a package-local workflow, weaken the seal/type boundary, or copy mutable shared Foundation source.

Keep this issue open until PR #42 is normally integrated to protected develop, or a verified successor demonstrably carries every valid source/test/docs/evidence delta. Central required-workflow failures are repaired at their canonical owners rather than with leaf retries or gate weakening.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions