One typed fact for many statements - #753
Merged
Merged
Conversation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: WaylandYang <wayland0916@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: WaylandYang <wayland0916@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: WaylandYang <wayland0916@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
0044 cut 2, third slice: several statements that produce the same triple give one typed row. Follows #752, which gave one row per statement and left the merge for later.
What lands
Migration 0068:
typed_fact_sources (fact_id, statement_id), one row per statement behind a typed row, backfilled fromfrom_statement_id;from_statement_idstays as the first source.Materialisation goes through the typed graph's own gate. Instead of inserting a row per statement,
utopia_store::materializecallsinsert_fact/insert_value_factfor each due (statement, binding) pair, so the rules the rest of the typed graph already lives by apply: the same assertion with the same start reuses the row and only attests it earlier; a bare row (no time) is superseded by a dated observation of the same assertion, with thesupersedeslink and the evidence carried over; an observation that says "ended" closes the open row. A row's sources are then whatever statements it was computed from; its evidence rows and role-word qualifiers are the union of theirs. When a new row supersedes an old one, the old row's sources move to it in the same pass, so one run converges.Recomputation, restated for many sources. A source is dropped when its statement no longer holds under a bound signature that yields this row (statement invalidated, signature unbound, property or direction changed, a mood added, or the row itself superseded); a computed row is retired only when it has no source left; due pairs are added as before. Idempotent: a second run changes nothing.
Test (
a_bound_statement_becomes_a_typed_fact, database-backed): a bare statement, a dated one and a second document's dated one on the same pair give one live row with three sources and two evidence rows in one run (the bare row superseded, its source moved); the statement with amoodgives none; a second run is a no-op; invalidating one statement keeps the row with one source fewer; flipping both signatures toreverseretires the row and rebuilds it with the ends swapped; setting both tononeretires it and adds nothing.Measured
No model call. The two bases of #751, cleared and re-materialised under this branch:
The merged rows are figures a release states twice (a headline and a table: "revenue —value→ $96,221" with three sources) and the superseded ones are a table's cell first read without its period and then with it, all within one document; across documents the corpora repeat little. Before this branch (#752) the same bases held 184 and 125 rows, and a second run after the timeline's refinement had to run twice to settle.
Not in this change
Implication rules and readings; typed qualifiers from role words; the alignment queue (#725); the conflict detector's view of two sources that disagree (they stay two rows under
insert_fact's rules, as they do for any other writer).🤖 Generated with Claude Code