Repository navigation
Cross-run workspace substrate + reference agent - #26
Merged
Merged
Conversation
…epublish guard Adds the workspace layer above the single-run gate: dated run dirs under workspace_dir/runs/, an append-only regenerable runs.jsonl manifest (seal_run / list_runs / reindex_runs, V7 analog), claim_history and claim_by_id queries across sealed runs, and standing_refutations + guard_republished_claims — the persistent guard that surfaces a critic-refuted claim_id being republished in a later run (emits a refuting critic claim with prior-run provenance and applies a severity=high critique, V16 record-then-enforce; surfaces, never blocks). Closes the deferred review finding that the refutation guard was in-memory per-run only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Joez4MiYjd6owPcRQNcKrv
…ish guard An adversarial find->verify review of 5282101 surfaced 17 reproduced defects (0 refuted), collapsing to 8 fixes: - guard was not idempotent and could crash: a re-invocation or a 900-bucket critic-id hash collision re-emitted a duplicate claim_id and raised LayerAValidationError out of a surface-never-block function. Critic ids are now 9-digit and salted with the target record id; the guard reuses an already-emitted critic instead of re-emitting, and wraps emit in try/except as a safety net (critic_record_id=None branch). - guard spent the shared V16 critiqueRounds budget, so draft-tier surfacings could silently downgrade a later legitimate high critique; the counter is now saved/restored around the guard's apply_critique. - guard hardcoded audience=None, letting board-audience drafts escape the gate; it now passes the record's real audience. - new_run_dir accepted dot-only run_ids ("..") that wrote bundles into the workspace root; rejected now. - seal_run could not seal a run under a symlinked runs/ dir (resolve() asymmetry); the runs root is now resolved on both sides. - "latest" sighting depended on manifest file order, so a reindex could flip standing_refutations; order is now canonical (completed_at, run_id). - _build_entry silently treated a missing/stale records.jsonl as no claims, poisoning the guard; it now regenerates via store.reindex (V7) and raises on genuine corruption. - a typo'd workspace path silently answered "no refutations"; queries now raise WorkspaceNotFoundError, and a deleted-but-regenerable manifest falls back to an in-memory bundle scan without rewriting on read. Adds 15 regression tests (guard idempotency, multi-hit, guard->seal->next run end-to-end, budget preservation, board audience, at-cap branch, symlinked runs/, out-of-order reindex, interrupted-seal recovery, deleted manifest, nonexistent workspace, fixed-space critic id). Full suite 914 passed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Joez4MiYjd6owPcRQNcKrv
…nstruction Quality-only cleanup from a /simplify pass (no behavior change; 914 tests still green): - serialize rows via dataclasses.asdict instead of hand-written _sighting_to_dict/_entry_to_dict mirrors; the deserialize side stays explicit for its coercion/defaulting. - one _write_manifest_rows(mode=) helper for both the seal-append and reindex-overwrite sites, so the V7 'seal row == reindex row' invariant cannot drift between two copies. - seal_run idempotency check scans run_id off the raw manifest lines instead of deserializing every prior run's full claim list. - single canonical (completed_at, run_id) sort key, defined once and used by both _scan_bundles and list_runs. - build RepublishFinding once after the reuse/emit branches rather than from two near-identical literals. - honest docstrings on _build_entry/RunEntry: records.jsonl order is emission order on a fresh bundle but record_id order after an index-repair reindex (verdict resolution is order-independent). Deferred cross-module extractions noted for follow-up (shared claim-id minter in libs/validation; paired read_run_json + shared jsonl helpers in store/runstate; splitting apply_critique's record-vs-spend concerns). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Joez4MiYjd6owPcRQNcKrv
Consolidate the duplicated 'namespace + tier token + sha256 bounded number' id grammar into one libs.validation.mint_claim_id(namespace, tier_token, seed, *, digits) — the /simplify altitude + reuse pass flagged two divergent copies (hamilton adapter _gen_metric_claim_id at 3 digits; workspace _guard_critic_claim_id at 9) that would drift from CLAIM_ID_REGEX and each other over time. - adapter._gen_metric_claim_id now delegates (digits=3); output is arithmetically identical to the old inline form, so generated metric ids are unchanged. Drops the now-dead _ID_TIERS classvar and unused re import. - workspace._guard_critic_claim_id delegates (digits=9), keeping its namespace extraction and wide collision-resistant space; drops the unused hashlib import. - the id grammar's tier-token set now lives once beside CLAIM_ID_REGEX. No behavior change to persisted ids; 914 tests green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Joez4MiYjd6owPcRQNcKrv
…loop A worked example over the growth_demo fixture showing what the cross-run substrate is for: a memoryless agent that reconstructs context from sealed runs. Two 'pulse days' — day 1 runs the DAG, emits CAC/MER/naive-CAC claims, reconciles each against the fixture ground truth (true CAC supported, the P5-trap naive CAC refuted), seals; day 2 re-runs on a longer window, reads the blended-CAC drift back from claim_history, and runs the persistent republish guard, which catches that the naive claim — refuted on day 1 — was re-emitted without a superseding verdict. Nothing is held in memory between runs: day 2 reads day 1 back from the sealed workspace (claim_history / the guard), mirroring how an external, ephemeral pulse agent would work. Ships with tests pinning the drift read-back, the guard catch (asserted on the guard's own findings, not the reconciliation edge), and reproducibility under a fixed emit_timestamp. 916 tests green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Joez4MiYjd6owPcRQNcKrv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the cross-run workspace substrate — the layer that lets a memoryless
agent remember across runs — and a reference agent that demonstrates the
full read-history → diff → report loop over the seeded
growth_demofixture.A single run bundle can't answer "when did this claim_id last appear", "how
has this number drifted", or "was this claim refuted in a prior run". The
substrate answers all three, and closes a confirmed hole: a critic-refuted
claim could silently republish in a later run because the guard was in-memory
per-run only.
New surface (
insight_kit.platform.gate)new_run_dir— dated, collision-safe run isolation under a workspace.seal_run/list_runs/reindex_runs— an append-only, regenerableruns.jsonlmanifest (V7 analog: rebuildable from the run bundles).claim_history/claim_by_id— query a claim_id's sightings across sealedruns in canonical
(completed_at, run_id)order.standing_refutations— claim_ids whose latest verdicted sighting isrefuted (an unverdicted re-emission does not clear a refutation — that's
the republish hole).
guard_republished_claims— the persistent guard: for each draft/publishedclaim carrying a standing refutation, it emits a critic refuting the new
record and applies a high-severity critique (V16 record-then-enforce;
published tier →
downgrade_required=True). It surfaces, never blocks —doctrine holds: only deductive identities block.
RunNotSealedError,WorkspaceNotFoundError(never guess — anabsent fact is not a reconstructable one).
Reference agent (
examples/growth_demo/reference_agent.py)Two "pulse days" over the fixture, holding nothing in memory between them:
Day 2 reconstructs day 1 entirely from the sealed workspace — the pattern an
external, ephemeral pulse agent would use. Run it with
python -m insight_kit.examples.growth_demo.reference_agent.How it was built
The substrate was implemented, then put through an adversarial find→verify
review that reproduced 17 defects (0 false positives); all are fixed in
the second commit (guard idempotency + critic-id collision space, V16 budget
preservation, board-audience gating, dot-only run_id rejection, symlink-safe
seal, canonical ordering independent of file order, never-trust-a-stale-index,
typed workspace errors). Then a
/simplifypass (asdict serialization, onemanifest-write helper, cheap idempotency scan, single sort key) and a
consolidation of the duplicated claim-id minter into one
libs.validationhelper shared by the adapter and the guard.
No changes to the canonical immutable-record store; the workspace layer is
purely a regenerable index above it.
Tests
916 passed, 1 deselected. New coverage: 49 workspace tests (guard idempotency,
multi-hit, guard→seal→next-run end-to-end, budget preservation, board
audience, at-cap branch, symlinked runs, out-of-order reindex, interrupted-seal
recovery, deleted manifest, nonexistent workspace) + 2 reference-agent tests
(drift read-back, guard catch asserted on the guard's own findings, fixed-
timestamp reproducibility).
🤖 Generated with Claude Code
https://claude.ai/code/session_01Joez4MiYjd6owPcRQNcKrv
Generated by Claude Code