Open
Labels
enhancementNew feature or request
Description
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_forexists but only tests call it;entity_detail,edges_among,document_extractions, MCPentity_factsand the export attachfact_qualifiers(typed) only. - The first value written wins forever.
add_statement_qualifierisON CONFLICT (fact_id, role) DO NOTHING. When a source re-pushes a statement under the sameexternal_idwith 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.materializealso 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 itstale.
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_qualifiersfield (role words are not declared attributes, so they stay out ofqualifiers), batched next tofact_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)
materializere-syncs evidence and qualifiers onto live typed rows
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
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!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…
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…