Skip to content

Add confirmed Organization Brain deletion for admins - #1126

Open
AustinKelsay wants to merge 8 commits into
mainfrom
codex/org-brain-delete-prototype
Open

AustinKelsay wants to merge 8 commits into
mainfrom
codex/org-brain-delete-prototype

Conversation

@AustinKelsay

@AustinKelsay AustinKelsay commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Organization Brain admins can permanently delete a retired Brain from the dashboard or fbrain brain delete. Previously, deleting its folders left an empty Brain in everyone's list. The CLI release version is 0.9.0.

preview exact Brain, server, counts and state digest
  → explicit confirmation signed by the admin's own key
  → atomic authority, state and active-mount recheck
  → remove owned content and access; retain receipt and retired-ID marker

Organization Brains only; Personal Brains and non-admins are refused. Active cross-Brain mounts block deletion and identify what must be disconnected. Stale previews cannot be confirmed, exact retries return the original receipt, and older clients cannot recreate a retired ID. Deleted Working Trees stop syncing while preserving local files and unsynced paths. A server override cannot stop a tree bound to another server.

The dashboard signs with the account's Hosted Device key. Accepted UI limitation: the existing list follows the selected Agent's access; an admin whose Agent cannot see a Brain uses the CLI. No account-wide browser, trash, undo, restore UI or retention-policy change.

Evidence

  • Before: the empty Brain remained visible after Folder deletion. After: the built CLI, file-backed server, real Hosted Device and dashboard browser flow delete a synthetic V1 while preserving the other synthetic Brains' encrypted exports byte-for-byte.
  • The receipt-loss P2 is fixed at a94a1f1: invalid-UTF-8 Markdown or invalid local Agent State cannot suppress confirmed server success. The receipt survives with a separate bookkeeping warning and preserved local files. CLI library 269 passed, 2 existing ignored; real-process deletion suite 5 passed, including checksum-verified released fbrain 0.8.0, supervisor stop, server override, and isolated restore.
  • Store/server full suites passed 154/149. Fable independently reproduced deletion tests and an older server reopening the new database: surviving Brains remained usable and retired-ID reuse stayed blocked.
  • Fable 5.1 approved the combined deletion, names and people integration at 64f9c62c, with no blocking/high/medium findings. Root applied the small deletion copy/error fixes in this PR; the final combined content passed 19 focused unit/real-hosted-route tests, 4 browser tests, project typecheck, lint, production build and the real combined composition proof. The proof covers stale previews after invite/revoke/removal, private aliases, authoritative keys, stale-tab refusals and old-client non-resurrection.
  • The combined proof uses real Core/Postgres, Brain server, Hosted Device, production dashboard, Runner-rendered Caddy, packaged Hermes and CLI. WorkOS provider, Agent key pin, Core Hermes-access grant and Chat are fixtures. It does not qualify production or live OAuth.
  • Formatting, strict clippy, source-structure, Brain API/language and skills checks passed on the implementation. CI passed at the current head a992859c, including the required CI gate and every listed job: Rust, dashboard, Hermes, Brain acceptance, Nix service packages, devfinity and repository checks.

The original review defect is resolved and the reviewer confirmed source review passes. The formal GitHub changes-requested review remains in place and must be reconciled through the normal review process.

Merge Danger

Door: one-way for a confirmed deletion.

Blast Radius: Brain.

Deletion removes the selected Brain's owned data, history and access. Retired mount references naming it and their derived counters are cleaned up; other Brains' content, members, keys and records remain intact. A minimal permanent audience of npubs enables private terminal notices.

Landing order: #1126 → #1128 → #1127. The release coordinator is qualifying a scoped application source on retained production generation 6a923870; whole-main qualification does not authorize bringing unrelated trial-archive migrations into production.

Deploy the new Brain server and Hosted Device before deletion clients; Core before the names dashboard; qualify the Runtime image before enabling people controls. Use immutable CI artifacts, named backups, full hosted recovery gates, canonical pre/post status and disposable canaries. Publish fbrain/v0.9.0 only after green main CI and service verification.

