Skip to content

fix(palace): explain derives withdrawals from the masked statement - #488

Merged
dimetron merged 1 commit into
mainfrom
fix/explain-mask-retractedby
Nov 22, 2026
Merged

dimetron merged 1 commit into
mainfrom
fix/explain-mask-retractedby

Conversation

@dimetron

Copy link
Copy Markdown
Owner

Summary

One field in Explain still reads the unmasked row, so palace-kg-explain contradicts itself under an as-of view.

Phase 2 (#487) added View.mask and wired it into the list reads and into Explanation.Statement. But the withdrawal is derived a few lines later from the raw st.TRet:

ex := &Explanation{Statement: v.mask([]Statement{*st})[0], View: v.String()}
// …
if st.TRet != nil {
    if ex.RetractedBy, err = loadTx(ctx, q, *st.TRet); err != nil {

palace-kg-explain renders both fields, so asking about the past prints:

- Status: live
- Withdrawn: tx2 at 2026-01-01 00:00:02

for a statement retracted at tx2 while the view asked about tx1. Reproduced on main at 891ccc2. Phase 2's TestKGAsOfMasksLaterRetraction asserts ex.Statement.TRet but not ex.RetractedBy, which is why it passes.

Fix

Read the retraction off ex.Statement.TRet, the same masked copy the status comes from, so the two cannot disagree. One line.

Verification

  • The existing TestKGAsOfMasksLaterRetraction gains the assertion that was missing: RetractedBy is nil under the as-of view. It also pins the now view, so the fix cannot hide a real retraction.

  • Guard seen failing. With the one line reverted:

    kg_core2_test.go:449: as-of tx1: RetractedBy = tx2, a retraction that had not
    happened yet (the row is masked, so this contradicts Status)
    

    Restored, it passes.

  • go test ./internal/palace/ → ok (7.0s), go vet clean, golangci-lint run ./internal/palace/... → 0 issues, go test ./internal/cli -run TestMemoryKG → ok.

  • Branched from current main (891ccc2), so no conflict with feat(palace): Tiramemsu port phase 2 — graphs, query languages, paths, rules, saved answers, vectors, bundles, crypto-shredding #487.

Relation to #486

#486 carried the whole as-of mask, branched before #487 merged. Phase 2 landed that independently, so #486 was duplicate and conflicting; it is now closed, and this is the only delta left from it.

Same pattern as the review that found this: masking was applied to the row and to the list reads, but not to the field derived from the row.

Explain carries the retraction twice: on the statement, and as the
RetractedBy transaction that palace-kg-explain renders as
"- Withdrawn: txN". The statement is masked for an as-of view but the
RetractedBy was loaded from the raw st.TRet, so the two disagreed and the
tool printed a self-contradicting block:

    - Status: live
    - Withdrawn: tx2 at 2026-01-01 00:00:02

for a statement retracted at tx2 while the view asked about tx1. Read the
retraction off ex.Statement.TRet instead, so it comes from the same masked
copy the status does.

The list reads (About, Match, Conflicts, textSearch) and Explain's own
statement were already masked; this was the one field left reading the
unmasked row.

TestKGAsOfMasksLaterRetraction now asserts RetractedBy is nil under the
as-of view and still set under the now view. Reverting the one-line change
makes it fail with "as-of tx1: RetractedBy = tx2, a retraction that had
not happened yet".

Signed-off-by: pi <dimetron@me.com>
@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.22%. Comparing base (891ccc2) to head (a4c510a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #488      +/-   ##
==========================================
- Coverage   92.23%   92.22%   -0.01%     
==========================================
  Files         426      426              
  Lines       57744    57744              
==========================================
- Hits        53258    53255       -3     
- Misses       4480     4483       +3     
  Partials        6        6              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dimetron
dimetron merged commit 6d236a5 into main Nov 22, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant