Fix: UPDATE branch of upsert_entry dropped doc_refs + valid_until #3

Merged
profit merged 5 commits from fix/upsert-outcome-update-merge into main 2026-04-22 09:11:16 +00:00
Owner

Surfaced by

The auditor's hybrid fixture on PR #1 (branch auditor/scaffold) caught this
during layer 3 validation on 2026-04-22. A re-seed with fresh doc_refs on
the same (operation, day) produced mode=updated but the doc_refs vanished.

Root cause

upsert_entry UPDATE arm only merged endorsed_names + partially handled
schema_fingerprint. Three fields were dropped: doc_refs, valid_until,
plus the schema_fingerprint partial handling was inconsistent with the
Phase 25 intent.

Fix

  • doc_refs — merge by tool (case-insensitive). Same-tool supersedes,
    different-tool appends, empty incoming preserves existing.
  • valid_until — refresh if caller provides one.
  • schema_fingerprint — already correct, clarified in comment.

Tests

4 new regression tests under upsert_tests. All 9 upsert tests pass.

Merge order

Independent of PR #2. Either can merge first. If PR #2 merges first
(which changes the UpsertOutcome enum shape), this branch needs a
rebase — only the 2 pattern-match sites in the tests update (_ → { .. }),
the fix logic is untouched.

🤖 Generated with Claude Code

## Surfaced by The auditor's hybrid fixture on PR #1 (branch `auditor/scaffold`) caught this during layer 3 validation on 2026-04-22. A re-seed with fresh doc_refs on the same (operation, day) produced mode=updated but the doc_refs vanished. ## Root cause `upsert_entry` UPDATE arm only merged endorsed_names + partially handled schema_fingerprint. Three fields were dropped: `doc_refs`, `valid_until`, plus the `schema_fingerprint` partial handling was inconsistent with the Phase 25 intent. ## Fix - `doc_refs` — merge by tool (case-insensitive). Same-tool supersedes, different-tool appends, empty incoming preserves existing. - `valid_until` — refresh if caller provides one. - `schema_fingerprint` — already correct, clarified in comment. ## Tests 4 new regression tests under `upsert_tests`. All 9 upsert tests pass. ## Merge order Independent of PR #2. Either can merge first. If PR #2 merges first (which changes the UpsertOutcome enum shape), this branch needs a rebase — only the 2 pattern-match sites in the tests update (_ → { .. }), the fix logic is untouched. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
profit added 1 commit 2026-04-22 09:06:57 +00:00
Fix: UPDATE branch of upsert_entry dropped doc_refs + valid_until
All checks were successful
lakehouse/auditor all checks passed (3 findings, all info)
320009ddf4
The auditor's hybrid fixture (branch auditor/scaffold) surfaced this
on 2026-04-22. A re-seed of the same (operation, day) pair with new
endorsed_names merged the names but silently discarded the incoming
doc_refs and valid_until fields. schema_fingerprint was partially
handled (set-if-Some) but doc_refs and valid_until weren't touched.

Root cause: the UPDATE arm of upsert_entry at playbook_memory.rs:609
only covered:
  - endorsed_names (union-merge)
  - timestamp
  - embedding (if Some)
  - schema_fingerprint (if Some)

Fix:
  - valid_until — refresh if caller provides one
  - doc_refs — merge by tool (case-insensitive). Same-tool new entry
    supersedes older one; different-tool refs are appended. Empty
    incoming doc_refs preserves existing (don't wipe on partial seed).

4 new regression tests under upsert_tests:
  - update_merges_doc_refs_with_existing_ones
  - update_same_tool_supersedes_older_version
  - update_preserves_existing_doc_refs_when_new_entry_has_none
  - update_refreshes_valid_until_when_caller_provides_one

Test result: 9/9 upsert tests pass (4 new + 5 pre-existing).

Branch basis note: this branch is off main, so the UpsertOutcome enum
here still has the newtype variants Added(String) / Noop(String). PR
#2 (fix/upsert-outcome-serde) changes that enum to struct-like. When
PR #2 merges first this branch needs a trivial rebase; the UPDATE
arm logic is untouched by that change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Author
Owner

Auditor verdict: approve

One-liner: all checks passed (3 findings, all info)
Head SHA: 320009ddf4de
Audited at: 2026-04-22T09:07:16.396Z

dynamic — 1 findings (0 block, 0 warn, 1 info)

ℹ️ info — dynamic check skipped — skipped by options

  • skipped by options
inference — 1 findings (0 block, 0 warn, 1 info)

ℹ️ info — no ship-claims extracted — skipping cloud inference

  • parser returned empty claim list; nothing to verify against cloud
kb_query — 1 findings (0 block, 0 warn, 1 info)

ℹ️ info — KB: 69 recent scenario runs, 209/289 events ok (fail rate 27.7%)

  • most recent: scenario-2026-04-21T05-29-34
  • recent failing sigs: 5745bcd5e4c68591, 5745bcd5e4c68591, caeeeffc69d36009

Metrics

{
  "audit_duration_ms": 73,
  "findings_total": 3,
  "findings_block": 0,
  "findings_warn": 0,
  "findings_info": 3,
  "claims_strong": 0,
  "claims_moderate": 0,
  "claims_weak": 0,
  "claims_total": 0,
  "diff_bytes": 7975
}

Lakehouse auditor · SHA 320009dd · re-audit on new commit flips the status automatically.

## Auditor verdict: ✅ `approve` **One-liner:** all checks passed (3 findings, all info) **Head SHA:** `320009ddf4de` **Audited at:** 2026-04-22T09:07:16.396Z <details><summary><b>dynamic</b> — 1 findings (0 block, 0 warn, 1 info)</summary> ℹ️ **info** — dynamic check skipped — skipped by options - `skipped by options` </details> <details><summary><b>inference</b> — 1 findings (0 block, 0 warn, 1 info)</summary> ℹ️ **info** — no ship-claims extracted — skipping cloud inference - `parser returned empty claim list; nothing to verify against cloud` </details> <details><summary><b>kb_query</b> — 1 findings (0 block, 0 warn, 1 info)</summary> ℹ️ **info** — KB: 69 recent scenario runs, 209/289 events ok (fail rate 27.7%) - `most recent: scenario-2026-04-21T05-29-34` - `recent failing sigs: 5745bcd5e4c68591, 5745bcd5e4c68591, caeeeffc69d36009` </details> ### Metrics ```json { "audit_duration_ms": 73, "findings_total": 3, "findings_block": 0, "findings_warn": 0, "findings_info": 3, "claims_strong": 0, "claims_moderate": 0, "claims_weak": 0, "claims_total": 0, "diff_bytes": 7975 } ``` <sub>Lakehouse auditor · SHA 320009dd · re-audit on new commit flips the status automatically.</sub>
profit added 2 commits 2026-04-22 09:11:15 +00:00
After merging main (with the UpsertOutcome struct-like enum shape
from PR #2), the 4 new upsert tests needed pattern-match updates:
  UpsertOutcome::Added(_) → UpsertOutcome::Added { .. }

9/9 upsert tests pass.
profit merged commit b82caa9971 into main 2026-04-22 09:11:16 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: profit/lakehouse#3
No description provided.