Skip to content

fix(dash): delete declaration_text with retention and account purge - #1472

Merged
amiddavid merged 2 commits into
mainfrom
feat/declaration-text-purge
Nov 26, 2026
Merged

amiddavid merged 2 commits into
mainfrom
feat/declaration-text-purge

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior change: needs a human yes.

  • Who: every account on a dashboard database with content capture on.
  • Old: stored tool declarations and system prompts stayed in declaration_text for ever. Retention and an account purge did not remove them.
  • New: retention, a size trim, an archive move and an account purge remove the text when the last declaration that names it goes. A start-up sweep removes rows left over from before.
  • Turn it off: no switch. Remove the text step from trg_tool_inventory_gc (dash/schema.go) to restore the old behavior.

Summary

Closes #689. Stored prompt text is customer data. It now follows the request rows it came from.

What changed

  • Trigger. trg_tool_inventory_gc now deletes declaration_text rows first. It deletes a row only when no other (tenant, session) declaration row names the same hash. A shared row stays.

  • One path for all deletions. Retention, size trim, archive and account purge all delete from requests. The trigger covers all of them. No new delete path.

  • Old databases. The trigger is dropped and created again on open. CREATE IF NOT EXISTS would keep the old one.

  • Index. New partial index idx_tooldecl_text_hash makes the "still named?" check cheap.

  • Start-up sweep. sweepOrphanDeclarationText removes rows already orphaned. It runs once before the dedupe backfill.

  • Writer memo removed. invWriter.storedText assumed nothing deletes from declaration_text. That is no longer true. The writer now runs one INSERT ... ON CONFLICT DO NOTHING per distinct text per transaction.

  • Data dependence. The row dashboard-database says when the text is deleted. The level does not change. docs/data-dependence.md is regenerated.

  • Writer cost. One INSERT ... ON CONFLICT DO NOTHING per distinct text per transaction, on the background writer only.

  • Writer lag. An orphan row from a late write waits for the next start sweep.

How a row still in use is kept

  • The delete runs only when the session's last request row goes.
  • It skips any hash that another declaration row names (another session or account).
  • Both happen in one transaction, so the writer never sees a half state.

How it was tested

Local tests: waived (owner rule)

macOS, Go 1.27.4, no -race:

  • go test ./dash/ -run 'DeclarationText|PartialTrim|PurgeTenantRemoves|WriterRestores|SweepRemoves|OpenReplaces|Retention|WriterForgets|Dedupe' passes.
  • go test ./dash/ passes (92 s).
  • New tests in dash/declarationtextpurge_test.go: retention removes text and keeps shared text. A partial trim keeps text. A purge removes one account and keeps shared text. The writer stores text again after a purge. The sweep removes only orphans. An old trigger is replaced on open.

Open questions

  • Is the start-up sweep wanted for existing deployments? It deletes old orphan rows once.