SCHEMA_V31 is additive. The tested older server reopens it and blocks retired-ID reuse, but loses the new routes and 410 notices. Binary rollback does not restore deleted content. Restore pre-deletion backups onto an empty isolated target; the feature's Brain database/admin-key drill does not replace the full Hosted Recovery Set gate.

No deployment or production deletion has been performed. Linear remains unavailable because its connection requires reauthentication.

AustinKelsay and others added 5 commits October 25, 2026 23:27
A Brain admin previews the deletion, signs the preview's state digest into
a delete-brain admin access-change event, and the store rechecks admin
standing, Brain kind, active Mounts, confirmation age and the digest in the
same write transaction that removes every Brain-owned row. A permanent
deletion record outside the Brain foreign-key graph retires the id (a
database trigger refuses reinsertion), answers exact retries with the same
receipt, and lets only former readers see 410 Gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fbrain brain delete <brain-id> previews the server scope and digest;
--confirm <stateDigest> signs and deletes exactly that state, with one exact
retry after a transport failure. There is no flag that skips the preview.
When the server reports a Brain deleted, its Working Tree records the
terminal state with the unsynced paths it kept in place, and sync, daemon
watch and the supervisor stop contacting the server for it.

The process acceptance test drives the built fbrain against a real
file-backed server with synthetic V1, content-brain and
marketing-comms-brain: authority, stale previews with unchanged counts,
mounts in both directions, deletion by an Agent admin, invitation and token
failure, recreate refusal, a dirty stale client, restart durability, and a
restore of the pre-deletion backup onto an empty target. The FiniteBrain
skill routes Brain deletion through an exact-scope user confirmation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The selected Organization Brain gains a Delete Brain panel: it shows the
server's exact preview (server, name and ID, folders, pages, members,
guests, invitations, tokens, blocking mounts), requires typing the Brain
ID, and deletes exactly the previewed state. The route signs with the
account's hosted Brain key through the hosted device, the same delete-brain
event the CLI signs, and resends the identical signed deletion once if the
response is lost. A stale preview is refused and must be reviewed again.

Proof: unit tests pin the canonical event to finite-brain-core; a hosted
device test signs it and the Brain server accepts it; an opt-in route test
and an opt-in browser test drive the real hosted device and Brain server
binaries (FC_BRAIN_DELETION_PROOF_BIN_DIR). The web design fixture forwards
only Brain identity-provider calls to a real hosted device when asked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… proofs

The retired email-delegation tables keep their deployed column name, so
their deletion predicates now live beside the exempt schema migrations.
The process acceptance harness moves to its own module, and the
supervisor test no longer writes a page between the admin's preview and
confirmation: a concurrent push correctly invalidated the preview.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Documentation census

This PR adds 0 new Markdown files and 105 lines of Markdown, and removes 0 Markdown files and 7 lines of Markdown.

Net documentation change: +98 lines.

Counts .md and .markdown files anywhere in the repo, case-insensitively. Lines include additions and deletions across all matching files; net change is additions minus deletions. Renamed files are not counted as new or removed. Advisory only; never a merge gate.

@AustinKelsay AustinKelsay changed the title Prototype confirmed Organization Brain deletion for admins Add confirmed Organization Brain deletion for admins Oct 26, 2026
@AustinKelsay
AustinKelsay marked this pull request as ready for review October 26, 2026 23:40

@alexlwn123 alexlwn123 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fail for now — one P2 failure-reporting defect in the confirmed CLI deletion path (inline). The server can permanently delete the Brain, then local Working Tree bookkeeping can suppress the accepted receipt and return only a local error.

Reviewed 084939f57dce6fac014b1f1408a246a394387396 against 534416b04fa62ddb5be922b067b98b8a1a1ba00b, tracing store transactions/schema retirement, signed server and hosted-device requests, CLI sync/receipt handling, and dashboard confirmation. git diff --check passed. The finding is source-traced, not runtime-reproduced: the required Nix environment fails before tool startup with bwrap: setting up uid map: Read-only file system. Consequently I could not run the focused Rust/dashboard tests, exercise the actual UI, capture screenshots, or verify mobile overflow. CI currently reports Brain acceptance and other completed checks passing; Rust workspace, Dashboard, Nix service packages and Nix static contracts remain pending. The new hosted-route/browser deletion proofs are opt-in via FC_BRAIN_DELETION_PROOF_BIN_DIR, which this CI workflow does not set, so a generic dashboard pass would not independently verify those flows.

