Skip to content

Purge on a brain without a write owner removes the page's text from the write journal - #9835

Merged
capy-ai[bot] merged 58 commits into
masterfrom
f4-unmanaged-purge-redacts-journal
Nov 20, 2026
Merged

capy-ai[bot] merged 58 commits into
masterfrom
f4-unmanaged-purge-redacts-journal

Conversation

@garrytan

@garrytan garrytan commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

On a brain without a write owner, the automatic purge now removes a purged page's text from the write journal too, including journal rows written while the brain had a write owner. Before, those rows kept the page's stored requests, timeline entry text and edit diffs after the page itself was gone.

What changed
  • Every way such a brain hard-deletes a page now redacts the page's journal rows in the same transaction: the bulk expiry, the per-page expiry for sources the belief ledger covers, and the concept rebuild that replaces a held concept. Each declares the persistence protocol first, which the journal's guard trigger requires.
  • The redaction (redactExpiredPageJournal in page-purge.ts) pages through every row in sequence order, 1,000 at a time. It clears the stored request and removes the text that the page's timeline receipts and edit receipts keep, compacted ones included. A request still pending keeps its stored request.
  • An explicit gbrain delete --purge now also removes the diff kept in the page's compacted edit receipts. It shares the receipt lookup with the expiry.
  • The engine's bulk purge now also returns the pages it deleted, with their sources, so the redaction is scoped per source.
Tests

test/purge-unmanaged-redacts-managed-journal.test.ts runs on PGLite and Postgres. It covers the bulk expiry, the belief-ledger expiry and the explicit purge, each with timeline and edit receipts, compacted ones included. The two expiry tests fail on master. Related purge suites also pass: concept purge rebuild, page purge, purge eval fixes, claim sweep, belief-ledger purge, engine parity pages, concept hold and parks. Verify passes 103/103 and typecheck is clean.

Agent notes
  • F4 from the Purging a retired atom soft-deletes concepts that were already re-synthesized without it (derivation_inputs edges are never replaced) #9653 design audit (GBRA-635). A fix to a diagnosed finding, so no plan round (R40).
  • /ship review: the full panel ran at be1d59a, and its two blocking findings were fixed at 74c1c74 (the 10,000-row stop, and timeline receipt text). The red-team reader's missed concept-rebuild path was fixed too. GBRA-108 granted one scoped fix-check (a-784a2b718c09: "GBRA-108 grants one scoped fix-check of the round-2 redaction fixes on Purge on a brain without a write owner removes the page's text from the write journal #9835, 2026-11-19"). It ran at 74c1c74, and its one blocking finding (edit-receipt diffs) was fixed at 51499af. gstack 1.101.0.0 has no --owner-ref; gstack-ship-release finish stops with "behavior, tests or build inputs changed since review", so this PR has no /ship receipt and lands by hand.
  • Noted, not fixed: counters are locked after page keys (at worst a deadlock, retried next run); pending requests keep their stored request; one redaction error rolls back the whole bulk expiry; other pages' requests that quote a purged page are swept only by an explicit purge.
  • Also noted from the fix-check: no test pages past one 1,000-row batch or drives the concept rebuild path; a bulk expiry's redaction is unbounded in time; deleting an expired archived source (deleteSourceRow) does not touch the journal, a gap that predates this PR.

Open in Capy

