diff --git a/docs/decisions/0054-a-source-may-push-statements-in-the-open-contract.md b/docs/decisions/0054-a-source-may-push-statements-in-the-open-contract.md index 5d3c36f68..451cd9406 100644 --- a/docs/decisions/0054-a-source-may-push-statements-in-the-open-contract.md +++ b/docs/decisions/0054-a-source-may-push-statements-in-the-open-contract.md @@ -96,3 +96,4 @@ Content-Type: application/json - 2026-10-16 ([#1267](https://github.com/deeplethe/utopia/issues/1267)): decision 7 keeps a re-pushed statement's identity, but its role words stayed first-write-wins, so a re-push with a new qualifier value kept the old one; [0070](0070-a-role-word-speaks-while-its-chunk-is-live.md) proposes that a role word is recorded against its evidence chunk and speaks while that chunk is live. - 2026-10-19 ([#1293](https://github.com/deeplethe/utopia/issues/1293)): proposed in [0071](0071-a-source-may-declare-its-names-identities.md): a `statements` source whose config says `{"names": "identity"}` attaches its named entities by exact name and gives their names no vectors. Decision 3's "same path" stands for every other source. - 2026-10-23 ([#1375](https://github.com/deeplethe/utopia/issues/1375)): decision 2's intact `statements` chunk is indexed for keyword search but is not embedded, so an embedding model's input limit cannot block its deterministic extraction; vectors already written for statements chunks are left in place. +- 2026-11-29 ([#1478](https://github.com/deeplethe/utopia/issues/1478)): proposed in [0079](0079-a-source-may-say-a-new-version-replaces-the-old.md): a `statements` source whose config says `{"restates": "replace"}` reads a new version of an item as replacing the old one, so once that version is extracted, the open statements only its superseded chunks attested are closed, history kept. Decision 7 stands for every other source. diff --git a/docs/decisions/0079-a-source-may-say-a-new-version-replaces-the-old.md b/docs/decisions/0079-a-source-may-say-a-new-version-replaces-the-old.md new file mode 100644 index 000000000..80a16fde1 --- /dev/null +++ b/docs/decisions/0079-a-source-may-say-a-new-version-replaces-the-old.md @@ -0,0 +1,78 @@ +# 0079 · A source may say a new version replaces the old + +- **Status**: Proposed · 2026-11-29 · [#1478](https://github.com/deeplethe/utopia/issues/1478) · open: everything +- **Written**: 2026-11-29 (conventions in the [README](README.md)) +- **Related**: [0054](0054-a-source-may-push-statements-in-the-open-contract.md) decision 7 reads a re-push as a new observation, and this record narrows that for sources that opt in; [0071](0071-a-source-may-declare-its-names-identities.md) is the per-source switch this one copies; [#1489](https://github.com/deeplethe/utopia/pull/1489) is why nothing is judged before the new version is read; [0022](0022-an-unknown-date-is-not-an-open-one.md) is what a closed end means on the world axis; [#875](https://github.com/deeplethe/utopia/issues/875) is the case decision 7 was written for, and it keeps the default + +> A backend mirrors a repository's specs and tests into a base and re-pushes each item on every merge. A spec item that once said `s0128 validated_by a.test.ts::parses a date` stops saying it when the test moves. The fact keeps its evidence on the superseded chunk, reads as unconfirmed, and waits in Review. Over three weeks one statement entity collected 55 `validated_by` facts and 18 `text` values from nine different sentences, and a reader of the graph gets the current links and the old ones mixed together. + +## The problem + +0054 decision 7 is right for the sources it was written for. A robot that pushes "the cup is on the table" and later "the cup is on the shelf" has made two observations, and the first stays true of its own moment. Not mentioning something again does not make it false, and the same holds for prose. + +Some producers mean something else by a re-push. A mirror pushes an item as the current state of a thing it owns, so the new version is the whole of what the item says now and anything the old version said and the new one does not is withdrawn. Today a person has to close each of those facts in Review, one by one, with the same close the Review page already offers. The producer knows which reading its pushes need, and one base can hold both kinds of source. + +## Decisions + +**1. The switch lives on the source, and it is off by default.** + +A `statements` source whose config says `{"restates": "replace"}` declares that a new version of one of its items replaces the old one. Without it, and on every other kind of source, 0054 decision 7 stands as it is. The switch sits next to `{"names": "identity"}` and `{"extract": false}` and is read the same way, by a method on `Source` beside `names_are_identities`. A value other than `"replace"` is read as the default. + +The key names the act a producer is declaring something about, which is what a re-push restates, and the value says what the restatement does to the earlier version. It is a word and not a boolean so that a third reading can be named later without a second key. `state` was the other candidate and was dropped because 0054 decision 6 already uses that word for tables that belong on a mount. + +**2. Nothing closes before the new version has been read.** + +The close runs at the end of the open extraction of the new version (`extraction_open::run_open`), only when every live chunk of the document was extracted and the run still owns the document's extraction epoch. A version that failed, was skipped, or is still queued closes nothing, which is the rule #1489 set for staleness. A half-read version could look as if it dropped facts it never got to. A source with `{"extract": false}` never closes anything this way, because nothing reads its new versions. + +**3. Only facts whose whole evidence is this document's superseded chunks.** + +A fact qualifies when it is unconfirmed in the sense of `review::unconfirmed_fact`, all of its evidence rows sit on chunks of this document, and every one of those chunks is superseded. A fact the new version restates has evidence on a live chunk and stays. A fact another item or another document also attests stays too, even when that other evidence is itself superseded, because that is another document's question. A fact two items state therefore stays open until both have dropped it. + +The check reads the document's whole history, so facts that earlier versions dropped are closed along with the latest ones. + +**4. The close is the Review close, history kept.** + +Each fact is closed with `temporal::close_superseded`, the same invalidate and rewrite a person's close in Review performs. The old row gets `invalidated_at`, a successor row carries the end and the copied evidence, and `as_of` still shows the fact open before the close. The end is the latest `superseded_at` among the fact's evidence chunks, at `second` precision, which is the moment the item stopped saying it. A fact whose start is later than that moment would be refused as `interval_inverted`, so it is skipped and stays in Review for a person. The close writes no audit row per fact. The push that caused it is already recorded as an ingest run. + +**5. Names Utopia wrote itself are left alone.** + +`known_as` facts are excluded (`names::not_a_name`). Utopia writes them from the payload's text, not from a statement the producer made, and an entity keeps its name when the item that introduced it stops talking about it. Retiring an entity is a different question from withdrawing a statement about it. + +This is also where the record meets 0071. A source can set both flags, and a mirror usually will. Identity names are name facts, so this record never closes one, and 0071's vectors, exact attachment and merge gate see the same rows they saw before. Neither flag needs the other. + +**6. Typed facts are left to the temporal engine.** + +Only open statements are closed. A typed row that was materialized from a closed statement is not closed here. The close queues one typed recompute, as `graph::reject_fact` does for a rejected statement, and what the typed row does then is materialization's and the temporal engine's (0054's revision of 2026-09-25). This keeps decision 7's line between the two layers. The opt-in changes how an item's own statements are read, and typed intervals are still decided only on the typed layer. + +**7. Switching the flag.** + +- **On:** nothing is closed at the moment the flag is set. From the next extracted version of each item, that item's dropped facts close, including those earlier versions dropped (decision 3). An item that is never pushed again keeps its old unconfirmed facts in Review. +- **Off:** nothing is reopened. A fact that was closed while the flag was on stays closed, as it would after a person closed it in Review. The next re-push of each item is read as 0054 decision 7 reads it. + +## Not doing + +- **Prose and `api` sources.** The flag is read only on `statements` sources. A document a person wrote keeps "not mentioned is not false". +- **A sweep over a source's existing backlog.** Switching the flag on (decision 7) closes as items are re-pushed. Closing everything a source has dropped, on request, would be a separate route with its own audit, and the Review page can already do it one fact at a time. +- **Deleting or retiring entities.** An entity whose statements have all closed stays, with its names. +- **Changing decision 7 for anyone who has not opted in**, the #875 case included. + +## Dead ends + +- **Every `statements` source replaces.** That is what our fork ran first, and it is wrong for the sources 0054 was written for. An observation stream would lose the honest answer decision 7 gives. +- **Closing at push time.** The new chunk is unread then, so every fact the item supports would look dropped (#1477, #1489). +- **Closing facts that also have evidence elsewhere, at the latest end among all their documents.** One item's new version would then speak for another item that never changed. +- **A per-base switch.** One base mixes mirrors with observation streams and prose, and only the producer knows which reading its pushes need. 0071 chose per source for the same reason. + +## Tests the code PR adds + +- `a_repush_closes_the_statement_its_new_version_dropped` sets the flag, pushes v1 with p and q, extracts, pushes v2 with p only and extracts again. q ends at v1's supersede moment with a successor row, and p stays open. +- `a_repush_keeps_a_statement_another_item_still_states` checks that a second item stating q keeps it open. +- `a_repush_without_the_flag_closes_nothing` checks that the same pushes on a source without the flag leave q open and unconfirmed, as today. +- A store test on the candidate query checks that a `known_as` fact, a fact with evidence on a live chunk, a fact with evidence on another document and a fact whose start is after the supersede moment all stay open, and only the fact whose evidence is the document's superseded chunks closes. +- A version whose extraction failed or is still queued closes nothing. + +## Open questions + +- Whether a source update should refuse a `restates` value other than `"replace"` with 422. 0071 reads an unknown `names` value as the default, and this record follows it for now. +- Whether the close should be counted somewhere a person can see it, such as the extraction job's result or the document's run history, since it writes no audit row. +- Whether a sweep for a source's existing backlog belongs upstream at all (Not doing, second item), or whether closing as items are re-pushed is enough. diff --git a/docs/decisions/README.md b/docs/decisions/README.md index 6357309ce..82a650b80 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -119,6 +119,7 @@ By domain; the domains are the files of [../design/](../design/README.md). **Sta | 0072 | [A source checkpoint ends at a timestamp boundary](0072-a-source-checkpoint-ends-at-a-timestamp-boundary.md) | Implemented | | | 0074 | [A Google Drive source is connected by a person](0074-a-google-drive-source-is-connected-by-a-person.md) | Implemented | | | 0075 | [A ticket source says in the API where its reading stopped](0075-a-ticket-source-says-where-its-reading-stopped.md) | Implemented | | +| 0079 | [A source may say a new version replaces the old](0079-a-source-may-say-a-new-version-replaces-the-old.md) | Proposed | | ### [lakehouse-and-actions](../design/lakehouse-and-actions.md)