Comment thread finite-brain/crates/finite-brain-cli/src/brain_deletion.rs Outdated

@alexlwn123 alexlwn123 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Pass on source review — the prior P2 receipt-loss finding is addressed at a94a1f1fb00254845fb6acff0483967c4bf38c13. No new actionable defect found in the seven-file repair delta from 084939f5.

Confirmed deletion now preserves success and the receipt in both JSON and text output when local discovery/scanning/state persistence fails, reporting a separate warning. Failed scanning no longer prevents a terminal marker when Agent State is writable; unsyncedPathsError preserves the incomplete-scan warning, defaults safely for existing state, and is shown by later terminal sync errors. The Brain/server binding check remains intact.

I inspected the two added real-process tests: invalid-UTF-8 Markdown checks JSON/text receipts, retained bytes, terminal state and offline sync refusal; invalid Agent State checks receipt plus warning without rewriting local state/files. These are source-reviewed tests, not independently executed results. git diff --check passed across the complete PR; the isolated checkout is clean. The prior Nix startup failure (bwrap: setting up uid map: Read-only file system) still blocks local Rust/dashboard execution; I did not retry or bypass it, or the denied CI-log download. Current-head substantive CI jobs are pending. Actual UI, screenshots/mobile overflow and opt-in hosted-route/browser execution remain unverified by this review; this repair changes no UI.

AustinKelsay added a commit that referenced this pull request Oct 27, 2026
Inputs: #1126 a94a1f1 and #1128
2517eba (e19b18c, 0aca26f, 2517eba).
Clean textual merge. Cargo.lock keeps the 0.9.0 Brain crate versions from
#1126 and the secp256k1 dependency #1128 adds to finite-saas-core.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AustinKelsay added a commit that referenced this pull request Oct 27, 2026
Inputs: #1127 2da1d3c on top of the
#1126 + #1128 integration.

agent-brain-browser.tsx merged cleanly: the roster passes agentName and
the deletion panel stays below it.

brain-identity-roster.tsx conflict resolution keeps both data contracts
and every affordance:
- readBrainIdentities returns { identities, changes }; the alias lookup
  memoizes the npubs of `identities`, so a refresh after a roster change
  looks the new key set up again.
- Columns are Identity, Your alias, Owner, Role, Folders, Key, and the
  Actions column when the Agent offers removal.
- The identity cell keeps names' alias rendering over the scoped,
  lifecycle and public-name labels. The Remove button and its dialog keep
  the authoritative label from people's personLabel; removal still sends
  only row.npub.
- One short-key helper (shortNpub) replaces names' identical local
  shortKey.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@alexlwn123 alexlwn123 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Pass on source review — no new actionable finding at a992859ccefcead4ed43c56b16f5159082f16cce.

Reviewed the four-file delta from a94a1f1f: explicit spacing in the confirmation copy and readable stale/expired/generic 409 messages. I traced server conflict reasons through the hosted client, dashboard route and panel: HTTP 409 is preserved, active-mount details remain available, and a refused confirmation still requires a fresh preview before retrying. The added unit cases and browser assertions match the changed paths in source. The prior CLI receipt-loss fix is unchanged; its resolved finding is not repeated.

Full-PR git diff --check passed; applicable AGENTS guidance and the authoritative review skill were rechecked. I did not independently execute the tests or the changed UI: the previously observed Nix/bwrap UID-map restriction remains unresolved, and neither that operation nor the denied CI-log download was retried or bypassed. No genuine desktop/mobile screenshots were captured or uploaded, and mobile overflow remains unverified. Current-head CI is still in progress; author-reported combined integration results are not independent evidence from this review. Posting COMMENT with these coverage limits.

This branch has not been deployed

No deployments
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.

2 participants