test(global-db): prove refusal fast path with corruption tripwire - #653
test(global-db): prove refusal fast path with corruption tripwire#653ScriptedAlchemy wants to merge 9 commits into
Conversation
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 44119bff05
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…plan' into codex/globaldb-collision-tripwire
…e' into codex/globaldb-collision-tripwire
|
Closing this PR unmerged because its head advanced concurrently from the last reviewed clean head The clean, corrected implementation is preserved in ready replacement PR #659: #659 Replacement exact pair: base |
|
Superseded by clean corrective PR #659; closing unmerged to exclude the concurrently added rejected counter/schema draft. |
Checkpoint of the superseded durable-receipt lane after PR #653 was replaced by #659: removes the accumulate_admission_work write amplification (a durable write per re-admitted candidate), instruments begin_engine_read_snapshot as a traced runtime dispatch, dedupes merge-duplicated imports, and converts one of three covered-replay receipt assertions to the unchanged-receipt contract. Draft preserved for reference; not for merge.
Finding addressed
Codex P1 on #652: the restored
identity-digest-probefeature intracedecay-domainwas another test-only production port — a public feature with no production caller whose thread-local counter mutations get compiled into every instrumented canonical hashing path by any--all-featuresbuild (which CI runs). This PR removes counter instrumentation entirely and replaces its proof role with a counter-free behavioral proof.Tripwire design
The refusal fast path's contract: a re-admitted identical candidate is answered from the
observation_admission_refusalsmarker and the frontier cursor with bare-column reads — zero stored-row decode, zero identity derivation, zero payload hashing of stored data. The tests now prove that contract behaviorally:observationsrow:observation_jsonandcommitted_cursor_jsonbecome undecodable garbage andpayload_digestbecomes a value no re-hash can match. The corruption staysjson_validwith a matching$.observation_id, so production retention'sjson_extractbookkeeping and mount-time audits that legitimately touch committed rows keep working; the fixture writes through theobservations_immutable_updateguard exactly the way production retention's tombstone writer does (drop trigger → update → recreate trigger, one transaction).IdentityCollisionwith converged coverage and no error, and the corrupted bytes must remain byte-identical afterward — proving no pass read back, repaired, or rewrote the row.If a regression reintroduces stored-row decode, identity re-derivation, or payload re-hashing on the fast path, the corrupted bytes make it fail loudly. Six tests arm the tripwire:
re_admitted_identity_collision_short_circuits_without_decode_or_hash,replacement_domain_collision_records_terminal_coverage_without_rework,terminal_refusal_survives_retention_and_catch_up_never_reopens_the_record,post_retention_rescan_re_admits_from_raw_source_without_terminal_rework,eof_refusal_converges_new_generation_rescans_without_reopening,orphaned_refusal_marker_repairs_coverage_on_the_next_frontier_pass.RED receipt
Temporarily disabling the marker fast path (appending
.filter(|_| false)to theread_admission_refusalresult inpersist_observation, forcing the full path) made all six tripwire tests fail RED on the corruption:(The other five failed identically:
terminal_refusal…,post_retention…,eof…,orphaned…,replacement_domain….) The fast path was then restored and all tests went green again — the tripwire is falsifiable, not vacuous.Deletions
All counter instrumentation is gone (net −241 lines across the two commits):
crates/tracedecay-domain:identity-digest-probefeature (Cargo.toml),identity_digest_probemodule (68 lines), and all three probe call sites inobservation.rs(domain_digest,sha256_digest) andresearch/canonical.rs(canonical_sha256). −84 lines.crates/tracedecay-global-db: the probe dev-dependency feature,digest_counts(),CatchUpRecordReceipt/digest_deltas, and every counter assertion including the(0,0,1)command-digest shape. Frontier-read behavior stays proven by the existing coverage-convergence assertions.cargo build -p tracedecay-domain --all-featurescompiles no probe code (the feature no longer exists);rg identity.digest.probe crates/returns nothing.Verification
cargo test -p tracedecay-global-db: 399 passed, 4 failed — exactly the 4 known pre-existing base failures (registered_database_lease_keeps_runtime_alive_after_map_owner_drops,registered_project_graph_binding_retains_only_the_database_weak_proxy,registered_legacy_relations…installation_requires_typed_reset…,concurrent_registered_mounts_singleflight_to_one_runtime); all 18 collision tests green.cargo test -p tracedecay-domain: all green (209 unit + doc/integration suites).cargo clippy -p tracedecay-global-db -p tracedecay-domain --all-targets -- -D warnings: clean.cargo fmt -p tracedecay-global-db -p tracedecay-domain -- --check: clean.