You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Statement qualifiers are never read back, and a re-push cannot change them #1267
A pushed statement can carry role words as qualifiers ([null, subject, phrase, object, value, {"lines": "10-42", "commit": "abc123"}, …], 0054), and extraction keeps them in statement_qualifiers (0061). Two things stop a client from using them:
No read returns them.graph::statement_qualifiers_for exists but only tests call it; entity_detail, edges_among, document_extractions, MCP entity_facts and the export attach fact_qualifiers (typed) only.
The first value written wins forever.add_statement_qualifier is ON CONFLICT (fact_id, role) DO NOTHING. When a source re-pushes a statement under the same external_id with a new qualifier value (a test's line range moved, a status changed), the fact is deduplicated, the new chunk becomes its evidence, and the old value stays. materialize also copies qualifiers and evidence to a typed row only when it creates it, so after a re-push the typed row keeps the old qualifiers and only superseded evidence, and reads mark it stale.
Our use: we push which tests validate which spec statements, with the line range as a qualifier, and need to read the current range back.
Proposal, as small PRs:
reads return a separate statement_qualifiers field (role words are not declared attributes, so they stay out of qualifiers), batched next to fact_qualifiers_for; then the same for extractions and export
a qualifier row per evidence chunk, read by a rule: values from live chunks, else the fact's newest evidence; newest wins (an ADR, since it changes 0037's first-write-wins for role words)
materialize re-syncs evidence and qualifiers onto live typed rows
Thank you. Part 1, reading role words back, yes: it is additive, and #1272 is the right shape once the MCP docs list the field.
Parts 2 and 3 need a decision record first. Letting a re-push change a statement's role words reverses 0037's first-write-wins, and it raises questions the code alone won't answer: does a changed role word get a record time, what does an as_of read show for a value that changed, and does a typed row that copied the old value follow the new one. Please write those down as a short ADR (or a revision of 0037) here before the PR, and we can agree it in this thread.
Thanks. The record is up as #1278 (0070) so it can be agreed here before any code; on your three questions:
Record time. A changed role word is not a new row on the fact; it arrives as a row on the new evidence chunk, so its record time is that chunk's. Which value a read sees is decided by chunk and document liveness on the record axis, the same as for evidence.
as_of. A read applies the rule at that instant, so it shows the value the fact's live evidence carried then: between the two pushes, the old value; today, the new one.
Typed rows. Yes, they follow: materialize copies a statement's new evidence and role-word rows onto its live typed rows on each run, and the mood checks use the same rule, so a typed row is stale exactly when its statements are.
If you'd rather this be a revision of 0037 than a new record, I'll fold it in.
Part 1 landed in #1272 and the record for parts 2 and 3 is 0070. What remains is the code: the chunk_id column and backfill on statement_qualifiers, the liveness rule for readers, and materialize re-syncing typed rows (add_statement_qualifier is still ON CONFLICT DO NOTHING). Is that PR still on your list?
Thanks for checking. Yes, it's on my list, and the plan is three small PRs: the migration with per-chunk writes, the reads following chunk liveness, then materialize keeping typed and implied rows in step. Four questions before I start:
Read shape. Decision 2 says a read returns each value with its chunk, but decision 1 promises reads are unchanged after the backfill. Could PR 1 keep today's JSON (one entry per role and value), with chunk_ids added in a later PR?
Role words on a statement with no evidence. The backfill can't give them a chunk. Drop them with a notice, or stop the migration the way 0070's audit does?
Stale fallback. Use the fact's last-superseded evidence chunks, so a role that chunk dropped stays gone, or the last-superseded chunk that carries that role? I'd suggest the first.
Copies from former sources. After an errata retract or a binding change, copies already on a typed row keep speaking while their chunk is live. Accept that, or prune them?
Thanks, the three-PR split works. On your four questions:
Read shape. Yes, PR 1 can keep today's JSON. For that PR, 0070 decision 1 is the contract: reads after the backfill return what they did before. That means the reader has to collapse the backfill's copies to one entry per role and value (DISTINCT on role, value, entity_id), or each role shows once per evidence chunk. chunk_ids is additive and should come in PR 2, because that is when two live values can both speak (decision 2). Until PR 2 lands, a re-push that changes a value shows both values, so please keep that gap short.
No evidence. Live statements always have evidence, as decision 1 assumes. But documents::purge cascades away chunks and evidence and leaves invalidated facts that still carry their role words. Those rows can't speak under decision 2, and purge is meant to erase the document's words. So drop them and report the count. Abort the way migration 0070's §0 audit does only if a live fact has role words and no evidence. Give chunk_idON DELETE CASCADE, like fact_evidence.
Stale fallback. Already decided in decision 2: "the rows on its evidence chunks that were superseded last". That is your first option, so a role the last chunk dropped stays gone. Choose "last" as of as_of, and date a deleted document's chunks by its deleted_at.
Former sources. Accept it. Decision 4 only adds copies, and a former source's fact_evidence copies already stay today. Pruning role words alone would make them disagree with the row's evidence. An errata retract rejects the whole typed row, so this only arises when a binding changes on a row that has another source.
Please move 0070's status line to In progress in PR 1. One more thing for PR 3: implied rows don't copy statement_qualifiers at all today (materialize.rs copies evidence only); decision 4 adds that.
@WaylandYang a small status note: the first two PRs of the three are in (#1428 and #1450), and the last one is #1544, with the EXPLAIN (ANALYZE, BUFFERS) numbers you asked for posted there. Whenever you have a moment, thank you!
Activity
gedaiu commentedon Oct 16, 2026
Related: the reads this needs a token for are #1262 (#1263–#1266); first part is #1272. Same backend use as #1269 and #1271.
WaylandYang commentedon Oct 16, 2026
Thank you. Part 1, reading role words back, yes: it is additive, and #1272 is the right shape once the MCP docs list the field.
Parts 2 and 3 need a decision record first. Letting a re-push change a statement's role words reverses 0037's first-write-wins, and it raises questions the code alone won't answer: does a changed role word get a record time, what does an
as_ofread show for a value that changed, and does a typed row that copied the old value follow the new one. Please write those down as a short ADR (or a revision of 0037) here before the PR, and we can agree it in this thread.gedaiu commentedon Oct 16, 2026
Thanks. The record is up as #1278 (0070) so it can be agreed here before any code; on your three questions:
as_of. A read applies the rule at that instant, so it shows the value the fact's live evidence carried then: between the two pushes, the old value; today, the new one.materializecopies a statement's new evidence and role-word rows onto its live typed rows on each run, and themoodchecks use the same rule, so a typed row is stale exactly when its statements are.If you'd rather this be a revision of 0037 than a new record, I'll fold it in.
WaylandYang commentedon Oct 22, 2026
Part 1 landed in #1272 and the record for parts 2 and 3 is 0070. What remains is the code: the
chunk_idcolumn and backfill onstatement_qualifiers, the liveness rule for readers, andmaterializere-syncing typed rows (add_statement_qualifieris stillON CONFLICT DO NOTHING). Is that PR still on your list?gedaiu commentedon Oct 22, 2026
Yes, it's on my list. I'll send the code after the open token reads and #1333 land, to keep the queue short.
gedaiu commentedon Oct 24, 2026
Thanks for checking. Yes, it's on my list, and the plan is three small PRs: the migration with per-chunk writes, the reads following chunk liveness, then
materializekeeping typed and implied rows in step. Four questions before I start:chunk_idsadded in a later PR?WaylandYang commentedon Oct 25, 2026
Thanks, the three-PR split works. On your four questions:
chunk_idsis additive and should come in PR 2, because that is when two live values can both speak (decision 2). Until PR 2 lands, a re-push that changes a value shows both values, so please keep that gap short.documents::purgecascades away chunks and evidence and leaves invalidated facts that still carry their role words. Those rows can't speak under decision 2, and purge is meant to erase the document's words. So drop them and report the count. Abort the way migration 0070's §0 audit does only if a live fact has role words and no evidence. Givechunk_idON DELETE CASCADE, likefact_evidence.as_of, and date a deleted document's chunks by itsdeleted_at.fact_evidencecopies already stay today. Pruning role words alone would make them disagree with the row's evidence. An errata retract rejects the whole typed row, so this only arises when a binding changes on a row that has another source.Please move 0070's status line to In progress in PR 1. One more thing for PR 3: implied rows don't copy
statement_qualifiersat all today (materialize.rscopies evidence only); decision 4 adds that.A typed or implied row follows its statements' evidence and role word…
A typed or implied row follows its statements' evidence and role word…
A typed or implied row follows its statements' evidence and role word…
Skip rows a typed row already holds before the whole-base copy (deepl…
gedaiu commentedon Nov 29, 2026
@WaylandYang a small status note: the first two PRs of the three are in (#1428 and #1450), and the last one is #1544, with the
EXPLAIN (ANALYZE, BUFFERS)numbers you asked for posted there. Whenever you have a moment, thank you!