garrytan and others added 26 commits November 19, 2026 14:07
…s (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…els into fundraise (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… reads (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…aces too (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ll commands, no crash line on inspect, doctor re-checks the host skill list

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… so every reader sees the old value end (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…of failing the write (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…es and Postgres arm in their inventories (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…-running full setup

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…L.C. as LLC; judge restricted pages in the engine scope (GST-3127)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…he scoped check

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…y lets it load; bound doctor's skills list probe at 20 s

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…olicy lets the plugin load

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…tials never read as a title

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…blish at once, keep the newest-first fact scans on their index, and stop folding runway, loan and target labels into fundraise (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ng does

The owner-only tests built their engines without the connect-time version
read, so on a snapshot-restored PGLite or a cloned Postgres brain the
restricted-page check fell back to treating every page as owner-only.
The two new owner-only tests also wrote the source config as a JSON
string on Postgres; they now write a real JSON object.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…w each reader's trust floor and access, so they go to a follow-up (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…art instead of matching or merging it, and keep managed imports as read (GST-3170)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…approved

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ules at their previewed prefix

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 3 commits November 19, 2026 17:08
…6143)

The race hunt planned each shard at 55 minutes of tests while the shards of
the 2026-11-19 nightly took 30 to 45 minutes with setup, so the 3-iteration
floor filled long before the runners did. Re-mine the stress iteration
weights from that night's 24 shard logs, and schedule the files listed in
test/postgres-unit-arms.txt before the importers of changed helpers, so a
widely imported helper can no longer push listed arms out of the night.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…cept rebuild included

The unmanaged expiry now pages through all of the purged pages' journal rows instead of stopping at the first 10,000, redacts the entry text kept in their timeline receipts (compacted ones included) as an explicit purge does, and the unmanaged concept rebuild's hard purge redacts too.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…included

The edit_page receipt keeps a unified diff of the page text in its outcome. Both the unmanaged expiry and the explicit purge now read the page's edit receipts with its timeline receipts and redact that diff.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
garrytan and others added 20 commits November 19, 2026 22:14
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…page writes strip U+0000

Frontmatter parsing now removes U+0000 for page writes, which also reached two
readers that must not change:

- Rename identity (S-51) read a frontmatter title holding U+0000 with the character
  removed. Such a title reads as no value again, so the pair takes the
  unconfirmed-rename path and never matches a page with the plain title. A lone
  surrogate still reads as no value, as before.
- The skill resolver's module graph gained src/core/text-safe.ts through
  data-frontmatter.ts. The helper now lives in data-frontmatter.ts itself, so the
  resolver loads exactly the modules it loaded before.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The mock's first prose answer now gets one re-ask (#9648) before the job
falls back, so the mock answers that re-ask in prose too and the agentic
loop's tool call moves to the third call. Every assertion stays; the call
count floor rises from 2 to 3.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai capy-ai Bot added the full-ci Maintainer-only: run the full Test and E2E suite on this PR head label Nov 20, 2026
@github-actions github-actions Bot removed the full-ci Maintainer-only: run the full Test and E2E suite on this PR head label Nov 20, 2026
garrytan added a commit that referenced this pull request Nov 20, 2026
@capy-ai
capy-ai Bot merged commit d6edf6c into master Nov 20, 2026
227 checks passed
This was referenced Nov 20, 2026
garrytan pushed a commit that referenced this pull request Nov 20, 2026
…ture-dated fact order, purge receipts

Brings master up to 3132308 (10 commits, including #9834 handover
preview binding, GST-3170 fact ordering, #9835 purge without a write
owner, and #9838 gbrain identity). No new schema migrations.

Conflicts (3): docs/architecture/key-files/memory-purge.md (master's
intent-redaction and page-purge text, the trunk's Rust raw_sql line),
src/core/search/fact-relevance.ts (kept the trunk's
engine.listFactsForRelevance call; master's new SQL moved into
engine-sql), test/fixtures/goldens/exports/types.json (regenerated).

Parity ports so a Rust brain answers like PGLite and Postgres:
- listFactsByEntity and the relevance entity arms rank a fact dated in
  the future by when it was written (engine-sql/facts-trust.ts and the
  Rust store). New parity test fact-future-order: red on PGLite (old
  engine-sql) and on Rust (old addon) 0/1; green 1/0 on PGLite,
  Postgres and Rust.
- purgeDeletedPages returns the purged pages on a real run too (Rust
  store), as master's engine-sql now does. pages parity on Rust: red
  38/1 (realHasPages), green 39/0 on all 3 arms.

Master's new tests on 3 arms (PGLite / Postgres / Rust): handover
8/16/8, owner-identity 12/24/12, doctor-owner-identity 5/10/5,
strip-nul 4/7/4, purge-unmanaged 3/6/3, facts-future-valid-from
1/2/1, all 0 fail. verify 104/104, cargo gbrain-store + gbrain-napi
1255/0.
garrytan pushed a commit that referenced this pull request Nov 20, 2026
… and Postgres do

Master's purgeDeletedPages (#9835) now returns
pages: [{ slug, source_id, deleted_at }] on the destructive run too, and the
purge-deleted journal redaction reads that list. The Rust store returned the list only
on a dry run, so a purge on a Rust brain would skip that redaction. The shared parity
case 'purgeDeletedPages skips excludeIds and treats an empty list as no filter' failed
on the Rust arm before this change and passes after it.
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