Skip to content

A secret store restore ties an original only to a page that still holds its marker (GST-3178) - #9806

Merged
capy-ai[bot] merged 44 commits into
masterfrom
secret-restore-marker
Nov 19, 2026
Merged

capy-ai[bot] merged 44 commits into
masterfrom
secret-restore-marker

Conversation

@garrytan

@garrytan garrytan commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

A secret store restore now ties an original only to the page at its backed-up slug, and only while that page still holds the entry's marker. A page that merely took an old slug never gets the original, so its readers never pass the reveal_secret read check for it.
This closes the restore gap #9796 listed as a known limit. A restore can't bring back an original that a purge removed.
Nothing to do.

What changed
  • Restore checks the marker. insertBackupRows (src/core/secret-store/store.ts) puts a backed-up place back only when the page at its slug holds the full marker <REDACTED:<rule>:<id>>. It looks in the page's own columns, raw data, timeline entries, takes, link contexts and facts (pageHoldsSql in the new marker-sql.ts). For a page stored in segments it reads the segments.
  • Restore pins the page it checked. It locks the pages it checks (FOR SHARE, which both PGLite and Postgres accept). Each place is written with the checked page's id, and only while that page still has the slug. So a rename running at the same time can't hand the original to a page that takes the slug.
  • Nothing restored without a page. An entry recorded only on pages, none of which holds its marker, is skipped and counted in skipped_no_page. That covers a page that was purged, isn't synced yet, or was renamed before the backup was taken. An entry whose places all failed to land, because its page was purged while the restore ran, is taken back out.
  • Renames are unchanged from master. A place with no page id still moves with the renamed page.
  • Changelog. The fragment is marked important: security. It says a full copy of the marker still counts as holding it, and it replaces 0.60.744.0's note promising that such an entry would come back without a place.
Tests

New cases in test/secret-store-purge.test.ts pass on PGLite and Postgres:

  • A page at the old slug without the marker gets nothing.
  • The marker counts in segments, frontmatter, raw data and timeline entries, and a segmented page without it gets nothing.
  • An entry whose page is gone before its place lands is taken back out. Simulated with a trigger.
  • A page that takes the slug during the restore gets nothing. Simulated with a trigger; red before the pin.
  • A rename moves a place with no page id, so a page that later takes the old slug gets nothing.

Local runs on the final head: purge suite 25 on PGLite and 51 on Postgres, backup suite 13 on Postgres, rename suite 16, SQL-text golden 15. Typecheck, the raw-SQL and page-body-readers ratchets, semgrep on the changed files and gitleaks are all clean.

Agent notes

Open notes from review. None of them blocks; each was decided by the owning lead.

  • An allowed entry is still deleted with its last page, by decision.
  • A restore and a purge of the same page running at the same time can, in one ordering, leave the original behind. In another ordering they deadlock, and Postgres aborts one side with a clean rollback.
  • A rename's leftover place is matched by the slug. reveal_secret trusts a commit occurrence's slug (GST-3065).
  • A copy of the full marker counts: one in the page, or in a timeline entry or fact filed on it, including one written by another page through event_page_id. The guide and changelog say so.
  • Pre-0.60.744.0 backups that name a page by a slug from before a rename now skip that entry. The "sync and rerun" hint doesn't help in that case.
  • A restore holds share locks on the pages it checks while it scans their text, which has no index.
  • A segmented body is re-read once per entry, and a missing segment aborts the whole restore.
  • The entry id isn't re-checked against the id format before it goes into the pattern. Backups are authenticated, so only a backup forged with the store key could exploit it.
  • No tests yet for the event_page_id path or for an entry the store already holds whose slug's page lacks the marker.
  • The take-back and the pin are tested with triggers only; there is no two-connection Postgres race test.

Review: an Astra fix round, then /ship (specialists, red team, Opus adversarial, GPT-6.1 Sol second-model review, targeted secret reader). The second-model review's restore-race blocker was fixed under an extra round granted by GBRA-108 at 04df027. A read-only full review at 5071243 found that the stricter rename behaviour this PR had added left places on reusable slugs. GBRA-108 ruled to revert that hunk to master with a test, and no further round.

Open in Capy

Agent notes
{"head":"04df0276f14eff36ed2b21bdd3c3d9c80928bd78","run":"ship-20261119T095011-a7ccda","status":"started","review_loop":{"passes":1,"blocking_found":1,"deferred":0,"noted":4,"fixed":3,"scope":"frozen","rounds":1,"dispatches":{"specialist":3}}}

garrytan and others added 30 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>
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>
…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.
…ds its marker (GST-3178)

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 9 commits November 19, 2026 09:29
…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>
…, and never undoes a racing purge

Review round 1: tying an old-backup entry to every page holding the marker would bind a copied marker, so that path is
gone and a stale-slug entry is skipped. The marker check matches a whole marker, the rename's page-less branch checks
only the page at the new slug, and an entry whose places all failed to land is taken back out.

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

/ship review: treating every page stored in segments as holding every marker let a restore tie an original to a large
page that took its old slug. Restore now reads that page's segments; the rename's page-less branch counts only what SQL
reads. Tests cover a marker in segments, frontmatter, raw data and a timeline entry.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Test the take-back of an entry whose page is gone before its place lands, and match the marker in segmented bodies with a fixed pattern instead of one built from the entry id (semgrep detect-non-literal-regexp).

Review-Finding: p1/specialist-batched#1 reader=specialist-batched
Review-Finding: p1/specialist-batched#2 reader=specialist-batched
Review-Finding: p1/red-team#1 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The restore now locks the pages it checks for the marker and writes each place with that checked page's id, only while the page still holds the slug, so a rename running at the same time cannot hand the original to a page that took the slug. The guide now says a copy of the marker in a timeline entry filed on the page counts as the page holding it.

Review-Finding: outside-voice#1 reader=outside-voice
Review-Round-Grant: GBRA-108 extra-round at 04df027
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…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>
Return the rename's handling of a place with no page id to what master does: it moves with the renamed page, so no page that later takes the old slug can reveal the original. The changelog now says a full copy of the marker still counts as holding it.

Review-Finding: v2/outside-voice#1 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot marked this pull request as ready for review November 19, 2026 10:50
garrytan and others added 5 commits November 19, 2026 10:51
…concept-purge-rebuild

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… 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 2bbdede into master Nov 19, 2026
231 of 232 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