Repository navigation
feat(D140): in-force periods as an adjudication input, with fact window review (WP-ET.7) - #506
Merged
Merged
Conversation
… review (WP-ET.7, WIP) Claims from versions with declared periods carry their in-force intervals into E3 adjudication; undated attempts render and fingerprint exactly as before. A period basis on each fact records what its window was adjudicated against; a new review_fact_windows stage reviews facts whose basis moved after a period write, clear, version completion or deletion. Tests and docs follow. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
Work rows are unique per (target, stage, version), so each lineage request, per-fact review and relabel gets its own target id with the lineage/fact in the payload. Adds PG proofs (VAT example, retroactive correction, clear/redeclare, mixed support, deleting the closing edition, undated parity) and unit tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
…, plan and public docs §8.2 promised 'ordinary re-adjudication' on declaration changes, but no mechanism re-adjudicates already-applied evidence. The design now defines the window review (period basis, triggers, fan-out, keep-or-replace review) and D140 records the refinement in place. Public docs: the guide explains the input and the review; not-built-yet drops the item; install lists the new worker. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
…fixes A fact whose only source was deleted has nothing to review against; the lifecycle cascade already settled it, so the fan-out does not spend a model call on it. Test helpers order jobs by enqueued_at and resolve claims by handle. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
…d inventories Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
Regression proof for the owner invariant: a periodised v1 -> v2 with one changed paragraph extracts and embeds only the edited chunk and its same-section neighbours (the undated bound); a later period correction queues no pipeline work, writes no chunk/claim/search rows and makes no extraction or embedding call; its window review is one model call. WP-ET.7 touches no chunking, reuse-key, text-origin or embedding input. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
- A first fact from periodised evidence is adjudicated (prompt engine) or dated from its single in-force interval (jev), never stamped by the novelty gate. - A deployment period fence: decisions hold it shared from final validation through commit; the lineage fan-out passes it exclusively before reading stored bases. - Ingest that declares or corrects a period on an existing version queues a review; new versions are reviewed on completion. - A review changes only the window: no fact relabel or re-embedding; profile repair is keyed by the adjudication receipt. - Bounded work: SQL-side period basis, paged fan-out with continuation jobs, bounded review inputs (periodised claims first). - Completed review answers are stored per fact and fingerprint and reused; a live claim blocks duplicate paid calls. - Crash-safe review requests on version, lineage and source deletion and late-testimony retirement; none during hard forget. - Hard forget clears period_basis and review attempts. - The owner regression now moves a fact's period, requires a replacement and proves no chunk, claim or fact re-embedding. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
…eviews and response Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
Merged
1 task done
- Ordinary apply watches the in-force periods of every claim its bases can cover (shown claims and all candidate evidence), records bases only for facts that were current, and rolls back if those periods move before commit (Sol R2 P1-1). - Review repairs no longer clear entity vectors; the production profile refresher re-embeds only profiles whose rendered text changed (P1-2). - Review claims record their owning job; a failed inference releases its claim, and another job's live claim defers the work instead of failing (P1-3). Migration adds fact_window_review_attempts.claimed_by. - Citations are validated before an answer is stored (P1-4). - Migration docstring NULL wording (nit). Round-2 reviews and response. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
- The ordinary-apply watch reads the prepared inputs before final validation, in one SQL statement: stale candidates, one digest over the in-force periods of all coverable evidence, and the shown claims' periods. Validation also requires the shown periods to match the watch; bases are recorded only for non-stale facts and the digest is re-read after recording (Sol R3 P1-1). - The comparison stays in SQL: the worker holds a digest, the stale ids and at most the shown claims' periods, however much evidence a fact has (R3 P1-3; 5,001-claim regression). - R3 P1-2 (profile re-embedding) is awaiting an owner decision; behaviour unchanged. Round-3 review and response; design §8.2 protocol. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
R4-P1-1 was the third race of one family (certifying from reads that agree across separate READ COMMITTED statements). Structural rule, D140 §8.2: - Every period-dependent input (current bases, stale facts, shown claims' periods, all-evidence digest) is read by one SQL statement, read_period_inputs_on, at preparation and validation: ordinary apply, review and the fan-out's stored/current comparison. - A basis is stored only from a validated one-statement read: reviews store the basis their validated read produced; ordinary apply stores the bases from its post-write verified read (record + re-check merged; record_period_basis_on removed). - The fence orders certification before the fan-out of any later writer. Period writers take no lock: extraction's chunk_claims writes change in-force intervals, so freezing periods would serialise extraction. Tests: the reviewer's torn A->B->A review interleaving (fails on 3b676c1) and real concurrent period writers racing the worker. Removes a scratch script committed by mistake in 3b676c1. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
… window review (WP-ET.7 R3-P1-2) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
…ngestion; note the accepted profile refresh (review r6) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF
fazpu
marked this pull request as ready for review
October 22, 2026 09:55
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.
Review round 7 (GPT-6.1 Sol, on
292ab95f8): Approve (closure)Review round 6 (GPT-6.1 Sol, on
44118ae07): no P0/P1; merge-interaction audit with D142 clean; one wording P2 and one nit → fixed in this round✅ Owner decision on R3-P1-2 (2026-10-22): keep option (a)
A profile is re-embedded when its rendered (dated) text changes after a window review. The owner said: "Okay, leave it as is." This is a cheap projection refresh of text that really changed, and it re-processes no document text, so it sits outside CLAUDE.md Rule 4. It is recorded in decisions.md D140 and in design §8.2 (commit
ac5366426). Option (b), a date-free embedded profile, was rejected: it saves only that call and shows no measured matching benefit. Backlog: #509, identity time for time-bound entities, to be built only if an eval shows distinct same-name events merged into one entity.origin/main(D142, #505) was merged in44118ae07.Implements WP-ET.7 of D140 (
plan/plans/effective_time_and_section_references.md, design §8.2): a version's in-force periods become an input to E3 fact adjudication, and fact windows are reviewed when those periods change later. Ready for review; still a draft.What it does
Adjudication input. A claim that occurs in versions with declared periods is shown to adjudication with
source_in_force(the union of those versions' in-force intervals, current readings, current belief) andsource_in_force_also_undatedwhen the same text also occurs in an undated source. A prompt section explains when periods are world dates (rules/rates/obligations a document establishes) and when not (events it reports). D118 stays the only window authority. Thejevengine'suse_claimaction dates an undated claim from a single in-force interval.Undated parity. No new snapshot keys, so the fingerprint is unchanged; the prompt template is unchanged, and the section is spliced in only when a claim carries periods. There are no new jobs and no extra model calls. The only new work is one indexed existence probe (
document_effective_time_eventsfor the deployment) per snapshot and per apply.Window review.
relations/observations.period_basisfingerprints the in-force periods a window was adjudicated against. Every period-dependent input (bases, stale facts, shown periods, evidence digest) is read by one SQL statement. A basis is stored only from such a validated read: by every review, and by an applied adjudication for facts whose periods it saw unchanged through commit. A newreview_fact_windowsstage has two job kinds:clear, version completion (reconcile), operator version deletion and document deletion, and only for lineages that ever had periods. It finds the facts whose basis moved.Duplicate triggers are free. Facts with no live evidence left are skipped.
Wiring. Migration
p9_39_0060(two nullable columns, one enum value);worker-review-fact-windowscompose service; self-host handler; the label stage accepts single-fact targets.Incremental ingestion is untouched (owner invariant)
WP-ET.7 changes no reuse input. It changes nothing in:
core/chunker.py,workers/e1.pyextraction_input_hashor D140reuse_identity_hash/ text origin:core/text_origin.py,workers/e2.pycore/embedding_input_policy.pygit diff origin/main...HEADshows no change in those files. Periods are not inputs to any of them, and a window review only reads evidence and writes a fact window, an adjudication-log row,period_basisand a profile repair job. It never enqueues convert/structure/chunk/embed/extract work.Regression proof
src/tests/workers/test_d140_period_reuse_pg.py, a periodised dated lineage:LabelFactsHandler+EntityProfileRefresher, over a pre-built profile) makes exactly one embedding call: for the entity profile, because it displays the fact's window and that text changed. It embeds no fact, chunk or claim. A profile whose rendered text did not change costs no call (test_a_review_whose_window_leaves_profiles_unchanged_embeds_nothing).Dual review round 1 (
1c5cfc05): all findings addressed (head3419f295)Reviews and the per-finding response are in
design/reviews/:REVIEW_gpt-6.1-sol_d140_wpet7_r1_2026-10-21.md,REVIEW_agy-gemini-4-argon_d140_wpet7_r1_2026-10-21.mdandRESPONSE_d140_wpet7_r1_2026-10-21.md.jev). It is never left undated by the novelty gate with its basis already stamped.fact_window_review_attemptsstores one answer per fact and fingerprint, and retries and duplicate jobs reuse it.period_basisand the review attemptsReview round 4 (
3b676c17): R4-P1-1 fixed structurally (head17c81c1f)Sol requested changes (one P1). The review and response are in
design/reviews/:REVIEW_gpt-6.1-sol_d140_wpet7_r4_2026-10-21.mdandRESPONSE_d140_wpet7_r4_2026-10-21.md.R4-P1-1 was the third race of one family: certifying from two reads that agree across separate READ COMMITTED statements. The fix is one rule (design §8.2, "Consistency: certify only one consistent read"):
read_period_inputs_on. That covers bases, stale facts, the shown claims' periods and the all-evidence digest. Preparation and validation both use it, in ordinary apply, review and the fan-out.record_period_basis_onis removed.Period writers take no lock. This deliberately differs from the coordinator's suggested step 1.
chunk_claimswrite, because a version's representation becomes current at structuring time, before extraction.The lock order is unchanged and there is no new lock.
Tests:
test_a_torn_review_read_cannot_certify_a_window_from_another_period, the reviewer's interleaving. It fails on3b676c17every time: a 2022 window is certified against 2023.test_reviews_racing_real_period_writers_settle_on_the_final_periods: 48 realset_effective_periodstransactions race the real worker, and every fact settles on its final periods.The earlier race tests stay green, with two hooks moved to the renamed functions.
Review round 3 (
dc44041f): P1-1 and P1-3 fixed, P1-2 awaiting an owner decision (head3b676c17) — P1-2 resolved by the owner on 2026-10-22 (option a, see top)Sol requested changes (three P1s, no P2s). The review and response are in
design/reviews/:REVIEW_gpt-6.1-sol_d140_wpet7_r3_2026-10-21.mdandRESPONSE_d140_wpet7_r3_2026-10-21.md.Each new test fails on
dc44041f's engine sources and passes here.test_a_correction_after_final_validation_is_never_certifiedandtest_a_correction_inside_the_watch_is_never_certified.test_the_period_watch_stays_bounded_over_5001_evidence_claims. Peak traced memory stays under 256 KiB, and changes to the 5,001 unshown claims are still detected. Ondc44041fthe peak was 4.68 MB.owner decision pendingresolved 2026-10-22, owner keeps option (a) (see top).Dual review round 2 (
3419f295): all findings addressed (headdc44041f)Argon approved, with one nit. Sol requested changes (four P1s and a nit). The reviews and the per-finding response are in
design/reviews/:REVIEW_gpt-6.1-sol_d140_wpet7_r2_2026-10-21.md,REVIEW_agy-gemini-4-argon_d140_wpet7_r2_2026-10-21.mdandRESPONSE_d140_wpet7_r2_2026-10-21.md.Each P1 test fails on
3419f295's engine sources and passes here.test_ordinary_apply_never_certifies_periods_its_decision_did_not_seeand…_evidence_periods_it_was_not_shown.test_a_review_whose_window_leaves_profiles_unchanged_embeds_nothing(zero calls), and the owner regression now on the production refresher (exactly one call, for the changed profile text).test_a_failed_inference_releases_its_claim_so_the_retry_succeeds(realWorker+WorkLedger: one retry, no dead letter) andtest_another_jobs_live_claim_defers_instead_of_paying_or_failing.test_an_answer_citing_an_unsupplied_claim_is_never_replayed.fact_window_review_attempts.claimed_by. Design §8.2 and the D140 note are updated in place.Design refinement (please check)
D140 §8.2 promised that declaration changes "enqueue ordinary D118 re-adjudication". No mechanism re-adjudicates already-applied evidence, so this PR defines one: the window review. It refines §8.2, D140 (marked in place),
mutable_fact_windows_design.mdand the schema design, with no new decision number.Checks run
17c81c1f: all green (20 pass, 1 skipped), CLA included.test_d140_period_adjudication_pg.py(26 tests), the reuse regression and the forget proof: 28 passed. The torn-read test fails on3b676c17(shim: a stubverified_period_bases_on, for collection only).workers+spine: 967 passed;adapters,profiles,surfacesandcore: 2646 passed, 6 skipped.test_graph_queries.pywas deselected because it hits statement timeouts on the small VM; it passes in CI and this PR does not touch graph code.generate_docs_llms --check.Not done
Contributor agreement
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd3Dz4iq5SKNAJcefffvqF