Stored tool declarations and system prompts stayed in declaration_text
after the requests they came from were deleted (#689).

The inventory trigger now deletes a text row when the last declaration
row that names it goes. It keeps a row that another session or account
still names. A partial index on tool_declarations(text_hash) makes the
check cheap. A start-up sweep removes rows orphaned before this change.

The writer no longer keeps a memo of stored hashes. The trigger can
delete a row at any time, so the memo could point new rows at missing
text.

Closes #689

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 767d6bc45f71 blocking

Verdict: blocking

Findings

  1. docs/data-dependence/page.md.tmpl:331 — the technical-notes table still says retention and size limits do not remove declaration_text
    • What fails: a user reads docs/data-dependence.md:389 (generated from this template) and sees two opposite claims on one page. The "Does not turn off" column of --dashboard-retention and size limits lists declaration_text. The Dashboard-database row, which this PR edits, says "Retention, a size trim, an archive move and an account purge remove it when the last declaration that names it goes." After this PR the table cell is false: every deletion path goes through DELETE FROM requests (dash/store.go:883, dash/store.go:1365), and the new trigger fires on each.
    • Proof: grep -n "dashboard-retention" docs/data-dependence.md → line 389 lists declaration_text under "Does not turn off". The PR diff touches features/dashboard-database.md and the generated page's row, but not page.md.tmpl. The data-dependence page is the record CLAUDE.md mandates for what each switch deletes, and this PR's whole change is that deletion behavior.
    • Fix: edit the --dashboard-retention cell in docs/data-dependence/page.md.tmpl (drop declaration_text from "Does not turn off", or say it follows the declarations). Run go run ./cmd/gen-datadep. Commit the template and the regenerated page.

Non-blocking

  • docs/data-dependence/page.md.tmpl:238 (generated page line 296): audit finding 3 still says "Nothing deletes declaration_text". The section is a dated record of the audit at commit 2a7a86f, so leaving it is defensible. But this PR closes that finding (#689). A short "fixed by #689" note would stop the page disagreeing with itself.
  • dash/dedupetext_test.go:461-465: the comment on TestWriterForgetsTextFromARolledBackTransaction still explains invWriter.storedText. This PR removes that field. A reader looks for a field that is gone.
  • dash/schema.go:778: the comment says "the delete above counts the other users first". The trigger lives below the table comment, in additiveDDL2. "Above" points the wrong way.
  • Perf, acknowledged: the memo removal re-issues one INSERT ... ON CONFLICT DO NOTHING per distinct text per transaction. The removed comment measured ~87k such inserts over the corpus, each binding a kilobyte or two. The code comment and the PR body state the reason (a memo would point at purged bytes). The cost is a conflict discard. Acceptable.

What I checked

  • Full diff, all 7 files, and the code around each change.
  • Trigger correctness. The text delete runs before the declaration delete, in one statement. The "other user" check is scoped by (tenant, session), which matches the writer's key. Shared text survives a purge of one namer. Tests cover same-tenant and cross-tenant sharing.
  • Deletion paths. Every path that removes a session deletes from requests: dash/archive.go:346, dash/janitor.go:416, dash/purge.go:143, dash/store.go:883, 1135, 1365, 1499, dash/schema.go:1155. The trigger covers each. The PR body's "no new delete path" claim holds.
  • Fail-open and the read invariant. The writer stores text and its naming rows in one transaction. The trigger removes text and its namers in one statement. The sweep removes only rows no declaration names. So no committed state names a hash whose bytes are gone, and the reader (declTextJoin, a LEFT JOIN with COALESCE) tolerates a missing row anyway. A sweep failure logs a warning and the recorder starts anyway.
  • Sweep placement. It runs in dedupeLoop (dash/capture.go:347) at every recorder start, before the dedupe backfill. The dedupe marker's short-circuit sits inside dedupeDeclarationText, after the sweep, so the sweep runs even on databases whose backfill is done.
  • Writer memo removal. No code references storedText or rememberText after the change. The rolled-back-transaction test keeps its database-level assertion. The restore-after-purge test covers the case the memo would have broken.
  • Old databases. additiveDDL2 runs on every open, on both paths, so the DROP plus CREATE replaces the old trigger. OpenReadOnly runs no DDL, so the unconditional DROP does not break read-only opens. TestOpenReplacesTheOldInventoryTrigger covers the replacement.
  • Data dependence. The new paragraph matches byte-for-byte between features/dashboard-database.md and the generated page. The level does not change; only the deletion time does. The row-file procedure was followed, except for the template cell in finding 1.
  • Host boundary and client rules. The change extends the dash database's own schema and lifecycle. No Cortex-visible behaviour, no client rules, no route-path lookups.
  • Behavior change. The PR names it at the top, with old and new behavior and how to turn it off. Round 1: I did not read the PR comments, so I cannot confirm the human yes is recorded. Merge requires it.
  • Tests were not run. Live tests are not approved for this review.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 767d6bc45f71 blocking

Verdict: blocking

Findings

  1. dash/schema.go:850 — the recreated trigger can fail a concurrent open, and a failed open hides all history

    • What fails: two processes run dash.Open on the same file at the same time (a proxy restart while cmd/cg-backfill-project starts, or two proxy instances on one file). additiveDDL2 runs DROP TRIGGER and CREATE TRIGGER as two separate auto-committed statements. If both processes run their DROP before either runs its CREATE, the second CREATE fails with "trigger trg_tool_inventory_gc already exists". migrate returns the error, Open fails, and NewRecorder (dash/capture.go:273) falls back to an in-memory database. The dashboard then looks healthy and records nothing to disk.
    • Proof: dash/schema.go:849-850 issues DROP TRIGGER IF EXISTS then a bare CREATE TRIGGER. modernc.org/sqlite executes the multi-statement string statement by statement, each in its own auto-commit, so SQLite's write lock serializes single statements, not the pair. The codebase already treats this exact case as real: runImportedHistoryPurge (dash/schema.go:1158) uses INSERT OR IGNORE because "two processes opening the same old database" happens, and the schema comments call the in-memory fallback the worst outcome ("the dashboard comes up looking healthy with every row of history gone. Observed doing exactly that."). The window is narrow — the two statements sit microseconds apart — but the fix costs nothing.
    • Fix: write CREATE TRIGGER IF NOT EXISTS trg_tool_inventory_gc .... The DROP above still replaces an old build's trigger; the IF NOT EXISTS only stops a second process from failing on the first one's identical trigger.
  2. dash/dedupetext.go:263 — the dedupe backfill now aborts its pass when the new trigger deletes a hash between its two transactions

    • What fails: the backfill migrates a session's rows (tx 1 inserts declaration_text and sets text_hash). Before tx 2 verifies and clears, a concurrent retention or purge pass deletes that session's last request row. The new trigger then removes the text row too, because no other declaration names it. Tx 2's read (SELECT text_gz FROM declaration_text WHERE hash = ?) returns sql.ErrNoRows, and dedupeOneBatch returns it as an error. dedupeDeclarationText stops the whole pass and logs "stopped early". Before this PR nothing deleted from declaration_text, so this error path was unreachable.
    • Proof: dash/dedupetext.go:262-265 returns the scan error. The design comment at dash/dedupetext.go:248-251 says a row that "was deleted by the GC trigger" between the two transactions "is not an error" — but that comment covers the tool_declarations row; the code now also loses the declaration_text row and takes the error path. The rows the backfill walks are the oldest (rowid order), which is exactly what retention deletes, so the overlap is more likely than random. No data is lost and the next start resumes, but the migration can stop early on every start while retention runs, and the code's own stated intent is to skip, not abort.
    • Fix: treat sql.ErrNoRows from that read as "the row went with its session": skip the row (do not clear) and continue the batch.

Non-blocking

  • dash/dedupetext_test.go:460-468 — the comment describes the removed storedText memo. The test still asserts the right things, but its doc paragraph explains machinery this PR deleted. Rewrite it around the per-transaction done map.
  • Writer cost of the removed memo (dash/toolinventory.go:977-989). Every transaction now re-issues one INSERT ... ON CONFLICT DO NOTHING per distinct text, binding the gzip blob each time. The removed comment measured ~87k such inserts over the corpus. This runs on the background writer goroutine, so it does not touch the request path, and the trade is required for correctness (a memo would point at purged bytes). Worth a line in the PR, not a change.
  • Orphans from writer lag wait for the next start. A capture that lands after retention deleted its session's request rows writes declarations and text that nothing names. The sweep only runs at start. Bounded and small, but it is a steady source, not only the "rows orphaned before this rule" the comments name.
  • The human's yes for the behavior change. The PR names the change at the top, as the rules ask. Round 1 forbids me to read PR comments, so I could not verify that a human said yes. The integrator should check that before merge.

What I checked

  • Read the full diff and the code around each change: dash/schema.go, dash/toolinventory.go, dash/dedupetext.go, the new test file, and both docs files.
  • Traced every DELETE FROM requests path against the new trigger: retention (PruneWith), the size rule (pruneBySize, DropOldestSessions), disk-pressure eviction (evictSessions, both the archive and the delete fallback), the archive moves (ArchiveSessionContent, ArchiveSessionFull), PurgeTenant, trimTenantToQuota, and the imported-history purge. All fire the trigger; none deletes tool_declarations before requests, so the trigger's subquery always sees the session's own rows. The archive objects hold request events only, so no reachable data is lost on an archive move.
  • Checked the trigger's SQL semantics: the text delete runs before the declaration delete inside one trigger body; the NOT EXISTS probe excludes the dying session's own rows by (tenant, session); NULL text hashes are filtered; the new partial index idx_tooldecl_text_hash covers the probe, and addColumns adds text_hash before additiveDDL2 runs, on both the fresh and the existing-database path.
  • Checked the writer invariant the PR relies on: blob-first insert order, the per-transaction done map, and ON CONFLICT DO NOTHING. A text row deleted between two writer transactions is re-inserted before any declaration names it, so no committed state points at missing bytes. The memo removal is required for this, not just safe.
  • Checked the sweep: it runs before the dedupe backfill on the shared migrations goroutine, and its single DELETE cannot observe the writer's half-committed state (SQLite allows one writer at a time).
  • Checked the open/upgrade path: migrate runs additiveDDL (creates declaration_text) before additiveDDL2 on both paths, and migrateToolUsesProject's trigger drop is still followed by additiveDDL2's create.
  • Read the new tests and the helpers they use (storedTexts reads through the same join the reveal serves, so the assertions test the real read path).
  • Checked the data-dependence rule: the row file docs/data-dependence/features/dashboard-database.md and the regenerated page carry the same new paragraph, the level does not change, and the PR says so at the top.
  • Read the PR description (not the reviews or comments). Did not run builds or tests; live tests are not approved for this review.

- Create the GC trigger with IF NOT EXISTS after the DROP, so two
  concurrent opens do not fail.
- The dedupe backfill skips a row whose text the trigger removed
  between its two transactions, and keeps the batch.
- The data-dependence page no longer says nothing deletes
  declaration_text; audit finding 3 is marked fixed by #689.
- Fix two stale comments. Make the retention test count orphan rows
  in the table, so it fails on the old trigger.

Refs #689

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 1 replies. All findings are fixed in 68368748.

Reviewer 1

  1. dash/schema.go:850, concurrent open: fixed. The trigger is now DROP TRIGGER IF EXISTS, then CREATE TRIGGER IF NOT EXISTS. A second process no longer fails on the first one's trigger.
  2. dash/dedupetext.go:263, backfill aborts: fixed. sql.ErrNoRows on the verify read now skips the row, and the batch continues. The new test TestBackfillSkipsATextRowTheTriggerRemoved fails with "the batch aborted" when the check is removed.
  • Non-blocking: the stale storedText comment in dedupetext_test.go is rewritten. The PR body now states the writer cost and the orphans from writer lag.

Reviewer 2

  1. docs/data-dependence/page.md.tmpl:331: fixed. declaration_text is no longer under "Does not turn off" for retention and the size limits. The page is regenerated.

Extra check: the new tests fail on the old trigger.

  • Fail on the old trigger: TestPurgeTenantRemovesDeclarationText, TestWriterRestoresTextAfterItWasPurged, TestOpenReplacesTheOldInventoryTrigger, TestRetentionRemovesDeclarationTextButKeepsSharedText.
  • The retention test passed on the old trigger at first, so it was too weak. It now counts orphan rows in declaration_text itself.
  • TestPartialTrimKeepsDeclarationText passes on both, as expected: it guards the keep case.

Tests: go test ./dash/ passes (macOS, Go 1.27.4, no -race, 94 s).

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 6836874881d8 approve

Verdict: approve

Findings

None. Both round-1 findings are fixed and verified. No new defect in the new commit.

Earlier findings

  • Reviewer 1, finding 1 (dash/schema.go:850, concurrent open fails on the trigger CREATE): fixed. The DDL is now DROP TRIGGER IF EXISTS then CREATE TRIGGER IF NOT EXISTS (dash/schema.go:850-851). I checked every interleaving of two concurrent opens: each process drops first, so no old trigger survives, and the second CREATE is now a no-op instead of an error. A failed migrate and the in-memory fallback can no longer come from this pair. The new comment states both reasons for the DROP-plus-IF-NOT-EXISTS shape, and it is accurate.
  • Reviewer 1, finding 2 (dash/dedupetext.go:263, the backfill aborted when the trigger removed a hash between its transactions): fixed. The verify read now treats sql.ErrNoRows as "the row went with its session" and skips it, keeping the batch (dash/dedupetext.go:266-271). I checked the skip is safe in both states it can meet: if the declaration row is gone (the normal case — the same trigger statement that removed the hash removed the row), there is nothing to clear; if the row somehow survives, its text_gz was not cleared, so the reader's COALESCE(t.text_gz, d.text_gz) still serves the text. The new test drives the real trigger through a seam between the two transactions and fails with "the batch aborted" without the fix.
  • Reviewer 1, non-blocking items: addressed. The stale storedText comment on TestWriterForgetsTextFromARolledBackTransaction is rewritten around the no-memo design. The PR body now states the writer cost and the writer-lag orphans.
  • Reviewer 2, finding 1 (docs/data-dependence/page.md.tmpl:331, the switch table still listed declaration_text under "Does not turn off" for retention and size limits): fixed. The cell now lists only tenant_spend and archived_sessions, and the regenerated docs/data-dependence.md carries the identical change. I checked both hunks match each other.
  • Reviewer 2, non-blocking items: addressed. Audit finding 3 in the template and the page now says "Fixed by #689". The schema.go comment says "the delete below", which is the right direction. The test comment is rewritten (same item as mine).

New code in this commit

  • TestBackfillSkipsATextRowTheTriggerRemoved (dash/dedupetext_test.go:518-542): sound. It seeds two legacy rows, deletes one session's requests through the real trigger via the seam, and asserts the batch completes and the surviving row migrates. I traced the hashes: only the "gone" session names its hash, so the trigger removes it, the read misses, and the skip path runs.
  • dedupeAfterCommit (dash/dedupetext.go:300-301): acceptable. A package-level test seam, nil in production, commented as a seam, reset by a defer in the test. Not a defect.
  • The strengthened retention test (dash/declarationtextpurge_test.go:54-64): correct and stronger. Counting orphan rows in declaration_text itself closes the gap the author found — the reveal goes through declaration rows, which are gone under both triggers, so the old assertion could not see an orphaned text row. The NOT IN subquery filters text_hash IS NOT NULL, so NULLs cannot make the predicate never-true.

Non-blocking

  • The human's yes for the behavior change is still not visible in the conversation. The PR names the change at the top, as the rules ask. The round-1 replies come from the PR author's account, so I cannot tell a human's yes from a session's reply. The integrator should confirm it before merge, as both round-1 reviews asked.
  • The DROP + CREATE pair leaves the database with no GC trigger for the microseconds between the two statements. A DELETE FROM requests in that window would skip the inventory cleanup once. The next open recreates the trigger, and the start-up sweep plus the per-session trigger catch up. Not worth a change.

What I checked

  • Last review: round 1, 767d6bc, 2026-11-26T15:16:23Z.
  • New commits read: 1 — 68368748 "fix(dash): address review round 1 on declaration_text purge".
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from .review-in-reviews.txt, .review-in-comments.txt, .review-in-inline.txt).
  • New items since my last review, and what I did about each:
    • Commit 68368748 (17:22): read the full diff and the final state of each changed file at the new head. Reviewed above; no new finding.
    • Comment by amiddavid at 15:23:04Z (round-1 replies): checked each claim against the code. The "fixed" claims for both reviewers' findings hold. The "the retention test passed on the old trigger at first" observation matches the gap the stronger assertion closes.
    • PR body update: the two new bullets (writer cost, writer lag) match the code.
  • Verified the fix sites in the working tree at the new head: the trigger DDL (dash/schema.go:849-851) and the ErrNoRows skip (dash/dedupetext.go:266-271).
  • Confirmed the template and the generated data-dependence page agree with each other and with the code's new deletion behavior.
  • Did not run builds or tests; live tests are not approved for this review.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 6836874881d8 approve

Verdict: approve

Findings

None.

Earlier findings

  • Mine, round 1 (page.md.tmpl:331, retention cell): fixed. Both the template and the generated page drop declaration_text from "Does not turn off" for --dashboard-retention and size limits (page.md.tmpl:329, docs/data-dependence.md:390). The two edits are identical, so the generator stays in sync. The remaining declaration_text mentions on the page are the fixed audit finding and the --dashboard-content cell, both correct.
  • My non-blocking items: all fixed. Audit finding 3 now reads "Fixed by #689" with accurate wording. The schema comment says "below", not "above". The stale storedText test comment is rewritten around the current design. The PR body now states the writer cost and the writer-lag orphans.
  • Reviewer 1, finding 1 (concurrent open fails on the bare CREATE): fixed, and I checked it myself. The fix is DROP TRIGGER IF EXISTS then CREATE TRIGGER IF NOT EXISTS (dash/schema.go:852-853). Convergence argument: each process runs its DROP before its own CREATE, so in any interleaving of two processes the last statement is a CREATE IF NOT EXISTS, which cannot fail on existence. Every CREATE uses the new body, and both DROPs run, so an old-build trigger cannot survive. A brief window with no trigger remains (one process's DROP can remove the other's fresh trigger before its own CREATE). A purge in that window leaves an orphaned text row, which the next start's sweep removes. Fail-open and bounded. Not a defect.
  • Reviewer 1, finding 2 (backfill aborts when the trigger removes a text row between its two transactions): fixed, and I checked it myself. The verify read now treats sql.ErrNoRows as "the row went with its session" and skips it (dash/dedupetext.go:268-273). Placement is right: the hashes[i] == "" check comes first, and the skip is before the compare and the clear. The skipped row's declaration row is deleted by the same trigger statement that deleted the text, so nothing dangles. Even in a mismatch case the skip does not clear text_gz, so the row keeps its own blob and reads fine through the COALESCE. The sweep cannot race the backfill the same way: tx 1 commits the namer and the text together, so another process's sweep sees the namer. The new test TestBackfillSkipsATextRowTheTriggerRemoved drives the exact window through a seam between the two transactions.

Non-blocking

  • The human yes for the behavior change is still not recorded in the PR conversation. The PR names the change at the top and asks for the yes. The integrator should confirm it before merge.
  • dedupeAfterCommit (dash/dedupetext.go:301) is a package-level var with no lock. Safe today: no dash test calls t.Parallel(), and only one test sets it, synchronously. Worth a lock or a DB field if a second test ever uses it in parallel.

What I checked

  • Last review: round 1, 767d6bc, 2026-11-26T15:15:23Z.
  • New commits read: 1 (6836874 "fix(dash): address review round 1 on declaration_text purge").
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files in my folder).
  • New items since my last review: the fix commit, reviewer 1's round-1 review (2 findings, 4 non-blocking), and the author's reply comment. I verified each fix myself; see "Earlier findings".
  • The fix commit, file by file:
    • dash/schema.go: DROP plus CREATE IF NOT EXISTS, comment updated. Verified the convergence argument above.
    • dash/dedupetext.go: the ErrNoRows skip and the test seam. Verified the placement, the dangling-row argument, and that the skip cannot clear a blob it did not verify. The errors import is used.
    • dash/dedupetext_test.go: the rewritten comment is accurate. The new test's seam fires between the two transactions, deletes one session's requests, and the trigger removes that session's declarations and its text. The assertion checks the surviving session's row was migrated. The seam is reset with a defer.
    • dash/declarationtextpurge_test.go: the retention test now counts orphan rows in declaration_text directly, so it fails on the old trigger. The SQL filters NULL text_hash in the subquery, so NOT IN is safe.
    • docs/data-dependence/page.md.tmpl and docs/data-dependence.md: identical edits in both, so the generated page matches its source. All remaining declaration_text mentions on the page are correct.
  • Re-checked the full PR diff against base for anything the fix commit could have broken: the trigger body, the index, the sweep, and the writer are unchanged from the head I reviewed in round 1.
  • PR body re-read: it now states the writer cost and the writer-lag orphans, as the author's comment claims.
  • Tests were not run. Live tests are not approved for this review.

@amiddavid
amiddavid merged commit 7a02270 into main Nov 26, 2026
12 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 26, 2026
amiddavid added a commit that referenced this pull request Nov 26, 2026
Only the generated docs/data-dependence.md conflicted, after #1472. It is
regenerated with go run ./cmd/gen-datadep.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

privacy: nothing deletes declaration_text, not retention and not an account purge

1 participant