Skip to content

Concepts hidden by a purged input come back rebuilt from their current members (#9653) - #9794

Merged
capy-ai[bot] merged 36 commits into
masterfrom
gbra635-concept-purge-rebuild
Nov 19, 2026
Merged

capy-ai[bot] merged 36 commits into
masterfrom
gbra635-concept-purge-rebuild

Conversation

@garrytan

@garrytan garrytan commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

When a purge removes a page that a concept page was built from, the next concept synthesis on a brain without managed writes now deletes that hidden concept for good and writes a new one from its remaining members, so the old text never comes back.
Why: before this, a purged input left its concept soft-deleted and the purge then also hid every concept re-synthesized over it (#9653).
Nothing to do: it runs inside the existing synthesize phase. On a brain with managed writes the concept stays hidden, as today, until a follow-up (GST-3179) lands.

What changed
  • Synthesize phase. For each concept that an input purge hid, synthesis purges the tombstone with the purge's own code (purgeDeletedPages limited to that page id), then writes a fresh page at the same slug from current members only, in one transaction. The model never sees the old concept's text. Incoming links to the slug come back on the fresh page; concept-provenance edges are not carried, so a member that left gets a retraction and the current members' edges are written fresh.
  • Belief ledger. On a source the ledger records, the rebuild runs in one belief batch: the old page's lifetime ends as page.expired (retention, not a purge) and the fresh page starts its own.
  • Privacy dependents. A page that depends on the hidden concept for its privacy parks it before the delete; the park is kept and the rebuild writes nothing.
  • Kept hidden. A concept stays hidden when something a person or agent stated is attached to it (facts, tags, labels, curated ## Facets / ## Merged sections and similar, named by kind), when no chat model is configured, when the new page would be readable by more people than its members are, or when the brain has managed writes.
  • Previews. gbrain pages purge-deleted --dry-run, gbrain maintain --purge and the cycle's purge phase name each held concept and, for one kept hidden, why.
  • Delete receipt. Deleting a held concept states its true expiry; the tombstone date does not change.
  • Engine. purgeDeletedPages takes an internal onlyIds option (the type-surface golden changes by that one optional field).
Known limits
  • A brain with managed writes keeps a held concept hidden until GST-3179 re-checks the hold and the members inside the write owner's transaction. The managed code path is in this PR but switched off outside tests.
  • A brain with no chat model keeps such a concept hidden indefinitely. The preview says so. No new setting changes this.
  • A concept left with fewer than two members is not rebuilt; it stays hidden until an explicit purge, and the preview says so.
  • The rebuild's retention purge must stay outside any future record of "a person deleted this concept".
  • Out of scope, tracked on GST-3071: three related findings, and old body text left in journal rows written while a brain was managed (follow-up PR).
Open review notes (non-blocking)
  • The held-concept read in selectPurgeCandidates has no error fallback (the cycle's call has one); it also runs one stated-rows query per held concept.
  • With no chat model, the preview lists small concepts as kept although a deterministic synthesis could rebuild them.
  • Deleting an already-past held tombstone says "recoverable until the next purge", but the automatic purge keeps it.
  • On managed brains (inactive here, GST-3179): incoming links return only when the linking page is next imported; the stated-rows and member checks run before the purge is submitted.
Tests

test/concept-purge-rebuild-9653.test.ts (all pass on PGLite and on Postgres) covers the rebuild, the model request holding no tombstone text, the belief-ledger expiry and the provenance retraction, the park that survives a refusal, curated sections keeping a concept held (including a brain with no git repository), the managed guard leaving the tombstone and its revision unchanged, the managed purge path with the guard lifted, the single-page purge clearing exactly the stores the cutoff purge clears, and the previews. Existing purge tests: 154 pass unchanged.

Review of the final head (cc6008b, advisory)

After the last full review, cc6008b changed the hold (a hidden concept is rebuilt only when synthesis wrote everything on it) and the link carry (every column, with a census test). That head had red-then-green tests on PGLite and Postgres and one scoped second-model read, which is advisory and was not a full review round. Its findings are listed on GST-3179.

Sealed secrets on a hidden concept

A hidden concept whose page records a sealed secret original (a page-level secret occurrence) stays hidden, because the rebuild's purge would otherwise delete an original that nothing removes today. The cost: a concept that only copied a redaction from a live member also stays hidden until entries can be compared across pages (GST-3179).

Agent notes

Replaces #9777. GBRA-635. Follow-up: GST-3179.

Open in Capy

Agent notes
{"head":"812e66d5791095a9919a5b35a90549d049a13f48","run":"ship-20261119T055650-569ddb","status":"started","review_loop":{"passes":2,"blocking_found":1,"deferred":0,"noted":0,"fixed":3,"scope":"frozen","rounds":2,"dispatches":{"specialist":2,"red-team":2}}}

garrytan and others added 10 commits November 19, 2026 00:18
Admin used to hold the settings lock across the owner's Touch ID dialog,
so sends waited for it. Admin now works out the change from a snapshot,
asks with no lock held, then takes the lock, reloads, and applies the
change only if the settings still match what the dialog showed; otherwise
it answers overloaded and the owner reruns the command. A send reads and
checks its settings under the same lock admin saves under. Turning sending
off, removing a key and lowering a limit always save, so a failed write
reaches the caller. The CLI's wait for key and limit changes is the Touch
ID wait plus a minute.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The shared dispatch queue can hold new work behind blocked test work on a
small CI runner, so the background steps never started. Each step now gets
its own thread, and the lock test double restates its Sendable conformance.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Changes that need no Touch ID (off, removing a key, lowering a limit) now
read, change and save under one lock, and each such save counts. An
approval that was open while one landed is refused with overloaded even
when the saved value looks the same. send-setup --off exits with an error
when the helper answers but cannot save.

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

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

Each send checks the kill switch and its key again under the settings lock
right before it hands the text to Messages. send-setup --off releases the
config lock before an earlier setup's Touch ID wait can hold it, and an
approval given after the switch went off is refused. --off now says what
answered when the helper refuses.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…isabled for a setup approved after it

A text already being handed to Messages can outlast the CLI's wait, so
--off now exits nonzero when the helper doesn't confirm. A Touch ID
approval that would turn sending on after the switch went off answers
send_disabled before the overloaded check, and send-key remove waits as
long as --off.

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

send-setup --off now holds the config file lock until the helper has answered,
so a send-setup started meanwhile waits for it. A refused connection means the
helper isn't running: --off says so and exits 0, because the config switch
alone stops every send; 69 stays for a helper that doesn't answer in time.
The success text for --off and send-key remove says no new text is handed to
Messages, and that a text Messages has already accepted may still be delivered.

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>
… members (#9653)

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 7 commits November 19, 2026 05:56
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…gins before the purge; census row; preview wording

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/specialist-batched#1 reader=specialist-batched
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/red-team#2 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…hen the rebuild refuses

Review-Finding: p2/outside-voice#1 reader=outside-voice
Review-Finding: p2/outside-voice#2 reader=outside-voice
Review-Finding: p2/specialist-batched#1 reader=specialist-batched
Review-Finding: p2/adversarial-native#1 reader=adversarial-native
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…keep held concepts hidden until the write owner re-checks them (GST-3179)

Review-Finding: p3/outside-voice#2 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… it, and keep every link column

A hidden concept now stays hidden when its title is not the slug title, it has a frontmatter key synthesis does not
write, a stored timeline, a file other than <slug>.md, or dated link transitions. Incoming links the fresh page takes
over keep every column (link_kind, resolution_type, assertion_tense, created_at included), and a census test lists
each links and pages column so a new one cannot be dropped silently.

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

capy-ai Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Open notes from the final read-only review of afe2046 (none block on an unmanaged brain; carried to GST-3179 where marked):

  1. Purge previews can say "no model" for a concept with two to four members, which synthesis writes without a model. Low.
  2. selectPurgeCandidates calls readHeldConcepts with no catch, so an error there fails the real purge and status (purge-deleted.ts:308/322). GST-3179.
  3. A rebuild refused after the model call (readers, park, folder rule) is not counted by MAX_CONCEPT_ATTEMPTS, so it can cost one chat call per cycle until its state changes; each run stays inside the phase budget.
  4. A rebuild leaves the old row's needs_rederive mark behind as an orphan; it can never re-hold anything.
  5. Every soft delete now reads the retention setting; a failing read fails the delete.
  6. Managed: the purge commits before the publish. Unreachable while managed brains keep held concepts hidden. GST-3179.
  7. Derivation edges for the fresh page are recorded after the rebuild commits (concept-publication.ts:291); a brand-new concept has the same gap. GST-3179.

cc6008b changes the hold: a hidden concept is rebuilt only when synthesis wrote everything on it (title, frontmatter keys, timeline, sections, file path), and incoming links keep every column, with a census test over the links and pages columns. Its review is one scoped second-model read, advisory.

garrytan and others added 10 commits November 19, 2026 08:16
…son's edge decision, an identity or a guest mark

Attached raw_data, a rejected, undone or reverted edge proposal, an entity identity and a guest mark or promotion
each keep the concept hidden instead of being deleted by its rebuild. The census test now also lists every table
keyed to a page, so a new one has to be classified.

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

The exact-title lookup index was a btree on (source_id, lower(title)); a btree
entry must fit in 2,704 bytes, so a longer title stopped the v240 upgrade and
was refused on save. v240 and schema.sql now build a hash index on
lower(title), and v326 builds it online on brains that have the btree, then
drops the btree online. Transcript imports cap a new page's title at 200
characters. Reported by @mweber82.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… each test brain its own setup

The v326 drop runs DROP INDEX CONCURRENTLY on PGLite too, so the migration has
no engine-kind branch, and it returns without dropping while another session
still builds the hash index instead of throwing. The PGLite test builds each
brain in beforeAll and disconnects it in afterAll.

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

A brain restored from the test runners' schema snapshot does not replay
migrations after a rewind, so under bun run test and the stress gate the
upgrade scenarios never ran v240 or v326.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ndex is still building\n\nA transcript page written under the 200-character title cap no longer loses the cap on its next re-import; only a page stored with a longer title keeps it. v326 now fails instead of recording itself applied while another session still builds the hash index, so the next upgrade drops the old btree. Docs and TODOS name the new index.

Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/red-team#2 reader=red-team
Review-Finding: src/core/transcripts/ingest.ts:351:functional-contract reader=core
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…e locally

The test and e2e run profiles in .gstack/pregate.json now say their
runners are Linux. /ship's accept step only carries a CI run's tests
stage when the profile's os matches the machine, so without it a Linux
ship machine ran the whole selection again (or hit its time limit).
…ward the transcript title cap

schema.sql replays on every boot, where a plain CREATE INDEX on an existing
brain blocks page writes for the whole build and leaves v326 nothing to build
online. Like v270 and v284, the index is now built only by v240 and v326, each
online. A split transcript's part titles, suffix included, stay within 200
characters, so a capped part never measures as over the cap on re-import.

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>
…st runs

The test and e2e run profiles now require os: Linux, and gstack refuses a run
whose tree.json records no OS. scripts/ci-full-suite-tree.sh now writes os from
RUNNER_OS, and docs/ci-event-parity.md describes the field.
vorflux Bot and others added 4 commits November 19, 2026 09:14
…send-stop-wins

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

# Conflicts:
#	apple/helper/README.md
#	apple/helper/Sources/HelperCore/SendService.swift
#	apple/helper/Sources/gbrain-apple-helper/main.swift
#	apple/helper/Tests/HelperCoreTests/SendTests.swift
…concept-purge-rebuild

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 19, 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 19, 2026
garrytan and others added 3 commits November 19, 2026 10:39
…ssify the secret store for it

The rebuild's access comparison and the purge preview's member classification read the plain private-pages
fragment; neither serves a remote caller, so both are listed as maintenance sites. The secret store's two purge
tables are rows derived from the old page's text and are classified as such.

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

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 19, 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 19, 2026
garrytan and others added 2 commits November 19, 2026 11:12
… original

The rebuild's purge would delete a sealed original recorded only on the hidden concept's page, which nothing removes
today because the automatic expiry skips a held tombstone. A page-level secret occurrence now keeps the concept
hidden. A concept that only copied a redaction from a live member stays hidden too, until entries can be compared
across pages.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…t its slug with no page

The purge deletes a slug's page-level secret occurrences that name the purged page or no page at all, so the hold
now matches both, as the purge's own predicate does.

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 19, 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 19, 2026
@capy-ai
capy-ai Bot merged commit 8b6ebdf into master Nov 19, 2026
225 checks passed
@garrytan garrytan mentioned this pull request Nov 19, 2026
capy-ai Bot added a commit that referenced this pull request Nov 19, 2026
Releases v0.60.746.0 with five changes since v0.60.745.0, including a security fix: a secret store restore now ties an original only to a page that still holds its marker (#9806).
- Turning GBrain Helper's sending off now cancels a text that was still on its way, and `send-setup --off` only reports success when it can show the helper is stopped or has confirmed (#9791)
- A concept page hidden because one of its source notes was purged is now rebuilt from its remaining notes, unless anyone wrote something on it (#9794)
- An MCP client on the starter tool list can now say when a remembered fact was true by passing `valid_from` to `remember` (#9802)
- A secret store restore ties an original only to the page at its backed-up slug, and only when that page still holds its marker (#9806)
- Shipping a gbrain change no longer reruns the full test suite on the developer's machine when Linux CI already passed at the same code (#9805)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: garrytan <garrytan@gmail.com>
garrytan pushed a commit that referenced this pull request Nov 19, 2026
What users get from master in this sync:
- gbrain access member handover hands a leaver's pages to the owner (#9684)
- Duplicate-person linking now asks first and confirms people who share an id one at a time (#9762)
- Company-brain tutorial explains how imported calls are kept to their attendees; --propose heading fixed for partly matched calls (#9718)
- One-script install of GBrain Helper on a Mac that keeps its macOS permissions (#9816)
- The brain owner is told when a remote put_page kept private fact rows (#9760)
- The brain owner sees the same private fact rows in as_of and known_as_of reads as in get_page (#9733)
- Turning iMessage sending off cancels a text still on its way, and --off only reports success it can show (#9791)
- Starter MCP clients can date a remembered fact with valid_from (#9802)
- A secret store restore ties an original only to a page that still holds its marker (#9806)
- Concepts hidden by a purged input come back rebuilt from their current members (#9794)
- Nightly test of the OpenClaw skill-resolver plugin inside a real gateway (#9799)
- Version stamps v0.60.746.0 and v0.60.747.0 (#9814, #9828)

Conflict resolution: valid-time-read.ts keeps the trunk's engine-sql imports and adds master's owner fence view. The generated files (migration registry, CLI flag registry, raw-SQL baseline, export and migration goldens) take master's copy for now and are regenerated in the next commit. Master took migration v327 (access handovers), which clashes with the trunk's v327; the renumber follows.
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