Repository navigation
Conversation
An as-of view selected the right rows but handed them back carrying the
later retraction. View.cond already excludes a statement retracted at or
before the view's transaction, yet the row kept its t_ret, ret_kind and
retracted_at from the transaction that retracted it afterwards. So
Statement.Live() returned false and the legacy Triple.Status said
"retracted" for a fact that was live at the instant asked about --
exactly the question a bitemporal store exists to answer. Reachable from
the CLI: `pi memory kg query alice --tx-as-of tx1` printed
status=retracted for a fact retracted later.
Mask the retraction for as-of rows only, matching Tiramemsu's
read::row_to_triple ((t_ret: if mask_retraction { None })). The now view
needs nothing (everything it selects is live) and the history view must
keep the retraction, which is its purpose.
Route every view-scoped read through View.query (and View.lookup for the
single-row Explains) so a new read cannot forget the mask. Get and the
legacy Invalidate path keep queryStatements: Get is documented to return
a statement whatever its state, and the legacy path resolves rows under
a history view.
TestKGAsOfMasksLaterRetraction covers About, Match, Explain and
QueryWith, and asserts History still reports the retraction while Now
reports nothing. With the mask disabled it fails on all four, naming the
retracted row and status=retracted.
Signed-off-by: pi <dimetron@me.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #486 +/- ##
=======================================
Coverage 91.31% 91.32%
=======================================
Files 403 403
Lines 52380 52393 +13
=======================================
+ Hits 47831 47846 +15
+ Misses 4543 4541 -2
Partials 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Superseded by #488 — closing rather than rebasing. WhyThis PR was branched from
So the bulk of this PR is now duplicate, and it conflicted ( What phase 2 left behindOne field still reads the unmasked row. ex := &Explanation{Statement: v.mask([]Statement{*st})[0], View: v.String()}but three lines of that block later derives the withdrawal from the raw if st.TRet != nil {
if ex.RetractedBy, err = loadTx(ctx, q, *st.TRet); err != nil {
for a statement retracted at tx2 while the view asked about tx1. Phase 2's own test checks What moves to #488Exactly that one line, plus the missing assertion on |
Summary
An as-of view selected the right rows but handed them back carrying the
retraction that happened later. This fixes that, and adds the test that
should have caught it.
View.condalready excludes a statement retracted at or before the view'stransaction:
but the row kept its
t_ret,ret_kindandretracted_atfrom thetransaction that retracted it afterwards. So
Statement.Live()returnedfalseand the legacyTriple.Statussaidretractedfor a fact that waslive at the instant asked about — the one question a bitemporal store exists
to answer. A caller reusing a historical row (for a report, a diff, or a
"what did I believe last Tuesday" answer) got the present state wearing a
past timestamp.
Reachable from the CLI, which is how I found it on
mainat1023b37:Fix
Mask the retraction for as-of rows only, matching the reference
implementation's
read::row_to_triple:Live()andStatusagree with the bound.Every view-scoped read now goes through
View.query(View.lookupfor thesingle-row reads in
Explain) so a future read cannot forget the mask.Getdeliberately keeps
queryStatements: it is documented to return a statementwhatever its state. The legacy
Invalidatepath resolves rows under ahistory view and is unaffected.
Verification
TestKGAsOfMasksLaterRetractioncoversAbout,Match,ExplainandQueryWith, and pins the other two views:Historystill reports theretraction,
Nowreports nothing.Guard seen failing. With the mask neutralised it fails on all four
paths, naming the cause:
Restored, it passes.
go test ./internal/palace/→ok,-race→ok(19.2s),go vetclean,golangci-lint run ./internal/palace/...→0 issues.go test ./internal/cli/ -run TestMemoryKG→ok(the CLI path the bugshowed up on).
Build on current
mainafter rebase.Not verified: the full
internal/clipackage. Running it whole on this hostwas starved by concurrent builds (load average 17) and timed out; CI covers it.
Scope
One behavioural change, in a
fix/PR and not folded into phase 2: phase 2adds more read paths, and every one of them would have inherited the same lie.