diff --git a/decisions.md b/decisions.md index 0d0dead08..42c21ec85 100644 --- a/decisions.md +++ b/decisions.md @@ -648,6 +648,16 @@ provenance-stamped, redirect-preserving record (D21). The design is the CLI queu Argilla is an optional addition if review volume ever justifies it, not part of the core design. (R10.) +**Amendment (2026-09-03, D107).** The queue gains a `temporal_window` item +kind for discrepancies between a fact's adjudicated verdict window and its +evidence-derived occurrence window. Its verdict is an append-only, reversible, +provenance-stamped record — target fact, seed claim, old and new canonical +bounds with bases, rationale, reviewer, reversal linkage — checked against +invariants (a start may move earlier, never later; no endpoint moves past a +neighbouring slice; a closed end is never reopened) and replayed +idempotently after caps and retractions. Full contract: +`plan/designs/temporal_clocks_design.md` §4.3. + ## D25. No pre-extraction value/salience gate — junk-control is in-call at E2 Selection + D2 **Decision.** There is **no E1.5 stage and no value/salience gate**. Plane E is `E0 → E1 → E2 → E3`; @@ -4989,3 +4999,208 @@ rung) and `plan/designs/locomo_benchmark_design.md` Full-v21 protocol. design named but never implemented) and D105's Full-v20 benchmark identity. Preserves D41 (claims stay the one home of asserted validity), D98 retrieval, D100/D102 identity, and D104/D105 answer-prompt contracts. + +## D107. World-time flows from the claim's window; said-on time is provenance, never validity + +**Decision (2026-09-03).** Every stage that reasons about *when* a fact held +reads the claim's resolved D41 window (what the statement **is about**) and +treats the source's own date (when it was **said**) as provenance shown +beside it and as the processing order — never as a window boundary. A +missing time stays missing. Concretely: + +1. Every fact carries a **temporal kind** seeded from its claim's D41 kind — + `state` (a span that held), `occurrence` (something happened, or a figure + for a period), `undated` — and **two windows**: the adjudicated **verdict + window** (`valid_from`/`valid_until`, with a basis per endpoint — + `world_time`, `verdict`, `source_removed`, `legacy`, `unknown` — and the + recorded `seed_claim_id`) and a derived, non-authoritative **occurrence + window** (`occurs_from`/`occurs_until`/`occurs_precision`: the union of + all attached evidence's canonical D41 windows, current or withdrawn, so + D55 never erases a historical fact's world-time). A state's verdict + window is its span and its identity; an occurrence is believed from its + occurrence start onward, never capped (D43's no-cap rule extended to + events), and has an **adjudicated** identity under the per-key lock — + never a database exclusion — so a January and an October visit are two + facts, and so are two same-day visits the ladder judges distinct; an + unknown window stays `NULL`/`unknown`. The said-on date is never written + into a window. +2. The verdict is seeded **once** from the seed claim — the claim whose + processing created the row, recorded atomically in `seed_claim_id` and + as the `triggering_claim_id` of the fact's `add` adjudication on both + planes — and is never revised automatically. Attaching evidence + recomputes the occurrence window only. A discrepancy between the two is + surfaced as a **`temporal_window` review item** — a new D24 kind whose + append-only verdict relation records the D49 fact identity, seed, old and + new canonical bounds with bases, provenance and reversal linkage, checks + invariants (start earlier never later; no endpoint past a neighbouring + slice; a closed end never reopened, D41; a state never empty), allows a + reviewer's compensating reversal as the one documented exception, and + replays idempotently after caps and retractions. Only such a verdict, a + supersede cap, a D55 retraction, or a recorded migration adjudication + changes a verdict window. +3. Candidate **nomination is unchanged** (block, then similarity-ranked + residue), so a same-occurrence date dispute between disjoint dated claims + still reaches the ladder (D106); the **temporal relation bounds the + verdict** — disjoint dated pairs may only be `new` or `contradict`, mixed + pairs never `evidence`. Matching compares an incoming claim against two + candidate sets: same-kind facts, and — for an incoming occurrence — the + states it may end, open-ended or finite-ended, eligible for supersede or + contradict only. A normalised relation claim is held unattached until + its verdict, which is idempotent on the triggering claim and adjudicator + generation. +4. **Temporal succession** is separate from D90's processing order, which is + unchanged: a state is capped only at a world-time instant supplied by its + successor — a successor state's verdict start or an ending occurrence's + start (D106's dated resignation still ends an undated "is CEO" state; a + 2027 resignation shortens "CEO 2025–2030") — and only when that instant + lies strictly inside the predecessor's known window; otherwise the pair + contradicts or coexists and a review item is raised. `now()` is never a + boundary. D55 caps a withdrawn state under the same guard when the source + supplied the removal time (basis `source_removed`); otherwise, and for + every withdrawn occurrence or undated fact, only the belief interval + closes, from the persisted reconciliation instant. The D90 late-arrival + re-split decides eligibility by the evidence's occurrence start against + the world-time cap, not by `asserted_at`. +5. Precision is honoured through one **canonical-bounds** function — shipped + as `memory_v1.canonical_bounds` with a `claims_canonical` view and mirrored + in Python — that turns a stored claim window into a half-open interval + with both ends aligned to its precision unit (a year stored + 2022-01-01…12-31 is `[2022-01-01, 2023-01-01)`; a day is the calendar day + whatever the stored time; an `instant` is a non-empty point; `open` is + unbounded; an inclusive request `(t, t)` is a point query). Fact windows + are **stored** canonical at seeding, a state with two known endpoints + must be non-empty, and every fact predicate and the relations exclusion + read consistent bounds; claim comparisons, saved examples and open SQL + canonicalise through the same function; claim storage and its `CHECK`s + are unchanged. +6. "Current" is the full interval-containment predicate `facts_current` + already uses, evaluated at an explicit instant (`ingested_at <= E`, not + invalidated, `valid_from` absent or `<= E`, `valid_until` absent or + `> E`), on every current fact read — including the aggregate and + predicate-absence queries that test only `invalidated_at` today; cached + profiles and K pages carry their earliest future activation and expiry + instants in their input hash and a durable, idempotent + `fact_expiry_schedule` regenerates them when either passes, with the + read-time predicate as the correctness backstop. +7. Every prompt that compares, merges, ranks, or summarises facts shows the + D106 two-clock block (`said on` / `is about`, defined): relation + supersession, T4 identity candidates, the K prose writer, the benchmark + answer agent. +8. Testimony deduplication keys on the full D41 tuple (or `asserted_at` when + unknown) and grouped rows list every member's times; the fact-grain + envelope, `GraphEdge`, the K fact model, the `memory_v1` fact views and + the open-query confirmation surface gain bases, kind and occurrence + (additive, D49) — and because the envelope schema is shared, + `resolve_entity@2`, `testimony_context@2`, `fact_context@3` and + `answer_context@3` roll; P1 gains is-about claim filters and an `occurs` + fact mode; the timeline aggregate buckets by occurrence with an explicit + `undated` bucket; profiles rank by evidence then occurrence recency. +9. Extraction teaches all four D41 kinds and `open` with examples and shows + the extractor the full source timestamp. Statements stay canonical (D43); + dated labels are derived from the occurrence window. Consumer surfaces + print a date under a world-time heading only for `world_time`/`verdict` + bases, and the consumption skill defines `claims_as_of` over source + world-time (D41), not system time. +10. Cutover is stop → drain → migrate → **convert in place** with a recorded + migration adjudication per fact → readiness. Observations recover their + seed from the recorded `add` adjudication; relations never recorded a + creator, so a legacy relation converts under basis `legacy` with its + kind derived from its evidence when unanimous, else `undated`. Legacy + caps are not kept as they are: a recoverable supersede cap is recomputed + at its successor's world-time start, a cap on a converted occurrence is + removed, a D55 fallback cap becomes a belief-time close at the persisted + reconciliation instant, and the rest become `legacy_unknown_boundary` + review items that readiness reports. Fact ids and D55 historical facts + are preserved; a store never mixes pre- and post-D107 fact semantics; + re-adjudicating identities decided under old rules is a fresh rebuild + (D7), not a migration. + +**Context.** D106 fixed the observation adjudicator merging "won a +tournament last week" across a nine-month gap because it never read the +claims' resolved windows. The follow-up audit +(`plan/analysis/time_handling_audit.md`, revision `02b79904`) found the same +confusion in twenty-one more places: relations' `valid_from` is never +seeded, so a `valid_at` lookup cannot exclude a fact before its true +beginning; the relation supersession prompt asks the model about "the same +period" while showing only document dates; undated supersessions cap at the +ingest wall-clock, so a rebuild on another day yields a different history; +the two adjudicators orient undated testimony in opposite directions; +retrieval dedupes identical text across dates exactly as the adjudicator did +before D106; the K fact sheet sorts by a said-on date it does not show; the +timeline aggregate falls back to ingest year; the answer agent is told to +"use timestamps" without being told which; day-precision windows are +compared as zero-width points; the consumption skill and the open-query +confirmation surface respectively misdefine and truncate the clocks; the +aggregate and predicate-absence queries never evaluate `valid_until`; the +shipped `claims_as_of` example's `unknown` count can never be non-zero; and +D55's observation close is shape-blind. The docs (`/docs/concepts`, +`fact_context`'s description) promise world-time semantics the code does +not keep. + +Four independent Codex design reviews shaped the mechanics, each withdrawing +part of the previous revision: said-on seeding, mechanical evidence +widening, universal half-open storage and a merged ordering key (round one); +verdict-window identity for occurrences, an automatic `extend_start`, +"+ one unit" ends, a clock-crossing D90 re-split and dated-states-only +succession (round two); an occurrence exclusion constraint, kind-routed +matching that lost D106's cross-kind cap, an unspecified review mechanism, +a replay rebuild and a belief-time end labelled `source_removed` (round +three); exact legacy seed recovery, preserved legacy caps, a current +predicate without a lower bound, an overlap-only candidate filter that lost +D106's disjoint-date contradiction, and open-states-only state-ending +candidates (round four). Design §10 records each. + +**Consequences.** `valid_at` / `facts_as_of` become true on both fact planes; +recurring occurrences stay distinct facts on both planes; histories are +rebuild-stable (D7) because no boundary depends on ingest time; the two fact +planes agree on undated testimony; readers, profiles and compiled pages see +resolved dates as labels while statements keep source wording. Costs: one +migration (the new columns, the non-empty state check, a partial exclusion, +a unique key, an expiry schedule, a review kind and verdict relation, and +the query-space function and view), generation rolls for the extractor, +normaliser, both adjudicators and the flush component, four +assured-operation version rolls, an in-place conversion of existing stores +with migration adjudications and possibly open `legacy_unknown_boundary` +items to resolve, activation/expiry sweeps, and LoCoMo protocol rolls per +landed package. Undated, differently worded restatements of a changing +state coexist instead of capping at `now()`; their count per key is a +reported metric and the lever is extraction coverage of the D41 kinds. + +**Rejected.** Seeding windows from the said-on date (provenance is not +validity); seeding a measurement's or event's end from its claim (D43 +no-cap); matching every fact by verdict-window overlap or an occurrence +exclusion (recreates D106 for occurrences; distinct occurrences may +overlap); an overlap-only candidate filter (loses D106's disjoint-date +contradiction); automatic earliest-evidence start revision (D41 reduction); +a replay rebuild and exact legacy seed recovery (erases D55 history; +relation creators were never recorded); keeping legacy cap boundaries (they +are the said-on/`now()` values removed); a current predicate without a lower +bound; half-open claim storage (empties `instant`) and "+ one unit" ends +with raw starts; one coalesced key for processing and succession (D90); +succession only between dated states or only against open states; capping +at a retrospective's said-on date; baking the resolved date into the +observation statement (D43 identity); twenty-two local patches; keeping +`now()` as the undated cap (D7). + +**Design.** `plan/designs/temporal_clocks_design.md`; amendment banners on +`e2_e3_claims_relations_design.md`, `observations_design.md`, +`registries_design.md`, `retrieval_design.md`, `k_layers_design.md`, +`locomo_benchmark_design.md`, `e3_entity_obs_flush_fanout_design.md`. + +**Analysis.** `plan/analysis/time_handling_audit.md`. + +**Sequencing.** `plan/plans/temporal_clocks.md`. + +**Amends.** D24 (a `temporal_window` review kind with its verdict relation +and the documented reversal exception); D41's consequences become binding +mechanics (claim windows seed fact verdicts once; the retrospective guard +holds; revisions are review verdicts); the observations design §3 +(matching by kind, the cap boundary, succession, the no-cap rule extended to +events); D88/D90 (processing order unchanged; the §5.5.3 re-split decides by +occurrence start against a world-time cap); D106 (its two-clock prompt block +becomes the engine-wide contract; its disjoint-date contradiction and +ending-event supersession are preserved; its `valid_from` seeding gap is +closed); D55 (retraction by temporal kind; unknown source time closes on +belief-time from the persisted reconciliation instant, never `now()`); D49 +(additive envelope fields; four operation versions roll). Preserves D3, D6, +D32, D43's untyped statement, D98, D100–D105. diff --git a/plan/analysis/time_handling_audit.md b/plan/analysis/time_handling_audit.md new file mode 100644 index 000000000..a13fe9ca8 --- /dev/null +++ b/plan/analysis/time_handling_audit.md @@ -0,0 +1,375 @@ +# Time-handling audit: where the engine reads the wrong clock + +**Date:** 2026-09-03 + +**Status:** analysis (non-binding). The decision it motivated is D107; the +binding contract is `plan/designs/temporal_clocks_design.md`. + +**Revision audited:** `02b79904` (the merge of D106). Line numbers below are +for that revision; function and statement names are the stable anchors. +Findings 4.2, 4.5, 4.6, 4.12, 4.13, 4.14 and 4.15 were narrowed after four +independent Codex reviews verified each against the code; 4.18–4.22 were +added from those reviews. + +## 1. Question + +D106 fixed one defect: the observation adjudicator compared two statements +as bare strings and merged "won a tournament last week" said in January with +the same words said in October, although both claims carried resolved D41 +windows nine months apart. That defect had a shape — a stage that *has* the +resolved world-time available and reasons on the source's date instead. This +audit asks whether the same shape occurs anywhere else, stage by stage. + +## 2. The clocks, so the findings read cold + +The engine records three distinct clocks, and the defects are all +confusions between the first two: + +| Clock | Column(s) | Meaning | Plain example | +| --- | --- | --- | --- | +| **said-on** | `claims.asserted_at` (from the document's `source_modified_at`) | when the SOURCE said it | the chat session was on 2022-10-06 | +| **is-about** | `claims.claim_valid_kind` / `claim_valid_from` / `claim_valid_until` / `claim_valid_precision` (D41) | the world-time the statement refers to, resolved by the extractor from the wording against the said-on date | "last week" in that session → 2022-09-29 | +| **believed** | `ingested_at` / `invalidated_at` | when the system held the belief | ingested 2026-09-01 | + +`claim_valid_kind` says what sort of interval the is-about window is: +`event_time` (a datable event), `measurement_period` (a figure for a span), +`effective_period` (a state that held over a span), `proposition_validity` +(the proposition was true over a span), or `NULL` when the source tied nothing +to a date. A resolved start with `claim_valid_until IS NULL` is an *open* +interval (unbounded end), not a point. + +The fact layer — `relations.valid_from/valid_until` and +`observations.valid_from/valid_until` — is meant to hold the adjudicated +world-time of each fact (D3, D43): the window a caller filters on with +`valid_at` / `facts_as_of`. + +## 3. Patterns + +Each finding is tagged with the pattern it instantiates: + +- **P1 ignored** — resolved timing is available on the row and not read. +- **P2 conflated** — the said-on clock is used where the is-about clock is meant. +- **P3 precision lost** — an interval is stored or compared as a point, or a + timestamp is truncated before use. +- **P4 blind model** — a model is asked a time-dependent question without + the dates it would need. +- **P5 wrong sort key** — ordering, deduplication, or supersession uses the + wrong clock. +- **P6 silent degrade** — a missing time is replaced by a value that changes + the meaning (typically `now()`). + +## 4. Findings, ordered by likely impact on answers + +### 4.1 Retrieval dedupes testimony by text only — the D106 defect, one layer up (P1, P5) + +`src/rememberstack/surfaces/query_engine.py` — `_group_claim_evidence` +(`:3388-3405`), invoked from `_testimony_context_retrieval` with +`group_exact_text=True` (`:2230`), which serves both `testimony_context` and +`answer_context` (`surfaces/operation_executor.py:75-117`). + +```python +grouped.setdefault(_normalize_hybrid_text(value=record.claim_text), []).append(record) +... +members[0].model_copy(update={"corroboration_count": len({m.doc_id for m in members}), ...}) +``` + +The group key is the normalised claim text. `asserted_at` and the four +`claim_valid_*` fields are on every `EvidenceResult` +(`model/envelope.py:294-298`) and are not consulted. Two claims with the same +words about different dates become one evidence row carrying only the +top-ranked member's dates, with `corroboration_count = 2`. The second date is +absent from the envelope, not merely unlabeled. The conv-42 counting question +escaped this only because the seven win claims were worded differently. + +### 4.2 Relations' `valid_from` is never seeded (P1, P6) + +`src/rememberstack/spine/fact_catalog.py:78-89`, `:523-533`, +`_LATEST_CLOSED_UNTIL` (`:867-877`). A new relation's `valid_from` is the +`max(valid_until)` of a previously *closed* spell of the same +`(subject, predicate, object)` — `NULL` for every first occurrence — and is +never written anywhere else: not from `claim_valid_from`, not from +`asserted_at`. D41's consequences say the opposite ("a claim 'Alice joined in +March 2024' can seed `works_for.valid_from`"), and the docs promise +`valid_at` answers "when was this true in the world" +(`website/src/app/docs/concepts/page.mdx:80`). `lookup_relations(valid_at=…)` +does filter both ends (`valid_from IS NULL OR valid_from <= :as_of` and +`valid_until IS NULL OR valid_until > :as_of`, `query_engine.py:3696-3697`), +so a *capped* spell is excluded after its end — but with `valid_from` always +`NULL`, no fact can be excluded *before its true beginning*: "who did Alice +work for in 2010?" returns her 2024 employer alongside any earlier one. The +start half of the as-of axis is a no-op on the relation side. + +### 4.3 Relation supersession judges "the same period" without seeing any period (P2, P4) + +`src/rememberstack/spine/supersession.py` — `_ADJUDICATION_PROMPT` +(`:37-51`), formatted at `:231-238`: + +``` +EXISTING: {existing_label} + evidence: {existing_evidence!r} (asserted {existing_asserted}) +NEW: {new_label} + evidence: {new_evidence!r} (asserted {new_asserted}) +... +- contradict: the sources describe the SAME period incompatibly +``` + +Only the said-on dates are shown. `_LOAD_RELATION` (`:436-443`) and +`_BLOCK_CANDIDATES` (`:459-466`) select `c.claim_text, c.asserted_at` and not +the `claim_valid_*` columns on the same row. A 2024 memoir ("Alice worked for +Acme from 2015 to 2018") beside a 2023 email ("Alice works for Zeta") makes +the memoir look newer; `works_for Zeta` is superseded by a historical spell. + +### 4.4 Supersession boundaries are the speaking date, and undated ones become `now()` (P2, P6) + +`supersession.py:272-282` and `_CLOSE_WINDOW` (`:503-511`); +`observation_adjudication.py` `_CAP_WINDOW` (`:1539-1546`); +`lifecycle.py` `_CAP_RELATION` (`:929-936`, the D55 retraction path): + +```sql +SET valid_until = coalesce(:boundary_asserted, now()) +``` + +The cap is the *successor's said-on date* even when its is-about start is +known, and an undated successor caps the predecessor at the wall-clock +instant of ingestion. Consequences: `facts_as_of(valid_at='2026-09-02')` +reports Alice still at Acme the day before an undated CV was ingested, and +the same ingest replayed on another day yields a different history — the +value is not rebuild-stable (D7). + +### 4.5 Normalisation and label construction do not propagate the resolved window, so the fact statement keeps "last week" forever (P1, P6) + +`src/rememberstack/workers/e3.py:98-120` (normaliser prompt: `CLAIM +(attributed=…): {claim_text}`; no valid-time fields at `:436-441`). E2's prompt +correctly *forbids* writing the resolved date into `claim_text` +(`e2.py:176-179`), so the only place the date exists is the claim row. The +observation `statement` (and `obs_label`) is minted from `claim_text` +(`fact_catalog.py:571-581`, `observation_adjudication.py:1527-1537`), then +embedded by P1 (`workers/p1.py:214, 231-236`), returned as `FactResult.label` +(`query_engine.py:3709`), listed in entity profiles +(`profile_refresher.py:687`), and rendered into K pages. Every fact-grain +consumer reads "Nate won a video game tournament last week" with no anchor. + +### 4.6 The answer agent is never told which clock is which (P4, P2) + +`benchmarks/locomo/protocol.py:135-137` — the prompt says "Use timestamps to +resolve relative dates" and nothing else about time. The envelopes carry +`asserted_at`, `claim_valid_*`, and `validity.valid_from` (fact grain) side +by side, and `fact_context` does include representative evidence rows with +`asserted_at` and claim windows (`query_engine.py:778-867`); but the direct +relation result's own `Validity` is all-`NULL` for a first-occurrence +relation (4.2), and `_reader_trace_record` (`:344-347`) drops `None` fields, +so on that row the only surviving timestamp is `ingested_at` — the +benchmark's own run clock — while for an observation `validity.valid_from` is +the session date under a name that reads as world-time. The reader is never +told which is which. Contrast `observation_adjudication.py:63-72`, which +spells the distinction out for the verdict model. + +### 4.7 K fact sheets label the said-on date "valid since" and sort history by it (P2, P5) + +`src/rememberstack/core/knowledge_fact_sheet.py:55-63`, `:72-99`: the +"Current relations" column `valid since` is `fact.valid_from` (empty for +every first spell of a relation, 4.2; a re-occurring spell shows the prior +spell's end) and the observation table's `valid from` is the session date; +"Observation history" is sorted by that same value, so a back-dated +retrospective reads in the wrong order. + +### 4.8 The K prose writer's claims carry no dates at all (P4) + +`src/rememberstack/spine/knowledge.py:4636-4658` (`_SELECT_WRITER_CLAIMS`) +and `model/knowledge.py:531-543` (`KnowledgeWriterClaim`): `claim_text`, +`source_span`, `document_title`, `source_kind` — no `asserted_at`, no +`claim_valid_*`. The writer is asked to compile durable prose from "last +week". + +### 4.9 `aggregate(form="timeline")` buckets by ingest year (P2, P6) + +`query_engine.py:4285-4307`: `coalesce(valid_from, ingested_at)` for both fact +kinds. With 4.2, most relation entries fall back to ingest time (only +re-occurring spells carry a start); the observation half is said-on time. A +2015–2020 archive imported today is one bar labelled 2026, under a docstring +that says "an entity's facts by year" (`:2087-2088`). + +### 4.10 Observation batch order — who supersedes whom — follows the said-on clock (P5) + +`fact_catalog.py:652`, `:725`; `observation_adjudication.py:1614`, `:1630`: +`ORDER BY c.asserted_at NULLS LAST, …`. The order fixes predecessor/successor +(`_is_strictly_earlier(asserted_at, existing_from)`, `:664-665`) and the cap +boundary (`:718-724`). "I moved to Berlin in 2019" said in 2023 caps "I live +in Prague" said in 2022 — the reverse of the world. D106 made the verdict +window-aware; not the ordering. + +### 4.11 The two adjudicators disagree about undated testimony (P5, P6) + +`supersession.py:545-562` (`_is_source_successor`: "dated testimony is later +than undated" → undated is the *predecessor*) versus +`observation_adjudication.py:1453-1481` (`_is_later_in_total_order`: +`asserted_at NULLS LAST` → undated is the *successor*). One document pair +yields contradictory histories on the two fact planes, and neither is +replay-stable under reordering. + +### 4.12 P1 offers a said-on filter and no is-about filter (P1, P2) + +`adapters/postgres_p1.py:1371-1400`: *claim* search accepts `asserted_from` +/ `asserted_to` only — the D41 partial index on +`(claim_valid_from, claim_valid_until)` is unused by the search path, so +"Nate's claims about October" returns what was *spoken* in October. *Fact* +search is not time-blind: `_fact_time` (`:1449-1492`) offers as-of and window +selectors over the fact's `valid_from`/`valid_until` — which, per 4.2 and +4.17, hold the wrong clock, so the selector is correct over incorrect +inputs. + +### 4.13 Day/month/year precision is stored as a zero-width interval (P3) + +`workers/e2.py:181-186` (prompt: "the resolved date as both ISO ends"), +`_parse_iso_timestamp` (`:660-667`, date-only → midnight UTC); +`_CLAIMS_AS_OF_CANDIDATES` (`query_engine.py:3585-3600`) intersects closed +intervals. A day-precision May-7 claim is `[May 7 00:00, May 7 00:00]`, so +"what held during May 7, 09:00–23:00" returns nothing; a year-precision 2022 +claim ends at 2022-12-31 00:00. D106's `_windows_disjoint` compares with +strict `<`, so two *equal* points do overlap; but a day-precision claim and an +instant-precision claim about the same day miss each other, and two +day-precision claims about adjacent days touch at a point neither covers. +(Two genuinely instant-precision events at different times of one day *are* +disjoint, and correctly so.) + +### 4.14 E2 teaches only `event_time` (P4) + +`workers/e2.py:167-209`: all three worked examples are `event_time`; +`measurement_period`, `effective_period`, `proposition_validity` are never +named; `open` gets one structural mention and no example; `CandidateClaim` +(`model/claims.py:158-168`) has no field descriptions. The kinds are exposed +structurally, so the model *can* emit `proposition_validity` / `open` for +"Alice has been CEO since 2019", but nothing teaches it their semantics; how +often it does is unmeasured. Whatever it emits instead, D106's rung fires on +`about_kind == "event_time"` only, so mislabelled kinds silently change which +pairs the rung governs. + +### 4.15 The document header shown to E2 drops the time of day (P3) + +`workers/e2.py:899-906`: `date {modified.date().isoformat()}` while +`asserted_at` keeps the full timestamp (`:599`). LoCoMo sessions carry wall +times; offset expressions ("three hours ago") cannot resolve to an instant, +and two same-day sessions are the same anchor. (Part-of-day expressions such +as "this morning" have no precision in the D41 enum and are an expressivity +boundary, not an anchor defect.) + +### 4.16 Entity profiles and the T4 candidate list carry no dates and rank by row-touch time (P4, P5) + +`spine/profile_refresher.py:838, 840, 877, 889, 677-695`; +`spine/resolver.py:1158-1175`: salient facts are bare strings ordered by +`evidence_count DESC, updated_at DESC` — `updated_at` is bumped by every +recount and label write (`fact_catalog.py:556, 616`). Two people named Nate +five years apart present to T4 with no temporal separation; a fact recounted +today outranks a heavily evidenced older one. The `valid_until IS NULL` gate +combined with 4.4 means one undated supersession removes a fact from every +profile and from T3 embeddings. + +### 4.17 `_pull_valid_from_earlier` widens the stored window with the speaking date (P2, P1) + +`observation_adjudication.py:917-962`: on evidence collapse the persisted +`valid_from` moves to the earliest `asserted_at`, while `_absorb_timing` +(`:1357-1383`) simultaneously widens the correct is-about window in memory and +discards it — nothing persists it (`_INSERT_OBSERVATION:1527-1537` stores no +window). Two sessions re-asserting one event leave the row's world-window at +`[earliest session, ∞)` although the event window `[2023-09-29, 2023-09-29]` +was computed one function away. + +### 4.18 The consumption skill defines `claims_as_of` as a system-time query (P2) + +`src/rememberstack/core/consumption_skill.py:191-194`: "`claims_as_of` means +what sources asserted as of a past **system** time" — D41 defines it over the +claims' *world*-time window, and the implementation filters +`claim_valid_from/until` (5. below). The skill's "Time and media" section +(`:202-210`) teaches fact validity versus ingestion but not the said-on / +is-about distinction. Under D60 the skill is part of the complete agent-facing +surface, so agents are taught the wrong clock in the one place meant to teach +clocks. + +### 4.19 The open-query confirmation surface truncates the clocks (P1, P4) + +`src/rememberstack/surfaces/query_sandbox/nomination.py:323-327` +(`_CONFIRM_SQL["claims"]`) confirms claim search rows with `asserted_at`, +`claim_valid_from`, `claim_valid_until` — and omits `claim_valid_precision` +and `claim_valid_kind`; the fact-row confirmation carries no verdict or +occurrence time at all. An agent on this public path cannot tell a point from +a coarse period, an open interval, or an unknown, even after is-about filters +exist. + +### 4.20 Aggregates and predicate absence never evaluate `valid_until` (P1) + +`src/rememberstack/surfaces/query_engine.py` — `_AGG_COUNT` (`:4246`) and +its group variants, and `_AGG_PREDICATE_ABSENCE` (`:4335`) select "live" +relations by `invalidated_at IS NULL` alone. Today every relation is +open-ended (4.2), so the omission is invisible; once a state can carry a +finite end, an expired relation keeps counting and can block a true absence +answer, against D49's rule that current fact-grain answers are +validity-filtered. + +### 4.21 The shipped `claims_as_of` example cannot count what it excludes (P3) + +The saved `claims_as_of` example reports its `unknown`-precision exclusion +by combining `precision = 'unknown'` with a non-null bound comparison; D41's +`CHECK` makes an unknown-precision claim's bounds `NULL`, so the count is +permanently zero. (Reported by the third independent review; the fix rides +the query-space canonicalisation of design §5.) + +### 4.22 D55's observation close is shape-blind (P6) + +`src/rememberstack/spine/lifecycle.py:438-468` (`close_observations`) +invalidates every withdrawn observation, by its own docstring because +"observations are untyped (state vs measurement is semantic)" and +`invalidated_at` is the exit safe for both shapes. D55 and +`evidence_lifecycle_design.md:153-165` ask for a per-shape judgement — a +withdrawn effective state caps its world-time, a withdrawn measurement keeps +its window and closes belief only. Without a temporal kind the code cannot +make that judgement, so a withdrawn state observation gets a belief-time +invalidation where D55 requires a world-time close: its state end is never +recorded, and the removal is classified as invalidation. + +## 5. Checked and sound + +Absence of a finding above is a result, not an omission: + +- **E2's D41 parse/validate gate** (`workers/e2.py:607-713`) — rejects naive + datetimes rather than inventing a zone, mirrors every DB CHECK, refuses to + promote a date-only input to `instant`, degrades the temporal fields to + unknown without dropping the claim; `asserted_at` comes from + `source_modified_at or published_at` (`:599`); the header reaches every + chunk's bundle (`:731, :759`). +- **D106's rung** (`observation_adjudication.py:1304-1354, 1398-1424, + 1503-1512`) — `None` ends are unbounded, incomparable values fail safe to + "overlap", one open supporting claim keeps the aggregate open; its prompt + (`:55-98`) is the model the other prompts should follow. +- **`claims_as_of`** (`query_engine.py:522-587`, `_CLAIMS_AS_OF_CANDIDATES`) + — filters on the is-about columns, refuses `unknown` precision, orders by + `claim_valid_from`, discloses `excluded_unstamped`; only 4.13's boundary + semantics apply. +- **The evidence-grain envelope** (`model/envelope.py:280-302`) — carries all + five D41 fields beside `asserted_at`, and the `EvidenceResult` hydration + queries select them (`query_engine.py:3881-3933`, `:3995-3996`). D41's + promise that evidence payloads surface `claim_valid_from/until` is kept + there; the open-query confirmation path is the exception (4.19). The + fact-grain `Validity` (`:171-179`) is where the conflation lives. +- **Belief-time plumbing** (`query_engine.py:3463-3483`; migration + `p9_03_0024_facts_as_of.py:92-95`) — the transaction-time axis is separate + and sound. +- **Query-space catalog typing** (`spine/query_space/catalog.py:371-434, + 447-509, 869-916`) — claim views expose all five D41 columns to open SQL. +- **D55 retraction for relations** (`spine/lifecycle.py:412-437`) — caps at + the withdrawing version's source time; only the `now()` fallback (4.4) is + wrong. (The observation side is not sound — 4.22.) +- **Adjudication transcripts** (`supersession.py:298-307`; + `observation_adjudication.py:553-571, 741-751`) — every cap boundary and + every D106 coercion is recorded, so all of the above is diagnosable from + the audit tables without a rerun. + +## 6. Why this is one decision, not twenty-two fixes + +Every finding is the same confusion: the engine resolves world-time once, at +extraction, and then reasons on the source's date. The fix that closes all of +them is a single contract — world-time flows from the claim's is-about window +into fact windows, temporal succession, prompts, dedupe keys, and consumer +surfaces; said-on time is provenance, never validity; a missing time stays +missing rather than becoming `now()`. That contract is D107 and +`plan/designs/temporal_clocks_design.md`; the sequencing is +`plan/plans/temporal_clocks.md`. diff --git a/plan/designs/e2_e3_claims_relations_design.md b/plan/designs/e2_e3_claims_relations_design.md index 803ec85d9..fe253c969 100644 --- a/plan/designs/e2_e3_claims_relations_design.md +++ b/plan/designs/e2_e3_claims_relations_design.md @@ -1,5 +1,17 @@ # E2 / E3 — Claim Extraction and Relation Normalization (Design) +> **Binding D107 amendment (2026-09-03).** E2 teaches all four D41 kinds and +> `open` with examples and sees the full source timestamp in the header; claim +> storage is unchanged and comparisons use canonical bounds. E3 seeds each new +> fact's temporal kind and verdict window once from the D90-first claim's +> canonical D41 window (bases per endpoint, seed claim recorded on both +> planes), matches later claims by kind — states by verdict-window overlap +> under the exclusion; occurrences by adjudicated identity under the per-key +> lock, with the temporal relation bounding the verdict — holds a relation +> claim unattached until its idempotent verdict, and never revises a verdict +> automatically; statements stay canonical and dated labels are derived. +> Contract: `temporal_clocks_design.md` §3–§5. + How the system turns a chunk of source text into **claims** (atomic, standalone, verifiable assertions) and then into **relations** (the distinct facts those claims are evidence for). This is the cost center and the quality bottleneck of plane E, so the design is opinionated about *what* to diff --git a/plan/designs/e3_entity_obs_flush_fanout_design.md b/plan/designs/e3_entity_obs_flush_fanout_design.md index 4f11ae00c..fe3692a22 100644 --- a/plan/designs/e3_entity_obs_flush_fanout_design.md +++ b/plan/designs/e3_entity_obs_flush_fanout_design.md @@ -1,5 +1,14 @@ # Design: entity-grain observation flush fan-out +> **Binding D107 amendment (2026-09-03).** The total processing order of §5.5 +> (`asserted_at NULLS LAST, claim_id, statement`) is unchanged and remains a +> work order only. The §5.5.3 late-arrival re-split decides eligibility by the +> attached state claim's canonical occurrence start relative to the +> world-time cap `T`, not by `asserted_at`; undated attached evidence is never +> re-split. The staggered acceptance case gains a variant with said-on and +> is-about orders reversed whose final slices follow the world. Contract: +> `temporal_clocks_design.md` §4.5. + **Status:** revised through dual design r3 — Claude APPROVE_WITH_NITS (r3+r4); Codex r3 ordering gap closed in this revision — binding once landed on `main` **Date:** 2026-08-12 @@ -239,17 +248,23 @@ Entity-global merge only sees **unapplied** staging. If unit A fully applied materializes `{t2:B}`, a plain supersede of open A at t2 yields `A[t1,t2), B[t2,∞)` and loses A-at-t3. -**Required:** when an apply caps open observation O at boundary T, any **evidence -claims** (or reassertions) already attached to O with `asserted_at > T` (total -order) must be re-materialized as subsequent open slices after the cap — not left -only as evidence on a capped row. Concretely the staggered acceptance case: +**Required (as amended by D107):** when an apply caps open observation O at the +world-time boundary T, any **state evidence claims** (or reassertions) already +attached to O whose canonical occurrence start (`temporal_clocks_design.md` §5) +is later than T must be re-materialized as subsequent open slices after the +cap — not left only as evidence on a capped row. `asserted_at` remains the +total *work* order of §5.5 and plays no part in this eligibility test; undated +attached evidence is never re-split. (Before D107 this rule compared +`asserted_at > T`; that compared a said-on clock to a world-time boundary.) Concretely the staggered acceptance case: 1. Fully succeed unit A `{t1:A, t3:A}` alone. 2. Later materialize/apply unit B `{t2:B}`. 3. Final slices must still be `A[t1,t2), B[t2,t3), A[t3,∞)`. -Impl may walk evidence claim `asserted_at` on O after cap, or rebuild open -history for E from durable adjudications + claim times. This is a D43 co-requisite +Impl may walk the evidence claims attached to O after the cap, testing each +state claim's canonical occurrence start against T (never `asserted_at`, +D107), or rebuild open history for E from durable adjudications + claim +windows. This is a D43 co-requisite of multi-version continuous flush under D90. ### 5.6 LLM and locking (binding) diff --git a/plan/designs/k_layers_design.md b/plan/designs/k_layers_design.md index 98ba16bbf..89a151a02 100644 --- a/plan/designs/k_layers_design.md +++ b/plan/designs/k_layers_design.md @@ -1,5 +1,13 @@ # K Plane — Compiled and Authored Knowledge (Design) +> **Binding D107 amendment (2026-09-03).** The K prose writer's claim bundle +> carries `asserted_at` and the D41 fields with the two-clock framing; the +> deterministic fact sheet prints `valid from`/`valid until` only for +> `world_time`/`verdict` bases, an `about` column from the occurrence window, +> and `—` for `unknown`; observation history sorts by occurrence start; the K +> fact model gains bases and occurrence. Contract: +> `temporal_clocks_design.md` §6–§7. + > **Binding D98 amendment (2026-08-27).** D98 supersedes D11 and removes the > unproved global community analytics product. The shipped K layout has entity > pages, source digests, root indexes, and purpose-scope pages; it has no diff --git a/plan/designs/locomo_benchmark_design.md b/plan/designs/locomo_benchmark_design.md index d528728a1..7c0f73a85 100644 --- a/plan/designs/locomo_benchmark_design.md +++ b/plan/designs/locomo_benchmark_design.md @@ -1,5 +1,12 @@ # LoCoMo full-system benchmark design +> **Binding D107 amendment (2026-09-03).** The answer-agent prompt carries the +> two-clock paragraph naming `asserted_at` (said on), `claim_valid_*` (is +> about), and the fact-grain `validity` fields with their bases and occurrence +> window. Each D107 work package that changes ingestion provenance or the +> assured surface rolls this protocol; the sequencing is +> `plan/plans/temporal_clocks.md`. Contract: `temporal_clocks_design.md` §6–§8. + > **Binding D106 amendment (2026-09-03).** The current protocol is > `RS-LoCoMo-Full-v21`. It retains v20's dataset, rendered documents, models, > tools, budgets, answer and judge prompts, counterfactual and complete-answer diff --git a/plan/designs/observations_design.md b/plan/designs/observations_design.md index 6830d4c67..4ad1afbd9 100644 --- a/plan/designs/observations_design.md +++ b/plan/designs/observations_design.md @@ -1,5 +1,25 @@ # The Observation Layer — Non-Graph Facts with Temporal Validity (Design) +> **Binding D107 amendment (2026-09-03).** An observation carries a temporal +> kind (`state` / `occurrence` / `undated`) and two windows: the adjudicated +> verdict window (`valid_from`/`valid_until` with a basis per endpoint and the +> recorded seed claim), seeded once from the D90-first claim's canonical D41 +> window — a state's span; an occurrence believed from its start onward and +> never capped; `NULL`/`unknown` when undated — and a derived occurrence +> window (`occurs_*`) that widens as evidence attaches. Candidate nomination +> is unchanged (entity block, then similarity order, regardless of temporal +> overlap); the temporal relation of canonical bounds only bounds the verdict, +> so a disjoint pair may still contradict (D106) and recurring events stay +> distinct rows because occurrence identity is the ladder's verdict under +> the entity lock. The said-on +> date is never a boundary. No verdict changes automatically (discrepancies +> become `temporal_window` review verdicts, D24); a state is capped only at a +> world-time instant its successor supplies, later than its own known start — a successor state's start or an ending occurrence's +> start, so a dated resignation still ends an undated "is CEO" state — else +> the pair coexists, never `now()`. D90's staging order is unchanged; its +> re-split decides by occurrence start. Contract: `temporal_clocks_design.md` +> §3–§5. + > **Binding D98 amendment (2026-08-27).** Relations are the only fact kind > mapped as live graph edges over PostgreSQL views. Observations remain > PostgreSQL facts and P1 search targets but are not graph elements. There is no diff --git a/plan/designs/registries_design.md b/plan/designs/registries_design.md index f5f5ef0f2..8578c8c83 100644 --- a/plan/designs/registries_design.md +++ b/plan/designs/registries_design.md @@ -1,5 +1,12 @@ # Registries Design — Entity Resolution, Ontology, Governance +> **Binding D107 amendment (2026-09-03).** The T4 candidate snapshot carries +> each salient fact's occurrence window and bases, ranked by evidence then +> occurrence recency (never `updated_at`); the relation supersession prompt +> and its evidence laterals show both clocks (`said on` / `is about`) as +> `temporal_clocks_design.md` §7.2 requires; matching, verdict revision and +> temporal succession follow §4.2–§4.4. + > **Binding D102 amendment (2026-08-31).** T0 remains candidate-only globally. > One current `T4_small` match may establish a derived exact-name binding inside > the same catalog document; later exact canonical-name occurrences replay it diff --git a/plan/designs/retrieval_design.md b/plan/designs/retrieval_design.md index 27d727dee..9f3a10a5c 100644 --- a/plan/designs/retrieval_design.md +++ b/plan/designs/retrieval_design.md @@ -1,5 +1,17 @@ # Retrieval Design — the Query Machine +> **Binding D107 amendment (2026-09-03).** Testimony grouping keys on the full +> D41 tuple (or `asserted_at` when unknown) and `EvidenceResult` lists every +> grouped member's times; the fact-grain `Validity`, `GraphEdge`, the +> `memory_v1` fact views and the open-query confirmation rows gain +> per-endpoint bases, temporal kind and the occurrence window (additive), and +> because the envelope schema is shared, `resolve_entity@2`, +> `testimony_context@2`, `fact_context@3` and `answer_context@3` roll; P1 +> accepts is-about claim filters and an `occurs` fact mode; +> `aggregate(form="timeline")` buckets by occurrence with an explicit +> `undated` bucket; "current" is the single evaluated-at predicate of §7.1. +> Contract: `temporal_clocks_design.md` §7. + > **Binding D98 amendment (2026-08-27).** The graph channel reads live > PostgreSQL authority views. Fixed one-hop server statements use SQL/PGQ; > depth-two/variable neighborhoods, entity paths, and citation paths use bounded diff --git a/plan/designs/temporal_clocks_design.md b/plan/designs/temporal_clocks_design.md new file mode 100644 index 000000000..1cdd335af --- /dev/null +++ b/plan/designs/temporal_clocks_design.md @@ -0,0 +1,654 @@ +# Temporal Clocks — world-time flows from the claim's window (Design) + +**Status:** binding under D107 + +**Date:** 2026-09-03 (sixth revision the same day, after five independent +Codex design reviews; §10 records what each round withdrew, §12 what is +still open) + +**Analysis:** `plan/analysis/time_handling_audit.md` (twenty-two findings at +`02b79904`, each cited by file and function) + +**Open under D107 (decided in the sequencing, not here):** deterministic +relation seeding under D88 concurrency, the locked compare-and-swap +application of review verdicts, cached-artifact staleness, and the D74 +hard-forget inventory — see §12. + +**Builds on:** D41 (claims carry an immutable, source-asserted validity +interval; a fact's window is the adjudicator's single recorded verdict, never +a reduction over claim columns, never reopened by a late retrospective), +D3/D4 (supersession over verdicts; the cheap-first cascade), D43 +(observations; the no-cap rule for fixed-period figures), D88/D90 +(continuous-ingest processing order and the late-arrival re-split), D106 +(temporal compatibility in observation adjudication), D24 (append-only, +reversible review verdicts — amended here), D7/D12 (rebuild, generations, +idempotency), D55 (retraction), D49 (envelopes and fact identity). + +> **Reading this cold.** RememberStack extracts **claims** (what a source +> said, immutable) and adjudicates them into **facts** — relations between +> two entities, observations about one entity — each with a validity window: +> the span over which the system believes the fact held. The extractor +> already resolves *when* a statement is about ("last week" said on +> 2022-10-06 → 2022-09-29) and stores it on the claim as its **D41 window**. +> This design says where that resolved time must flow, which clock each +> stage reasons on, how facts about *things that happened* differ from facts +> about *states that held*, and what happens when a time is unknown. + +## 1. The problem, in one sentence + +The engine resolves world-time once, at extraction, and then most later +stages — fact windows, supersession, ordering, deduplication, prompts, +summaries, filters, timelines, aggregates, retraction — reason on the +*source's own date* instead, or on no date at all. The audit lists +twenty-two instances; D106 fixed one. This design closes the class without +creating a second validity authority. + +## 2. The three clocks and the two rules + +| Clock | Where it lives | Meaning | Role | +| --- | --- | --- | --- | +| **said-on** | `claims.asserted_at` | when the source said it | provenance, shown beside every statement a model or reader judges; the total *processing* order (D90); never a window boundary | +| **is-about** | `claims.claim_valid_kind` / `claim_valid_from` / `claim_valid_until` / `claim_valid_precision` (D41) | the world-time the statement refers to, resolved from the wording against the said-on date | the source of every fact window, every succession decision, every dated label, every temporal prompt line | +| **believed** | `ingested_at` / `invalidated_at` | when the system held the belief | belief-time only; never a substitute for world-time | + +`claim_valid_kind` says what sort of interval the is-about window is: +`event_time` (something happened), `effective_period` (a state held over a +span), `measurement_period` (a figure for a reporting span), +`proposition_validity` (the proposition held over a span). `NULL` means the +source tied nothing to a date. `claim_valid_precision` says how coarse the +resolved bounds are; a start with `claim_valid_until IS NULL` is **open**; +`instant` is a point (`until = from`, enforced by the schema). + +- **Rule 1 — world-time comes from the is-about window.** Fact windows, + temporal succession, dated labels, dedupe keys, and every temporal prompt + read the is-about window. The said-on clock is displayed as provenance and + orders processing; it is never a window boundary. +- **Rule 2 — a missing time stays missing.** An unknown is-about window + leaves a fact's window endpoints `NULL` with basis `unknown`. Nothing is + ever filled with `now()`, with the said-on date, or with belief-time. A + fact whose bounds are unknown may still be *ended* by a successor that + supplies a world-time instant (a dated resignation ends "is CEO" even when + nobody said when the tenure began — D106); what an undated fact can never + do is *supply* a boundary to another. + +## 3. Two kinds of fact, two windows + +Every fact (relation or observation) carries a **temporal kind** — its +*shape*, which is independent of whether its bounds are known — and two +windows with different authority: + +| `temporal_kind` | seeded from claim kind | what the fact says | identity | +| --- | --- | --- | --- | +| `state` | `effective_period`, `proposition_validity` | something held over a span ("was CEO 2015–2018"; "is CEO" with no start given) | key + **verdict window** (disjoint slices per key; the relations `EXCLUDE`) — bounds may be unknown | +| `occurrence` | `event_time`, `measurement_period` | something happened, or a figure for a span ("won the final on 2022-11-05"; "FY2023 revenue was $5M") | key + an **adjudicated** occurrence identity (§4.2) — windows may overlap | +| `unknown` | `NULL` kind, and the ladder cannot tell shape from wording | the source tied nothing to a date and the statement does not say whether it is a state or an occurrence | key (+ statement wording for observations) | + +Shape and datedness are different questions. A claim with no D41 window is +first classified by the normaliser's existing shape judgement (a state or +an occurrence, from the wording, the same call that routes a claim to a +relation or an observation); only when that judgement is itself unsure is +the fact's kind `unknown`. A `state` with unknown bounds is still a state: +it can be superseded and ended, and it is what most undated "X is Y" +testimony becomes. + +| Window | Columns | Authority | Changes when | +| --- | --- | --- | --- | +| **verdict window** | `valid_from` / `valid_until` (existing), `valid_from_basis` / `valid_until_basis` (new, `NOT NULL DEFAULT 'unknown'`: `world_time`, `verdict`, `source_removed`, `legacy`, `unknown`), `seed_claim_id` (new, nullable — `NULL` only for legacy facts whose creator is unrecoverable and after hard forget scrubs it) | the adjudicator's single recorded verdict (D3/D41/D43): over which span the fact is believed to have held | seeded **once** at insert from the seed claim (§4.1); afterwards only by a recorded verdict: a supersede cap (§4.4), a `temporal_window` review verdict (§4.3), a D55 retraction (§4.4), or a migration verdict (§9) — never automatically from evidence | +| **occurrence window** | `occurs_from` / `occurs_until` / `occurs_precision` (new, nullable) | **non-authoritative** derived metadata: the union of the canonical D41 windows of the fact's **attached** evidence — current or withdrawn testimony alike, so a D55 withdrawal never erases a historical fact's world-time; hard forget recomputes from surviving evidence | recomputed whenever evidence attaches or is forgotten; a database check forbids it from writing the verdict window | + +Why two kinds and two windows: a measurement is *about* FY2023 but is +*believed* from the day it was reported onward and is never capped (D43's +no-cap rule); a past event is about one day but stays a believed fact +forever — and a later occurrence of the same key is a **different fact**, +not corroboration (D106); a state is about the same span it is believed to +have held and is what supersession caps. Occurrences therefore have an open +verdict window `[occurs_from, ∞)` that is *not* their identity; states have a +verdict window that *is*. D41's boundary holds: the verdict is single-valued +and recorded; the occurrence window is evidence-derived and cannot mutate +it. + +## 4. Fact windows: seeding, matching, revising, closing + +### 4.1 Seeding at insert (once, from the seed claim) + +The **seed claim** is the claim whose processing created the fact row — the +first claim for it in D90 processing order in a fresh ingest — recorded +atomically with the row in `seed_claim_id` **and** as the +`triggering_claim_id` of the fact's `add` adjudication on both planes (today +only observation `add` rows carry one; relation `add` rows gain it). Windows +are the seed claim's **canonical bounds** (§5): + +| seed claim kind | `temporal_kind` | `valid_from` | `valid_until` | bases | `occurs_*` | +| --- | --- | --- | --- | --- | --- | +| `effective_period`, `proposition_validity` | `state` | canonical start | canonical end (bounded span → a closed historical slice; open → `NULL`) | `world_time` / `world_time`, or `unknown` for an open end | same as the verdict window | +| `event_time`, `measurement_period` | `occurrence` | canonical start (believed from then on) | `NULL` — never capped (D43, extended to events) | `world_time` / `unknown` | the claim's canonical window | +| `NULL`, shape judged `state` | `state` | `NULL` | `NULL` | `unknown` / `unknown` | `NULL` | +| `NULL`, shape judged `occurrence` | `occurrence` | `NULL` | `NULL` | `unknown` / `unknown` | `NULL` | +| `NULL`, shape unsure | `unknown` | `NULL` | `NULL` | `unknown` / `unknown` | `NULL` | + +The re-occurrence floor (a reopened state slice starts no earlier than the +prior closed slice's end) applies **only** when the seed's start is provably +later than that end — a chronological successor; an older spell discovered +late is inserted as its own closed slice (§4.2). The schema requires a +`state` with two known endpoints to be non-empty (`valid_until > +valid_from`); the existing checks that allow `valid_until = valid_from` are +replaced, because in half-open form that is an empty fact that the +`EXCLUDE` cannot see. + +### 4.2 Matching: nomination as today, verdicts bounded by temporal relation + +All matching for one key runs under the per-key advisory lock the +observation path already takes, so identity decisions are serialised and no +database exclusion is needed to keep them consistent. + +**Candidate nomination is unchanged in mechanism**: the entity/key block, +then the similarity-ranked residue (D43 §3) — never an overlap filter, so a +same-occurrence date dispute between two disjoint dated claims still reaches +the ladder, as D106 requires. What changes is the **two candidate sets** and +the **verdicts a temporal relation permits**: + +- **same-kind candidates** — live facts of the same key and the same + `temporal_kind`; eligible for `evidence`, `supersede` (states only), + `contradict`, or `new`; +- **state-ending candidates** — for an incoming `occurrence` claim only: the + non-invalidated `state` slices of the same key (for observations, the same + entity) whose known interval does not end before the occurrence's + canonical start — bounds unknown, open-ended, *or* finite-ended (a 2027 + resignation must reach "CEO 2025–2030", and a dated resignation must reach + "is CEO" with no start given) — eligible **only** for `supersede` or + `contradict` (§4.4), never for evidence. This is the cross-kind comparison + D106's dated resignation needs. + +Within the same-kind set, the temporal relation of the two canonical +windows bounds the verdict, as D106 does today (`supersede` rows apply to +states; occurrences are never superseded): + +| relation | permitted verdicts | +| --- | --- | +| both dated, **disjoint** | `new`, or `contradict` when the ladder finds one occurrence with a disputed date (D106); for states, `supersede` only when the incoming start is later than the existing start (a later disjoint spell that ends the earlier one at the incoming start) — never `evidence` | +| both dated, **overlapping** | `evidence` (the same occurrence or state re-mentioned; `occurs_*` widens), `supersede` (a state's value changed; cap at the incoming start under the guard), `contradict`, `new` (a different occurrence that merely overlaps: two visits on one day; a day-precision and an instant-precision claim about different things) | +| **mixed** (one dated, one undated) | `supersede` (only when the *incoming* side is dated — it supplies the boundary), `contradict`, `new` — never `evidence` | +| both undated | `evidence`, `contradict`, `new` — never `supersede` (no boundary exists) | + +Consequences by kind: + +**States.** An overlapping same-property claim with the same value attaches +as evidence; a disjoint one seeds a new slice (disjoint ranges satisfy the +relations `EXCLUDE`, which applies `WHERE temporal_kind = 'state'`); an +overlapping different value is the supersede/contradict question (§4.4). + +**Occurrences.** Identity is the ladder's verdict, not the window: there is +**no** occurrence exclusion constraint; overlapping occurrence rows of one +key are legal, a union expansion that comes to overlap a neighbouring +occurrence never merges rows, and the advisory lock plus the recorded verdict +prevent duplicates. Acceptance covers same-key recurring events, coarse and +fine precision overlap judged `new`, a disjoint pair judged `contradict`, and +a union expansion bridging two existing occurrences. + +**Undated claims.** A claim without a D41 window takes its shape from the +normaliser's judgement (§3) and then follows its kind's rules with unknown +bounds. Observations of kind `unknown`: identical wording collapses onto an +existing `unknown` row of the same key, otherwise a new row. Relations: the +triple *is* the content, so an undated relation claim attaches to the single +open `state` slice if exactly one exists, else seeds one `state` slice with +unknown bounds for the key (created once); it never attaches to an +`occurrence` and never creates a second unbounded slice. + +**The relation write path becomes staged.** Today `upsert_relation` finds a +live triple and attaches evidence before the relation ladder runs, which +would collapse two same-triple occurrences before any verdict. Under this +design a normalised relation claim is **held unattached** (staged, as +observation claims already are) until, under the key's block lock, candidate +nomination and the verdict complete; `new` inserts the fact, its `add` +adjudication (with `triggering_claim_id`) and the evidence link in one +transaction; `evidence` attaches in one transaction; every identity verdict +is idempotent on `(triggering_claim_id, adjudicator generation)` so a retry +or a concurrent D88 normaliser replays the recorded verdict rather than +deciding again. The relation ladder's "same object after redirects → exact +no-op" short-circuit applies to `state` and `undated` triples only. + +**Relations schema.** The existing GiST `EXCLUDE` on `(subject, predicate, +object) && tstzrange(valid_from, valid_until)` becomes partial on +`temporal_kind = 'state'` (an unbounded-bounds state slice is one range +`(,)` under it, so the "created once" rule above is what the constraint +enforces); occurrence relations have no constraint. + +### 4.3 Revising a verdict: a `temporal_window` review verdict (amends D24) + +No automatic path changes a verdict window after seeding. A discrepancy — +attached evidence whose occurrence start precedes a `state` slice's verdict +start, or dated evidence attaching to a slice with an unknown window — is +surfaced in the envelope (`occurs_from < valid_from`; bases `unknown` beside +a dated `occurrence`) and raised as a `review_queue` item of a new kind, +`temporal_window`. Its verdicts live in an append-only relation, +`temporal_window_verdicts`: + +| column | meaning | +| --- | --- | +| `verdict_id` | primary key; the idempotency key for apply and replay | +| `review_id` | the `review_queue` item it answers | +| `target_fact_kind`, `target_fact_id` | D49 fact identity (`relation` / `observation` + id) | +| `seed_claim_id` | the seed as recorded at the time of the verdict | +| `old_valid_from`, `old_valid_until`, `old_from_basis`, `old_until_basis` | canonical bounds and bases before | +| `new_valid_from`, `new_valid_until`, `new_from_basis`, `new_until_basis` | canonical bounds and bases after; a changed endpoint's basis is `verdict` | +| `rationale`, `actor`, `decided_at` | provenance (D24) | +| `reverses_verdict_id` | set on a reversal | + +Invariants checked before apply, for verdicts that are not reversals: the +start may move earlier, never later, and an `unknown` start may become known +(the transition `NULL → known` is the one permitted "later" move, because +there was no start before); no endpoint moves past a neighbouring slice's +bound; a closed end is never reopened (D41); a `state` with two known +endpoints stays non-empty. A verdict applies only under the fact's lock and +only when the fact's current bounds and bases still equal its `old_*` +values (compare-and-swap); a stale verdict is not applied and returns to +review. Review items are unique per `(fact, discrepancy fingerprint)` so a +recurring recompute raises one item, not many. The full locked, ordered +application contract — including how a reversal compensates only the +endpoints its referenced verdict changed while preserving intervening caps +and retractions — is an open item of §12. **Reversal is the one documented +exception**: a reviewer may reverse a `temporal_window` verdict with a +compensating verdict that restores the prior bounds and bases exactly — +D24's reversibility applies to human verdicts over human verdicts, while +D41's retrospective guard governs evidence-driven change; the two do not +conflict because no evidence ever moves a window. Verdicts apply in +`(decided_at, verdict_id)` order after caps and retractions on the same +fact and replay in that order on rebuild (D7). Anything the invariants refuse +stays a review item. + +### 4.4 Closing: temporal succession, separate from processing order + +D90's deterministic **processing** order — `(asserted_at NULLS LAST, +claim_id, statement)` — is unchanged; it makes replay total and reproducible +and decides nothing about the world. + +**Temporal succession** is the rule for capping a `state` slice. A supersede +verdict caps the predecessor at a **world-time instant supplied by the +successor**: + +- a successor `state`'s verdict start (basis `world_time` or `verdict`); or +- an **ending occurrence** from the state-ending candidate set (§4.2) that + the ladder judged `supersede`, at the occurrence's canonical start — so a + dated resignation ends an "is CEO" state whose own start may be unknown, + and a 2027 resignation shortens "CEO 2025–2030" to end in 2027. + +**Chronological guard, applied to every cap source including D55**, stated +mechanically over the predecessor's verdict window: +`(valid_from IS NULL OR T > valid_from) AND (valid_until IS NULL OR T < +valid_until)`. A boundary that fails it is not a cap — the ladder's outcome +is recorded, the pair routes to `contradict` (both stand, grouped) when the +values conflict and coexists otherwise, and a `temporal_window` review item +is raised. When the successor supplies no world-time instant (an undated +successor), there is no succession: the pair **coexists** and the +adjudication row records `reason = "no world-time boundary -> coexist"`. +The cap's basis is `verdict`. Relation supersession and observation +supersession share this one rule. `now()` is never a boundary. + +**Retraction (D55) by temporal kind, fail-closed.** A withdrawn `state` +whose withdrawing document version has a known source time is capped there +under the guard (basis `source_removed`). When that time is unknown, **or +the guard refuses it**, the world-time end stays `NULL` with basis `unknown` +and the belief interval closes regardless — `invalidated_at` set from the +**persisted reconciliation event's timestamp**, never from the database +clock, so a rebuild replays the same instant and a sole-support removal can +never leave a zombie fact that later activates; a refused boundary is +additionally sent to review as the disputed world-time endpoint. A withdrawn +`occurrence` or `unknown`-kind fact is never capped: it closes on belief-time +the same way. This is the per-shape judgement D55 asks for and +`close_observations` could not make while shape was semantic; +`temporal_kind` makes it mechanical. + +**Residual, measured rather than assumed:** undated, differently worded +restatements of a changing state coexist as unknown-bounds rows instead of +capping. Identical wording collapses (§4.2), so growth comes only from +distinct undated wordings; the count of unknown-bounds rows per key is a +reported metric and the lever is extraction coverage of the D41 kinds (§6). + +### 4.5 The D90 late-arrival re-split uses the world clock + +D90 §5.5.3 re-materialises evidence attached to a capped observation when +that evidence lies *after* the cap. Under this design the cap `T` is a +world-time instant, so eligibility compares the attached **state** claim's +canonical occurrence start to `T` — not its `asserted_at`, which stays the +total work order only. Undated attached evidence is never re-split (it +coexists on the slice it attached to). The staggered acceptance case gains a +variant in which said-on order and is-about order are deliberately reversed +and the final slices must follow the world. The D90 design's §5.5.3 is +rewritten to this rule, including its implementation note. + +### 4.6 Statements stay canonical; dated labels are derived + +The observation `statement` remains the canonical source-faithful wording +(D43; unchanged on collapse and supersession). The human-facing **label** — +`obs_label`, `FactResult.label`, the profile line, the K fact-sheet cell — is +derived deterministically from `statement` plus `occurs_*` and +`occurs_precision` ("Nate won a video game tournament last week — on +2022-09-29"), refreshed whenever the occurrence window recomputes. Nothing +source-specific enters identity; claims of different precision that collapse +yield one label from the union window at the coarser precision. + +## 5. Canonical bounds: precision honoured once, consistently + +Claim storage is unchanged (inclusive bounds; `instant` as `until = from`; +`open` as a `NULL` end; the schema `CHECK`s as they are). One function, +`canonical_bounds(from, until, precision) → [start, end)`, converts a stored +claim window to a **half-open** interval, aligning **both** ends to the +precision unit in UTC (D41 bounds are timezone-aware; the calendar is the +proleptic Gregorian calendar PostgreSQL's `date_trunc` uses): + +| `claim_valid_precision` | canonical `[start, end)` | +| --- | --- | +| `day` / `month` / `quarter` / `year` | `[date_trunc(unit, from), date_trunc(unit, until) + unit)` — a year stored 2022-01-01…2022-12-31 becomes `[2022-01-01, 2023-01-01)`; a day whose stored start is noon on 2023-05-07 still becomes `[05-07 00:00, 05-08 00:00)` | +| `instant` | `[t, t + 1 µs)` — a non-empty point | +| `open` | `[date_trunc(day, from), NULL)` when the source gave a date, `[from, NULL)` when it gave an instant; unbounded end | +| `unknown` | no interval; never matches a window predicate and is disclosed as excluded | + +The overlap predicate is `a.start < b.end AND b.start < a.end` with `NULL` +ends as +∞. A caller's inclusive request `claims_as_of(from, to)` converts +to `[from, to + 1 µs)`, so `from == to` is a point-in-time query, not an +empty one. + +**Where it runs.** The function ships as one immutable SQL function in the +`memory_v1` query space (`memory_v1.canonical_bounds`) with a companion +`claims_canonical` view exposing `canon_start`/`canon_end` beside the raw +columns, so saved examples, open SQL, the catalog metadata and the +open-query prose use the same canonicalisation as the engine; the Python +side calls the same definition. **Fact windows are stored canonical** — +`valid_from`/`valid_until` and `occurs_from`/`occurs_until` are written from +`canonical_bounds` at seeding, so every fact predicate the engine already +has (`valid_until > :as_of`, `tstzrange(valid_from, valid_until)` in the +`EXCLUDE`, the P1 `FactTime` selectors) is correct without a precision +column; `occurs_precision` is kept for labels only. **Claim comparisons +canonicalise at query time** — `claims_as_of`, D106's `_windows_disjoint`, +§4.2 matching, the §7 dedupe key and filters. Acceptance covers adjacent +boundaries, equality queries, non-aligned stored inputs, and existing claim +rows. + +## 6. Extraction: vocabulary and anchor + +The extractor prompt defines and exemplifies **all four kinds** and `open` +("has been CEO since 2019" → `proposition_validity`, `open`; "FY2023 revenue +was $5M" → `measurement_period`, `year`; "worked at Acme from 2015 to 2018" +→ `effective_period`, `year`), and the structured-output model describes +each field. The document header shown to the extractor carries the **full +source timestamp**, so offset expressions ("three hours ago") resolve to +instants and two same-day sources are distinct anchors. Expressions the +precision enum cannot represent ("this morning" has no part-of-day +precision) remain unresolved by design — a documented expressivity boundary, +not a defect of the anchor. + +## 7. Every temporal judgement sees both clocks; every surface names them + +### 7.1 The current-fact predicate and activation/expiry + +"Current" is one predicate — the interval containment `memory_v1.facts_current` +and `fact_context` already use — evaluated at an explicit instant `E`: + +``` +ingested_at <= E AND invalidated_at IS NULL +AND (valid_from IS NULL OR valid_from <= E) +AND (valid_until IS NULL OR valid_until > E) +``` + +A fact whose verdict start lies in the future is not yet current; a `state` +with a finite future end is current until it passes; occurrences and undated +facts are current from their start (or always, when undated). **Every** +current fact read uses this predicate with `E` fixed per evaluation — the +consumers that today test `valid_until IS NULL` (entity profiles, +source-removal eligibility, K routing) *and* the ones that today test only +`invalidated_at` (the `aggregate` count/group queries and the +predicate-absence query, which would otherwise keep counting an expired +relation and block a true absence answer; D49 requires fact-grain answers to +be validity-filtered). + +Cached artifacts (profiles, K pages) carry, in their input hash, the earliest +future **activation** instant (`valid_from > E`) and the earliest future +**expiry** instant (`valid_until > E`) among their inputs, and a durable, +indexed `fact_expiry_schedule` (keyed by the artifact, the boundary instant, +its kind — activation or expiry — and the generation; D12 idempotent) queues +regeneration when either instant passes, with the boundary instant as the +evaluation time `E`; restart catches up from the schedule. The read-time +predicate remains the correctness backstop, so a late sweep can delay a +refresh but never serve a not-yet-current or expired fact as current. + +### 7.2 Prompts + +The two-clock block D106 introduced — + +``` +EXISTING: … + said on: + is about: +NEW: … + said on: … + is about: … +``` + +with its definitions — is the contract for **every** prompt that compares, +merges, ranks, or summarises facts: relation supersession (its evidence +laterals select the D41 columns), the T4 identity candidate list (each +salient fact with its occurrence window and kind), the K prose writer's +claim bundle (each claim with said-on and is-about), and the benchmark +answer agent, which additionally names the envelope fields (`asserted_at`, +`claim_valid_*`, `validity` with bases, `occurrence`, `temporal_kind`). + +### 7.3 Envelopes and versions (D49, additive fields; rolled versions) + +- `EvidenceResult` gains `grouped_members` — one `(claim_id, asserted_at, + claim_valid_kind, claim_valid_from, claim_valid_until, + claim_valid_precision)` record per grouped claim — so grouping never hides + a member's times. +- The fact-grain `Validity` gains `valid_from_basis`, `valid_until_basis`, + `temporal_kind`, and `occurrence` (`from`/`until`/`precision`); the same + fields are added to `GraphEdge`'s flat validity, the K-layer fact model, + and the `memory_v1` fact views. +- Because every envelope-returning operation derives its result schema from + the shared `Envelope` schema, all of them roll: `resolve_entity@2`, + `testimony_context@2`, `fact_context@3`, `answer_context@3`; the surface + manifest hash, the query-space manifest, the generated OpenAPI/SDK + artifacts, and the benchmark protocol roll with them. +- The open-query confirmation surface (`query_sandbox/nomination.py`) returns + the complete D41 tuple for claim rows and bases/occurrence/kind for fact + rows; the shipped `claims_as_of` saved example counts `unknown` precision + by precision alone (its current bound-based count can never be non-zero + under D41's checks) and reads through `claims_canonical`. + +### 7.4 Dedupe, filters, timeline, profiles + +- **Deduplication** keys on `(normalised text, claim_valid_kind, + canonical start, canonical end, claim_valid_precision)` when the window is + known and on `(normalised text, asserted_at)` when it is not. +- **Filters.** P1 claim search gains `valid_from` / `valid_until` (is-about, + canonical overlap) beside the said-on `asserted_from` / `asserted_to`; P1 + fact search's `FactTime` selector gains an `occurs` mode over `occurs_*`. +- **Timeline.** `aggregate(form="timeline")` buckets facts by `occurs_from`, + then `valid_from`, and emits an explicit `undated` bucket; it never + substitutes `ingested_at`. +- **Profiles.** Salient facts rank by evidence, then by occurrence recency; + never by `updated_at`; each carries its occurrence window and kind into the + T4 prompt. + +### 7.5 Consumer surfaces + +The K fact sheet prints `valid from` / `valid until` from the verdict window +only where the basis is `world_time` or `verdict`, prints `about` from the +occurrence window, `legacy` rows under a `legacy` heading, and `—` for +`unknown`; "Observation history" sorts by `occurs_from`. The consumption +skill states the three clocks, the two fact kinds, and defines +`claims_as_of` over source world-time (D41), not system time. + +## 8. Generations and protocol + +- Generations: the extractor (kinds, header), the normaliser (kind, seeding, + the staged relation write), both adjudicators (matching by kind, + succession, re-split, D55 by kind), the `adjudicate_observations` flush + component, P1 labels and selection, K page generation, and the query space + (`canonical_bounds`, `claims_canonical`). +- Versions: the assured operations of §7.3, the surface and query-space + manifests, OpenAPI/SDK, and the LoCoMo protocol. **Any package whose + observable result semantics change rolls the protocol**, including ones + whose JSON shape does not; packages released together roll it once. Scores + across a roll are directional. + +## 9. Cutover: in-place conversion with recorded migration verdicts + +A store never mixes pre- and post-D107 fact semantics, and conversion never +replaces a fact row — fact ids are provenance handles referenced by +evidence, review payloads and K citations, and D55 keeps historical facts +with no current support, which a replay from current testimony would erase. +Conversion is a **recorded migration adjudication** per fact (outcome +`migrate`, with the legacy and converted bounds in its features), so what it +did is auditable like any verdict. + +1. **stop** intake and **drain** in-flight units (the D106 contract lets + pre-roll observation units complete under their own generation); +2. **migrate** — add the new columns (`temporal_kind`, the two bases, + `occurs_from`/`occurs_until`/`occurs_precision`, `seed_claim_id`), + the non-empty `state` check, the partial `EXCLUDE`, the + `fact_expiry_schedule` table, the `temporal_window` review kind and + `temporal_window_verdicts`, the `adjudication_outcome` value `migrate` + and `adjudication_method` value `migration`, and the `memory_v1` + canonicalisation function and view (`relation_adjudications.triggering_claim_id` + already exists and is populated from now on; `postgres_schema_design.md` + receives the matching D107 amendment with the full DDL); +3. **convert in place**, per fact, idempotently and in batches, shadow-first + (computed into staging columns, validated against §4.1 and §4.3 + invariants, swapped in one transaction per batch, resumable from the last + validated batch): + - **seed** — an observation's seed is the `triggering_claim_id` of its + recorded `add` adjudication (present today except where hard forget + scrubbed it); a **relation's creator was never recorded**, so its seed + is *not* recovered: `seed_claim_id` stays `NULL`, the verdict window's + bases become `legacy`, and the fact's `temporal_kind` is derived from + the kinds of its attached evidence when they agree (all state, all + occurrence, all undated) and set to `undated` otherwise — every such + choice recorded in the migration adjudication; the same `legacy` path + applies to any observation whose seed was scrubbed; + - **windows** — with a recovered seed, `temporal_kind` and the verdict + window follow §4.1 from that seed's canonical bounds; without one, the + legacy `valid_from` is kept with basis `legacy`; `occurs_*` is the union + over attached evidence in every case; + - **legacy caps are not kept as they are**, because they are the said-on + and `now()` boundaries this decision removes: a legacy supersede cap + whose successor fact is recorded (the adjudication's related fact) is + recomputed at that successor's canonical world-time start when it has + one, basis `verdict`; a legacy cap on a row converted to `occurrence` + is removed (no-cap rule) with the cap moved to the belief interval only + if the row was withdrawn; a D55 fallback cap (the withdrawing version's + time unknown) becomes belief-time invalidation at the persisted + reconciliation instant with `valid_until` set to `NULL`, basis + `unknown`; a cap that + cannot be recomputed (successor unknown or undated) is set to `NULL`, + basis `unknown`, with a `legacy_unknown_boundary` review item, and a cap the + chronological guard would refuse is likewise routed to review; +4. **readiness** reports the fact-layer generation and the count of open + `legacy_unknown_boundary` items; consumers refuse to serve a store whose + fact generation predates D107, and the operator resolves or accepts the + open items before promoting the store; +5. **rollback** is restore of the pre-migration backup, as for any + generation roll. + +Conversion does not re-adjudicate identity decisions made under the old +rules: two occurrences a pre-D106 adjudicator merged stay one row until an +operator chooses a fresh rebuild (D7), which is a re-ingest, not a migration. +Only §6's added kinds benefit from re-extraction. + +## 10. Alternatives considered + +- **Seed `valid_from` from the said-on date when the window is unknown** + (revision 1). Withdrawn: provenance is not validity (Rule 2). +- **Seed a measurement's or event's `valid_until` from its claim** + (revision 1). Withdrawn: D43 never caps a fixed-period figure. +- **Match every fact by verdict-window overlap** (revision 2) and **an + occurrence exclusion constraint** (revision 3). Withdrawn: an occurrence's + open verdict window overlaps every later occurrence; two distinct + occurrences can legitimately overlap. +- **Overlap as the occurrence candidate filter** (revision 4). Withdrawn: it + removed D106's disjoint-date `contradict` path; nomination stays as today + and the temporal relation bounds the verdict. +- **Automatic `extend_start` to the earliest evidenced start** (revision 2). + Withdrawn: `min()` over claim columns is the reduction D41 forbids. +- **A replay-based rebuild from current testimony** (revision 3) and + **exact seed recovery for every legacy fact** (revision 4). Withdrawn: + replay erases D55 history and re-picks seeds; relation creators were never + recorded, so legacy relations convert under an explicit `legacy` basis + with migration verdicts. +- **Keeping legacy cap boundaries through conversion** (revision 4). + Withdrawn: they are the said-on/`now()` values D107 removes; recoverable + caps are recomputed, the rest become belief-time closes or review items. +- **A current predicate without a lower bound** (revision 4). Withdrawn: it + made a 2030 fact current in 2026 and regressed `facts_current`; the full + containment predicate is used and activation is scheduled too. +- **State-ending candidates limited to open states** (revision 4). + Withdrawn: an ending event could not shorten a finite-ended state. +- **Universal half-open claim storage** (revision 1) and **"+ one unit" ends + with raw starts** (revisions 2–3). Withdrawn: both ends are truncated to + the unit, in SQL and Python alike. +- **One coalesced key for processing order and succession** (revision 1). + Withdrawn: D90 needs a total processing order. +- **Succession only between two dated states** (revision 2). Withdrawn: it + lost D106's ending-event case. +- **Closing a retracted state on belief-time labelled `source_removed`** + (revision 3). Withdrawn: belief-time is not world-time. +- **An `undated` temporal kind that conflates shape with datedness** + (revisions 3–5). Withdrawn: it made "is CEO" with no start uncappable and + so lost D106's ending-event case again; shape and datedness are separate, + and only an undated *successor* is barred from supplying a boundary. +- **Cap at the successor's said-on date** (revision 1); **bake the resolved + date into the observation statement** (revision 1); **twenty-two local + patches**; **keep `now()` as the undated cap**. Withdrawn for the reasons + above. + +## 11. Non-goals (scope boundaries) + +- Recurrence ("every Q4"), anchor-relative time ("as of the merger"), and + part-of-day expressions ("this morning") remain outside the single-interval + precision model (D41). +- Belief-time semantics are unchanged. +- No new authority: the claim window stays immutable evidence; the verdict + window stays the one adjudicated home; the occurrence window is derived + metadata and is documented as such wherever it is shown. + +## 12. Open items this design does not yet decide + +Four contracts were identified by the fifth independent review as necessary +for implementation and as touching decisions beyond this design's current +scope. They are recorded here as open, are gated in `plan/plans/temporal_clocks.md` +WP-T.1, and each is a spike whose result amends the named design before that +package starts. Tracking: program issue #364; spikes #365 (1), #366 (2), +#367 (3), #368 (4). + +1. **Deterministic relation seeding under D88 concurrency.** D88 lets + concurrent claim jobs upsert relations ("relation evidence attach is + commutative"); a per-key lock serialises arrival, not the D90 total + order, so which claim seeds a relation is a race. Required: a durable, + claim-idempotent relation staging relation and a post-barrier per-block + drain in the total order, analogous to D90 for observations — an + amendment to D88 and `e3_claim_level_normalize_fanout_design.md`. +2. **The locked application of `temporal_window` verdicts.** §4.3 fixes the + compare-and-swap precondition, the order key and item uniqueness; + remaining are the per-fact locking rule between review and + ingestion/retraction writes, dependency validation on replay, and the + compensating-reversal algorithm that preserves intervening caps. +3. **Cached-artifact staleness.** §7.1's schedule regenerates profiles and K + pages when their inputs' boundaries pass; remaining are how a future fact + that is not yet an input becomes a scheduled dependency, transactional + schedule maintenance on every boundary change, draining and coalescing + boundaries missed during downtime with the current instant as `E`, and a + checked stale state (or a D49-disclosed staleness) for an artifact whose + refresh is late, since the read-time predicate cannot protect + already-rendered text. +4. **Hard-forget inventory (D74).** `seed_claim_id`, `occurs_*`, the review + payloads, `temporal_window_verdicts` (seed, actor, rationale, bounds), + migration-adjudication features, the expiry schedule, derived labels and + their embeddings must each be classified as delete / null / recompute in + `hard_forget_design.md` §4 and the canary matrix. + +## References + +Decisions: D107 (this design), D41, D3, D4, D43, D88, D90, D106, D24, D7, +D12, D55, D49, D74. Analysis: `plan/analysis/time_handling_audit.md`. Sequencing: +`plan/plans/temporal_clocks.md`. Affected designs carry a D107 amendment +banner: `e2_e3_claims_relations_design.md`, `observations_design.md`, +`registries_design.md`, `retrieval_design.md`, `k_layers_design.md`, +`locomo_benchmark_design.md`, `e3_entity_obs_flush_fanout_design.md`. diff --git a/plan/plans/temporal_clocks.md b/plan/plans/temporal_clocks.md new file mode 100644 index 000000000..35d3b574c --- /dev/null +++ b/plan/plans/temporal_clocks.md @@ -0,0 +1,32 @@ +# Temporal clocks — sequencing (D107) + +**Status:** proposed sequencing; no work package is started by this document + +**Binding design:** `plan/designs/temporal_clocks_design.md` + +**Analysis:** `plan/analysis/time_handling_audit.md` + +Order follows dependency and answer impact: the shared canonical-bounds +function first (everything compares through it), then the fact model and +cutover (it makes the documented `valid_at` promise true), then the prompts +that decide supersession and identity, then retrieval keys and envelopes, +then extraction vocabulary and consumer labels. Each package rolls the +generations it touches, rolls the LoCoMo protocol whenever its observable +result semantics change (even with an unchanged JSON shape), and lands with +tests that assert the *clock*, not only the outcome. + +| WP | Scope | Audit findings closed | Generations / surfaces rolled | Acceptance | +| --- | --- | --- | --- | --- | +| **WP-T.0 — canonical bounds** | `canonical_bounds` in Python and as `memory_v1.canonical_bounds` + the `claims_canonical` view (design §5): both ends truncated to the unit; instants as non-empty points; inclusive request conversion; used by `claims_as_of`, D106's disjointness test, the shipped `claims_as_of` example (with its `unknown` count fixed), open-query prose and catalog metadata | 4.13, 4.21 | query-space manifest; LoCoMo protocol (result semantics change) | an intraday `claims_as_of` window finds a day-precision claim; `claims_as_of(t, t)` is a point query; a year stored 2022-01-01…12-31 canonicalises to `[2022-01-01, 2023-01-01)`; a day whose stored start is noon canonicalises to the calendar day; an `instant` overlaps itself; adjacent day windows do not overlap; the example's `unknown` count is non-zero on a corpus with unstamped claims | +| **WP-T.1 — fact model, matching, closing, cutover** | **gated on the four §12 spikes — #365 D88 relation staging, #366 locked review application, #367 artifact staleness, #368 D74 inventory — each landing as a design amendment first (program: #364);** migration: `temporal_kind`, `valid_from_basis`, `valid_until_basis`, `occurs_from`/`occurs_until`/`occurs_precision`, `seed_claim_id`, populating the existing `relation_adjudications.triggering_claim_id` on `add`, the `migrate`/`migration` adjudication enum values, the non-empty state check, `EXCLUDE` partial on states (an unknown-bounds state slice is one unbounded range under it), `fact_expiry_schedule`, the `temporal_window` review kind and `temporal_window_verdicts`; seed once by kind with the seed recorded atomically on both planes; nomination as today with verdicts bounded by temporal relation, two candidate sets (state-ending includes finite-ended states), and the staged, idempotent relation write (§4.2); `temporal_window` verdicts with invariants, the documented reversal exception, and replay (§4.3); succession by any successor-supplied world-time instant incl. ending occurrences, the chronological guard on every cap source incl. D55, else contradict/coexist + review (§4.4); D55 by temporal kind with belief-time closes from the persisted reconciliation instant; D90 re-split by occurrence start (§4.5); the full containment current predicate on every current read incl. aggregate/absence, with activation and expiry scheduling (§7.1); occurrence windows over all attached evidence (D55 history retained); in-place conversion with migration adjudications, the `legacy` basis for unrecoverable seeds, legacy-cap recomputation, `legacy_unknown_boundary` review items, and the readiness gate (§9) | 4.2, 4.4, 4.10, 4.11, 4.17, 4.20, 4.22 | normaliser, both adjudicators, obs flush component; schema head; fact-layer generation in readiness; LoCoMo protocol | `lookup_relations(valid_at=2010)` returns the 2010 employer and excludes the 2024 one; a fact starting in 2030 is not current in 2026 and its profile activates when it starts; a January and an October visit are two occurrence relations, two same-day visits judged `new` coexist, a disjoint pair the ladder judges one disputed occurrence contradicts, and a union expansion bridging two occurrences merges nothing; a same-triple occurrence claim is held unattached until its verdict and a retried claim replays it; the same ingest replayed on different days yields byte-identical windows; both adjudicators orient one undated/dated pair identically (coexist); a dated resignation caps an undated "is CEO" state and a 2027 resignation shortens "CEO 2025–2030"; a purported cap at or before a known start routes to contradict/coexist plus a review item; a `state` with `valid_until = valid_from` is rejected by the schema; a `temporal_window` verdict applies, is reversed by a compensating verdict, and replays idempotently; the staggered D90 case with said-on and is-about reversed yields world-ordered slices; a withdrawn state with unknown or guard-refused source time leaves `valid_until` `NULL`/`unknown` and always sets `invalidated_at` to the recorded reconciliation instant (no zombie fact), and a withdrawn occurrence keeps its `occurs_*`; an expired relation no longer counts in `aggregate` nor blocks `predicate_absence`; a state with a future end is current today and its profile refreshes when the end passes, including after a restart; conversion keeps every fact id and every D55 historical fact, converts a legacy relation under basis `legacy` with a migration adjudication, recomputes a recoverable legacy cap at its successor's world-time start, removes a cap from a converted occurrence, turns a D55 fallback cap into a belief-time close, raises `legacy_unknown_boundary` for the rest, and readiness refuses an unconverted store and reports the open item count | +| **WP-T.2 — two clocks in every temporal prompt** | relation supersession prompt and laterals show `said on` / `is about`; T4 candidate salient facts carry occurrence windows and kinds and rank by evidence then occurrence recency; K writer claims carry `asserted_at` + D41 fields; answer-agent prompt names the envelope fields | 4.3, 4.6, 4.8, 4.16 | relation adjudicator, resolver, K writer; LoCoMo protocol | a 2024 retrospective spell does not supersede a 2023 current fact in the supersession proofs; T4 sees windows and kinds in its candidate JSON; the answer prompt fixture contains the two-clock paragraph | +| **WP-T.3 — retrieval keys, envelopes, skill** | dedupe on the full D41 tuple (or `asserted_at` when unknown) with `grouped_members`; `Validity`, `GraphEdge`, the K fact model and `memory_v1` fact views gain bases, kind and occurrence; `resolve_entity@2`, `testimony_context@2`, `fact_context@3`, `answer_context@3`; open-query confirmation returns the full D41 tuple and fact bases/occurrence; P1 is-about claim filters and the `occurs` fact mode; timeline by occurrence with an `undated` bucket; consumption skill teaches the three clocks and two fact kinds and defines `claims_as_of` over world-time | 4.1, 4.9, 4.12, 4.18, 4.19 | assured operation versions, surface manifest hash, query-space manifest, generated OpenAPI/SDK; LoCoMo protocol | identical text on two dates is two evidence rows in `testimony_context`, and a grouped row lists every member's times; a 2015–2020 archive imported today produces 2015–2020 timeline buckets; the regenerated skill text contains the corrected `claims_as_of` definition; an open-query claim row carries precision and kind | +| **WP-T.4 — extraction vocabulary and anchor** | all four D41 kinds and `open` taught with examples and field descriptions; full-timestamp header | 4.14, 4.15 | extractor; LoCoMo protocol | "has been CEO since 2019" extracts as `proposition_validity` / `open`; "three hours ago" in a source stamped 19:30 resolves to an `instant` at 16:30 of that day, and the same words in a second same-day source stamped 22:00 resolve to a different instant | +| **WP-T.5 — dated labels and consumer surfaces** | labels derived from statement + occurrence window (obs label, `FactResult.label`, profile lines); K fact sheet columns by basis with `about` and `legacy` handling; observation history by `occurs_from` | 4.5, 4.7 | P1 labels and selection, K page generation; LoCoMo protocol (answer inputs change) | an observation minted from "last week" carries the resolved date in its label but not its statement; a sheet never prints a said-on date under a world-time heading | + +Dependencies: T.0 first. T.1 depends on T.0. T.2, T.3 and T.5 depend on +T.1's columns and cutover. T.4 is independent and may run in parallel. +Packages released together roll the protocol once. Every package updates the +same-PR documentation the CLAUDE.md rule requires (concepts and API pages for +`valid_at`, the benchmark README when the protocol rolls) and the +project-status page.