Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Scan every push gbrain makes from an unmanaged checkout, and let a long first push finish (GST-2456)
garrytan8eb30915e8d3
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5b2d883e3e..529b461848 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,18 @@ identifiers and attribution are available in the pre-removal Git revision## [Unreleased]+**Every push gbrain makes from an unmanaged checkout now scans the commits it publishes for secrets, and a long first push can finish.** `gbrain git commit-push` scanned only with `--push-only --scan-secrets`, so its commit mode, `--pending`, the post-commit hook `gbrain sources harden` installs and `scripts/brain-commit-push.sh` pushed earlier local commits unscanned; they now refuse `publish_secret_found` or `publish_scan_unreadable` like the four pushes below, and the refusal is logged in `brain-push.log`. The helper's fallback for a machine without gbrain commits and no longer pushes, since it cannot scan. A scan that runs out of its 300 s budget refuses naming the same command with `--scan-timeout <seconds>`, which `gbrain git commit-push`, `gbrain sources push` and `gbrain bootstrap repo` now take; the scan reads every commit either way, prints its progress on stderr and keeps its temporary disk use to one batch of commits. No push follows tags any more, so `push.followTags` cannot publish an annotated tag's message unscanned. `gbrain sources push` reads origin's branch tip from origin itself when the branch tracks another remote (it used to fail the push, never skip commits), prints its refusal with `--json` and exits 5, and the access-policy commit reports a refusal as `committed_not_pushed` instead of failing.++### Itemized changes++- `src/commands/git.ts`: every mode passes `scanSecrets` (`--scan-secrets` is still accepted), `--scan-timeout <s>` (whole seconds, not with `--pull`), progress lines on stderr, and a scan refusal logged as `LOCAL-ONLY, NEEDS ATTENTION ... the push was refused (<code>)`.+- `src/core/git/range-secret-scan.ts`: commit messages read with one `cat-file --batch` and patches with one `diff-tree` per 256 commits (the patch file holds one batch, not the whole history), progress lines, `PublishScanOptions` (budget, progress, retry command), and a timed-out scan refused with an agent fix that reruns with four times the budget (at least 1200 s).+- `src/core/git/commit-push.ts`, `src/core/workspace-push.ts`, `src/core/bootstrap/repo.ts`: `--no-follow-tags` on every push; `gbrain sources push` fetches origin's branch before it scans and returns the scan refusal as `blocked_history`.+- `src/commands/sources.ts`, `src/commands/bootstrap.ts`: `--scan-timeout`; `sources push` prints a `blocked_history` refusal and exits 5.+- `src/core/access/policy-git.ts`: a scan refusal returns `committed_not_pushed` with the refusal in its note.+- `src/core/brain-repo-durability.ts`: the helper's no-gbrain fallback commits, logs the commit as local-only and exits 4 (0 when the branch is already on the remote).+- Tests: `test/unmanaged-push-every-site-gst2456.serial.test.ts` (each push site against a local bare remote, tags, another upstream remote, the `--json` refusal, the budget and progress); the #8902, fallback and bootstrap argv tests follow the new contracts.+**Pushes from an unmanaged checkout now scan every commit they publish for secrets, not only the files they just wrote.** Four gbrain pushes from a checkout that is not a managed worktree carried earlier local commits to the remote unscanned: the access-policy commit, the durability-scaffolding commit, `gbrain sources push` (which scanned only its own staged files, then pushed the whole branch tip, even with nothing new to commit) and the first push of `gbrain bootstrap repo` after the remote branch was gone (which scanned only the current tree). A credential a script committed with plain `git commit`, including one a later commit removed or one in a commit message, went out with them. Each now runs the range scan managed publishes use over what the remote lacks (the whole history when the remote has no such branch) and refuses `publish_secret_found` or `publish_scan_unreadable`, with nothing pushed and the local commits kept. `gbrain sources push` pushes the exact commit it scanned, leased on the remote tip it read, so a remote rewound in between is scanned again. An allowlist edit that `gbrain sources push` or `gbrain bootstrap repo` commits itself, after scanning it, still publishes; one a script committed is left to the user. Remoteless checkouts, managed worktrees and repo-less brains are unchanged, and the policy command's retry hint keeps `--scan-secrets`.Reported and first fixed by @javieraldape (#9159).diff --git a/docs/architecture/key-files/workspace-push-and-backup.md b/docs/architecture/key-files/workspace-push-and-backup.mdindex d7d9403f55..db1dc03769 100644--- a/docs/architecture/key-files/workspace-push-and-backup.md+++ b/docs/architecture/key-files/workspace-push-and-backup.md@@ -13,7 +13,7 @@ Key files:## Shared-checkout git writer- `src/core/git/commit-push.ts` + `src/core/git/commit-guard.ts` — writer safety in a shared checkout (#7381). `integrate` replaces the tip 3-way merge when any local commit is patch-equivalent to an upstream one (`rev-list --cherry-mark`): it replays the local commits onto the remote tip in memory (`merge-tree --merge-base` on git 2.40+, a 3-way `read-tree` otherwise), leaving out the equivalent ones and clean merges, so a copy the remote edited never conflicts and one it reverted is never re-applied; the merge message lists what it left out. `supersededPaths` resolves a content conflict to ours when the remote's blob is one the same path held earlier in ours' history (last 200 commits touching it) and a different blob replaced it there; the push reports them as `superseded_remote_paths`, and `integrate_conflict` lists only the rest (`detail.superseded` names them). `commitPaths` refuses a path outside the source roots (`configuredSourceRoots`, git config `gbrain.sourceRoot`, recorded by `sources harden`'s `recordSourceRoot`) and a file another writer staged under a named directory (`commit_prestaged_paths`), and restores the exact index entries (`update-index --index-info`) when git refuses the commit. After the commit step (and its index restore) `commitPaths` returns the named paths HEAD still lacks (`unstagedPaths`: a modified entry flagged assume-unchanged or skip-worktree, a named file git did not index such as one inside a nested repository, and unstaged status entries under a named directory; a skip-worktree entry absent from disk, a flagged gitlink and ignored files under a named directory are left out) and keeps an unindexed file out of `commit --only`; `commitAndPush` (classic, managed and remoteless) and `commitPathsLocked` then throw `commit_paths_skipped`, or `writer_coordinator_required` for a page in a managed worktree (its `put_page` fix names the managed source), once the rest is committed and, on a classic checkout, pushed (`detail`: `skipped`, `committed`, `pushed`, `branch`, and `publish` when the push failed too). Every commit gbrain makes carries `GBRAIN_COMMIT_VIA=<lock path>`. Every pathspec it passes goes through `literalPathspecs` (`git-env.ts`), never `git --literal-pathspecs`, so the commit's hooks keep Git's normal pathspec rules: a pre-commit guard that selects files by glob still sees and can refuse them (`git_unavailable`, paths unstaged). `commitPathsLocked` (write-through) never commits without the lock: a busy lock or refused commit notes the file in `brain-writethrough-pending.log` (git dir, O_APPEND lines), which the next locked write-through and `commit-push --pending` commit and `settlePending` prunes. `notePending` is exported: the derived and dream write-through (`cycle/derived-write-through.ts`, #8073) records each file it writes before its batch commit, so a crash in between leaves the file for that sweep. A publish refuses local non-merge commits outside the roots (`commit_outside_source_root`; `--allow-outside-source-root` lifts both refusals, and `sources harden` passes it for its root scaffolding). With git config `gbrain.quarantine` (opt-in) a content conflict publishes the remote's version of each conflicted file plus every other local change, names the local commit under `refs/gbrain/quarantine/<time>-<sha>` and appends it to `brain-quarantine.log` (`readQuarantine` lists entries whose ref still exists); structural conflicts still refuse. `commit-guard.ts` installs the opt-in `prepare-commit-msg` guard (`gbrain git guard`), which admits only commits naming a held commit lock, passes merges and in-progress operations, and honors `GBRAIN_COMMIT_GUARD=off`. The helper's no-gbrain fallback (`renderCommitPushHelper`) marks children with the absolute lock path and releases the commit lock before pushing under `brain-publish.lock`; it runs the same skipped-path check after its commit and reports `commit_paths_skipped` after the push (exit 1, or 4 when the push failed). The CLI (`src/commands/git.ts`) refuses `checkout_not_a_source` before staging when this brain home's managed-root registry records source checkouts and the resolved checkout is none of them and has no `gbrain.sourceRoot` (#8662); a registered checkout must contain the resolved one, or be a subdirectory its HEAD tracks, so a repository that only encloses one is refused, and a registry that cannot be listed refuses `writer_coordinator_required` (GST-1623). Tests: `test/git-writer-safety-7381.serial.test.ts`, `test/git-literal-pathspec-hooks-7759.test.ts`, `test/git-commit-push-not-a-source-8662.test.ts`, `test/git-commit-push-skipped-paths-gst2116.test.ts`.-- `src/core/git/range-secret-scan.ts` — `scanRange(root, from, to)`, the secret gate for automatic publishes: `gbrain git commit-push --push-only --scan-secrets` (the child `gbrain sources refresh` runs to publish a diverged managed checkout) scans `trackingRef..target` under the publish lock, right before the push. Plumbing only (`rev-list`, `cat-file commit`, one streamed `diff-tree --stdin -p --root --cc`), so log, diff and attribute settings never change what is scanned. Commit messages, added lines and merge resolutions go through `scanText` with the `.gbrain-scan-allow` allowlist; a finding, added text over the scan cap or a change to `.gbrain-scan-allow`/`.gitattributes` refuses `publish_secret_found` (file, line, rule, commit, never the value), and a range it cannot read in full (git failure, unrecognised output, 300 s budget) refuses `publish_scan_unreadable`. Commits the commit ledger records as page writes are not scanned: door and hosted-repository commits, and Git effect commits recorded `verified` (`effectCommit` in `effect-git.ts` builds the commit with `commit-tree` and moves HEAD with an `update-ref` compare-and-swap, so the recorded sha is gbrain's own; `verified` when each staged blob is the bytes whose sha256 the effect recorded); adopted records, records without `verified` and an unreadable ledger leave the commits scanned. Doctor `git_convergence`'s agent push fixes pass `--scan-secrets` too. `stagedScanPublishRefusal(root, base, target)` is the same refusal for `gbrain sources push` (`workspace-push.ts`: `origin/<branch>..HEAD` after its pull, then a push of that exact sha leased on the scanned tip, and no push when the local branch lacks the remote tip) and both first pushes of `gbrain bootstrap repo` (`bootstrap/repo.ts`, the whole history; `scanHistory` is the runner-fake seam), with gate changes exempt in commits the ledger records as `workspace_push` or `bootstrap`, whose blobs those writers scanned staged with the same allowlist. The access-policy commit (`access/policy-git.ts`) and the durability-scaffolding commit (`brain-repo-durability.ts`) publish through `commitAndPush` with `scanSecrets` (#8902). Test: `test/unmanaged-push-history-scan-8902.serial.test.ts`.+- `src/core/git/range-secret-scan.ts` — `scanRange(root, from, to, timeoutMs, progress)`, the secret gate for every push gbrain makes: `gbrain git commit-push` in every mode (the CLI always sets `scanSecrets`; the post-commit hook, `scripts/brain-commit-push.sh` and the child `gbrain sources refresh` runs all go through it) scans `trackingRef..target` under the publish lock, right before a push that never follows tags (`--no-follow-tags`). Plumbing only (`rev-list`, then `cat-file --batch` and `diff-tree --stdin -p --root --cc` over batches of 256 commits, so the temporary patch file stays one batch in size), so log, diff and attribute settings never change what is scanned. The budget is 300 s unless `--scan-timeout` sets it; `progress` gets `secret scan:` lines (at once for a whole history, then every 10 s), and with `retryArgv` a timed-out scan refuses `publish_scan_unreadable` whose agent fix is that command with `--scan-timeout` four times longer (at least 1200 s). Commit messages, added lines and merge resolutions go through `scanText` with the `.gbrain-scan-allow` allowlist; a finding, added text over the scan cap or a change to `.gbrain-scan-allow`/`.gitattributes` refuses `publish_secret_found` (file, line, rule, commit, never the value), and a range it cannot read in full (git failure, unrecognised output, 300 s budget) refuses `publish_scan_unreadable`. Commits the commit ledger records as page writes are not scanned: door and hosted-repository commits, and Git effect commits recorded `verified` (`effectCommit` in `effect-git.ts` builds the commit with `commit-tree` and moves HEAD with an `update-ref` compare-and-swap, so the recorded sha is gbrain's own; `verified` when each staged blob is the bytes whose sha256 the effect recorded); adopted records, records without `verified` and an unreadable ledger leave the commits scanned. Doctor `git_convergence`'s agent push fixes pass `--scan-secrets` too. `stagedScanPublishRefusal(root, base, target, opts)` is the same refusal for `gbrain sources push` (`workspace-push.ts`: origin's tip read from origin itself with `ls-remote` and a fetch, since the pull may follow another upstream remote, then `<tip>..HEAD` scanned and that exact sha pushed leased on the tip, no push when the local branch lacks the tip; a refusal is the `blocked_history` result, exit 5, printed by `--json` too) and both first pushes of `gbrain bootstrap repo` (`bootstrap/repo.ts`, the whole history; `scanHistory` is the runner-fake seam), with gate changes exempt in commits the ledger records as `workspace_push` or `bootstrap`, whose blobs those writers scanned staged with the same allowlist. The access-policy commit (`access/policy-git.ts`, which reports a scan refusal as `committed_not_pushed` with the refusal in its note) and the durability-scaffolding commit (`brain-repo-durability.ts`) publish through `commitAndPush` with `scanSecrets` (#8902). The helper's no-gbrain fallback commits and never pushes. Tests: `test/unmanaged-push-history-scan-8902.serial.test.ts`, `test/unmanaged-push-every-site-gst2456.serial.test.ts`.- `src/commands/doctor/checks/git-writer.ts` — `checkout_lagging`, `dirty_age`, `commits_outside_source_root`, `quarantined_changes` (#7381, brain category, after `git_convergence`): over the unmanaged source checkouts with an upstream (`sourceRoots` from git-convergence, grouped by toplevel with each source's toplevel-relative root), never fetching, every git call bounded at 5 s. Lagging warns when `HEAD..@{u}` holds a commit over an hour old (fix: `gbrain git commit-push --pull --path <top>`, agent). Dirty age warns on pending write-through files older than 30 minutes (`pendingWriteThroughStillDirty`; fix: `commit-push --pending`, agent) and on files staged that long (ask_user: unstage or commit by name). Outside-root warns on unpushed non-merge commits that change files outside the DB source roots plus `gbrain.sourceRoot` (`localCommitsOutsideRoots`; ask_user fix with `--allow-outside-source-root`), and says when the checkout has no root recorded. Test: `test/doctor-git-writer-7381.test.ts`.- `src/core/git/commit-ledger.ts` — the commit ledger (PR B, docs/designs/REFRESH_WRITE_BARRIER.md part 3): `<git common dir>/gbrain/commit-ledger.jsonl`, one O_APPEND JSON line under 1 KiB per record, under its own flock `commit-ledger.lock` (start line, append, 4 MiB rotation to `commit-ledger.1.jsonl`). `recordCommit`/`recordCommitAsync` take the sha and writer kind (`commit_push`, `door`, `merge`, `replay`, `effect`, `sync_init`, `workspace_push`, `bootstrap`, `hosted_repo`); porcelain sites call `recordIntent` (head_before, `messageDigest` of the message) before `git commit`, plumbing sites record the `commit-tree` sha before the ref moves. A failed append never fails the commit (logged once); a directory outside git records nothing. `readLedger` reads both files; only a missing file reads as empty, any other read error throws (GST-1623). Tests: `test/commit-ledger.test.ts`.- `src/commands/doctor/checks/foreign-writers.ts` — `foreign_writers` (PR B part 4): every registered source checkout on this host, managed worktrees included, deduplicated by git common dir. Reflogs (`logs/HEAD`, `logs/refs/heads/*`, `worktrees/*/logs/HEAD`, newest 5,000 entries each) are classified by `classifyReflogMessage`: porcelain creations by new sha, other ref moves by the `old..new` range within 10 minutes of the entry, merges/fast-forwards/resets/checkouts/branch/clone excluded. Unledgered commits fail (`plain`, `amend`, `rewrite`, `plumbing`; `guard_bypassed` when the enforce guard predates the commit); intent matches are `unconfirmed` (warn, never written back); entries before the ledger start are uncovered. Dirty page files come from `status --porcelain=v2` under the source roots minus queued/running git effects and the write-through pending ledger. GST-1623: a foreign commit carries `gbrain_trailer` when its trailer paragraph has a `gbrain-*:` line (named as possibly an older gbrain without the ledger; still fails); `partial_reasons` names what the scan skipped (a root inside a checkout whose `rev-parse` fails, roots past `MAX_ROOTS` 50, an unreadable ledger, a failed or timed-out status, given up to 30 s within doctor's budget, the budget itself), and a scan that read no repository but skipped one warns. Repo-less: `not_applicable`. Tests: `test/doctor-foreign-writers.test.ts`.diff --git a/docs/guides/shared-checkout-git.md b/docs/guides/shared-checkout-git.mdindex ce31cdd103..79b07e8022 100644--- a/docs/guides/shared-checkout-git.md+++ b/docs/guides/shared-checkout-git.md@@ -114,16 +114,17 @@ current directory (the paths are then relative to `<dir>`, like `git -C`),`-m` repeats like `git commit` (each one is a new paragraph, so a second `-m`carries a trailer), `--json` prints one JSON result (or the error envelope),`--require-clean` makes `--pull` skip when the checkout has any local edit-(the rule the unattended pull cron uses). The command is local only: it pushes+(the rule the unattended pull cron uses), `--scan-timeout <seconds>` gives the+secret scan every push runs a longer budget than its 300 s default. The command is local only: it pusheswith this machine's git credentials and is never exposed over MCP.When gbrain is not installed on the machine, the helper falls back to a locked-path-scoped commit and a plain push. A rejected push then fails loudly (exit 4)-and tells you to install gbrain and run `gbrain git commit-push --push-only`;-the fallback never integrates remote commits itself. A named path git left out-of the commit is reported as `commit_paths_skipped` after the push, as-`gbrain git commit-push` reports it; the helper then exits 1, or 4 when the-push failed too.+path-scoped commit and pushes nothing, because only gbrain scans the commits it+publishes for secrets. It exits 4 (0 when the branch is already on the remote),+logs the commit as local-only and tells you to install gbrain and run+`gbrain git commit-push --push-only`. A named path git left out of the commit+is reported as `commit_paths_skipped`, as `gbrain git commit-push` reports it;+the helper then exits 1, or 4 when the commit is not on the remote.In a managed canonical worktree (`gbrain sources writer git-durability`) itspersistence owner is the only Git publisher. Save pages with `put_page`,@@ -189,8 +190,8 @@ Follow the error's `fix.next` as the| `git_index_stale` | 1 | An `index.lock` older than 10 minutes blocks the checkout. Check that no git command is running there, tell the user, and remove the named lock file only with their agreement. || `git_operation_in_progress` | 1 | A rebase, merge, cherry-pick or revert is unfinished in the checkout. gbrain never aborts it for you. Follow [stuck rebase](#stuck-rebase). || `git_detached_head` | 1 | The checkout is on a detached HEAD or an unborn branch. Check out the branch the remote tracks (`git switch <branch>`), or make the first commit, then rerun. |-| <a id="publish_secret_found"></a>`publish_secret_found` | 1 | Only with `--scan-secrets`, which every automatic publish uses: the one `gbrain sources refresh` runs on its own, the push of a managed worktree's Git effects, doctor `git_convergence`'s push fixes, the access-policy and durability-scaffolding commits, `gbrain sources push` and the first push of `gbrain bootstrap repo` (#8902; there the remote has no branch yet, so the whole history is scanned). A commit about to be pushed that gbrain did not make for a page write (its commit ledger records its own page-write commits, whose bodies are stored raw by design and are not scanned; a Git effect's commit counts only by the sha gbrain created for it, when its files held the bytes the effect wrote, so an amended or reworded copy is scanned; one that adopted a file edited outside gbrain, or one older than the retained ledger, is scanned) adds a value that looks like a secret, in its message, an added line (even one a later commit removed) or a merge resolution, adds text too large to scan, or changes `.gbrain-scan-allow` or a `.gitattributes` (files that decide what the scan sees); nothing was pushed. The message names each file, line, rule and commit, never the value. Ask the user: remove the value from those unpushed commits, or add a false positive's fingerprint to `.gbrain-scan-allow`, then retry. A commit that changes `.gbrain-scan-allow` or a `.gitattributes` is never published automatically: the user reviews it and pushes it. The exception is the commit `gbrain sources push` or `gbrain bootstrap repo` makes itself from files it has just scanned with that allowlist. Never publish them with a command that skips the scan. On a managed worktree its Git effects hold meanwhile (`gbrain sync status` and doctor list them; the page writes are safe in the database and in local commits); after the fix, `gbrain sources writer retry-effects <source> --parked-pushes` runs the ones that parked. |-| <a id="publish_scan_unreadable"></a>`publish_scan_unreadable` | 1 | Only with `--scan-secrets`: the scan could not read the commits about to be pushed in full (a missing or corrupt object, git output it does not recognise, or its 300 s budget), so it reported no secret and nothing was pushed. Run `git fsck` in the checkout, fix what it names, then retry. When the remote has no such branch, a managed worktree's Git effect scans the branch's whole history and creates it only when that scan passes; a history too large to scan in the owner process holds the effects with this code and names `git ls-remote --heads <remote>`: check the upstream, then point it at the right branch or review the history and push the branch yourself. Never publish with a command that skips the scan. On a managed worktree its Git effects hold meanwhile, as for `publish_secret_found`. |+| <a id="publish_secret_found"></a>`publish_secret_found` | 1 | On every push `gbrain git commit-push` makes (commit mode, `--pending` and `--push-only`; `--scan-secrets` is accepted for older scripts), so also the post-commit hook `gbrain sources harden` installs and `scripts/brain-commit-push.sh`, and on every automatic publish: the one `gbrain sources refresh` runs on its own, the push of a managed worktree's Git effects, doctor `git_convergence`'s push fixes, the access-policy and durability-scaffolding commits, `gbrain sources push` and the first push of `gbrain bootstrap repo` (#8902; there the remote has no branch yet, so the whole history is scanned). A commit about to be pushed that gbrain did not make for a page write (its commit ledger records its own page-write commits, whose bodies are stored raw by design and are not scanned; a Git effect's commit counts only by the sha gbrain created for it, when its files held the bytes the effect wrote, so an amended or reworded copy is scanned; one that adopted a file edited outside gbrain, or one older than the retained ledger, is scanned) adds a value that looks like a secret, in its message, an added line (even one a later commit removed) or a merge resolution, adds text too large to scan, or changes `.gbrain-scan-allow` or a `.gitattributes` (files that decide what the scan sees); nothing was pushed. The message names each file, line, rule and commit, never the value. Ask the user: remove the value from those unpushed commits, or add a false positive's fingerprint to `.gbrain-scan-allow`, then retry. A commit that changes `.gbrain-scan-allow` or a `.gitattributes` is never published automatically: the user reviews it and pushes it. The exception is the commit `gbrain sources push` or `gbrain bootstrap repo` makes itself from files it has just scanned with that allowlist. Never publish them with a command that skips the scan. On a managed worktree its Git effects hold meanwhile (`gbrain sync status` and doctor list them; the page writes are safe in the database and in local commits); after the fix, `gbrain sources writer retry-effects <source> --parked-pushes` runs the ones that parked. |+| <a id="publish_scan_unreadable"></a>`publish_scan_unreadable` | 1 | Wherever `publish_secret_found` can refuse: the scan could not read the commits about to be pushed in full (a missing or corrupt object, git output it does not recognise, or its time budget), so it reported no secret and nothing was pushed. When it ran out of time (a first push of a long history can need more than the 300 s default), the fix is the same command with `--scan-timeout <seconds>`, four times the budget and at least 1200: run it; the scan still reads every commit, and prints its progress on stderr. `gbrain git commit-push`, `gbrain sources push` and `gbrain bootstrap repo` take `--scan-timeout`. Otherwise run `git fsck` in the checkout, fix what it names, then retry. When the remote has no such branch, a managed worktree's Git effect scans the branch's whole history and creates it only when that scan passes; a history too large to scan in the owner process holds the effects with this code and names `git ls-remote --heads <remote>`: check the upstream, then point it at the right branch or review the history and push the branch yourself. Never publish with a command that skips the scan. On a managed worktree its Git effects hold meanwhile, as for `publish_secret_found`. || `integrate_conflict` | 1 | Local and remote commits changed the same file; nothing was merged and the checkout is unchanged. Stop, relay the question to the user, then [resolve](#conflicts). || `push_unconfirmed` | 4 | The commit is durable locally but no push destination confirmed it (network, credentials, branch protection, a remote that kept moving, or another push that held the push lock for the whole wait). Fix what the message names, then run `gbrain git commit-push --push-only`. Never force-push. || `writer_coordinator_required` | 1 | This is a managed worktree. Stop using git for pages; save them through `put_page` and the other gbrain write tools. `scripts/brain-commit-push.sh` refuses this way on a checkout marked managed and commits nothing; `gbrain git commit-push` refuses this way when git left a named page out of its commit (the same causes as `commit_paths_skipped`), after committing the other named paths locally. Ask the user before re-saving such a page through `put_page` with the managed source (`gbrain put --source-id <source> <slug>`, or `source_id` over MCP; without it the write goes to the default source): it replaces the stored page with the file's content. |@@ -203,7 +204,7 @@ All of these exit 0. A diverged branch whose two sides changed the same filefails with `integrate_conflict`, the same as a push.The helper's own exits: 2 for a usage error (no message, or no paths: it-refuses a repo-wide commit), 4 when its no-gbrain fallback could not push.+refuses a repo-wide commit), 4 when its no-gbrain fallback committed without pushing.With `--json`, a success prints `outcome`, `sha` (the commit now on theremote), `committed` (your commit, or null), `branch`, `remote`, `paths`,diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsvindex 2bd7148f2e..12757f7e96 100644--- a/scripts/module-size-limits.tsv+++ b/scripts/module-size-limits.tsv@@ -28,9 +28,9 @@ src/core/minions/queue.ts 2548 ratchet grown #4078 + megawave probe-liveness unlsrc/commands/init.ts 1892 ratchet +2 fix wave 9 lane F #5253: leaving deferred setup also clears the DB-plane embedding_disabled row (both init branches); grown v0.46.x keyless capability notices; grown db-availability loop: initPostgresCore typed-failure extraction + --prefer-postgres ladder hook + pgvector rethrow fix; +1 at megawave/wave-k merge; +master-merge true-up; wave-k: merge; #3753 --force re-init engine-preservation guard; +1 wave-k merge-union brace (--prefer-postgres close); +10 ambient-writeback WP8: runWritebackNudge consent ask in both engine epilogues (logic lives in core/onboard/writeback-nudge.ts); +4: v0.48.2 reranker readiness at init + test seam; +1: v0.48.2 provider normalization; +3: v0.48.2 review fixes; master integration: +2: preserve typed PGLite busy errors in schema-only init; shared-skills integration on company-ingestion base; retired provider integration removed; retain stored-vector identity on re-init; -14: first-run bundle + quickstart registration helpers live in init-first-run.ts (writeback/skills asks folded into the bundle); +5 agent operator follow-up Item 2: --surface flag (value flag, parse, help line, module-level registration surface, type import) for the printed harness registration; +2 fix wave lane B3: both engine paths stamp a database init created as a fresh install for the behavior_changes notice (core/behavior-change-notice.ts); +4 GBRA-81 item 1: --search-mode value flag, its parse line, module-level choice, help line (picker logic lives in init-mode-picker.ts); +2 D8 funnel: a fresh init counts one clean_install when the opt-in funnel is on (core/funnel.ts); +1 GBRA-199: --surface help line names the default verbs listing; +7 GBRA-248 W0b: the implicit-keyless marker on both zero-key fallbacks, the deferred-hint gate on both engine paths and the kept-identity call in both (logic in commands/init-embedding-plane.ts)src/commands/integrations.ts 1739 ratchet grown v0.46.26.0 megawave (#4039 connector compat) + 1 nosemgrep dataflow annotation (path-traversal audit); wave-k: exported heartbeatPath seam (#3900)src/core/minions/handlers/subagent.ts 1925 ratchet merged: master v131 settle rework + dream-wave C5 peel + C6 accounting + C7 lease heartbeats/lost-lease aborts + C9 oneshot dispatch + adversarial fix batches; grown by #4078 subagent-loop capability fix; +6 lines (reasoning-item replay: adaptContentBlocksToChatBlocks handles 'reasoning' blocks); +3 wave G #4514: Anthropic-via-OpenRouter allowed on the subagent loop; +36 lines (code review, same PR): isPromptTooLongError walks a bounded .cause chain so it still matches post-normalizeAIError() wrapping, plus extractPromptTooLongDetail so the dead-lettered job's error carries the matched provider detail instead of the generic normalizeAIError() wrapper text; master integration: harness support: boundary wiring to shared grants, isolated setup, withdrawal and delegated guards; #5105: +13 call-site wiring to shared tool-write-identity helper across fresh and replay dispatch; +7 fix wave 9 lane B #4921: ai.chat.per_turn_timeout_ms read once and passed to the oneshot and gateway-loop paths (resolver lives in minions/handler-timeouts.ts)-src/commands/bootstrap.ts 2160 ratchet grandfathered at merge (grew past the 1500 cap on master); raised for #4066 HOME_WORKSPACE_GUARD_EXEMPT (status/uninstall/harness); +5 for the harnessDetect test seam (bulk lives in core/bootstrap/harness.ts); +23 for the contract subcommand dispatcher glue (#4105 absorb — bulk lives in core/bootstrap/contract.ts); +codex hooks-consent gate + mcp+hooks receipt registration + uninstall arm; +42 ambient-writeback WP8: interview-time SURFACE_MULTIUSER audience apply (pre-init ordering) + applyDeclaredAudienceFromInterview; +3 #4897 harness usage clause documenting --source ID semantics; +5 #5878: --refresh-skills dispatch and usage lines (logic in core/bootstrap/harness-skills.ts); +11 #5488: SUBCOMMAND_HELP harness entry (gate on --help / -h / help) — CLI help line, cannot move; +11 #4618 seat: --seat/--no-seat help lines and the runHooks parse (parse + notes live in core/bootstrap/hooks.ts parseSeatFlags); +13 #4082: runAdoptHooks (the --adopt branch of the hooks subcommand, kept out of runHooks for the function-size ratchet) and its two help lines (adoption logic lives in core/bootstrap/adopt-connection.ts + adopted-connections.ts); +4 #8426/#8428: the user-scope MCP registration, its verify and the workspace and Codex SessionEnd hooks start gbrain through the hook launcher (logic in core/setup/hook-launcher.ts); +2 #8435: the user-global opencode entry starts serve through the hook launcher (logic in core/setup/hook-launcher.ts); +1 GBRA-224: INSTALL_PIN import (core/install-ref.ts; re-summed at the GBRA-346 merge: master 2153 + 1); +6 #8902: bootstrap prints an OperationError refusal with its code and next step+src/commands/bootstrap.ts 2165 ratchet grandfathered at merge (grew past the 1500 cap on master); raised for #4066 HOME_WORKSPACE_GUARD_EXEMPT (status/uninstall/harness); +5 for the harnessDetect test seam (bulk lives in core/bootstrap/harness.ts); +23 for the contract subcommand dispatcher glue (#4105 absorb — bulk lives in core/bootstrap/contract.ts); +codex hooks-consent gate + mcp+hooks receipt registration + uninstall arm; +42 ambient-writeback WP8: interview-time SURFACE_MULTIUSER audience apply (pre-init ordering) + applyDeclaredAudienceFromInterview; +3 #4897 harness usage clause documenting --source ID semantics; +5 #5878: --refresh-skills dispatch and usage lines (logic in core/bootstrap/harness-skills.ts); +11 #5488: SUBCOMMAND_HELP harness entry (gate on --help / -h / help) — CLI help line, cannot move; +11 #4618 seat: --seat/--no-seat help lines and the runHooks parse (parse + notes live in core/bootstrap/hooks.ts parseSeatFlags); +13 #4082: runAdoptHooks (the --adopt branch of the hooks subcommand, kept out of runHooks for the function-size ratchet) and its two help lines (adoption logic lives in core/bootstrap/adopt-connection.ts + adopted-connections.ts); +4 #8426/#8428: the user-scope MCP registration, its verify and the workspace and Codex SessionEnd hooks start gbrain through the hook launcher (logic in core/setup/hook-launcher.ts); +2 #8435: the user-global opencode entry starts serve through the hook launcher (logic in core/setup/hook-launcher.ts); +1 GBRA-224: INSTALL_PIN import (core/install-ref.ts; re-summed at the GBRA-346 merge: master 2153 + 1); +6 #8902: bootstrap prints an OperationError refusal with its code and next step; +5 GST-2456: bootstrap repo --scan-timeout parse and its help lines (the scan lives in core/bootstrap/repo.ts)src/core/minions/worker.ts 1795 ratchet grandfathered at merge (grew past the 1500 cap on master, #4170); grown v0.46.11.0 five-issue wave; security: durable queued authority and confined filesystem dispatch; typed readiness, configuration-blocked lifecycle and bounded release; post-validation readiness publication and confirmed isolated-execution stop evidence; latch typed lock-renewal faults before generic retry; +9 Lane D: JobDeferredError routing (deferJob helper); +1 spend authorization: runWithJobSpend import (both handler seams call it in place of the bare handler); +3 watchdog: gracefulShutdown records its reason and launchJob aborts a claim committed before it fired; +5 GBRA-130 A-30: watchdog-attribution import, InFlightJob.shared (interface field), the suspect-alone claim gate and option, and the watchdog settle call in the executeJob catch (logic in minions/watchdog-attribution.ts); +6 GBRA-133 2a.4 sync-queue wake: IdleWaiter import and field, claimStarted before each claim, the idle poll through it, and stop/requestShutdown ending its wait (logic in minions/idle-wait.ts); +1 GBRA-158 #7239: refusal.ts import (a deterministic refusal ends the job at once; classification in minions/refusal.ts); +3 #7242 lane reservation: lanes import and the longJobNames/shortJobReservedSlots defaults (the claim passes claimExclusions; policy in minions/lanes.ts); +2 #7242 terminal hook: onJobSettled default and the settle call (logic in terminal-hook.ts); #7252 x #7249 merge: both sides grew the file, re-summed (1794 measured); GBRA-151 #7183/#7187/#7188 re-summed at the v0.60.402.0 merge (1795 measured)-src/commands/sources.ts 2130 ratchet +3 url_source_origin: sources record-origin dispatch and help rows (body in sources-record-origin.ts, logic in core/url-source-origin.ts); +3 PR B: sources guard dispatch and help rows (body in sources-guard.ts); +3 G7b-2: sources host-repo dispatch and help row (body in sources-host-repo.ts and core/persistence/hosted-repo.ts); +5 PR #5955 / fix wave 14 P2.7: sources set-strategy dispatch and help row, the strategy field of sources list --json (body in sources-strategy.ts); +5 #5988: sources status/retry-held help rows describe Git holds (help lines cannot move); +2 #5988: sources status <id> filter and Git held files (view in persistence/connector-status.ts); +5 F0: sources refresh dispatch and help rows (command body in sources-refresh.ts, protocol in persistence/worktree-refresh.ts); +6 fix wave 5 #5409: mirror-readonly/mirror-writable dispatch, help rows and the list --json mirror_read_only field (body in sources-mirror.ts); grown v0.46.22.0 phone wave: github source kind (#4104); +129 v0.47 gmail-loops: google source-kind flags + vault preflight + duplicate-account warn + access-mode validation; +8 set-path dispatch + help rows (#4739 — command body peeled to sources-set-path.ts); +29 #4698 adoption: --calendar-id flag + duplicate-account warn scoped to overlapping services; #5105: trusted writer administration route; company handlers and receipt status wiring; parsing stays in dedicated modules; canonical reconciliation: +5 engine-free sibling-command dispatch and help row, implementation remains in source-reconcile.ts; +4 fix wave 3 lane A: sources status connector recovery state and run counts (view lives in persistence/connector-status.ts); +3 fix wave 4 lane B: sources retry-held dispatch and help row (command body in sources-retry-held.ts) and the connector first-sync note on add; bodies in source-delete.ts and sources-set-path.ts); +4 #5984: sources status shows the managed sync backlog (logic in persistence/sync-drain.ts); v0.60.48.0 merge: #5984 growth re-summed over v0.60.47.0 (2031 measured); +11 W-B4: sources shared-skills dispatch, its --help guard and help rows, and the shared_skills field/lines in sources status (body in sources-shared-skills.ts, view in shared-skills/source-opt-out.ts); +4 #6188: uncommitted legacy fence-repair notices in sources status (logic in fence-repair/uncommitted.ts); +7 #6317: data_moving/movement_state on sources status and its human line (reader in persistence/sync-movement.ts), writer movement help row; +1 GBRA-133: sources reset-upstream help row (body in sources-reset-upstream.ts); fix wave 20 integration: lane 3 (#6827) and master growth compose at 2062 measured; +3 GBRA-150: sources resolve-path dispatch and help rows (body in sources-resolve-path.ts); +10 #7326: sources status parses --holds/--limit/--cursor and passes the git_holds listing mode, plus 4 help lines (bounding logic in persistence/connector-status.ts gitHoldStatusJson); +2 GBRA-133 Q1: sources set-sync dispatch and help row (body in sources-sync-enabled.ts); +4 G1 git-canonical: sources git-gap dispatch, doc line and help rows (body in sources-git-gap.ts); +4 G3 git-canonical: sources reindex dispatch, doc line and help rows (body in sources-reindex.ts); +1 GBRA-156: the sources add non-federated warning line; re-summed at the master 33d73cb5 merge (2086 measured); +4 G8a git-canonical: sources canonical dispatch, doc line and help rows (body in sources-canonical.ts, plan and apply in persistence/git-conversion.ts); GBRA-156: sources add --json and its next step (logic in sources-add-next.ts); re-summed at the master ade6d638 merge (2100 measured); +2 GBRA-220 PR 2: the unmanaged sources add routes --kind meetings|slack to the shared lifecycle parser (body in sources-add-api.ts); re-summed at the master b85dd645 merge (2102 measured); +2 #7701: the archived field of SourceListEntry and its list entry (sources list now marks archived sources; an interface field cannot move): re-summed at the 0.60.583.0 merge: 2102 + 2; +1 GST-1113: sources federate refuses a QM scope source (one line; the check lives in core/access/attest-sources.ts), re-summed at the 0.60.594.0 gate-ahead: 2107 + 1; +5 GST-1113 /ship fix round: sources federate checks the scope mark and writes the config in one transaction under the source row lock (the check lives in core/access/attest-sources.ts); +7 #8982: sources federate and restore print the remote-written pages without readers they expose, federate --json, the prior federation read under the row lock (the read and the lines live in core/access/federation-exposure.ts); +6 sources git-reconcile dispatch, header and help rows (body in sources-git-reconcile.ts), re-summed at the master d25bd680 merge (2124 + 6)+src/commands/sources.ts 2142 ratchet +3 url_source_origin: sources record-origin dispatch and help rows (body in sources-record-origin.ts, logic in core/url-source-origin.ts); +3 PR B: sources guard dispatch and help rows (body in sources-guard.ts); +3 G7b-2: sources host-repo dispatch and help row (body in sources-host-repo.ts and core/persistence/hosted-repo.ts); +5 PR #5955 / fix wave 14 P2.7: sources set-strategy dispatch and help row, the strategy field of sources list --json (body in sources-strategy.ts); +5 #5988: sources status/retry-held help rows describe Git holds (help lines cannot move); +2 #5988: sources status <id> filter and Git held files (view in persistence/connector-status.ts); +5 F0: sources refresh dispatch and help rows (command body in sources-refresh.ts, protocol in persistence/worktree-refresh.ts); +6 fix wave 5 #5409: mirror-readonly/mirror-writable dispatch, help rows and the list --json mirror_read_only field (body in sources-mirror.ts); grown v0.46.22.0 phone wave: github source kind (#4104); +129 v0.47 gmail-loops: google source-kind flags + vault preflight + duplicate-account warn + access-mode validation; +8 set-path dispatch + help rows (#4739 — command body peeled to sources-set-path.ts); +29 #4698 adoption: --calendar-id flag + duplicate-account warn scoped to overlapping services; #5105: trusted writer administration route; company handlers and receipt status wiring; parsing stays in dedicated modules; canonical reconciliation: +5 engine-free sibling-command dispatch and help row, implementation remains in source-reconcile.ts; +4 fix wave 3 lane A: sources status connector recovery state and run counts (view lives in persistence/connector-status.ts); +3 fix wave 4 lane B: sources retry-held dispatch and help row (command body in sources-retry-held.ts) and the connector first-sync note on add; bodies in source-delete.ts and sources-set-path.ts); +4 #5984: sources status shows the managed sync backlog (logic in persistence/sync-drain.ts); v0.60.48.0 merge: #5984 growth re-summed over v0.60.47.0 (2031 measured); +11 W-B4: sources shared-skills dispatch, its --help guard and help rows, and the shared_skills field/lines in sources status (body in sources-shared-skills.ts, view in shared-skills/source-opt-out.ts); +4 #6188: uncommitted legacy fence-repair notices in sources status (logic in fence-repair/uncommitted.ts); +7 #6317: data_moving/movement_state on sources status and its human line (reader in persistence/sync-movement.ts), writer movement help row; +1 GBRA-133: sources reset-upstream help row (body in sources-reset-upstream.ts); fix wave 20 integration: lane 3 (#6827) and master growth compose at 2062 measured; +3 GBRA-150: sources resolve-path dispatch and help rows (body in sources-resolve-path.ts); +10 #7326: sources status parses --holds/--limit/--cursor and passes the git_holds listing mode, plus 4 help lines (bounding logic in persistence/connector-status.ts gitHoldStatusJson); +2 GBRA-133 Q1: sources set-sync dispatch and help row (body in sources-sync-enabled.ts); +4 G1 git-canonical: sources git-gap dispatch, doc line and help rows (body in sources-git-gap.ts); +4 G3 git-canonical: sources reindex dispatch, doc line and help rows (body in sources-reindex.ts); +1 GBRA-156: the sources add non-federated warning line; re-summed at the master 33d73cb5 merge (2086 measured); +4 G8a git-canonical: sources canonical dispatch, doc line and help rows (body in sources-canonical.ts, plan and apply in persistence/git-conversion.ts); GBRA-156: sources add --json and its next step (logic in sources-add-next.ts); re-summed at the master ade6d638 merge (2100 measured); +2 GBRA-220 PR 2: the unmanaged sources add routes --kind meetings|slack to the shared lifecycle parser (body in sources-add-api.ts); re-summed at the master b85dd645 merge (2102 measured); +2 #7701: the archived field of SourceListEntry and its list entry (sources list now marks archived sources; an interface field cannot move): re-summed at the 0.60.583.0 merge: 2102 + 2; +1 GST-1113: sources federate refuses a QM scope source (one line; the check lives in core/access/attest-sources.ts), re-summed at the 0.60.594.0 gate-ahead: 2107 + 1; +5 GST-1113 /ship fix round: sources federate checks the scope mark and writes the config in one transaction under the source row lock (the check lives in core/access/attest-sources.ts); +7 #8982: sources federate and restore print the remote-written pages without readers they expose, federate --json, the prior federation read under the row lock (the read and the lines live in core/access/federation-exposure.ts); +6 sources git-reconcile dispatch, header and help rows (body in sources-git-reconcile.ts), re-summed at the master d25bd680 merge (2124 + 6); +12 GST-2456: sources push --scan-timeout (parse, usage and help lines) and its blocked_history refusal case (logic in core/workspace-push.ts)src/core/link-extraction.ts 2424 ratchet grown v0.46.26.0 megawave: link-aware timeline split + delimiter-outside-links (#3957 #4062 #3737); +37 wave-k #3908 reimpl: isCrossSourceLinksEnabled config ladder; +10 wave #4277: parseTimelineEntries skips generated backlink receipts; +17 #4855: latin-fold in normalizeBasename + dir-hint step tries both slug grammars; +17: #4855 Latin stroke-letter fold; +5: #4873 ./-relative markdown links kept as live references; +34 wave review: `../y.md` sibling links resolve on the DB path + folded bare-wikilink grammar (#4873 class); +62 #4977: role-prior suppression in machine-list sections (rolePriorSuppressedRanges, EntityRef.index); +3 composed with #4985 (variation-selector strip) in the same wave; +4 #4995: markdown-link anchor strip + lowercase-candidate rationale comments; +6 pre-landing review: #4977 suppression on code-stripped content + truthful watermark/section-list comments; T2: source-qualified inference and atomic origin-scoped derived links; canonical attendance evidence, source-qualified orientation, strict attendee resolution, and relocated filesystem link scanner (command export preserved); +4: pack-owned fallback and ambiguous attendee guards Display-label attendance exclusion, indexed evidence membership, and bounded strict resolver caching; attendance-boundary review.; complete attendance resolution and fence-safe evidence traversal; frontmatter discovery, canonical basename admission and code-aware attendance comment masking; exclude inline HTML comment spans from admitted attendance ranges; +17 write-path wave: same-name rule for entity fuzzy matches + rename-alias fallback in makeResolver; +1 #5567: materialized marker ends bullet detail; +30 #5749: unique global-basename step before fuzzy and live keyword resolution (ResolveOptions, watermark note); #5765: bold **Attendees:** label accepted + LINK_EXTRACTOR_VERSION_TS bump note; +10 eval-wave N9-2/N9-3/N12-7: pack frontmatter mappings inherit FRONTMATTER_LINK_MAP direction, page-type-bound pack attended follows canonical attendance, LINK_EXTRACTOR_VERSION_TS bump note; +1 #5623: normalizeBasename collapses hyphen runs like slugifySegment (extractor watermark note); +11 #5562: parseTimelineEntries accepts dated ### headings (FS-extractor parity); +3 eval-wave N12-6: Participants accepted as attendance evidence + LINK_EXTRACTOR_VERSION_TS bump note; +22 P5 wanted pages: AuthoredRef on body link candidates; -33 lowered: P5 moved machine-section ranges to core/machine-sections.ts and stated relation types to core/line-grammar.ts; +7 P5: ExtractPageLinksOptions interface + wikilinkAuthoredRef helper (keeps extractPageLinks under the function-size limit); +32 P5: per-edge verb attachment (attachedVerb, VERB_RULES) + joined-as works_at + extractor watermark note; P5 x temporal-edges merge: verb attachment reads the verb at the link's own position in the window (excerptAnchor) and the within-page dedup (now dedupeCandidates) drops a mention of a target the page also links with a typed edge; links joined only by commas/conjunctions share the verb before the first (coordinated); board roles (BOARD_RE, BOARD_AFTER_RE) resolve to invested_in for an investor page and advises otherwise, never works_at; +1 fix wave 11 #6191: imports targetTakesVerb (role-verb target guard lives in link-target-roles.ts); v0.60.105.0 merge: #5984 Phase 5 link preparation (+6) re-summed over wave 11 at 2211; +109 Q2 Track C: stable verb-rule ids, traceLinkType/explainLinkType (reasons for every typing decision), per-occurrence typer hoisted out of extractPageLinks (makeTypeFor); unit logic lives in core/link-typing-units.ts; +25 Q2 Track C: typing-unit verb rules and vetoes in attachedVerb/traceLinkType, validity stints in explainLinkType; +4 U3: board-seat rule split out of INVESTED_RE (same verb and precedence) and investor-prior/link offsets passed to unit vetoes; +11 U2: locateLink shared by attachedVerb and the U2 post-pass in traceLinkType; -11 lowered: Q2 verdict reverted U2 (locateLink and the post-pass); +21 fix wave 13 P4.10 #6266: resolveSameDirSlug + exported resolveMarkdownLinkSlug, shared with the link validator; +41 Wave B PR 2 lane 2e: extractPageLinks split into extractBodyLinks (window-scoped, offset-shifted, pass-tagged candidates) and frontmatterLinks, plus entityRefPasses, candidateKey, rolePriorPhrases and the roleText/regexBudget/window options, so a segmented page streams through the same extractor (window and merge logic in core/page-body/segment-links.ts); +1 at the #6869 gate-ahead merge: the #6803 wave EXTRACTOR_BUMP_NOTES comment composed with lane 2e (2420 + 1); +3 G5 (GBRA-60): extractBodyLinks masks the ## Links fence (links-fence.ts), whose rows are projected as their own edgessrc/core/embedding-migration.ts 1587 ratchet new row: crossed 1500 in v0.46.25.0 fix waves (#4305 #4306 chunk-model truth helpers); retired provider integration removed; safety wave: canonical projection readiness and fact-aware completion; file configuration publication retains lease-row locks; +8 transactional retained-vector rebuildability checks before destructive migration boundaries; archived eligibility: source-locked reconciliation and live/current smoke revalidation; +2 #5680: authorization_generation field and its carry-forward on same-target re-apply (settle idempotency); +10 #5226: plan carries chunks_to_restamp beside chunks_to_embed; +9 #5088: schema transition defers HNSW builds into the marker (deferred_ann_indexes), carry-forward on re-apply, verify blocks on pending/INVALID ANN indexes (build phase in embedding-ann-build.ts); +10 #5088: dim-pinned tables (query_cache, facts, and any later entry of TEXT_EMBEDDING_DIM_PINNED_TABLES) defer their HNSW through the same worklist (DEFERRED_ANN_TABLES, recordDeferredAnnIndexes); +25 wave 8 lane D1 #5885: takes in the dim-pinned column list, plan (takes_to_embed), status (takes_pending) and completion verify; +17 #5334: smoke check samples one representative chunk per distinct page (bounded index-ordered batch walk, longest chunk re-read under the page lock, title-prefixed bounded query); +1 #5334: the smoke-query length limits are shared with the worst-case budgetsrc/core/github-source.ts 1530 ratchet new row: crossed the 1500 unlisted cap in v0.46.23.0 review fix wave (scope-state gating, client hardening, symlink containment); merged reliability/shared-skills source integration; managed sweep lease wrapper; fix wave 3 lane A: config parser peeled to github-source-config.ts (-47), +account pin wiring and pinned-installation refresh@@ -48,5 +48,5 @@ src/commands/doctor/checks/extraction-sync.ts 1500 ratchet +7 GBRA-130 A-1: linksrc/core/search/evidence-delivery.ts 1759 ratchet +5 W5: EvidencePlan.rankCut resolved with the plan (logic in search/page-rank-cut.ts); +20 W5 whole_pages: wholeCost prices a block as delivery would emit it whole (needs the private Block/enrichBlock internals) and the cut is wired before allocate (cutWholePages lives in search/page-rank-cut.ts); new row: crossed the 1500 unlisted cap at the #6367 merge (master 1479, its explicit-budget cap) by the C1 date header threaded through every block path, cap included; pagePlanHits (search/page-plan-hits.ts) and the header loader (evidence-date.ts blockDateHeaders) were peeled first; peel candidate: allocateCapped; +8 at the #6396 merge: page evidence text cut through the fence-chunk trust overlay and the caller minTrust floor (re-summed: our 1504 + master +8); +119 Cat 40 next wave F2: the search.long_page_unit policy (withLongPagePolicy, selectLongPages size preflight with page/byte/deadline limits) and the long-page fetch and fallback in deliverEvidence, kept in the shared seam the plan names (gbrain-evals docs/plans/2026-10-11-cat40-next-wave, F2); +17 F2 rework to the frozen-comparison policy: search.long_page_min_chars (rendered-body characters, default 20,000) read in withLongPagePolicy, a character count in the preflight, the rendered-body confirmation in deliverEvidence, and the long-page row exemption in capDeliveredSnippets (re-summed at the 0.60.225.0 merge: master 1537 + F2 136); +39 Wave B PR 2 lane 2b: planSegmentedBlock joins the windows search/segmented-evidence.ts reads around a segmented page's hits into one run-marked document (needs the private Doc/Piece/buildDoc/locateAnchor internals), planBlock's unit cut split into blockFromDoc for both, sections bounded by their run, selectionCost counts a gap between runs, and the fetch skips the whole-body fence overlay for a segmented page; +4 segmented pages read at once before planning (segmentedReads; the read is search/segmented-evidence.ts, the statements page-body/read-range.ts); +17 GBRA-156: tail trim plan flag, DeliverOptions.query, DeliveryMeta.tail_trim, the trim call and the frozen-hit score/query library fields (logic in search/evidence-tail-trim.ts; interface fields cannot move); +7 GBRA-205: EvidencePlan.titleHeader and DeliveryMeta.title_header (interface fields cannot move) and the titles option on the header loader (logic in search/evidence-date.ts; the query budget key lives in search/evidence-packing.ts); +11 #7600: assemble_evidence quotes conversation rows and capEvidenceToBudget counts the quote fence (logic in search/transcript-quote.ts); +2 GBRA-156 /ship review: the cut-path admission and title room count the quote fence; +2 GBRA-156 /ship review pass 2: capEvidenceToBudget counts the fence only for the paths that fence (quote flag; recall counts the text as returned); +4 GST-687: page evidence and the extractive fallback quote below-owner-tier text for untrusted readers (untrusted flag; logic in search/transcript-quote.ts)src/commands/config.ts 1530 ratchet +1 GBRA-216: recall.* config set value refusal (facts/recall-config.ts); +1 GBRA-216: config set refuses a dream.claim_conflicts.mode other than propose|off (refusal in facts/claim-conflicts.ts); new row: crossed the 1500 unlisted cap in wave 15 P7.4 #5461: set-time validation of think.pages_budget_chars / think.excerpt_ceiling_chars (range + parser live in core/think/pages-budget.ts), mirroring the cycle.consolidate.cluster_threshold hook; +1 wave 16 G5.1 (#6495): set-time refusal hook for search.keyword_statement_timeout_ms (check lives in commands/config/keyword-timeout-value.ts); +1 wave 18b lane 5 (#5012 item 6): search.contextual_retrieval prints the existing-pages hint after the write (text lives in commands/config/contextual-mode-hint.ts); +1 #6712 PR 2: retired/rollback sync key dispatch line (logic in core/sync-config-keys.ts handleSyncKeyConfig); +1 #6865: sync.slug_conflicts.auto_remove boolean validation at set time (refusal text in repair/slug-autoheal.ts); +1 #6948: sync.origin_twins.auto_resolve boolean validation at set time (refusal text in repair/origin-twins-heal.ts); +2 #6795: config set chat_model/expansion_model help line and the model-pin import (shadow report and file-pin unset live in commands/config/model-pin-shadow.ts); +1 #6712 PR 4b: sync.admission set-time hook (value logic in commands/config/sync-admission-value.ts); +4 #7130: set-time refusal hook for sync.max_deletes / sync.max_delete_ratio (and .source.<id>) / purge.retention_hours (check lives in core/sync-reconcile.ts deleteSafetyConfigRefusal); +1 GBRA-150: sync.metafile_pages set-time route (body in config/sync-metafile-pages-value.ts); re-summed at the v0.60.330.0 merge (1520 measured); +2 #7242 minions.terminal_hook file-plane key and its set branch (logic in minions/terminal-hook.ts); +1 GBRA-161: generations.* set-time route (refusal in commands/config/generations-values.ts); +1 GBRA-207 #7630: sync.repo_path set-time refusal hook (refusal in core/sync-config-keys.ts syncRepoPathRefusal); +4 GBRA-377 PR B: skills.resolver.* file-plane routing (doc line, the one-line router and its two dispatch lines; logic in core/setup/skill-resolver-config.ts)src/commands/mcp-expose.ts 1519 ratchet hosted_option: Session carries the gbrain.io coaching notice on the first-receipt run and Tailscale/service friction exits (copy, refs and gating live in core/onboard/hosted-option.ts); +7 GBRA-199: --surface help lines, surfaceChosen option field and the advertise pass-through (registrationAdvertise in core/mcp-registration.ts)-src/core/behavior-change-notice.ts 1728 ratchet +4 train R: #7491/#7492 keyword_identifier_probe and keyword_slug_handles rows and their comment, #7175 keyword phrase row; the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +1 GBRA-156 #7593: private_pages_granted_sources row (re-summed at the 0.60.527.0 merge: 1574 + 1); +3 GBRA-200 comment, write-grant refusal and degraded-stamp rows (re-summed at the 0.60.562.0 merge: 1615 + 3); +2 GBRA-280 get_page selector-precedence row and comment (re-summed at the 0.60.569.0 merge: 1619 + 2); the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +2 GBRA-205 saved_facts_stems row and its comment (re-summed at the #7901 0.60.492.0 merge: 1541 + 2); +2 GBRA-205 search.query_facts_block default-on row and its approval comment (re-summed at the #7610 0.60.490.0 merge: 1539 + 2); +2 the #7900 content checkpoint host-move row (since TBD until the merge slot), +2 the #7897 private-hold sweep row (since TBD until the merge slot), +2 the #7880 ingest_capture and company-brain private-hold row (since TBD until the merge slot), +5 the frozen-source wave comment and four rows (#7868, #7850, #7869/#7870, #7871), +2 the #7848 visibility_noncanonical hold row (since TBD until the merge slot), +2 the #7846 extract_atoms session-source row (re-summed at the 0.60.481.0 merge: master 1524 + 2), +2 the #7805 synthesize session-source and #7841 visibility_not_applied rows (re-summed at the 0.60.480.0 merge: master 1522 + 2), +2 strict door planned-state row (#7705, re-summed at the 0.60.470.0 merge: master 1514 + 2), +2 Bun floor 1.4.4 row (#7644), the GBRA-95 RLS backfill row (+2), +3 rows for #7596 pass_interrupted, #7599 read-only serve and the --access=read-only ceiling, +1 G5 lane C trust_release row, +1 #7619 cli_flag_equals, +3 GBRA-207 #7630 relative-anchor and stalled-write rows, +2 the #7632 function search_path disclosure row and +2 the #7679 orphaned worktree refresh row (re-summed at the 0.60.471.0 merge: master 1516 + 2), +2 the #7814 retired v0.13.1 grandfather row, +2 the #7618 conversion withhold/progress/push row (master 1520 + 2); the behavior-change table split (#7607) retires this row; +4 GBRA-188 #7489: the wave comment and three rows (brain-first instructions, starter surface default, per-turn rule); +1 GBRA-188 plugin_turn_hook_gbra188 row; +1 GBRA-242 provider_key_rules_7959 row (#7959), +2 the GBRA-199 registration_lists_verbs row (since TBD until the merge slot); +2 GBRA-133 #7652: the #7611 pass_abandoned reader row and the lean read-only serve socket row (re-summed at the 0.60.503.0 merge: master 1555 + 2); +1 GBRA-243: the per-turn hook disclosure row (rows are data and cannot move); +4 GBRA-156 #7598 harness wave comment and rows (remote page cap, sources_not_readable refusal, sources add next step); +4 GBRA-156 #7601 search_quotes_transcript_rows comment and row; +1 GBRA-175 #7475 autopilot_restarts_serve_7475 row (re-summed at the #8012 merge: 1566 + 1); +3 #7997/#8014/#8015 rows (redaction markers, company db_only keep, ignored supabase_only scope); +2 #7199 (re-port of #7228) classic_drift_rescreen_7199 comment and row; +2 #7931 file_drift_agrees_7931 comment and row; +1 #7950 file_drift_slug_release_7950 row; +1 #7974 file_drift_followups_7974 row; +1 #8059 quoted_fence_marker_8059 row; +2 GBRA-247 #8009 provenance_repair_held_8009 and #7982 pass_transient_streak_7982 rows; +4 GBRA-247 #7973 plain_directory_sync_7973, #7988 managed_marker_own_directory_7988, #7985 former_binding_parked_group_7985 and settle_effects_retire_7985 rows Train S merge: 1570 base + 5 (master since the #8077 base) + 13 (#8077) = 1588.; +2 GST-687 remote_quotes_unverified_text_gst687 row and its comment (re-summed at the gate-ahead on train S 0.60.534.0: 1588 + 2); +2 #8377: the quote fence follow-ups row and its comment; +2 #8384: the quote fence follow-ups 2 row and its comment; +2 #8384 wave 3: the quote fence follow-ups 3 row and its comment; +5 GBRA-218 train M rows (A1 member_read_access_gbra218 and member_access_hatch_scope_gbra218, B shared_agent_audience_gbra231, A2 folder_access_rules_gbra218, folder_access_scoped_role_gbra218), re-summed at the train M merge of master v0.60.541.0: 1596 + 5 = 1601 measured; +3 GST-359 train C rows (C1 qm_attested_actor_gst359, C2 member_facts_gst359, D qm_memory_provider_gst359), re-summed at the train C merge of master v0.60.543.0: 1601 + 3 = 1604 measured; +2 #8424: hook_launcher_8424 row and its comment (rows are data and cannot move), re-summed at the #8418 v0.60.546.0 merge: 1604 + 2 = 1606 measured; +2 #8426: mcp_lane_launcher_8426 row and its comment (rows are data and cannot move); +2 GST-927: empty_nonstring_args_gst927 row and its comment, re-summed at the gate-ahead on master v0.60.550.0 plus #8420: 1610 measured; +2 GBRA-283 Wave A (#8460): engine_keyed_caches_gbra283 row and its comment (rows are data and cannot move); +2 GBRA-287: segmented_freeze_hold_gbra287 and segmented_reexport_gbra287 rows (rows are data and cannot move); +1 GST-1209: segmented_tiling_gst1209 row (rows are data and cannot move); +1 GST-1251: skillopt_loop_deprecated_gst1251 row (rows are data and cannot move); +1 GST-1209 follow-up: untiled_hold_repair_gst1209 row (rows are data and cannot move); +1 GBRA-283 B3a: embedded_scope_required_gbra283 row (rows are data and cannot move); re-summed at the train R merge with v0.60.574.0: 1623 + 4; +2 GST-1387: refresh_fence_refusal_gst1387 row and its comment (rows are data and cannot move); re-summed at the memory train #8481 merge with v0.60.578.0 (1643 measured); +3 GBRA-253 #8109 rows (frontmatter_drift_write_8109, contacts_activity_advance_8109, contact_rows_dedupe_8109; rows are data and cannot move), re-summed at the master v0.60.581.0 merge: 1643 + 3 = 1646 measured; +3 #8123 part C rows: sync_write_through_off_writeback_7084, managed_sync_dry_run_counts_7087, frontmatter_missing_source_dir_7889 (since TBD until the merge slot; re-summed at the 0.60.583.0 merge: 1646 + 3); +4 PR B commit_ledger_prb, doctor_foreign_writers_prb and sources_guard_prb rows and their comment (rows are data and cannot move; since TBD until the merge slot); +1 PR B #8615: file_drift_held_needs_prefer_8615 row; +1 PR B #8617: refresh_source_changed_retry_8617 row; +1 PR B #8662: commit_push_checkout_not_a_source_8662 row (since TBD until the merge slot; rows are data and cannot move); +2 PR B refresh_barrier_prb and commit_push_base_prb rows (re-summed: 1658 measured); +3 convergence PR A: the wave comment and two rows (conversion_content_evidence_pr_a, git_gap_live_pages_pr_a; since TBD until the merge slot; rows are data and cannot move); re-summed at the gate-ahead on master v0.60.592.0 plus #8711: 1658 + 3 = 1661 measured; +4 GST-1094/GST-900 rows (memory_recall scope-read, member-bound acting_user, recall max_chars, unknown_param _meta-only) and +1 qm_scope_writes_gst1113 and +1 recall_question_terms_gst1304 rows (rows are data and cannot move), re-summed at the 0.60.595.0 slot merge: 1661 + 6; +1 GST-1582 refresh_barrier_import_gst1582 row (since TBD until the merge slot; rows are data and cannot move); +2 GST-1601 source_changed_origin_gst1601 and adopt_local_edits_gst1601 rows (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.596.0 merge: 1668 + 2; +1 GST-1623 refresh_barrier_capacity_gst1623 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.599.0 merge: 1670 + 1; +2 GBRA-224 W1 release_channel_stable_default row and its comment; +1 GST-1623 refresh_barrier_later_write_gst1623 row (#8765; rows are data and cannot move); +5 #8766 GST-1623 items 4/6-9 and #8755: the wave comment and four rows (doctor_foreign_writers_partial_gst1623, commit_push_enclosing_repo_gst1623, owner_guard_fail_closed_gst1623, adopt_local_edits_hardening_8755) and +1 managed_sync_kind_reserved_8765 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on master v0.60.608.0 plus #8798: 1674 + 6; +1 GST-1853 refresh_barrier_aborted_refresh_sync_gst1853 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.613.0 merge: 1680 + 1; +1 GST-1674 refresh_refused_merge_recovery_gst1674 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.614.0 merge: 1681 + 1; +1 #8824/#8826/#8767: adopt_local_edits_replay_markers_8824 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8837: 1682 + 1; +1 url_source_origin row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8834: 1683 + 1; +1 #8828: the refresh_replan_own_commits_8828 row (1684 + 1 at the 0.60.618.0 slot); +1 the managed commit-push unpublished-count row; +1 the refresh publish-diverged default row; +1 GST-2051 ungranted_member_writes_gst2051 row (since TBD until the merge slot; rows are data and cannot move); +1 GST-731 think_window_trajectory_gst731 row and +1 GST-1602 purge_cancels_deferred_write_gst1602 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8915 v0.60.621.0: 1688 + 2; +1 GST-2059: owner_reads_private row; +1 #8888: the record-origin checkout lock-down row (re-summed at the Q6 stack on #8934 v0.60.625.0: 1691 + 1); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 GST-1158 E1/F3/F4 rows (since TBD until the merge slot), re-summed at the master merge; +1 GBRA-284 personal_sources_gbra284 row (since TBD until the merge slot) (re-summed at the QM wave merge onto master v0.60.626.0: 1692 + 3); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 GST-1158 v3: the qm_personal_structured_gst1158 row (since TBD until the merge slot); +1 #8477 GST-1158 F2 personal-tools row at the QM wave merge (1695 + 1); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 #8483 memory_propose row at the QM wave merge (1696 + 1); +1 GST-1094 gap 4: the qm_admin_http_gst1094 row (since TBD until the merge slot); +1 GST-1158: the member_email_link_gst1158 row (since TBD until the merge slot); +2 #8479 member-email rows at the QM wave merge (1697 + 2); +1 GST-2112: ingest_keeps_readers_gst2112 row (re-summed at the Q7 v0.60.627.0 merge: 1692 + 1); +1 #8982 federated_member_writes_8982 row (since TBD until the merge slot; rows are data and cannot move); +1 GST-2116 commit_push_skipped_paths_gst2116 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the Q10 slot on #9009 ee0f4a78: 1694 + 1; +1 GST-2118 pending_ledger_flagged_gst2118 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the Q12 slot on #9016 afb49de5: 1695 + 1; +1 GBRA-431: read_scope_params_gbra431 row (rows are data and cannot move), re-summed at the #9032 stack merge: 1697 measured; +2 GST-2201 sync_restored_file_gst2201 and purge_keeps_committed_file_gst2201 rows (since is the current VERSION until the merge slot; +1 GST-2243 remember_share_gst2243 row (re-summed at the #9098 stack merge: 1699 + 1); +1 GST-2312 #9024 sync_filter_owned_hold_9024 row (re-summed at the #9064 stack merge: 1700 + 1; rows are data and cannot move); +2 access-privacy wave (0.60.649.0): the owner_private_facts_gst2089 and private_labels_write_ahead_gst2092 rows; +1 GBRA-443 private_labels_batch_exit_gbra443 row (rows are data and cannot move), re-summed at the 0.60.650.0 slot on #9038: 1703 + 1; +1 postgres_tls_default row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.651.0 merge: 1704 + 1; +1 GST-2331 sync_reads_fetch_nothing_gst2331 row (rows are data and cannot move), re-summed at the 0.60.654.0 stack on #9045 6ff5540d: 1705 + 1; +7 QM wave (#9037) rows: attest_scope_read_ops_gst1158, attest_direct_page_writes_deferred_gst1158, personal_sources_gbra284, qm_personal_structured_gst1158, memory_propose_held_writes_gst1158, member_email_link_gst1158, qm_admin_http_gst1094 (re-summed at the 0.60.655.0 stack on #9110 f9b2072e: 1706 + 7); +1 GST-2228 recreated_takes_section_keeps_stored_takes_gst2228 row (since TBD; re-summed at the keep-takes-and-link-dates train merge: 1713 + 1); +1 GST-2228 links_rows_keep_own_dates_gst2228 row (since TBD; re-summed at the same train merge: 1714 + 1); +2 the W1 + memory proposals train (#9133): attest_every_page_write_deferred_gst2249 and memory_proposals_owner_http_gst2407 rows (rows are data and cannot move), re-summed at the #9138 v0.60.661.0 stack merge: 1715 + 2 = 1717 measured; +1 #8903 effect_git_secret_gate_gst1923 row (rows are data and cannot move), re-summed at the 0.60.664.0 stack on #9142 3931adb4: 1717 + 1; +1 GST-2407 PR 3: qm_recall_own_page_contract_v4 row (rows are data and cannot move), re-summed at the 0.60.666.0 stack on #9148 69c12917: 1718 + 1; +2 GST-363 PR 1 and PR 3 (#9135): the serves_several_labels_gst363 and stdio_member_per_harness_gst363 rows; +3 #9134 train rows member_forget_names_host_9101, refresh_fence_retry_id_gst2353 and recorded_read_view_args_gst2214 (rows are data and cannot move), re-summed at the #9134 slot merge onto #8829 dfc24954: 1721 + 3; +3 source-checkouts wave rows (autopilot_git_reconcile_gbra386, unknown_drift_history_rescreen, refresh_abandon_members_gst1465), re-summed at the #9137 stack merge: 1724 + 3; +1 #8902 unmanaged_push_history_scan_8902 row+src/core/behavior-change-notice.ts 1729 ratchet +4 train R: #7491/#7492 keyword_identifier_probe and keyword_slug_handles rows and their comment, #7175 keyword phrase row; the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +1 GBRA-156 #7593: private_pages_granted_sources row (re-summed at the 0.60.527.0 merge: 1574 + 1); +3 GBRA-200 comment, write-grant refusal and degraded-stamp rows (re-summed at the 0.60.562.0 merge: 1615 + 3); +2 GBRA-280 get_page selector-precedence row and comment (re-summed at the 0.60.569.0 merge: 1619 + 2); the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +2 GBRA-205 saved_facts_stems row and its comment (re-summed at the #7901 0.60.492.0 merge: 1541 + 2); +2 GBRA-205 search.query_facts_block default-on row and its approval comment (re-summed at the #7610 0.60.490.0 merge: 1539 + 2); +2 the #7900 content checkpoint host-move row (since TBD until the merge slot), +2 the #7897 private-hold sweep row (since TBD until the merge slot), +2 the #7880 ingest_capture and company-brain private-hold row (since TBD until the merge slot), +5 the frozen-source wave comment and four rows (#7868, #7850, #7869/#7870, #7871), +2 the #7848 visibility_noncanonical hold row (since TBD until the merge slot), +2 the #7846 extract_atoms session-source row (re-summed at the 0.60.481.0 merge: master 1524 + 2), +2 the #7805 synthesize session-source and #7841 visibility_not_applied rows (re-summed at the 0.60.480.0 merge: master 1522 + 2), +2 strict door planned-state row (#7705, re-summed at the 0.60.470.0 merge: master 1514 + 2), +2 Bun floor 1.4.4 row (#7644), the GBRA-95 RLS backfill row (+2), +3 rows for #7596 pass_interrupted, #7599 read-only serve and the --access=read-only ceiling, +1 G5 lane C trust_release row, +1 #7619 cli_flag_equals, +3 GBRA-207 #7630 relative-anchor and stalled-write rows, +2 the #7632 function search_path disclosure row and +2 the #7679 orphaned worktree refresh row (re-summed at the 0.60.471.0 merge: master 1516 + 2), +2 the #7814 retired v0.13.1 grandfather row, +2 the #7618 conversion withhold/progress/push row (master 1520 + 2); the behavior-change table split (#7607) retires this row; +4 GBRA-188 #7489: the wave comment and three rows (brain-first instructions, starter surface default, per-turn rule); +1 GBRA-188 plugin_turn_hook_gbra188 row; +1 GBRA-242 provider_key_rules_7959 row (#7959), +2 the GBRA-199 registration_lists_verbs row (since TBD until the merge slot); +2 GBRA-133 #7652: the #7611 pass_abandoned reader row and the lean read-only serve socket row (re-summed at the 0.60.503.0 merge: master 1555 + 2); +1 GBRA-243: the per-turn hook disclosure row (rows are data and cannot move); +4 GBRA-156 #7598 harness wave comment and rows (remote page cap, sources_not_readable refusal, sources add next step); +4 GBRA-156 #7601 search_quotes_transcript_rows comment and row; +1 GBRA-175 #7475 autopilot_restarts_serve_7475 row (re-summed at the #8012 merge: 1566 + 1); +3 #7997/#8014/#8015 rows (redaction markers, company db_only keep, ignored supabase_only scope); +2 #7199 (re-port of #7228) classic_drift_rescreen_7199 comment and row; +2 #7931 file_drift_agrees_7931 comment and row; +1 #7950 file_drift_slug_release_7950 row; +1 #7974 file_drift_followups_7974 row; +1 #8059 quoted_fence_marker_8059 row; +2 GBRA-247 #8009 provenance_repair_held_8009 and #7982 pass_transient_streak_7982 rows; +4 GBRA-247 #7973 plain_directory_sync_7973, #7988 managed_marker_own_directory_7988, #7985 former_binding_parked_group_7985 and settle_effects_retire_7985 rows Train S merge: 1570 base + 5 (master since the #8077 base) + 13 (#8077) = 1588.; +2 GST-687 remote_quotes_unverified_text_gst687 row and its comment (re-summed at the gate-ahead on train S 0.60.534.0: 1588 + 2); +2 #8377: the quote fence follow-ups row and its comment; +2 #8384: the quote fence follow-ups 2 row and its comment; +2 #8384 wave 3: the quote fence follow-ups 3 row and its comment; +5 GBRA-218 train M rows (A1 member_read_access_gbra218 and member_access_hatch_scope_gbra218, B shared_agent_audience_gbra231, A2 folder_access_rules_gbra218, folder_access_scoped_role_gbra218), re-summed at the train M merge of master v0.60.541.0: 1596 + 5 = 1601 measured; +3 GST-359 train C rows (C1 qm_attested_actor_gst359, C2 member_facts_gst359, D qm_memory_provider_gst359), re-summed at the train C merge of master v0.60.543.0: 1601 + 3 = 1604 measured; +2 #8424: hook_launcher_8424 row and its comment (rows are data and cannot move), re-summed at the #8418 v0.60.546.0 merge: 1604 + 2 = 1606 measured; +2 #8426: mcp_lane_launcher_8426 row and its comment (rows are data and cannot move); +2 GST-927: empty_nonstring_args_gst927 row and its comment, re-summed at the gate-ahead on master v0.60.550.0 plus #8420: 1610 measured; +2 GBRA-283 Wave A (#8460): engine_keyed_caches_gbra283 row and its comment (rows are data and cannot move); +2 GBRA-287: segmented_freeze_hold_gbra287 and segmented_reexport_gbra287 rows (rows are data and cannot move); +1 GST-1209: segmented_tiling_gst1209 row (rows are data and cannot move); +1 GST-1251: skillopt_loop_deprecated_gst1251 row (rows are data and cannot move); +1 GST-1209 follow-up: untiled_hold_repair_gst1209 row (rows are data and cannot move); +1 GBRA-283 B3a: embedded_scope_required_gbra283 row (rows are data and cannot move); re-summed at the train R merge with v0.60.574.0: 1623 + 4; +2 GST-1387: refresh_fence_refusal_gst1387 row and its comment (rows are data and cannot move); re-summed at the memory train #8481 merge with v0.60.578.0 (1643 measured); +3 GBRA-253 #8109 rows (frontmatter_drift_write_8109, contacts_activity_advance_8109, contact_rows_dedupe_8109; rows are data and cannot move), re-summed at the master v0.60.581.0 merge: 1643 + 3 = 1646 measured; +3 #8123 part C rows: sync_write_through_off_writeback_7084, managed_sync_dry_run_counts_7087, frontmatter_missing_source_dir_7889 (since TBD until the merge slot; re-summed at the 0.60.583.0 merge: 1646 + 3); +4 PR B commit_ledger_prb, doctor_foreign_writers_prb and sources_guard_prb rows and their comment (rows are data and cannot move; since TBD until the merge slot); +1 PR B #8615: file_drift_held_needs_prefer_8615 row; +1 PR B #8617: refresh_source_changed_retry_8617 row; +1 PR B #8662: commit_push_checkout_not_a_source_8662 row (since TBD until the merge slot; rows are data and cannot move); +2 PR B refresh_barrier_prb and commit_push_base_prb rows (re-summed: 1658 measured); +3 convergence PR A: the wave comment and two rows (conversion_content_evidence_pr_a, git_gap_live_pages_pr_a; since TBD until the merge slot; rows are data and cannot move); re-summed at the gate-ahead on master v0.60.592.0 plus #8711: 1658 + 3 = 1661 measured; +4 GST-1094/GST-900 rows (memory_recall scope-read, member-bound acting_user, recall max_chars, unknown_param _meta-only) and +1 qm_scope_writes_gst1113 and +1 recall_question_terms_gst1304 rows (rows are data and cannot move), re-summed at the 0.60.595.0 slot merge: 1661 + 6; +1 GST-1582 refresh_barrier_import_gst1582 row (since TBD until the merge slot; rows are data and cannot move); +2 GST-1601 source_changed_origin_gst1601 and adopt_local_edits_gst1601 rows (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.596.0 merge: 1668 + 2; +1 GST-1623 refresh_barrier_capacity_gst1623 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.599.0 merge: 1670 + 1; +2 GBRA-224 W1 release_channel_stable_default row and its comment; +1 GST-1623 refresh_barrier_later_write_gst1623 row (#8765; rows are data and cannot move); +5 #8766 GST-1623 items 4/6-9 and #8755: the wave comment and four rows (doctor_foreign_writers_partial_gst1623, commit_push_enclosing_repo_gst1623, owner_guard_fail_closed_gst1623, adopt_local_edits_hardening_8755) and +1 managed_sync_kind_reserved_8765 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on master v0.60.608.0 plus #8798: 1674 + 6; +1 GST-1853 refresh_barrier_aborted_refresh_sync_gst1853 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.613.0 merge: 1680 + 1; +1 GST-1674 refresh_refused_merge_recovery_gst1674 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.614.0 merge: 1681 + 1; +1 #8824/#8826/#8767: adopt_local_edits_replay_markers_8824 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8837: 1682 + 1; +1 url_source_origin row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8834: 1683 + 1; +1 #8828: the refresh_replan_own_commits_8828 row (1684 + 1 at the 0.60.618.0 slot); +1 the managed commit-push unpublished-count row; +1 the refresh publish-diverged default row; +1 GST-2051 ungranted_member_writes_gst2051 row (since TBD until the merge slot; rows are data and cannot move); +1 GST-731 think_window_trajectory_gst731 row and +1 GST-1602 purge_cancels_deferred_write_gst1602 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8915 v0.60.621.0: 1688 + 2; +1 GST-2059: owner_reads_private row; +1 #8888: the record-origin checkout lock-down row (re-summed at the Q6 stack on #8934 v0.60.625.0: 1691 + 1); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 GST-1158 E1/F3/F4 rows (since TBD until the merge slot), re-summed at the master merge; +1 GBRA-284 personal_sources_gbra284 row (since TBD until the merge slot) (re-summed at the QM wave merge onto master v0.60.626.0: 1692 + 3); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 GST-1158 v3: the qm_personal_structured_gst1158 row (since TBD until the merge slot); +1 #8477 GST-1158 F2 personal-tools row at the QM wave merge (1695 + 1); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 #8483 memory_propose row at the QM wave merge (1696 + 1); +1 GST-1094 gap 4: the qm_admin_http_gst1094 row (since TBD until the merge slot); +1 GST-1158: the member_email_link_gst1158 row (since TBD until the merge slot); +2 #8479 member-email rows at the QM wave merge (1697 + 2); +1 GST-2112: ingest_keeps_readers_gst2112 row (re-summed at the Q7 v0.60.627.0 merge: 1692 + 1); +1 #8982 federated_member_writes_8982 row (since TBD until the merge slot; rows are data and cannot move); +1 GST-2116 commit_push_skipped_paths_gst2116 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the Q10 slot on #9009 ee0f4a78: 1694 + 1; +1 GST-2118 pending_ledger_flagged_gst2118 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the Q12 slot on #9016 afb49de5: 1695 + 1; +1 GBRA-431: read_scope_params_gbra431 row (rows are data and cannot move), re-summed at the #9032 stack merge: 1697 measured; +2 GST-2201 sync_restored_file_gst2201 and purge_keeps_committed_file_gst2201 rows (since is the current VERSION until the merge slot; +1 GST-2243 remember_share_gst2243 row (re-summed at the #9098 stack merge: 1699 + 1); +1 GST-2312 #9024 sync_filter_owned_hold_9024 row (re-summed at the #9064 stack merge: 1700 + 1; rows are data and cannot move); +2 access-privacy wave (0.60.649.0): the owner_private_facts_gst2089 and private_labels_write_ahead_gst2092 rows; +1 GBRA-443 private_labels_batch_exit_gbra443 row (rows are data and cannot move), re-summed at the 0.60.650.0 slot on #9038: 1703 + 1; +1 postgres_tls_default row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.651.0 merge: 1704 + 1; +1 GST-2331 sync_reads_fetch_nothing_gst2331 row (rows are data and cannot move), re-summed at the 0.60.654.0 stack on #9045 6ff5540d: 1705 + 1; +7 QM wave (#9037) rows: attest_scope_read_ops_gst1158, attest_direct_page_writes_deferred_gst1158, personal_sources_gbra284, qm_personal_structured_gst1158, memory_propose_held_writes_gst1158, member_email_link_gst1158, qm_admin_http_gst1094 (re-summed at the 0.60.655.0 stack on #9110 f9b2072e: 1706 + 7); +1 GST-2228 recreated_takes_section_keeps_stored_takes_gst2228 row (since TBD; re-summed at the keep-takes-and-link-dates train merge: 1713 + 1); +1 GST-2228 links_rows_keep_own_dates_gst2228 row (since TBD; re-summed at the same train merge: 1714 + 1); +2 the W1 + memory proposals train (#9133): attest_every_page_write_deferred_gst2249 and memory_proposals_owner_http_gst2407 rows (rows are data and cannot move), re-summed at the #9138 v0.60.661.0 stack merge: 1715 + 2 = 1717 measured; +1 #8903 effect_git_secret_gate_gst1923 row (rows are data and cannot move), re-summed at the 0.60.664.0 stack on #9142 3931adb4: 1717 + 1; +1 GST-2407 PR 3: qm_recall_own_page_contract_v4 row (rows are data and cannot move), re-summed at the 0.60.666.0 stack on #9148 69c12917: 1718 + 1; +2 GST-363 PR 1 and PR 3 (#9135): the serves_several_labels_gst363 and stdio_member_per_harness_gst363 rows; +3 #9134 train rows member_forget_names_host_9101, refresh_fence_retry_id_gst2353 and recorded_read_view_args_gst2214 (rows are data and cannot move), re-summed at the #9134 slot merge onto #8829 dfc24954: 1721 + 3; +3 source-checkouts wave rows (autopilot_git_reconcile_gbra386, unknown_drift_history_rescreen, refresh_abandon_members_gst1465), re-summed at the #9137 stack merge: 1724 + 3; +1 #8902 unmanaged_push_history_scan_8902 row; +1 GST-2456 unmanaged_push_every_site_gst2456 row (since TBD until the merge slot; rows are data and cannot move)src/commands/auth.ts 1503 ratchet new row: crossed the 1500 unlisted cap at the v0.60.595.0 merge: GST-1113 --attest-sources help lines plus GST-1158 F3 --attest-read help lines (3); CLI help lines cannot movediff --git a/scripts/serial-files.tsv b/scripts/serial-files.tsvindex d0c87895ee..ebf0bfb894 100644--- a/scripts/serial-files.tsv+++ b/scripts/serial-files.tsv@@ -2,6 +2,7 @@# class: R1 (process.env mutation) | R2 (mock.module) | global-state (other process-wide state) | exclusive (EXCLUSIVE_FILES in scripts/run-serial-tests.sh).# Before adding a row, run: bash scripts/check-test-isolation.sh --as-parallel <file> (docs/TESTING.md#when-to-quarantine-instead-of-fix)path class reason+test/unmanaged-push-every-site-gst2456.serial.test.ts R1 R1: mutates HOME, GBRAIN_HOME, PATH and GBRAIN_GIT_ALLOW_FILE_TRANSPORT for real commit-push, hook, helper and sources pushes to local bare remotestest/unmanaged-push-history-scan-8902.serial.test.ts R1 R1: mutates HOME, GBRAIN_HOME and GBRAIN_GIT_ALLOW_FILE_TRANSPORT for real policy, scaffolding, sources push and bootstrap pushes to local bare remotestest/http-db-config.serial.test.ts global-state global-state: binds HTTP listeners; drains process-wide pending eval capture registry; withEnv scopes GBRAIN_HOME and GBRAIN_CONTRIBUTOR_MODEtest/access-as.serial.test.ts global-state global-state: spawns real gbrain CLI children (src/cli.ts --as) that each open one on-disk PGLite brain and take its file lock in a temp GBRAIN_HOME; the cases seed and read that one brain in orderdiff --git a/src/commands/bootstrap.ts b/src/commands/bootstrap.tsindex d67dbc1d0e..9aa826a28c 100644--- a/src/commands/bootstrap.ts+++ b/src/commands/bootstrap.ts@@ -201,9 +201,10 @@ const SUBCOMMAND_HELP: Record<string, string> = {'gbrain bootstrap contract [--repair]\n' +' Audit AGENTS.md for the same-turn GBrain write-back contract. --repair appends a marker-owned block and backs up the original.',repo:- 'gbrain bootstrap repo\n' ++ 'gbrain bootstrap repo [--scan-timeout <seconds>]\n' +' Create the dedicated PRIVATE GitHub repo (or adopt an EMPTY private repo you created\n' +- ' under your own account), verify the privacy bit via the API, push.',+ ' under your own account), verify the privacy bit via the API, push. The push scans the\n' ++ ' whole history for secrets first; --scan-timeout gives a long history more time (default 300).',hooks:'gbrain bootstrap hooks [--harness claude-code|codex|opencode] [--repair] [--no-hooks] [--gbrain-bin <path>]\n' +' [--seat <label> | --no-seat] [--surface verbs|starter|full] [--adopt [--name <server>]]\n' +@@ -981,9 +982,13 @@ async function runRender(ws: string, rest: string[], home: string): Promise<numb}async function runRepo(ws: string, rest: string[], home: string, runner: ExecRunner): Promise<number> {- void rest;+ const scanTimeout = rest.includes('--scan-timeout') ? flagValue(rest, '--scan-timeout') ?? '' : undefined;+ if (scanTimeout !== undefined && !/^[1-9]\d{0,5}$/.test(scanTimeout)) {+ console.error('Usage: gbrain bootstrap repo [--scan-timeout <seconds>]');+ return 2;+ }return withLock(ws, async () => {- const result = await createPrivateRepo(ws, { runner, gbrainHomeDir: home });+ const result = await createPrivateRepo(ws, { runner, gbrainHomeDir: home, ...(scanTimeout ? { scanTimeoutMs: Number(scanTimeout) * 1000 } : {}) });const line =result.disposition === 'created'? `created private repo: ${result.url}`diff --git a/src/commands/git.ts b/src/commands/git.tsindex 9a96855da1..8133d5c5b8 100644--- a/src/commands/git.ts+++ b/src/commands/git.ts@@ -50,8 +50,10 @@ Flags:--keep-checkout With --push-only: never move the checkout and skip its pre-push hook. The onepublish allowed in a managed canonical worktree (its Git effects' integrate_conflictfix); gbrain sources refresh brings the merged remote files in afterwards.- --scan-secrets With --push-only: before pushing, scan what the unpublished commits add (messages,- added lines, merge resolutions) and refuse publish_secret_found on a finding.+ --scan-secrets Accepted for older scripts: every push scans what the unpublished commits add+ (messages, added lines, merge resolutions) and refuses publish_secret_found on a finding.+ --scan-timeout <s> The secret scan's time budget in seconds (default 300); a first push of a long+ history may need more. The scan still reads every commit.--pull Bring remote commits in (fast-forward, or an in-memory merge); never pushes.--require-clean Unattended rule: --pull skips when the checkout has any local edit;a push never advances a checkout that has one, and never waits for@@ -83,7 +85,7 @@ is installed.`;interface Parsed {sub?: string; path?: string; message?: string; branch?: string; expectRemote?: string; json: boolean; pushOnly: boolean; pull: boolean;requireClean: boolean; dryRun: boolean; help: boolean; keepCheckout: boolean; paths: string[]; resolve: string[]; base: string[];- pending: boolean; allowOutside: boolean; install: boolean; uninstall: boolean; scanSecrets: boolean;+ pending: boolean; allowOutside: boolean; install: boolean; uninstall: boolean; scanSecrets: boolean; scanTimeout?: string;}function parse(args: string[]): Parsed {@@ -119,6 +121,7 @@ function parse(args: string[]): Parsed {else if (a === '--base' || a.startsWith('--base=')) p.base.push(take('--base'));else if (a === '--branch' || a.startsWith('--branch=')) p.branch = take('--branch');else if (a === '--expect-remote' || a.startsWith('--expect-remote=')) p.expectRemote = take('--expect-remote');+ else if (a === '--scan-timeout' || a.startsWith('--scan-timeout=')) p.scanTimeout = take('--scan-timeout');else if (!p.sub) p.sub = a;else if (a.startsWith('-')) throw opError('commit_paths_invalid', `Unknown flag ${a}.`, HELP.split('\n')[0]);else p.paths.push(a);@@ -191,7 +194,7 @@ export async function runGit(args: string[]): Promise<number> {if (!p.path) assertSourceCheckout(repo);const cwd = p.path ? realpathSync(p.path) : process.cwd();if ((p.pull && p.pushOnly) || (p.pull && (p.message || p.paths.length || p.resolve.length || p.branch))- || (p.pushOnly && (p.message || p.paths.length)) || ((p.resolve.length || p.branch || p.expectRemote || p.keepCheckout || p.scanSecrets) && !p.pushOnly)+ || (p.pushOnly && (p.message || p.paths.length)) || ((p.resolve.length || p.branch || p.expectRemote || p.keepCheckout) && !p.pushOnly) || (p.scanTimeout !== undefined && p.pull)|| (p.pending && (p.pull || p.pushOnly || p.paths.length)) || (p.allowOutside && p.pull) || (p.base.length && (p.pull || p.pushOnly || p.pending))) {throw opError('commit_paths_invalid', 'These flags do not combine.','Use one mode: -m <msg> -- <paths> (commit + push), --pending [-m <msg>], --push-only [--keep-checkout] [--branch <b>] [--expect-remote <sha> --resolve ...], or --pull [--require-clean].');@@ -203,6 +206,9 @@ export async function runGit(args: string[]): Promise<number> {'Pass the full object id git rev-parse HEAD:<path> printed when you read the file, or absent for a new file.');return [path, blob] as const;}));+ if (p.scanTimeout !== undefined && !/^[1-9]\d{0,5}$/.test(p.scanTimeout)) {+ throw opError('commit_paths_invalid', `--scan-timeout ${p.scanTimeout} is not a number of seconds.`, 'Pass whole seconds, for example --scan-timeout 1800.');+ }if ((p.resolve.length && !p.expectRemote) || (p.expectRemote && !/^[0-9a-f]{7,64}$/i.test(p.expectRemote))) {throw opError('commit_paths_invalid', '--resolve and --expect-remote <sha> go together.','Copy both from the integrate_conflict report: --expect-remote names the remote commit your choice was made against.');@@ -231,7 +237,9 @@ export async function runGit(args: string[]): Promise<number> {...(p.pending ? { pending: true } : {}),...(p.allowOutside ? { allowOutsideSourceRoot: true } : {}),...(p.keepCheckout ? { keepCheckout: true } : {}),- ...(p.scanSecrets ? { scanSecrets: true } : {}),+ scanSecrets: true,+ ...(p.scanTimeout ? { scanTimeoutMs: Number(p.scanTimeout) * 1000 } : {}),+ scanProgress: (line: string) => process.stderr.write(`[gbrain] ${line}\n`),...(p.branch ? { branch: p.branch } : {}),...(p.resolve.length ? { resolutions: parseResolutions(p.resolve) } : {}),...(p.expectRemote ? { expectRemote: p.expectRemote } : {}),@@ -282,11 +290,13 @@ export async function runGit(args: string[]): Promise<number> {if (d.publish) failed = d.publish;} catch { /* best-effort */ }}- if (failed.code === 'push_unconfirmed' || failed.code === 'integrate_conflict' || failed.code === 'commit_outside_source_root') {+ if (failed.code === 'push_unconfirmed' || failed.code === 'integrate_conflict' || failed.code === 'commit_outside_source_root'+ || failed.code === 'publish_secret_found' || failed.code === 'publish_scan_unreadable') {try {const bi = args.indexOf('--branch');const branch = bi !== -1 && args[bi + 1] ? args[bi + 1].replace(/^refs\/heads\//, '') : currentBranchOf(args);- appendPushLog(failed.code === 'integrate_conflict' ? 'conflict' : 'local-only', branch, failed.detail ?? '');+ if (failed.code.startsWith('publish_')) appendPushLog('refused', branch, '', failed.code);+ else appendPushLog(failed.code === 'integrate_conflict' ? 'conflict' : 'local-only', branch, failed.detail ?? '');} catch { /* best-effort */ }}return writeCliError(e, 'git commit-push', { json });diff --git a/src/commands/sources.ts b/src/commands/sources.tsindex 4ae83442f8..711695a13b 100644--- a/src/commands/sources.ts+++ b/src/commands/sources.ts@@ -605,7 +605,7 @@ function deriveBrainId(created: OpsSourceRow, localPath: string): string {// wrapper only parses args, resolves <id> → local_path, and maps statuses// to exit codes:// 0 pushed / skipped (push already in flight — clean single-flight skip)-// 5 blocked (secrets / tracked deny-glob) or refused (unverified remote)+// 5 blocked (secrets / tracked deny-glob / the commits it would push) or refused (unverified remote)// 1 pull conflict / push failure / other errorasync function runPush(engine: BrainEngine, args: string[]): Promise<void> {@@ -615,10 +615,12 @@ async function runPush(engine: BrainEngine, args: string[]): Promise<void> {let message: string | undefined;let allowUnverified = false;let json = false;+ let scanTimeout: string | undefined;for (let i = 0; i < args.length; i++) {const a = args[i];if (a === '--path') { path = args[++i]; continue; }+ if (a === '--scan-timeout') { scanTimeout = args[++i]; continue; }if (a === '--branch') { branch = args[++i]; continue; }if (a === '--message') { message = args[++i]; continue; }if (a === '--allow-unverified-remote') { allowUnverified = true; continue; }@@ -628,8 +630,8 @@ async function runPush(engine: BrainEngine, args: string[]): Promise<void> {process.exit(2);}- if ((!id && !path) || (id && path)) {- console.error('Usage: gbrain sources push [<id> | --path <dir>] [--branch <b>] [--message <m>] [--allow-unverified-remote] [--json]');+ if ((!id && !path) || (id && path) || (scanTimeout !== undefined && !/^[1-9]\d{0,5}$/.test(scanTimeout))) {+ console.error('Usage: gbrain sources push [<id> | --path <dir>] [--branch <b>] [--message <m>] [--allow-unverified-remote] [--scan-timeout <seconds>] [--json]');process.exit(2);}@@ -657,6 +659,7 @@ async function runPush(engine: BrainEngine, args: string[]): Promise<void> {pullStrategy,commitMessage: message,allowUnverifiedRemote: allowUnverified,+ ...(scanTimeout ? { scanTimeoutMs: Number(scanTimeout) * 1000 } : {}),logger: (l) => console.error(`[gbrain] ${l}`),});@@ -709,6 +712,13 @@ async function runPush(engine: BrainEngine, args: string[]): Promise<void> {}process.exit(5);break;+ case 'blocked_history':+ if (!json) {+ console.error(`Error [${res.code}]: ${res.reason?.replace(/^\S+: /, '')}`);+ if (res.suggestion) console.error(`Fix: ${res.suggestion}`);+ }+ process.exit(5);+ break;default:if (!json) console.error(`push failed (${res.status}): ${res.reason ?? 'unknown error'}`);process.exit(1);@@ -2101,9 +2111,11 @@ Subcommands:Divergence-safe rebase-pull (skip-on-dirty).--path is DB-free (the harden cron's entry).push <id> | --path <dir> [--branch <b>] [--message <m>]- [--allow-unverified-remote] [--json]+ [--allow-unverified-remote] [--scan-timeout <s>] [--json]Scan-gated add→commit→pull→push of a workspace- repo. Blocks on secret-scan findings (override+ repo; every commit it pushes is scanned+ (--scan-timeout: the scan's budget, default+ 300 s). Blocks on secret-scan findings (overrideper finding via .gbrain-scan-allow) and ontracked deny-list files (*.pglite, .env*,*.pem, *.key, .gbrain/**). Refuses remotes notdiff --git a/src/core/access/policy-git.ts b/src/core/access/policy-git.tsindex 73c0dfe380..1f70f7b060 100644--- a/src/core/access/policy-git.ts+++ b/src/core/access/policy-git.ts@@ -197,8 +197,8 @@ export interface GitPolicyReceipt {/*** Writes one policy file under the checkout's commit lock (held across the read, the edit and the commit) and commits it* through the door. commit_lock_busy is retried once; integrate_conflict and writer_coordinator_required propagate (the- * first needs the user's choice, the second a managed write on the brain host); a commit whose push is unconfirmed is a- * success with a note.+ * first needs the user's choice, the second a managed write on the brain host); a commit whose push is unconfirmed, or+ * whose push the secret scan refused (publish_secret_found / publish_scan_unreadable), is committed_not_pushed with a note.*/export async function commitPolicyFile(root: string, relPath: string, edit: (current: string | null) => string, message: string): Promise<GitPolicyReceipt> {const file = join(root, relPath);@@ -219,6 +219,11 @@ export async function commitPolicyFile(root: string, relPath: string, edit: (curif (e instanceof OperationError && (e.code === 'push_unconfirmed' || (e as { canonical?: string }).canonical === 'push_unconfirmed') && e.detail) {return { outcome: 'committed_not_pushed', commit: String(e.detail), path: relPath, note: 'Committed locally; the push is unconfirmed. Rerun gbrain git commit-push --push-only --scan-secrets to publish it.' };}+ if (e instanceof OperationError && (e.code === 'publish_secret_found' || e.code === 'publish_scan_unreadable') && gitShow(root, 'HEAD', relPath) === next) {+ const head = spawnSync('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8', env: gitChildEnv() }).stdout.trim();+ return { outcome: 'committed_not_pushed', commit: head || null, path: relPath,+ note: `Committed locally; nothing was pushed. ${e.code}: ${e.message} Fix: ${e.suggestion}` };+ }if (gitShow(root, 'HEAD', relPath) !== next) {if (current === null) rmSync(file, { force: true }); else writeFileSync(file, current);}diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex bcb3fb2e56..28193ff3b1 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -1530,6 +1530,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;{ since: '0.60.673.0', id: 'unknown_drift_history_rescreen', text: 'A `file_drift` hold on a page with no import record that an earlier release held after comparing the page only with its file at the last synced commit is now screened once more on the next sync: when the page still holds one of its file\'s earlier committed versions (only Git changed since), the Git edit imports and the hold clears; otherwise the hold stays, unchanged, and is not screened again.' },{ since: '0.60.673.0', id: 'refresh_abandon_members_gst1465', text: '`gbrain sources refresh --abandon` of a `recovery_required` refresh now also refuses when a member\'s managed sync imported or deleted pages after the refresh began, even with its `last_commit` still at the start commit (a pass its budget stopped), and refuses `sync_drain_lease_held` while a member\'s sync pass still holds its drain lease, so the database is never left ahead of the checkout. At a HEAD past the upstream commit it names `--resume` instead of a reset. Members synced to diverged lines, or to a commit git cannot place, now get their own refusal (merge those lines, or fetch the commit) instead of a fast-forward that `--resume` would refuse again, and the refusals name the revert route for a deliberate rollback. Writer status read off the owner host names no step for such a refresh.' },{ since: 'TBD', id: 'unmanaged_push_history_scan_8902', text: 'Four pushes from a checkout that is not a managed worktree now scan every local commit they publish for secrets, not only what they just wrote: the access-policy commit (`gbrain access rule` and the other policy writers), the durability-scaffolding commit of `gbrain sources harden`, `gbrain sources push`, and the first push of `gbrain bootstrap repo` (the whole history, since the remote has no such branch yet). A credential that a commit made with plain `git commit` added, even one a later commit removed, or one in a commit message, now refuses `publish_secret_found` naming the file, line, rule and commit (never the value), and nothing is pushed; history the scan cannot read in full refuses `publish_scan_unreadable`. The local commits stay where they are. `gbrain sources push` now pushes the exact commit it scanned, leased on the remote tip it read, and an allowlist (`.gbrain-scan-allow`) edit it commits itself still publishes; one a script committed is left for the user to review and push. Remove the value from the unpublished commits, or allowlist a false positive by fingerprint, then rerun.' },+ { since: 'TBD', id: 'unmanaged_push_every_site_gst2456', text: 'Every push gbrain makes from a checkout that is not a managed worktree now scans the commits it publishes for secrets: `gbrain git commit-push` in commit mode and with `--pending` (it used to scan only with `--push-only --scan-secrets`), the post-commit hook `gbrain sources harden` installs and `scripts/brain-commit-push.sh`. A credential in an earlier local commit refuses `publish_secret_found` and nothing is pushed; the hook logs the refusal in brain-push.log. The helper no longer pushes on a machine without gbrain: it commits, logs the commit as local-only and exits 4. A scan that runs past its 300 s budget refuses `publish_scan_unreadable` naming the same command with `--scan-timeout <seconds>`, which `gbrain git commit-push`, `gbrain sources push` and `gbrain bootstrap repo` accept. No push follows tags (`push.followTags` is ignored). `gbrain sources push --json` prints a scan refusal (`blocked_history`, exit 5), and the access-policy commit reports one as `committed_not_pushed`.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */diff --git a/src/core/bootstrap/repo.ts b/src/core/bootstrap/repo.tsindex 5f3c13d3b3..0813661df0 100644--- a/src/core/bootstrap/repo.ts+++ b/src/core/bootstrap/repo.ts@@ -574,7 +574,7 @@ async function ensureRemoteHasWorkspace(const pushBranch = await currentBranch(runner, workspaceDir);await assertOriginMatches(runner, workspaceDir, owner, name);await assertHistoryPublishable(runner, workspaceDir, pushBranch, scan);- const push = await runner(['git', '-C', workspaceDir, 'push', '-u', 'origin', pushBranch]);+ const push = await runner(['git', '-C', workspaceDir, 'push', '-u', 'origin', pushBranch, '--no-follow-tags']);if (push.code !== 0) {throw new BootstrapError('REPO_CREATE_FAILED',@@ -595,10 +595,13 @@ export interface CreatePrivateRepoOptions {gbrainHomeDir?: string;/** The refusal for publishing `target` and its whole history (default: the range secret scan; a seam for runner fakes). */scanHistory?: HistoryScan;+ /** The whole-history scan's time budget (`--scan-timeout`; default 300 s). */+ scanTimeoutMs?: number;}type HistoryScan = (workspaceDir: string, target: string) => OperationError | null;-const scanWholeHistory: HistoryScan = (workspaceDir, target) => stagedScanPublishRefusal(workspaceDir, '', target);+const scanWholeHistory = (timeoutMs?: number): HistoryScan => (workspaceDir, target) => stagedScanPublishRefusal(workspaceDir, '', target,+ { timeoutMs, progress: line => process.stderr.write(`[gbrain] ${line}\n`), retryArgv: ['gbrain', 'bootstrap', 'repo'] });/*** #8902: a first push publishes the branch's whole history, including commits a script made with plain `git commit`@@ -651,7 +654,7 @@ export async function createPrivateRepo(): Promise<CreatePrivateRepoResult> {const runner = opts.runner ?? defaultRunner;const gbrainHomeDir = opts.gbrainHomeDir ?? configDir();- const scan = opts.scanHistory ?? scanWholeHistory;+ const scan = opts.scanHistory ?? scanWholeHistory(opts.scanTimeoutMs);// Gate 1: gh on PATH. Exit-code-2 semantics — the human installs gh.const ghVersion = await runner(['gh', '--version']);@@ -848,7 +851,7 @@ export async function createPrivateRepo(// [FIX4] Bind the verified privacy result to the actual push target.await assertOriginMatches(runner, workspaceDir, login, name);await assertHistoryPublishable(runner, workspaceDir, branch, scan);- const push = await runner(['git', '-C', workspaceDir, 'push', '-u', 'origin', branch]);+ const push = await runner(['git', '-C', workspaceDir, 'push', '-u', 'origin', branch, '--no-follow-tags']);if (push.code !== 0) {throw new BootstrapError('REPO_CREATE_FAILED',diff --git a/src/core/brain-repo-durability.ts b/src/core/brain-repo-durability.tsindex e8cad50dfd..1385f2e295 100644--- a/src/core/brain-repo-durability.ts+++ b/src/core/brain-repo-durability.ts@@ -232,8 +232,8 @@ ${PROTOCOL_LINE}# scripts/brain-commit-push.sh --pull# Delegates to \`gbrain git commit-push\` (lock, path-scoped commit, in-memory# merge, fast-forward-only checkout). Without a capable gbrain it only commits-# the paths under the lock and pushes; a rejected push fails loudly. It never-# runs pull --rebase, stash or reset. Guide: docs/guides/shared-checkout-git.md+# the paths under the lock and pushes nothing (only gbrain scans the unpublished+# commits for secrets first), exiting 4. It never runs pull --rebase, stash or reset. Guide: docs/guides/shared-checkout-git.mdset -euo pipefailunset $(git rev-parse --local-env-vars) 2>/dev/null || true@@ -325,10 +325,10 @@ _report_skipped() {}_finish() {[ -z "$_skipped" ] && exit 0- _report_skipped "committed and pushed"+ _report_skipped "committed, and already on the remote"exit 1}-echo "[brain-commit-push] gbrain git commit-push unavailable; using the minimal locked commit + push" >&2+echo "[brain-commit-push] gbrain git commit-push unavailable; using the minimal locked commit, which pushes nothing" >&2_log="\${GBRAIN_HOME:-$HOME}/.gbrain/brain-push.log"mkdir -p "$(dirname "$_log")" 2>/dev/null || true# The absolute lock path, as gbrain spells it: the marker below must name this exact lock.@@ -360,18 +360,14 @@ case "\${1:-}" in_skipped="$(_unstaged "$@" | sort -u)" ;;esac_head="$(git rev-parse HEAD)"-# Never hold the commit lock across the network: release it and push under the publish lock, like gbrain.exec 9>&- 8>&-unset BRAIN_COMMIT_LOCK_HELD GBRAIN_COMMIT_VIA-if command -v flock >/dev/null 2>&1; then- exec 7>"$_gd/brain-publish.lock"- flock -w "\${GBRAIN_PUBLISH_LOCK_WAIT_SECONDS:-300}" 7 || { echo "PUSH FAILED: another push held this checkout's publish lock; the commit is local-only. Run: gbrain git commit-push --push-only" >&2; _report_skipped "committed locally, not pushed"; exit 4; }-fi-if git push origin "$_head:refs/heads/$_branch" >>"$_log" 2>&1; then- echo "$(date -u +%FT%TZ) [push] ok $_branch $(git rev-parse --short "$_head")" >>"$_log"; _finish+# Never push without gbrain: its push scans every unpublished commit for secrets first, and this script cannot.+if [ "$(git ls-remote origin "refs/heads/$_branch" 2>/dev/null | cut -f1)" = "$_head" ]; then+ echo "$(date -u +%FT%TZ) [push] ok-already-on-remote $_branch $(git rev-parse --short "$_head")" >>"$_log"; _finishfi-echo "$(date -u +%FT%TZ) [push] LOCAL-ONLY, NEEDS ATTENTION: $_branch @ $(git rev-parse --short "$_head") push rejected; run gbrain git commit-push --push-only" >>"$_log"-echo "PUSH FAILED — the commit is local-only. Install gbrain, then run: gbrain git commit-push --push-only (it merges remote commits safely). Never git pull --rebase here." >&2+echo "$(date -u +%FT%TZ) [push] LOCAL-ONLY, NEEDS ATTENTION: $_branch @ $(git rev-parse --short "$_head") not pushed: gbrain is not installed, and only gbrain scans the commits before it pushes. Run: gbrain git commit-push --push-only" >>"$_log"+echo "NOT PUSHED — the commit is local-only. Install gbrain, then run: gbrain git commit-push --push-only (it scans the unpublished commits for secrets, then merges remote commits safely and pushes). Never git pull --rebase here." >&2_report_skipped "committed locally, not pushed"exit 4`;@@ -733,7 +729,7 @@ export interface PushLogOutcome {const PUSH_LOG_OK = /^(\S+) \[push\] (?:ok|ok-after-rebase|ok-after-merge|ok-already-on-remote) (\S+)\b/;const PUSH_LOG_LOCAL_ONLY = /^(\S+) \[push\] (?:LOCAL-ONLY|CONFLICT), NEEDS ATTENTION: (\S+) /;-export type PushLogKind = 'ok' | 'ok-after-merge' | 'nothing' | 'local-only' | 'conflict' | 'lock-timeout' | 'checkout-lagging';+export type PushLogKind = 'ok' | 'ok-after-merge' | 'nothing' | 'local-only' | 'refused' | 'conflict' | 'lock-timeout' | 'checkout-lagging';/*** #6530: one `brain-push.log` line per `gbrain git commit-push` outcome, in the@@ -750,6 +746,7 @@ export function appendPushLog(kind: PushLogKind, branch: string, sha: string, de: kind === 'nothing' ? `[push] ok-already-on-remote ${branch} ${short}`: kind === 'lock-timeout' ? `[push] lock-timeout ${branch}`: kind === 'checkout-lagging' ? `[push] checkout-lagging ${branch} ${short} ${clean}`+ : kind === 'refused' ? `[push] LOCAL-ONLY, NEEDS ATTENTION: ${branch} @ ${short} the push was refused (${clean}). Run: gbrain git commit-push --push-only`: kind === 'conflict' ? `[push] CONFLICT, NEEDS ATTENTION: ${branch} local and remote changed the same file. Run: gbrain git commit-push --push-only --resolve <path>=ours|theirs`: `[push] LOCAL-ONLY, NEEDS ATTENTION: ${branch} @ ${short} could not reach the remote. Run: gbrain git commit-push --push-only`;const p = pushLogPath();diff --git a/src/core/cli-flag-registry.generated.ts b/src/core/cli-flag-registry.generated.tsindex 8843bba5ad..d9900e81bd 100644--- a/src/core/cli-flag-registry.generated.ts+++ b/src/core/cli-flag-registry.generated.ts@@ -27,7 +27,7 @@ export const CLI_FLAG_REGISTRY: Record<string, readonly string[]> = {'beliefs': ['--apply', '--archived-at', '--brain', '--from-url-env', '--help', '--json', '--probe', '--purge-mirror', '--since', '--source'],'bench': ['--baseline', '--brain', '--force', '--from', '--help', '--json', '--label', '--limit', '--source', '--threshold-jaccard', '--threshold-latency-multiplier', '--threshold-top1', '--to', '--tool'],'book-mirror': ['--accept-pending', '--access', '--add', '--all', '--allowed-operations', '--as', '--asof', '--author', '--background', '--body', '--bound-slug-prefixes', '--brain', '--chapters-dir', '--client', '--context-file', '--cursor', '--date', '--dated-since', '--days', '--dry-run', '--entities', '--explain', '--federated-read', '--follow', '--from-index', '--full', '--fuzzy', '--group', '--group-by', '--help', '--http', '--id', '--include', '--include-deleted', '--json', '--kind', '--limit', '--max-cost', '--max-cost-usd', '--max-turns', '--max-usd', '--model', '--multimodal', '--no-accept-pending', '--no-autopilot-install', '--no-confirm', '--no-follow', '--of', '--only', '--page', '--params', '--path', '--phase', '--prefer', '--progress-interval', '--progress-json', '--purge', '--quiet', '--recent', '--refresh-operations', '--row', '--scopes', '--session', '--since', '--slug', '--slugs', '--source', '--sources', '--stale', '--surface', '--timeout', '--timeout-ms', '--timings', '--title', '--to', '--updated-after', '--url', '--wait', '--yes'],- 'bootstrap': ['--abbrev-ref', '--accept-visibility-change-consequences', '--active', '--add', '--adopt', '--advertise', '--all', '--allow-unverified-remote', '--auto', '--autostash', '--batch-check', '--bearer-token-env-var', '--brain', '--branch', '--cached', '--confirm', '--count', '--delete-brain', '--diff-filter', '--dim', '--dry-run', '--enable', '--env', '--error-unmatch', '--exclude-standard', '--expect-remote', '--ff-only', '--file', '--force', '--force-with-lease', '--gbrain-bin', '--get', '--get-all', '--git-dir', '--git-path', '--hard', '--harness', '--header', '--heads', '--help', '--home', '--host', '--hostname', '--http', '--id', '--init', '--install', '--is-ancestor', '--is-inside-work-tree', '--issuer-url', '--jq', '--json', '--keep-checkout', '--local', '--local-env-vars', '--mcp-even-if-plugin', '--mcp-only', '--mcp-url', '--minimal', '--name', '--name-only', '--no-assume-unchanged', '--no-autostash', '--no-capture', '--no-cron', '--no-hooks', '--no-instructions', '--no-renames', '--no-seat', '--no-skip-worktree', '--no-tags', '--no-verify', '--oauth-client-id', '--oauth-client-secret', '--only', '--operations', '--others', '--pat-file', '--path', '--pglite', '--porcelain', '--port', '--private', '--project', '--pull', '--pure', '--push-only', '--quiet', '--rebase', '--refresh-operations', '--refresh-skills', '--remove', '--repair', '--require-clean', '--resolve', '--scope', '--scopes', '--seat', '--set', '--short', '--show', '--show-toplevel', '--skill-loading', '--skills', '--skip', '--source', '--sources', '--status', '--stdin', '--surface', '--to', '--token', '--token-name', '--unset-all', '--untracked-files', '--url', '--verify', '--version', '--visibility', '--workspace', '--yes'],+ 'bootstrap': ['--abbrev-ref', '--accept-visibility-change-consequences', '--active', '--add', '--adopt', '--advertise', '--all', '--allow-unverified-remote', '--auto', '--autostash', '--batch-check', '--bearer-token-env-var', '--brain', '--branch', '--cached', '--confirm', '--count', '--delete-brain', '--diff-filter', '--dim', '--dry-run', '--enable', '--env', '--error-unmatch', '--exclude-standard', '--expect-remote', '--ff-only', '--file', '--force', '--force-with-lease', '--gbrain-bin', '--get', '--get-all', '--git-dir', '--git-path', '--hard', '--harness', '--header', '--heads', '--help', '--home', '--host', '--hostname', '--http', '--id', '--init', '--install', '--is-ancestor', '--is-inside-work-tree', '--issuer-url', '--jq', '--json', '--keep-checkout', '--local', '--local-env-vars', '--mcp-even-if-plugin', '--mcp-only', '--mcp-url', '--minimal', '--name', '--name-only', '--no-assume-unchanged', '--no-autostash', '--no-capture', '--no-cron', '--no-follow-tags', '--no-hooks', '--no-instructions', '--no-renames', '--no-seat', '--no-skip-worktree', '--no-tags', '--no-verify', '--oauth-client-id', '--oauth-client-secret', '--only', '--operations', '--others', '--pat-file', '--path', '--pglite', '--porcelain', '--port', '--private', '--project', '--pull', '--pure', '--push-only', '--quiet', '--rebase', '--refresh-operations', '--refresh-skills', '--remove', '--repair', '--require-clean', '--resolve', '--scan-timeout', '--scope', '--scopes', '--seat', '--set', '--short', '--show', '--show-toplevel', '--skill-loading', '--skills', '--skip', '--source', '--sources', '--status', '--stdin', '--surface', '--to', '--token', '--token-name', '--unset-all', '--untracked-files', '--url', '--verify', '--version', '--visibility', '--workspace', '--yes'],'brainstorm': ['--admin-intent', '--brain', '--confirm-relocated-root', '--dir', '--expected-epoch', '--expected-state', '--force-rechunk', '--force-resume', '--help', '--json', '--judge-model', '--limit', '--list-runs', '--manifest', '--max-cost', '--max-far-set', '--max-ideas-per-judge-call', '--max-usd', '--no-save', '--path', '--probe', '--resume', '--save', '--self-transfer', '--source', '--source-id', '--stale', '--strict-budget', '--yes'],'bundled-skill': ['--asset', '--brain', '--help', '--json', '--source'],'cache': ['--brain', '--help', '--json', '--source', '--yes'],@@ -52,7 +52,7 @@ export const CLI_FLAG_REGISTRY: Record<string, readonly string[]> = {'db-repair': ['--accept-pending', '--apply', '--apply-rewrites', '--as', '--background', '--brain', '--break-lock', '--db-url', '--dry-run', '--explain', '--filter', '--follow', '--force', '--force-retry', '--format', '--help', '--http', '--json', '--legacy-lock', '--locks', '--name', '--no-accept-pending', '--path', '--prefer-postgres', '--probe', '--progress-interval', '--progress-json', '--quiet', '--remediate', '--restart', '--skip-verify', '--source', '--statement-timeout', '--supabase', '--timeout', '--timings', '--undo-last-rewrite', '--url', '--version', '--wait', '--yes'],'decide': ['--accept-all', '--all', '--all-from', '--apply', '--brain', '--call-site', '--claims', '--dataset', '--dry-run', '--egress', '--embedding-dimensions', '--embedding-model', '--expect', '--from', '--help', '--include-withdrawals', '--input', '--items-out', '--json', '--kind', '--limit', '--max-cost', '--max-usd', '--min', '--non-interactive', '--out', '--provenance', '--provider', '--query', '--rate', '--reason', '--reason-family', '--recommended', '--remove', '--shadow', '--since', '--slot', '--source', '--status', '--suite', '--target', '--threshold', '--trust', '--undo', '--uri-prefix', '--version', '--what-if-threshold', '--yes'],'diag': ['--access', '--add', '--all', '--allowed-operations', '--apply', '--as', '--asof', '--body', '--bound-slug-prefixes', '--brain', '--budget-ms', '--client', '--count', '--cursor', '--date', '--dated-since', '--days', '--detach', '--entities', '--expect', '--expected-revision', '--federated-read', '--filter', '--follow', '--format', '--from-index', '--full', '--fuzzy', '--group-by', '--held', '--help', '--http', '--id', '--include', '--include-ambiguous', '--include-deleted', '--json', '--kind', '--limit', '--max-usd', '--model', '--multimodal', '--no-autopilot-install', '--no-pull', '--no-walk', '--of', '--only', '--page', '--params', '--path', '--phase', '--prefer', '--preview', '--purge', '--query', '--recent', '--refresh-operations', '--replace', '--restart-only', '--reverse', '--row', '--scopes', '--session', '--side', '--since', '--slug', '--slugs', '--source', '--source-id', '--sources', '--stale', '--state', '--surface', '--to', '--updated-after', '--url', '--yes'],- 'doctor': ['--abandon', '--abbrev-ref', '--abort', '--absolute-git-dir', '--accept-all', '--accept-capabilities', '--accept-pending', '--access', '--access-policy', '--account', '--acknowledge-managed', '--add', '--admin-intent', '--adopt', '--adopt-columns', '--adopt-permissions', '--advertise', '--after', '--agent', '--aggressive', '--aliases', '--all', '--all-drifted', '--all-from', '--allow-old-serve', '--allow-outside-source-root', '--allow-shell-jobs', '--allow-unverified-remote', '--allowed-operations', '--anchor', '--applied', '--apply', '--apply-rewrites', '--approval-out', '--approved', '--as', '--assign-corpus', '--attest-actor', '--attest-ops', '--attest-read', '--attest-sources', '--audit', '--auto', '--auto-additive', '--auto-fix', '--autostash', '--background', '--base', '--batch', '--batch-check', '--bound-brain', '--bound-max-concurrent', '--bound-slug-prefixes', '--bound-source', '--bound-tools', '--brain', '--branch', '--break-lock', '--budget-ms', '--budget-policy', '--budget-tokens', '--budget-usd', '--bundled', '--by-mention', '--cached', '--cacheinfo', '--call-site', '--catalog', '--catch-up', '--channel', '--check', '--check-downgrade', '--check-only', '--cherry-mark', '--claims', '--class', '--claude-plugins', '--clear', '--clear-never-installed', '--cli-socket', '--client', '--close', '--code', '--concurrency', '--confidence', '--config', '--confirm', '--confirm-destructive', '--confirm-quiesced', '--confirm-relocated-root', '--conflicts', '--contacts-dir', '--content-audit', '--content-root', '--continue', '--conversation', '--count', '--credentials-file', '--cursor', '--cwd', '--dataset', '--day', '--db-url', '--deadline', '--decisions', '--delegated-namespace', '--delegated-slug-prefixes', '--delete-brain', '--dest', '--detach', '--detail', '--diff-filter', '--dim', '--dimensions', '--dir', '--disable', '--drain', '--drain-timeout', '--dry-run', '--egress', '--email', '--embedding-dimensions', '--embedding-model', '--enable', '--enable-dcr', '--end-of-options', '--entity', '--env', '--env-file', '--error-unmatch', '--exclude', '--exclude-standard', '--exit-code', '--expand', '--expect', '--expect-local', '--expect-remote', '--expect-upstream', '--expected-epoch', '--expected-revision', '--expected-state', '--explain', '--facts', '--fast', '--federated', '--federated-read', '--fetch-timeout-ms', '--ff-only', '--file', '--filter', '--first-parent', '--fix', '--follow', '--force', '--force-break-lock', '--force-rechunk', '--force-remove', '--force-retry', '--force-schema', '--force-with-lease', '--format', '--fresh', '--fresh-token', '--from', '--from-json', '--from-meetings', '--from-pages', '--full', '--full-tree', '--fuzzy', '--gbrain-bin', '--generation', '--get', '--get-all', '--get-regexp', '--get-url', '--git-common-dir', '--git-dir', '--git-path', '--grammar', '--group', '--group-by', '--hard', '--hard-deadline', '--harness', '--heads', '--held', '--help', '--hold-state', '--holds', '--home', '--http', '--id', '--if-version', '--ignore-env-override', '--ignore-missing', '--images', '--import', '--include-ambiguous', '--include-covered', '--include-cross-entity', '--include-deleted', '--include-failures', '--include-flagged', '--include-frontmatter', '--include-gitignored', '--include-hidden', '--include-pseudo', '--include-repairs', '--include-withdrawals', '--index-audit', '--index-info', '--infer-dates', '--init', '--input', '--input-type', '--install', '--instructions', '--instructions-only', '--is-ancestor', '--is-bare-repository', '--is-inside-work-tree', '--is-shallow-repository', '--items-out', '--job-isolation', '--jq', '--json', '--keep', '--keep-checkout', '--key', '--kind', '--lanes', '--lang', '--left-right', '--legacy-lock', '--limit', '--link', '--link-source', '--link-type', '--list', '--list-out', '--literal-pathspecs', '--local', '--local-env-vars', '--locks', '--log-noop', '--manifest', '--markdown', '--max-cost', '--max-cost-usd', '--max-count', '--max-facts', '--max-jobs', '--max-requests', '--max-rss', '--max-runtime', '--max-usd', '--max-waiting', '--may-act-for', '--mcp-only', '--member', '--members', '--members-file', '--merge-base', '--migrate-legacy', '--migrate-only', '--migration', '--min', '--min-n', '--mode', '--model', '--multimodal', '--name', '--name-only', '--name-status', '--nice', '--no-accept-pending', '--no-assume-unchanged', '--no-autopilot-install', '--no-autostash', '--no-capture', '--no-commit-id', '--no-confirm', '--no-cron', '--no-delegate', '--no-edit', '--no-embed', '--no-embed-cache', '--no-embedding', '--no-expand', '--no-extract', '--no-federated', '--no-filters', '--no-gpg-sign', '--no-hooks', '--no-instructions', '--no-lanes', '--no-llm', '--no-merges', '--no-migrate', '--no-optional-locks', '--no-probe', '--no-pull', '--no-renames', '--no-repair', '--no-restart', '--no-schema-pack', '--no-seat', '--no-skip-worktree', '--no-stdio-member', '--no-tags', '--no-verify', '--no-walk', '--no-write-fetch-head', '--non-interactive', '--not', '--now', '--of', '--older-than', '--once', '--only', '--operation', '--operations', '--others', '--out', '--output', '--oversized', '--overwrite', '--page', '--parallel', '--params', '--parents', '--parked-code', '--parked-pushes', '--pat-file', '--path', '--path-format', '--pending', '--pglite', '--phase', '--pid-file', '--plan', '--porcelain', '--port', '--prefer', '--prefer-postgres', '--prefix', '--preload', '--preset', '--preview', '--principal', '--private-pages', '--probe', '--probe-pglite', '--profile', '--progress-interval', '--progress-json', '--project', '--provenance', '--provider', '--providers', '--prune-orphans', '--public-url', '--pull', '--pure', '--purge', '--push', '--push-only', '--qm', '--query', '--question', '--queue', '--quiet', '--rate', '--reader-mode', '--readers', '--reason', '--reauth', '--rebase', '--rebuild', '--recommended', '--redact-paths', '--reference-date', '--refresh', '--refresh-operations', '--refresh-skills', '--regenerate', '--reissue', '--relative', '--relower', '--remediate', '--remediation-plan', '--remote', '--remove', '--remove-core', '--repair', '--repair-unknown-markers', '--replace', '--repo', '--request', '--request-id', '--require', '--require-clean', '--reranker', '--reset', '--reset-checkpoint', '--reset-default', '--reset-session', '--resolve', '--restart-only', '--restore-only', '--resume', '--retire', '--retry-failed', '--retry-global', '--retry-held', '--retry-parked', '--reverse', '--review-lower', '--revision', '--right-only', '--rollback-to-source', '--root', '--routing', '--rules', '--run', '--runtime', '--sample', '--save', '--scan-secrets', '--scope', '--scopes', '--search-mode', '--seat', '--section', '--segmented', '--select', '--self-transfer', '--semantic', '--serves', '--session', '--session-id', '--set', '--set-upstream-to', '--shadow', '--shared-skills', '--short', '--show-current', '--show-object-format', '--show-prefix', '--show-token', '--show-toplevel', '--side', '--since', '--since-last-run', '--skill-loading', '--skills-dir', '--skills-index-only', '--skip', '--skip-bare-tweet', '--skip-failed', '--skip-urls', '--skip-verify', '--slot', '--slot-a-model', '--slot-b-model', '--slot-c-model', '--slug', '--slugs', '--source', '--source-id', '--source-ids', '--sources', '--squash', '--src-subpath', '--staged', '--stale', '--stat', '--state', '--statement-timeout', '--status', '--stdin', '--stdio-member', '--stop-mcp', '--strategy', '--strict', '--suite', '--supabase', '--surface', '--swap-only', '--symbol-kind', '--symbolic-full-name', '--tags', '--take', '--takes-holders', '--target', '--target-score', '--threshold', '--tier', '--timeout', '--timings', '--to', '--token', '--token-ttl', '--top-k', '--topo-order', '--trust', '--tsconfig-override', '--type', '--types', '--unindexed', '--uninstall', '--unsafe-bypass-dream-guard', '--unset', '--unset-all', '--unsettle', '--unshallow', '--untracked-files', '--url', '--url-env', '--user', '--vacuum', '--vectors', '--verbose', '--verify', '--version', '--wait', '--wait-drain', '--warn-only', '--watch', '--what-if-threshold', '--window', '--workers', '--working-tree', '--workspace', '--worktree', '--write-tree', '--yes'],+ 'doctor': ['--abandon', '--abbrev-ref', '--abort', '--absolute-git-dir', '--accept-all', '--accept-capabilities', '--accept-pending', '--access', '--access-policy', '--account', '--acknowledge-managed', '--add', '--admin-intent', '--adopt', '--adopt-columns', '--adopt-permissions', '--advertise', '--after', '--agent', '--aggressive', '--aliases', '--all', '--all-drifted', '--all-from', '--allow-old-serve', '--allow-outside-source-root', '--allow-shell-jobs', '--allow-unverified-remote', '--allowed-operations', '--anchor', '--applied', '--apply', '--apply-rewrites', '--approval-out', '--approved', '--as', '--assign-corpus', '--attest-actor', '--attest-ops', '--attest-read', '--attest-sources', '--audit', '--auto', '--auto-additive', '--auto-fix', '--autostash', '--background', '--base', '--batch', '--batch-check', '--bound-brain', '--bound-max-concurrent', '--bound-slug-prefixes', '--bound-source', '--bound-tools', '--brain', '--branch', '--break-lock', '--budget-ms', '--budget-policy', '--budget-tokens', '--budget-usd', '--bundled', '--by-mention', '--cached', '--cacheinfo', '--call-site', '--catalog', '--catch-up', '--channel', '--check', '--check-downgrade', '--check-only', '--cherry-mark', '--claims', '--class', '--claude-plugins', '--clear', '--clear-never-installed', '--cli-socket', '--client', '--close', '--code', '--concurrency', '--confidence', '--config', '--confirm', '--confirm-destructive', '--confirm-quiesced', '--confirm-relocated-root', '--conflicts', '--contacts-dir', '--content-audit', '--content-root', '--continue', '--conversation', '--count', '--credentials-file', '--cursor', '--cwd', '--dataset', '--day', '--db-url', '--deadline', '--decisions', '--delegated-namespace', '--delegated-slug-prefixes', '--delete-brain', '--dest', '--detach', '--detail', '--diff-filter', '--dim', '--dimensions', '--dir', '--disable', '--drain', '--drain-timeout', '--dry-run', '--egress', '--email', '--embedding-dimensions', '--embedding-model', '--enable', '--enable-dcr', '--end-of-options', '--entity', '--env', '--env-file', '--error-unmatch', '--exclude', '--exclude-standard', '--exit-code', '--expand', '--expect', '--expect-local', '--expect-remote', '--expect-upstream', '--expected-epoch', '--expected-revision', '--expected-state', '--explain', '--facts', '--fast', '--federated', '--federated-read', '--fetch-timeout-ms', '--ff-only', '--file', '--filter', '--first-parent', '--fix', '--follow', '--force', '--force-break-lock', '--force-rechunk', '--force-remove', '--force-retry', '--force-schema', '--force-with-lease', '--format', '--fresh', '--fresh-token', '--from', '--from-json', '--from-meetings', '--from-pages', '--full', '--full-tree', '--fuzzy', '--gbrain-bin', '--generation', '--get', '--get-all', '--get-regexp', '--get-url', '--git-common-dir', '--git-dir', '--git-path', '--grammar', '--group', '--group-by', '--hard', '--hard-deadline', '--harness', '--heads', '--held', '--help', '--hold-state', '--holds', '--home', '--http', '--id', '--if-version', '--ignore-env-override', '--ignore-missing', '--images', '--import', '--include-ambiguous', '--include-covered', '--include-cross-entity', '--include-deleted', '--include-failures', '--include-flagged', '--include-frontmatter', '--include-gitignored', '--include-hidden', '--include-pseudo', '--include-repairs', '--include-withdrawals', '--index-audit', '--index-info', '--infer-dates', '--init', '--input', '--input-type', '--install', '--instructions', '--instructions-only', '--is-ancestor', '--is-bare-repository', '--is-inside-work-tree', '--is-shallow-repository', '--items-out', '--job-isolation', '--jq', '--json', '--keep', '--keep-checkout', '--key', '--kind', '--lanes', '--lang', '--left-right', '--legacy-lock', '--limit', '--link', '--link-source', '--link-type', '--list', '--list-out', '--literal-pathspecs', '--local', '--local-env-vars', '--locks', '--log-noop', '--manifest', '--markdown', '--max-cost', '--max-cost-usd', '--max-count', '--max-facts', '--max-jobs', '--max-requests', '--max-rss', '--max-runtime', '--max-usd', '--max-waiting', '--may-act-for', '--mcp-only', '--member', '--members', '--members-file', '--merge-base', '--migrate-legacy', '--migrate-only', '--migration', '--min', '--min-n', '--mode', '--model', '--multimodal', '--name', '--name-only', '--name-status', '--nice', '--no-accept-pending', '--no-assume-unchanged', '--no-autopilot-install', '--no-autostash', '--no-capture', '--no-commit-id', '--no-confirm', '--no-cron', '--no-delegate', '--no-edit', '--no-embed', '--no-embed-cache', '--no-embedding', '--no-expand', '--no-extract', '--no-federated', '--no-filters', '--no-follow-tags', '--no-gpg-sign', '--no-hooks', '--no-instructions', '--no-lanes', '--no-llm', '--no-merges', '--no-migrate', '--no-optional-locks', '--no-probe', '--no-pull', '--no-renames', '--no-repair', '--no-restart', '--no-schema-pack', '--no-seat', '--no-skip-worktree', '--no-stdio-member', '--no-tags', '--no-verify', '--no-walk', '--no-write-fetch-head', '--non-interactive', '--not', '--now', '--of', '--older-than', '--once', '--only', '--operation', '--operations', '--others', '--out', '--output', '--oversized', '--overwrite', '--page', '--parallel', '--params', '--parents', '--parked-code', '--parked-pushes', '--pat-file', '--path', '--path-format', '--pending', '--pglite', '--phase', '--pid-file', '--plan', '--porcelain', '--port', '--prefer', '--prefer-postgres', '--prefix', '--preload', '--preset', '--preview', '--principal', '--private-pages', '--probe', '--probe-pglite', '--profile', '--progress-interval', '--progress-json', '--project', '--provenance', '--provider', '--providers', '--prune-orphans', '--public-url', '--pull', '--pure', '--purge', '--push', '--push-only', '--qm', '--query', '--question', '--queue', '--quiet', '--rate', '--reader-mode', '--readers', '--reason', '--reauth', '--rebase', '--rebuild', '--recommended', '--redact-paths', '--reference-date', '--refresh', '--refresh-operations', '--refresh-skills', '--regenerate', '--reissue', '--relative', '--relower', '--remediate', '--remediation-plan', '--remote', '--remove', '--remove-core', '--repair', '--repair-unknown-markers', '--replace', '--repo', '--request', '--request-id', '--require', '--require-clean', '--reranker', '--reset', '--reset-checkpoint', '--reset-default', '--reset-session', '--resolve', '--restart-only', '--restore-only', '--resume', '--retire', '--retry-failed', '--retry-global', '--retry-held', '--retry-parked', '--reverse', '--review-lower', '--revision', '--right-only', '--rollback-to-source', '--root', '--routing', '--rules', '--run', '--runtime', '--sample', '--save', '--scan-secrets', '--scope', '--scopes', '--search-mode', '--seat', '--section', '--segmented', '--select', '--self-transfer', '--semantic', '--serves', '--session', '--session-id', '--set', '--set-upstream-to', '--shadow', '--shared-skills', '--short', '--show-current', '--show-object-format', '--show-prefix', '--show-token', '--show-toplevel', '--side', '--since', '--since-last-run', '--skill-loading', '--skills-dir', '--skills-index-only', '--skip', '--skip-bare-tweet', '--skip-failed', '--skip-urls', '--skip-verify', '--slot', '--slot-a-model', '--slot-b-model', '--slot-c-model', '--slug', '--slugs', '--source', '--source-id', '--source-ids', '--sources', '--squash', '--src-subpath', '--staged', '--stale', '--stat', '--state', '--statement-timeout', '--status', '--stdin', '--stdio-member', '--stop-mcp', '--strategy', '--strict', '--suite', '--supabase', '--surface', '--swap-only', '--symbol-kind', '--symbolic-full-name', '--tags', '--take', '--takes-holders', '--target', '--target-score', '--threshold', '--tier', '--timeout', '--timings', '--to', '--token', '--token-ttl', '--top-k', '--topo-order', '--trust', '--tsconfig-override', '--type', '--types', '--unindexed', '--uninstall', '--unsafe-bypass-dream-guard', '--unset', '--unset-all', '--unsettle', '--unshallow', '--untracked-files', '--url', '--url-env', '--user', '--vacuum', '--vectors', '--verbose', '--verify', '--version', '--wait', '--wait-drain', '--warn-only', '--watch', '--what-if-threshold', '--window', '--workers', '--working-tree', '--workspace', '--worktree', '--write-tree', '--yes'],'dream': ['--audit-rejects', '--brain', '--cancel-unmatched', '--date', '--dir', '--drain', '--dry-run', '--eval-run', '--force', '--from', '--help', '--input', '--install', '--json', '--limit', '--list', '--max-usd', '--once', '--phase', '--probe', '--pull', '--reconcile-queue', '--since', '--source', '--source-id', '--threshold', '--to', '--unsafe-bypass-dream-guard', '--window', '--yes'],'edge-proposals': ['--access', '--add', '--all', '--all-applied', '--all-held', '--allowed-operations', '--as', '--asof', '--body', '--bound-slug-prefixes', '--brain', '--client', '--cursor', '--date', '--dated-since', '--days', '--entities', '--federated-read', '--follow', '--from-index', '--full', '--fuzzy', '--group-by', '--help', '--http', '--id', '--include', '--include-deleted', '--json', '--kind', '--limit', '--max-usd', '--model', '--multimodal', '--no-autopilot-install', '--of', '--only', '--page', '--params', '--path', '--phase', '--prefer', '--purge', '--recent', '--refresh-operations', '--row', '--scopes', '--session', '--since', '--slugs', '--source', '--sources', '--stale', '--status', '--surface', '--to', '--updated-after', '--url', '--yes'],'edges-backfill': ['--all-sources', '--brain', '--concurrency', '--help', '--json', '--max-chunks', '--source', '--workers'],@@ -73,10 +73,10 @@ export const CLI_FLAG_REGISTRY: Record<string, readonly string[]> = {'founder': ['--brain', '--help', '--json', '--mcp-only', '--request-id', '--since', '--source', '--until'],'friction': ['--agent', '--base', '--brain', '--compare', '--help', '--hint', '--json', '--kind', '--message', '--no-redact', '--phase', '--run-id', '--severity', '--source', '--transcript-path', '--transcripts'],'frontmatter': ['--allow-catch-all', '--batch', '--brain', '--cached', '--diff-filter', '--dry-run', '--exclude-standard', '--fix', '--force', '--full-name', '--get', '--git-common-dir', '--help', '--importable', '--include-ambiguous', '--include-catch-all', '--json', '--literal-pathspecs', '--local', '--name-only', '--no-verify', '--others', '--path', '--show-prefix', '--show-toplevel', '--source', '--stage', '--staged', '--stdin', '--type', '--uninstall'],- 'git': ['--abbrev-ref', '--absolute-git-dir', '--add', '--aggressive', '--all', '--allow-outside-source-root', '--autostash', '--base', '--batch-check', '--brain', '--branch', '--cached', '--cacheinfo', '--cherry-mark', '--count', '--dry-run', '--enable', '--error-unmatch', '--exit-code', '--expect-remote', '--ff-only', '--file', '--force', '--force-remove', '--force-with-lease', '--format', '--get', '--get-all', '--get-regexp', '--get-url', '--git-common-dir', '--git-dir', '--git-path', '--hard', '--help', '--index-info', '--install', '--is-ancestor', '--is-inside-work-tree', '--json', '--keep-checkout', '--local', '--local-env-vars', '--max-count', '--merge-base', '--message', '--mode', '--name-only', '--name-status', '--no-assume-unchanged', '--no-autostash', '--no-commit-id', '--no-cron', '--no-gpg-sign', '--no-merges', '--no-optional-locks', '--no-recurse-submodules', '--no-renames', '--no-skip-worktree', '--no-tags', '--no-verify', '--no-write-fetch-head', '--not', '--only', '--parents', '--pat-file', '--path', '--path-format', '--pending', '--porcelain', '--pull', '--push', '--push-only', '--quiet', '--rebase', '--repo', '--request-id', '--require-clean', '--resolve', '--reverse', '--right-only', '--root', '--scan-secrets', '--short', '--show-toplevel', '--source', '--source-id', '--staged', '--stat', '--stdin', '--topo-order', '--type', '--uninstall', '--unset', '--unset-all', '--untracked-files', '--verify', '--worktree', '--write-tree'],+ 'git': ['--abbrev-ref', '--absolute-git-dir', '--add', '--aggressive', '--all', '--allow-outside-source-root', '--autostash', '--base', '--batch-check', '--brain', '--branch', '--cached', '--cacheinfo', '--cherry-mark', '--count', '--dry-run', '--enable', '--error-unmatch', '--exit-code', '--expect-remote', '--ff-only', '--file', '--force', '--force-remove', '--force-with-lease', '--format', '--get', '--get-all', '--get-regexp', '--get-url', '--git-common-dir', '--git-dir', '--git-path', '--hard', '--help', '--index-info', '--install', '--is-ancestor', '--is-inside-work-tree', '--json', '--keep-checkout', '--local', '--local-env-vars', '--max-count', '--merge-base', '--message', '--mode', '--name-only', '--name-status', '--no-assume-unchanged', '--no-autostash', '--no-commit-id', '--no-cron', '--no-follow-tags', '--no-gpg-sign', '--no-merges', '--no-optional-locks', '--no-recurse-submodules', '--no-renames', '--no-skip-worktree', '--no-tags', '--no-verify', '--no-write-fetch-head', '--not', '--only', '--parents', '--pat-file', '--path', '--path-format', '--pending', '--porcelain', '--pull', '--push', '--push-only', '--quiet', '--rebase', '--repo', '--request-id', '--require-clean', '--resolve', '--reverse', '--right-only', '--root', '--scan-secrets', '--scan-timeout', '--short', '--show-toplevel', '--source', '--source-id', '--staged', '--stat', '--stdin', '--topo-order', '--type', '--uninstall', '--unset', '--unset-all', '--untracked-files', '--verify', '--worktree', '--write-tree'],'google': ['--access', '--account', '--allow-create-db', '--allow-docker', '--brain', '--calendar-id', '--chat-model', '--client-id', '--client-json', '--client-secret', '--code', '--consent-state', '--content-root', '--db-only', '--embedding-dimensions', '--embedding-model', '--expansion-model', '--force', '--git', '--grant-types', '--help', '--history-days', '--http', '--issuer-url', '--json', '--key', '--kind', '--limit', '--local-postgres', '--mcp-only', '--mcp-url', '--migrate-only', '--model', '--no-browser', '--no-embedding', '--no-git', '--no-probe', '--non-interactive', '--oauth-client-id', '--oauth-client-secret', '--paste', '--path', '--pglite', '--plan', '--port', '--prefer-postgres', '--probe', '--provenance', '--purge-client', '--query', '--reauth', '--retry-failed', '--schema-pack', '--scopes', '--search-mode', '--services', '--skip-embed-check', '--source', '--status', '--supabase', '--surface', '--sync-budget-ms', '--timeout-ms', '--to', '--token-command', '--url', '--version', '--via', '--yes'],'graph-query': ['--brain', '--depth', '--direction', '--help', '--hop', '--include-foreign', '--json', '--mcp-only', '--request-id', '--source', '--type'],- 'hook': ['--allow-unverified-remote', '--auto', '--batch-check', '--brain', '--branch', '--cached', '--catalog', '--count', '--diff-filter', '--dir', '--enable', '--end-of-options', '--env', '--force-with-lease', '--gbrain-bin', '--get', '--harness', '--help', '--instructions', '--instructions-only', '--is-ancestor', '--jq', '--json', '--limit', '--name-only', '--no-instructions', '--only', '--others', '--pat-file', '--path', '--porcelain', '--print', '--pure', '--quiet', '--remove', '--scope', '--seat', '--session', '--show-current', '--show-toplevel', '--since', '--source', '--source-ids', '--verify', '--workspace', '--yes'],+ 'hook': ['--allow-unverified-remote', '--auto', '--batch-check', '--brain', '--branch', '--cached', '--catalog', '--count', '--diff-filter', '--dir', '--enable', '--end-of-options', '--env', '--force-with-lease', '--gbrain-bin', '--get', '--harness', '--heads', '--help', '--instructions', '--instructions-only', '--is-ancestor', '--jq', '--json', '--limit', '--name-only', '--no-follow-tags', '--no-instructions', '--no-tags', '--only', '--others', '--pat-file', '--path', '--porcelain', '--print', '--pure', '--quiet', '--remove', '--scope', '--seat', '--session', '--show-current', '--show-toplevel', '--since', '--source', '--source-ids', '--verify', '--workspace', '--yes'],'import': ['--accept-pending', '--access-policy', '--admin-intent', '--allow-empty', '--allow-noncanonical-root', '--apply', '--as', '--background', '--batch-check', '--brain', '--cached', '--confirm-relocated-root', '--diff-filter', '--dim', '--embedding-dimensions', '--embedding-model', '--empty', '--exclude', '--exclude-standard', '--expected-epoch', '--expected-state', '--explain', '--follow', '--force', '--force-rechunk', '--format', '--fresh', '--help', '--include-gitignored', '--is-shallow-repository', '--json', '--literal-pathspecs', '--log-noop', '--manifest', '--name-only', '--no-accept-pending', '--no-embed', '--no-embedding', '--no-gpg-sign', '--no-pull', '--no-renames', '--no-verify', '--only', '--others', '--path', '--probe', '--progress-interval', '--progress-json', '--quiet', '--self-transfer', '--show-toplevel', '--skip-failed', '--slugs', '--source', '--source-id', '--stale', '--status', '--supabase', '--timeout', '--timings', '--to', '--url', '--verify', '--wait', '--workers'],'init': ['--abandon', '--absolute-git-dir', '--accept-all', '--accept-capabilities', '--access', '--access-policy', '--acknowledge-managed', '--adopt', '--advertise', '--after', '--aliases', '--all', '--all-drifted', '--allow-create-db', '--allow-docker', '--allow-outside-source-root', '--anchor', '--applied', '--apply', '--approval-out', '--approved', '--as', '--assign-corpus', '--attest-actor', '--attest-ops', '--attest-read', '--attest-sources', '--audit', '--auto', '--auto-additive', '--background', '--base', '--batch', '--bound-slug-prefixes', '--brain', '--branch', '--break-lock', '--budget-ms', '--budget-policy', '--budget-tokens', '--budget-usd', '--by-mention', '--catch-up', '--channel', '--chat-model', '--check', '--check-downgrade', '--class', '--clear', '--clear-never-installed', '--cli-socket', '--client', '--close', '--code', '--confirm-quiesced', '--confirm-relocated-root', '--conflicts', '--content-root', '--continue', '--conversation', '--cursor', '--db-only', '--deadline', '--decisions', '--dest', '--detach', '--detail', '--dim', '--disable', '--drain', '--email', '--embedding-dimensions', '--embedding-model', '--enable', '--entity', '--exclude', '--expand', '--expansion-model', '--expect', '--expect-local', '--expect-remote', '--expect-upstream', '--explain', '--facts', '--fast', '--federated', '--file', '--filter', '--first-parent', '--fix', '--force', '--force-retry', '--format', '--fresh-token', '--from', '--from-meetings', '--from-pages', '--full', '--git', '--grammar', '--grant-types', '--group-by', '--harness', '--held', '--help', '--hold-state', '--holds', '--http', '--id', '--images', '--include-ambiguous', '--include-covered', '--include-cross-entity', '--include-frontmatter', '--include-gitignored', '--include-hidden', '--infer-dates', '--input', '--install', '--instructions-only', '--issuer-url', '--job-isolation', '--json', '--keep', '--keep-checkout', '--key', '--kind', '--lanes', '--legacy-lock', '--limit', '--link', '--list', '--list-out', '--local', '--local-postgres', '--markdown', '--max-cost-usd', '--max-facts', '--max-requests', '--max-rss', '--max-usd', '--may-act-for', '--mcp-only', '--mcp-url', '--member', '--members', '--members-file', '--migrate-only', '--migration', '--min-n', '--mode', '--model', '--no-autopilot-install', '--no-autostash', '--no-delegate', '--no-embed', '--no-embedding', '--no-expand', '--no-extract', '--no-federated', '--no-filters', '--no-git', '--no-hooks', '--no-instructions', '--no-lanes', '--no-llm', '--no-probe', '--no-pull', '--no-renames', '--no-repair', '--no-restart', '--no-schema-pack', '--no-stdio-member', '--no-verify', '--non-interactive', '--oauth-client-id', '--oauth-client-secret', '--of', '--older-than', '--once', '--only', '--operation', '--output', '--oversized', '--page', '--params', '--parked-code', '--parked-pushes', '--pat-file', '--path', '--pending', '--pglite', '--phase', '--plan', '--prefer', '--prefer-postgres', '--prefix', '--preview', '--private-pages', '--probe', '--profile', '--provenance', '--providers', '--pull', '--purge', '--push-only', '--qm', '--query', '--question', '--quiet', '--readers', '--reason', '--rebase', '--rebuild', '--redact-paths', '--reference-date', '--remediate', '--remote', '--remove', '--repair', '--repair-unknown-markers', '--repo', '--request', '--request-id', '--require-clean', '--reset', '--resolve', '--restart-only', '--resume', '--retire', '--retry-failed', '--retry-parked', '--runtime', '--save', '--scan-secrets', '--schema-pack', '--scope', '--scopes', '--search-mode', '--section', '--segmented', '--self-transfer', '--semantic', '--serves', '--session', '--session-id', '--shared-skills', '--show-toplevel', '--side', '--since', '--since-last-run', '--skip', '--skip-embed-check', '--skip-failed', '--slug', '--slugs', '--source', '--source-id', '--sources', '--squash', '--src-subpath', '--stale', '--state', '--status', '--stdin', '--stdio-member', '--stop-mcp', '--strategy', '--supabase', '--surface', '--swap-only', '--take', '--tier', '--timeout', '--to', '--token', '--touchpoint', '--type', '--types', '--uninstall', '--unsettle', '--url', '--url-env', '--user', '--vacuum', '--verbose', '--version', '--wait', '--warn-only', '--watch', '--working-tree', '--workspace', '--yes'],'integrations': ['--auto', '--brain', '--dry-run', '--help', '--json', '--overwrite', '--refresh', '--source', '--target'],@@ -116,7 +116,7 @@ export const CLI_FLAG_REGISTRY: Record<string, readonly string[]> = {'repair': ['--accept-pending', '--acknowledge-managed', '--after', '--all', '--all-drifted', '--apply', '--as', '--auto-additive', '--background', '--brain', '--break-lock', '--class', '--client', '--close', '--cursor', '--cwd', '--day', '--diff', '--expect', '--explain', '--ff-only', '--follow', '--force', '--force-break-lock', '--from', '--full', '--full-history', '--generation', '--held', '--help', '--id', '--include-ambiguous', '--include-cross-entity', '--include-failures', '--include-repairs', '--json', '--keep', '--key', '--kind', '--limit', '--max-cost', '--max-cost-usd', '--max-usd', '--mode', '--no-accept-pending', '--no-delegate', '--no-embed', '--no-llm', '--older-than', '--only', '--prefer', '--principal', '--probe', '--progress-interval', '--progress-json', '--provenance', '--quiet', '--remediate', '--remediation-plan', '--request', '--request-id', '--reset-checkpoint', '--retry-failed', '--rules', '--run', '--scopes', '--seat', '--session', '--side', '--since', '--skip', '--skip-failed', '--slug', '--slugs', '--source', '--stale', '--state', '--timeout', '--timings', '--url', '--wait', '--yes'],'repair-jsonb': ['--accept-pending', '--as', '--background', '--brain', '--dry-run', '--explain', '--follow', '--help', '--json', '--no-accept-pending', '--probe', '--progress-interval', '--progress-json', '--quiet', '--source', '--supabase', '--timeout', '--timings', '--url', '--wait'],'report': ['--brain', '--content', '--dir', '--help', '--json', '--source', '--title', '--type'],- 'repos': ['--abandon', '--abbrev-ref', '--abort', '--accept-suggested', '--access', '--account', '--add', '--admin-intent', '--adopt-columns', '--adopt-permissions', '--adopt-slug-path', '--after', '--all', '--all-new', '--allow-unverified-remote', '--allowed-operations', '--app-id', '--app-install', '--app-pem', '--apply', '--approval-out', '--approved', '--attest-actor', '--attest-ops', '--attest-read', '--attest-sources', '--audit', '--auto-additive', '--autostash', '--backups', '--batch-check', '--before', '--bound-brain', '--bound-max-concurrent', '--bound-slug-prefixes', '--bound-source', '--bound-tools', '--brain', '--branch', '--break-lock', '--budget-usd-per-day', '--cached', '--calendar-id', '--category', '--classify', '--cleanup-dead-local-locks', '--clear', '--client', '--clone-dir', '--code', '--config', '--confirm-destructive', '--confirm-quiesced', '--confirm-relocated-root', '--conflicts', '--contacts-dir', '--count', '--cursor', '--days', '--decisions', '--delegated-namespace', '--delegated-slug-prefixes', '--depth', '--detect', '--diff-filter', '--dir', '--disable', '--dry-run', '--enable', '--error-unmatch', '--exclude', '--expect', '--expect-local', '--expect-remote', '--expect-upstream', '--expected-epoch', '--expected-incarnation', '--expected-state', '--federated', '--federated-read', '--fetch-timeout-ms', '--ff-only', '--file', '--fix', '--force', '--force-with-lease', '--format', '--from', '--from-git', '--full', '--future-days', '--get', '--get-all', '--git-dir', '--git-path', '--github-repo', '--grant-types', '--group-by', '--hard', '--help', '--history-days', '--holds', '--http', '--id', '--if-version', '--include', '--include-warns', '--install', '--is-ancestor', '--is-inside-work-tree', '--json', '--keep', '--keep-checkout', '--keep-storage', '--kind', '--lanes', '--limit', '--list-out', '--local', '--local-env-vars', '--loops-exclude-labels', '--manifest', '--max-cost-usd', '--may-act-for', '--member', '--message', '--migrate-legacy', '--migration', '--min-trust', '--mode', '--name', '--name-only', '--no-assume-unchanged', '--no-autostash', '--no-cron', '--no-embed', '--no-extract', '--no-federate', '--no-federated', '--no-harden', '--no-lanes', '--no-pull', '--no-renames', '--no-skip-worktree', '--no-tags', '--no-verify', '--not', '--only', '--operation', '--operations', '--origin', '--others', '--out', '--params', '--parked-code', '--parked-pushes', '--pat-file', '--path', '--path-format', '--plan', '--porcelain', '--prefix', '--preview', '--private-pages', '--probe', '--profile', '--pull', '--push-only', '--push-remote', '--quiet', '--read-sources', '--readers', '--rebase', '--redirect-uri', '--refresh-operations', '--remote', '--remove-backup', '--repair', '--replace', '--repos', '--request-id', '--require-clean', '--reset-checkpoint', '--reset-default', '--resolve', '--resume', '--retire', '--retry-failed', '--sample', '--scan-secrets', '--scope', '--scopes', '--secret', '--self-transfer', '--services', '--set', '--set-upstream-to', '--shared-skills', '--short', '--show-toplevel', '--since', '--slug-prefixes', '--source', '--source-id', '--source-ids', '--sources', '--stale', '--state', '--status', '--stdin', '--surface', '--symbolic-full-name', '--takes-holders', '--to', '--token', '--token-command', '--token-endpoint-auth-method', '--token-env', '--token-ttl', '--unindexed', '--uninstall', '--unset-all', '--unsettle', '--untracked-files', '--url', '--usage', '--verify', '--wait', '--wait-drain', '--warn-only', '--window', '--yes'],+ 'repos': ['--abandon', '--abbrev-ref', '--abort', '--accept-suggested', '--access', '--account', '--add', '--admin-intent', '--adopt-columns', '--adopt-permissions', '--adopt-slug-path', '--after', '--all', '--all-new', '--allow-unverified-remote', '--allowed-operations', '--app-id', '--app-install', '--app-pem', '--apply', '--approval-out', '--approved', '--attest-actor', '--attest-ops', '--attest-read', '--attest-sources', '--audit', '--auto-additive', '--autostash', '--backups', '--batch-check', '--before', '--bound-brain', '--bound-max-concurrent', '--bound-slug-prefixes', '--bound-source', '--bound-tools', '--brain', '--branch', '--break-lock', '--budget-usd-per-day', '--cached', '--calendar-id', '--category', '--classify', '--cleanup-dead-local-locks', '--clear', '--client', '--clone-dir', '--code', '--config', '--confirm-destructive', '--confirm-quiesced', '--confirm-relocated-root', '--conflicts', '--contacts-dir', '--count', '--cursor', '--days', '--decisions', '--delegated-namespace', '--delegated-slug-prefixes', '--depth', '--detect', '--diff-filter', '--dir', '--disable', '--dry-run', '--enable', '--error-unmatch', '--exclude', '--expect', '--expect-local', '--expect-remote', '--expect-upstream', '--expected-epoch', '--expected-incarnation', '--expected-state', '--federated', '--federated-read', '--fetch-timeout-ms', '--ff-only', '--file', '--fix', '--force', '--force-with-lease', '--format', '--from', '--from-git', '--full', '--future-days', '--get', '--get-all', '--git-dir', '--git-path', '--github-repo', '--grant-types', '--group-by', '--hard', '--heads', '--help', '--history-days', '--holds', '--http', '--id', '--if-version', '--include', '--include-warns', '--install', '--is-ancestor', '--is-inside-work-tree', '--json', '--keep', '--keep-checkout', '--keep-storage', '--kind', '--lanes', '--limit', '--list-out', '--local', '--local-env-vars', '--loops-exclude-labels', '--manifest', '--max-cost-usd', '--may-act-for', '--member', '--message', '--migrate-legacy', '--migration', '--min-trust', '--mode', '--name', '--name-only', '--no-assume-unchanged', '--no-autostash', '--no-cron', '--no-embed', '--no-extract', '--no-federate', '--no-federated', '--no-follow-tags', '--no-harden', '--no-lanes', '--no-pull', '--no-renames', '--no-skip-worktree', '--no-tags', '--no-verify', '--not', '--only', '--operation', '--operations', '--origin', '--others', '--out', '--params', '--parked-code', '--parked-pushes', '--pat-file', '--path', '--path-format', '--plan', '--porcelain', '--prefix', '--preview', '--private-pages', '--probe', '--profile', '--pull', '--push-only', '--push-remote', '--quiet', '--read-sources', '--readers', '--rebase', '--redirect-uri', '--refresh-operations', '--remote', '--remove-backup', '--repair', '--replace', '--repos', '--request-id', '--require-clean', '--reset-checkpoint', '--reset-default', '--resolve', '--resume', '--retire', '--retry-failed', '--sample', '--scan-secrets', '--scan-timeout', '--scope', '--scopes', '--secret', '--self-transfer', '--services', '--set', '--set-upstream-to', '--shared-skills', '--short', '--show-toplevel', '--since', '--slug-prefixes', '--source', '--source-id', '--source-ids', '--sources', '--stale', '--state', '--status', '--stdin', '--surface', '--symbolic-full-name', '--takes-holders', '--to', '--token', '--token-command', '--token-endpoint-auth-method', '--token-env', '--token-ttl', '--unindexed', '--uninstall', '--unset-all', '--unsettle', '--untracked-files', '--url', '--usage', '--verify', '--wait', '--wait-drain', '--warn-only', '--window', '--yes'],'resolvers': ['--backend', '--brain', '--cost', '--help', '--json', '--source'],'retrieval-upgrade': ['--accept-pending', '--all', '--as', '--background', '--batch-size', '--brain', '--catch-up', '--dim', '--dry-run', '--embedding-dimensions', '--embedding-model', '--explain', '--facts', '--follow', '--force', '--held', '--help', '--ignore-env-override', '--images', '--include-null-signature', '--json', '--max-cost-usd', '--max-usd', '--no-accept-pending', '--no-embed', '--non-interactive', '--only', '--oversized', '--pace', '--pace-max-concurrency', '--plan', '--priority', '--progress-interval', '--progress-json', '--quiet', '--replace', '--reranker', '--retarget', '--slugs', '--source', '--stale', '--status', '--timeout', '--timings', '--to', '--wait', '--yes'],'routing-eval': ['--brain', '--help', '--json', '--llm', '--skills-dir', '--source'],@@ -131,7 +131,7 @@ export const CLI_FLAG_REGISTRY: Record<string, readonly string[]> = {'skillpack': ['--all', '--apply-clean-hunks', '--author', '--auto', '--brain', '--dest', '--dry-run', '--env', '--exit-code', '--fast', '--fix', '--force-unlock', '--format', '--from', '--full', '--harness', '--help', '--homepage', '--json', '--license', '--list', '--minimal', '--name-only', '--no-cache', '--no-lint', '--note', '--out', '--overwrite-local', '--persona', '--probe', '--pure', '--push', '--quick', '--quiet', '--refresh', '--repo', '--schema-pack', '--scope', '--short', '--since', '--skill', '--skills', '--skills-dir', '--skip-doctor', '--source', '--strict', '--stub', '--supabase', '--target', '--tier', '--trust', '--url', '--verify', '--version', '--workspace', '--yes'],'skillpack-check': ['--accept-pending', '--as', '--background', '--brain', '--explain', '--fast', '--follow', '--help', '--json', '--list', '--no-accept-pending', '--progress-interval', '--progress-json', '--quiet', '--source', '--strict', '--timeout', '--timings', '--wait', '--yes'],'smoke-test': ['--brain', '--help', '--json', '--source'],- 'sources': ['--abandon', '--abbrev-ref', '--abort', '--accept-pending', '--accept-suggested', '--access', '--account', '--add', '--admin-intent', '--adopt-columns', '--adopt-permissions', '--adopt-slug-path', '--after', '--all', '--all-new', '--allow-unverified-remote', '--allowed-operations', '--app-id', '--app-install', '--app-pem', '--apply', '--approval-out', '--approved', '--as', '--attest-actor', '--attest-ops', '--attest-read', '--attest-sources', '--audit', '--auto-additive', '--autostash', '--background', '--backups', '--batch-check', '--before', '--bound-brain', '--bound-max-concurrent', '--bound-slug-prefixes', '--bound-source', '--bound-tools', '--brain', '--branch', '--break-lock', '--budget-usd-per-day', '--cached', '--calendar-id', '--category', '--channels', '--classify', '--cleanup-dead-local-locks', '--clear', '--client', '--clone-dir', '--code', '--config', '--confirm-destructive', '--confirm-quiesced', '--confirm-relocated-root', '--conflicts', '--contacts-dir', '--count', '--cursor', '--days', '--db-url', '--decisions', '--delegated-namespace', '--delegated-slug-prefixes', '--depth', '--detect', '--diff-filter', '--dir', '--disable', '--dry-run', '--enable', '--error-unmatch', '--exclude', '--expect', '--expect-local', '--expect-remote', '--expect-upstream', '--expected-epoch', '--expected-incarnation', '--expected-state', '--explain', '--federated', '--federated-read', '--fetch-timeout-ms', '--ff-only', '--file', '--fix', '--follow', '--force', '--force-with-lease', '--format', '--from', '--from-git', '--full', '--future-days', '--get', '--get-all', '--git-dir', '--git-path', '--github-repo', '--grant-types', '--group-by', '--hard', '--help', '--history-days', '--holds', '--http', '--id', '--if-version', '--include', '--include-warns', '--install', '--is-ancestor', '--is-inside-work-tree', '--json', '--keep', '--keep-checkout', '--keep-storage', '--kind', '--lanes', '--legacy-lock', '--limit', '--list-out', '--local', '--local-env-vars', '--lookback-days', '--loops-exclude-labels', '--manifest', '--max-cost-usd', '--max-requests', '--may-act-for', '--member', '--message', '--migrate-legacy', '--migration', '--min-trust', '--mode', '--name', '--name-only', '--no-accept-pending', '--no-assume-unchanged', '--no-autostash', '--no-cron', '--no-embed', '--no-extract', '--no-federate', '--no-federated', '--no-harden', '--no-lanes', '--no-pull', '--no-renames', '--no-skip-worktree', '--no-tags', '--no-verify', '--not', '--only', '--operation', '--operations', '--origin', '--others', '--out', '--params', '--parked-code', '--parked-pushes', '--pat-file', '--path', '--path-format', '--plan', '--porcelain', '--prefix', '--preview', '--private-pages', '--probe', '--profile', '--progress-interval', '--progress-json', '--provider', '--pull', '--push-only', '--push-remote', '--quiet', '--read-sources', '--readers', '--rebase', '--record', '--redirect-uri', '--refresh-operations', '--remote', '--remove-backup', '--repair', '--replace', '--repos', '--request-id', '--require-clean', '--reset-checkpoint', '--reset-default', '--resolve', '--resume', '--retire', '--retry-failed', '--sample', '--scan-secrets', '--scope', '--scopes', '--secret', '--self-transfer', '--services', '--set', '--set-upstream-to', '--shared-skills', '--short', '--show-toplevel', '--since', '--skip', '--slug-prefixes', '--source', '--source-id', '--source-ids', '--sources', '--stale', '--state', '--status', '--stdin', '--surface', '--symbolic-full-name', '--sync-interval-min', '--takes-holders', '--timeout', '--timezone', '--timings', '--to', '--token', '--token-command', '--token-endpoint-auth-method', '--token-env', '--token-ttl', '--transcript', '--unindexed', '--uninstall', '--unset-all', '--unsettle', '--untracked-files', '--url', '--usage', '--verify', '--visibility', '--wait', '--wait-drain', '--warn-only', '--window', '--yes'],+ 'sources': ['--abandon', '--abbrev-ref', '--abort', '--accept-pending', '--accept-suggested', '--access', '--account', '--add', '--admin-intent', '--adopt-columns', '--adopt-permissions', '--adopt-slug-path', '--after', '--all', '--all-new', '--allow-unverified-remote', '--allowed-operations', '--app-id', '--app-install', '--app-pem', '--apply', '--approval-out', '--approved', '--as', '--attest-actor', '--attest-ops', '--attest-read', '--attest-sources', '--audit', '--auto-additive', '--autostash', '--background', '--backups', '--batch-check', '--before', '--bound-brain', '--bound-max-concurrent', '--bound-slug-prefixes', '--bound-source', '--bound-tools', '--brain', '--branch', '--break-lock', '--budget-usd-per-day', '--cached', '--calendar-id', '--category', '--channels', '--classify', '--cleanup-dead-local-locks', '--clear', '--client', '--clone-dir', '--code', '--config', '--confirm-destructive', '--confirm-quiesced', '--confirm-relocated-root', '--conflicts', '--contacts-dir', '--count', '--cursor', '--days', '--db-url', '--decisions', '--delegated-namespace', '--delegated-slug-prefixes', '--depth', '--detect', '--diff-filter', '--dir', '--disable', '--dry-run', '--enable', '--error-unmatch', '--exclude', '--expect', '--expect-local', '--expect-remote', '--expect-upstream', '--expected-epoch', '--expected-incarnation', '--expected-state', '--explain', '--federated', '--federated-read', '--fetch-timeout-ms', '--ff-only', '--file', '--fix', '--follow', '--force', '--force-with-lease', '--format', '--from', '--from-git', '--full', '--future-days', '--get', '--get-all', '--git-dir', '--git-path', '--github-repo', '--grant-types', '--group-by', '--hard', '--heads', '--help', '--history-days', '--holds', '--http', '--id', '--if-version', '--include', '--include-warns', '--install', '--is-ancestor', '--is-inside-work-tree', '--json', '--keep', '--keep-checkout', '--keep-storage', '--kind', '--lanes', '--legacy-lock', '--limit', '--list-out', '--local', '--local-env-vars', '--lookback-days', '--loops-exclude-labels', '--manifest', '--max-cost-usd', '--max-requests', '--may-act-for', '--member', '--message', '--migrate-legacy', '--migration', '--min-trust', '--mode', '--name', '--name-only', '--no-accept-pending', '--no-assume-unchanged', '--no-autostash', '--no-cron', '--no-embed', '--no-extract', '--no-federate', '--no-federated', '--no-follow-tags', '--no-harden', '--no-lanes', '--no-pull', '--no-renames', '--no-skip-worktree', '--no-tags', '--no-verify', '--not', '--only', '--operation', '--operations', '--origin', '--others', '--out', '--params', '--parked-code', '--parked-pushes', '--pat-file', '--path', '--path-format', '--plan', '--porcelain', '--prefix', '--preview', '--private-pages', '--probe', '--profile', '--progress-interval', '--progress-json', '--provider', '--pull', '--push-only', '--push-remote', '--quiet', '--read-sources', '--readers', '--rebase', '--record', '--redirect-uri', '--refresh-operations', '--remote', '--remove-backup', '--repair', '--replace', '--repos', '--request-id', '--require-clean', '--reset-checkpoint', '--reset-default', '--resolve', '--resume', '--retire', '--retry-failed', '--sample', '--scan-secrets', '--scan-timeout', '--scope', '--scopes', '--secret', '--self-transfer', '--services', '--set', '--set-upstream-to', '--shared-skills', '--short', '--show-toplevel', '--since', '--skip', '--slug-prefixes', '--source', '--source-id', '--source-ids', '--sources', '--stale', '--state', '--status', '--stdin', '--surface', '--symbolic-full-name', '--sync-interval-min', '--takes-holders', '--timeout', '--timezone', '--timings', '--to', '--token', '--token-command', '--token-endpoint-auth-method', '--token-env', '--token-ttl', '--transcript', '--unindexed', '--uninstall', '--unset-all', '--unsettle', '--untracked-files', '--url', '--usage', '--verify', '--visibility', '--wait', '--wait-drain', '--warn-only', '--window', '--yes'],'status': ['--abbrev-ref', '--acknowledge-managed', '--all', '--allow-empty', '--apply', '--brain', '--break-lock', '--cached', '--check', '--code', '--concurrency', '--confirm-destructive', '--count', '--cursor', '--deadline-ms', '--delete', '--detail', '--diff-filter', '--empty', '--enable', '--exclude', '--exclude-standard', '--fast', '--filters', '--fix', '--force-break-lock', '--format', '--full', '--full-history', '--funnel', '--hard-deadline', '--help', '--hold-state', '--include-gitignored', '--include-hidden', '--install', '--interval', '--is-ancestor', '--is-shallow-repository', '--json', '--lanes', '--limit', '--max-age', '--max-sources', '--mcp-only', '--missing-path', '--name-only', '--no-auto-embed', '--no-bulk', '--no-delegate', '--no-embed', '--no-extract', '--no-gpg-sign', '--no-hard-deadline', '--no-lanes', '--no-llm', '--no-pull', '--no-renames', '--no-repair', '--no-schema-pack', '--no-verify', '--no-walk', '--others', '--parallel', '--path', '--prefer', '--preview', '--priority', '--quiet', '--reason', '--redact-paths', '--repo', '--request-id', '--reset-checkpoint', '--retry-failed', '--retry-held', '--reverse', '--section', '--serial', '--show-toplevel', '--skip-failed', '--slug', '--slugs', '--source', '--source-id', '--src-subpath', '--stale', '--status', '--strategy', '--timeout', '--url', '--verify', '--watch', '--workers', '--working-tree', '--yes'],'storage': ['--brain', '--help', '--json', '--plan', '--repo', '--restore-only', '--source', '--to'],'sweep': ['--accept-pending', '--apply', '--as', '--assign-corpus', '--background', '--batch-limit', '--brain', '--budget-ms', '--delete-brain', '--explain', '--follow', '--help', '--home', '--json', '--no-accept-pending', '--no-delegate', '--once', '--only', '--progress-interval', '--progress-json', '--quiet', '--retry-failed', '--session', '--source', '--source-id', '--stale', '--timeout', '--timings', '--wait'],diff --git a/src/core/git/commit-push.ts b/src/core/git/commit-push.tsindex 659370e193..beccf47228 100644--- a/src/core/git/commit-push.ts+++ b/src/core/git/commit-push.ts@@ -125,6 +125,9 @@ export interface CommitPushOptions {keepCheckout?: boolean;/** Before pushing, scan what the commits the upstream lacks add (messages, added lines, merge resolutions) and refuse `publish_secret_found` on a finding: the gate for automatic publishes of commits gbrain did not write. */scanSecrets?: boolean;+ /** The secret scan's time budget (`--scan-timeout`; default 300 s) and where its progress lines go. */+ scanTimeoutMs?: number;+ scanProgress?: (line: string) => void;/** Commit the pending write-through files (`--pending`) instead of named paths. */pending?: boolean;/** Commit and publish files outside the configured source root(s): the user's explicit choice, or gbrain's own scaffolding at the checkout root. */@@ -143,6 +146,8 @@ interface Ctx {trackingRef: string;keepCheckout?: boolean;scanSecrets?: boolean;+ scanTimeoutMs?: number;+ scanProgress?: (line: string) => void;}interface GitRun { code: number; stdout: string; stderr: string }@@ -1044,6 +1049,34 @@ function remoteContains(ctx: Ctx, sha: string): boolean {return true;}+/**+ * GST-2456: the commit a scanned push is scanned from and leased on. Normally the remote's tip as fetched (`fetched`); when+ * the remote pushes to URLs of its own (pushurl, #5138), what those URLs hold, read live, which must be one commit (or the+ * branch absent everywhere), since one push carries one lease. Anything else refuses push_unconfirmed, with nothing pushed.+ */+function pushBase(ctx: Ctx, fetched: string, candidate: string): string {+ const urls = git(ctx.root, ['remote', 'get-url', '--push', '--all', '--', ctx.remote]).stdout.split('\n').map(u => u.trim()).filter(Boolean);+ if (urls.length === 1 && urls[0] === git(ctx.root, ['remote', 'get-url', '--', ctx.remote]).stdout.trim()) return fetched;+ const refuse = (why: string) => opError('push_unconfirmed', `Nothing was pushed: ${why}, so no one scanned range covers what this push would publish to every push URL of ${ctx.remote}.`,+ `Bring every push URL of ${ctx.remote} to the same commit of ${ctx.mergeRef.replace(/^refs\/heads\//, '')} (git remote get-url --push --all ${ctx.remote} lists them), then rerun gbrain git commit-push --push-only.`,+ { detail: candidate, retryable: true });+ const tips = new Set<string>();+ for (const url of urls) {+ if (git(ctx.root, ['ls-remote', '--get-url', '--', url]).stdout.trim() !== url) throw refuse(`push URL ${url} names another remote`);+ const listed = git(ctx.root, [...transportFlags(), 'ls-remote', '--exit-code', '--', url, ctx.mergeRef], { auth: true, timeoutMs: 60_000 });+ if (listed.code === 2) { tips.add(''); continue; }+ const tip = listed.code === 0 ? listed.stdout.split(/\s/)[0] ?? '' : '';+ if (!/^[0-9a-f]{40,64}$/.test(tip)) throw refuse(`push URL ${url} could not be read`);+ if (git(ctx.root, ['cat-file', '-e', `${tip}^{commit}`]).code !== 0+ && git(ctx.root, [...transportFlags(), 'fetch', '--quiet', ...fetchFlags(ctx.root), ...GIT_SSRF_SUBCOMMAND_FLAGS, '--', url, tip], { auth: true, timeoutMs: 120_000 }).code !== 0) {+ throw refuse(`the commit push URL ${url} holds could not be fetched`);+ }+ tips.add(tip);+ }+ if (tips.size !== 1) throw refuse(`the push URLs hold different commits of ${ctx.mergeRef.replace(/^refs\/heads\//, '')}`);+ return [...tips][0]!;+}+interface Published { sha: string; integrated: number; confirmed: 'push' | 'remote'; quarantined?: QuarantineEntry; superseded?: string[] }// ── Quarantine (opt-in) ─────────────────────────────────────────────────────@@ -1089,7 +1122,7 @@ function publish(ctx: Ctx, start: string, resolutions: Map<string, Resolution> |const bound = expectRemote && !resolutions?.size ? gitOk(ctx.root, ['rev-parse', '--verify', `${expectRemote}^{commit}`], 'rev-parse --expect-remote') : undefined;// #8896: a scanned publish scans <base>..<candidate> before every push and leases the push on that base, so a remote that// moved or was rewound since the tracking ref was fetched (a stale ref hides commits from the scan) is fetched and scanned again.- let scannedBase = scanSecrets ? git(ctx.root, ['rev-parse', '--verify', '--quiet', ctx.trackingRef]).stdout.trim() : '';+ let scannedBase = scanSecrets ? pushBase(ctx, git(ctx.root, ['rev-parse', '--verify', '--quiet', ctx.trackingRef]).stdout.trim(), start) : '';let candidate = start;let integrated = 0;let lastError = '';@@ -1108,13 +1141,13 @@ function publish(ctx: Ctx, start: string, resolutions: Map<string, Resolution> |const lease = bound ?? (scanSecrets ? scannedBase : undefined);if (scanSecrets) assertNoSecretsInRange({ ...ctx, trackingRef: lease! }, candidate);const push = lease && !isAncestor(ctx.root, lease, candidate) ? null- : remoteGit(ctx.root, 'push', [...(ctx.keepCheckout ? ['--no-verify'] : []), ...(lease !== undefined ? [`--force-with-lease=${ctx.mergeRef}:${lease}`] : []), '--', ctx.remote, `${candidate}:${ctx.mergeRef}`]);+ : remoteGit(ctx.root, 'push', ['--no-follow-tags', ...(ctx.keepCheckout ? ['--no-verify'] : []), ...(lease !== undefined ? [`--force-with-lease=${ctx.mergeRef}:${lease}`] : []), '--', ctx.remote, `${candidate}:${ctx.mergeRef}`]);if (push?.code === 0) return { sha: candidate, integrated, confirmed: 'push', ...notes() };if (push) lastError = push.stderr.trim();if (remoteContains(ctx, candidate)) return onRemote();remoteTip = fetchTracking(ctx);if (!remoteTip) break;- scannedBase = remoteTip;+ if (scanSecrets) scannedBase = pushBase(ctx, remoteTip, candidate);if (bound && remoteTip !== bound) {throw opError('push_unconfirmed', `The remote moved to ${remoteTip.slice(0, 12)} after --expect-remote ${bound.slice(0, 12)} was checked, so nothing was pushed: publishing now could merge back commits a rewrite removed.`,'Check the remote history first (gbrain sources refresh checks it for a force-push), then rerun.', { detail: candidate, retryable: true });@@ -1193,7 +1226,8 @@ function assertLocalCommitsInsideRoots(ctx: Ctx, target: string, roots: string[]/** The automatic-publish secret gate: scan what the commits in trackingRef..target add (publish passes the base it leases its push on, under its lock). */function assertNoSecretsInRange(ctx: Ctx, target: string): void {- const refusal = rangeSecretRefusal(ctx.root, ctx.trackingRef, target, scanRange(ctx.root, ctx.trackingRef, target));+ const refusal = rangeSecretRefusal(ctx.root, ctx.trackingRef, target, scanRange(ctx.root, ctx.trackingRef, target, ctx.scanTimeoutMs, ctx.scanProgress), {+ timeoutMs: ctx.scanTimeoutMs, retryArgv: ['gbrain', 'git', 'commit-push', '--push-only', ...(ctx.keepCheckout ? ['--keep-checkout'] : []), '--path', ctx.root] });if (refusal) throw refusal;}@@ -1340,7 +1374,8 @@ export function commitAndPush(opts: CommitPushOptions): CommitPushResult {throw opError('commit_paths_invalid', 'A commit message is required.', 'Pass -m "<message>".');}const upstream = resolveCtx(root);- const ctx = { ...withBranch(upstream, opts.branch), ...(opts.keepCheckout ? { keepCheckout: true } : {}), ...(opts.scanSecrets ? { scanSecrets: true } : {}) };+ const ctx = { ...withBranch(upstream, opts.branch), ...(opts.keepCheckout ? { keepCheckout: true } : {}), ...(opts.scanSecrets ? { scanSecrets: true } : {}),+ ...(opts.scanTimeoutMs ? { scanTimeoutMs: opts.scanTimeoutMs } : {}), ...(opts.scanProgress ? { scanProgress: opts.scanProgress } : {}) };const elsewhere = ctx.mergeRef !== upstream.mergeRef;assertNoOperationInProgress(root);diff --git a/src/core/git/range-secret-scan.ts b/src/core/git/range-secret-scan.tsindex af3324b4bb..0a783c8aa0 100644--- a/src/core/git/range-secret-scan.ts+++ b/src/core/git/range-secret-scan.ts@@ -20,13 +20,14 @@* design (docs/guides/write-refusals.md#what-stays-raw-by-design) and their Git backups have always been pushed, so the* gate covers what gbrain did not write; `gbrain git commit-push` commits, which carry a script's files, are scanned.*/-import { closeSync, existsSync, mkdtempSync, openSync, readFileSync, readSync, rmSync } from 'node:fs';+import { closeSync, existsSync, fstatSync, mkdtempSync, openSync, readFileSync, readSync, rmSync } from 'node:fs';import { tmpdir } from 'node:os';import { isAbsolute, join } from 'node:path';import { GIT_READ_ENV, gitChildEnv } from '../git-env.ts';import { readLedger } from './commit-ledger.ts';import { GIT_ENV } from '../git-transport.ts';import { opError, type OperationError } from '../ops/contract.ts';+import { shellQuote } from '../agent-output.ts';import { loadWorkspaceAllowlist, pathAllowlisted, SCAN_ALLOW_FILENAME } from '../secret-scan-allowlist.ts';import { scanText, SCAN_MAX_FILE_BYTES } from '../secret-scan.ts';import { spawnSync } from '../spawn.ts';@@ -44,6 +45,11 @@ export interface RangeScan {export const MESSAGE_PATH = '(commit message)';const SNIFF_BYTES = 8000;+/** The default time budget of a range scan; a foreground publish takes a longer one with --scan-timeout. */+export const DEFAULT_SCAN_TIMEOUT_MS = 300_000;+const PROGRESS_EVERY_MS = 10_000;+/** Commits per diff-tree run, so the temporary patch file stays the size of one batch, not of the whole history. */+const DIFF_BATCH = 256;const BIG_FILE_THRESHOLD = 512 * 1024 * 1024;const CONFIG = ['-c', 'core.quotePath=false', '-c', 'core.attributesFile=/dev/null', '-c', `core.bigFileThreshold=${BIG_FILE_THRESHOLD}`];const DIFF = ['diff-tree', '--stdin', '-r', '-p', '--root', '--cc', '--no-renames', '--no-ext-diff', '--no-textconv', '--no-color',@@ -126,9 +132,19 @@ function attributesNeutral(root: string, deadline: number): boolean {return !existsSync(file) || readFileSync(file, 'utf8').split('\n').every(line => !line.trim() || line.trim().startsWith('#'));}-/** An empty `base` scans `head` and its whole history (a first push that creates the remote branch). */-export function scanRange(root: string, base: string, head: string, timeoutMs = 300_000): RangeScan {- const deadline = Date.now() + timeoutMs;+/**+ * An empty `base` scans `head` and its whole history (a first push that creates the remote branch). `progress` receives a+ * line at once for a whole-history scan, and every 10 s while any scan runs.+ */+export function scanRange(root: string, base: string, head: string, timeoutMs = DEFAULT_SCAN_TIMEOUT_MS, progress?: (line: string) => void): RangeScan {+ const started = Date.now();+ const deadline = started + timeoutMs;+ let reported = base ? started : 0, spoke = false;+ const report = (line: () => string) => {+ if (!progress || Date.now() - reported < PROGRESS_EVERY_MS) return;+ reported = Date.now(); spoke = true;+ progress(`secret scan: ${line()} (${Math.round((reported - started) / 1000)} s of a ${Math.round(timeoutMs / 1000)} s budget)`);+ };const scan: RangeScan = { findings: [], unscanned: [], gate_changes: [] };const allowlist = loadWorkspaceAllowlist(root);const scanned = (path: string, commit: string, text: string, lineAt: (line: number) => number = line => line) => {@@ -142,11 +158,9 @@ export function scanRange(root: string, base: string, head: string, timeoutMs =const commits = must(run(root, ['rev-list', base ? `${base}..${head}` : head, '--'], deadline), 'rev-list').toString().split('\n').filter(commit => commit && !pageWrites.has(commit));if (!commits.length) return scan;+ report(() => `reading ${commits.length} commit(s)${base ? '' : ', the whole history'}`);- for (const commit of commits) {- const raw = run(root, ['cat-file', 'commit', commit], deadline, { maxBuffer: SCAN_MAX_FILE_BYTES + 1024 * 1024 });- if ((raw.error as NodeJS.ErrnoException | undefined)?.code === 'ENOBUFS') { scan.unscanned.push({ path: MESSAGE_PATH, commit }); continue; }- const object = must(raw, 'cat-file commit');+ const scanMessage = (commit: string, object: Buffer): void => {const split = object.indexOf('\n\n');const encoding = /^encoding (.+)$/m.exec(object.subarray(0, split < 0 ? object.length : split).toString('latin1'))?.[1]?.trim() ?? 'utf-8';const bytes = split < 0 ? Buffer.alloc(0) : object.subarray(split + 2);@@ -156,81 +170,121 @@ export function scanRange(root: string, base: string, head: string, timeoutMs =}const before = scan.findings.length;scanned(MESSAGE_PATH, commit, message);- if (/^utf-?8$/i.test(encoding)) continue;+ if (/^utf-?8$/i.test(encoding)) return;const seen = new Set(scan.findings.slice(before).map(f => `${f.line}:${f.fingerprint}`));for (const f of scanText(bytes.toString('latin1'), { allowlist })) {if (!seen.has(`${f.line}:${f.fingerprint}`)) scan.findings.push({ path: MESSAGE_PATH, commit, line: f.line, pattern: f.pattern, fingerprint: f.fingerprint });}+ };+ for (let batch = 0; batch < commits.length; batch += DIFF_BATCH) {+ report(() => `read ${batch} of ${commits.length} commit message(s)`);+ const slice = commits.slice(batch, batch + DIFF_BATCH);+ const fd = openSync(join(dir, 'commits'), 'w+', 0o600);+ try {+ must(run(root, ['cat-file', '--batch'], deadline, { input: slice.join('\n') + '\n', out: fd }), 'cat-file --batch');+ let position = 0;+ const readAt = (length: number) => {+ const buf = Buffer.alloc(length);+ for (let got = 0, n; got < length; got += n) {+ n = readSync(fd, buf, got, length - got, position + got);+ if (!n) throw new Unreadable(`git cat-file --batch ended early in the commits after ${slice[0]!.slice(0, 12)}`);+ }+ return buf;+ };+ for (const commit of slice) {+ const peek = Buffer.alloc(200);+ const header = peek.subarray(0, readSync(fd, peek, 0, peek.length, position));+ const nl = header.indexOf(10);+ const m = nl < 0 ? null : /^([0-9a-f]+) commit (\d+)$/.exec(header.subarray(0, nl).toString('latin1'));+ if (!m || m[1] !== commit) throw new Unreadable(`git cat-file --batch could not read commit ${commit.slice(0, 12)}: ${JSON.stringify(header.subarray(0, nl < 0 ? 80 : nl).toString('latin1'))}`);+ const size = Number(m[2]);+ position += nl + 1;+ if (size > SCAN_MAX_FILE_BYTES + 1024 * 1024) { scan.unscanned.push({ path: MESSAGE_PATH, commit }); position += size + 1; continue; }+ const object = readAt(size);+ position += size + 1;+ scanMessage(commit, object);+ }+ } finally {+ closeSync(fd);+ }}const neutral = attributesNeutral(root, deadline);const attrSource = neutral ? [`--attr-source=${must(run(root, ['hash-object', '-t', 'tree', '--stdin'], deadline), 'hash-object').toString().trim()}`] : [];const out = join(dir, 'diff');- const fd = openSync(out, 'w+', 0o600);const binaries: Array<{ commit: string; path: string; blob: string; added: boolean }> = [];- try {- must(run(root, [...attrSource, ...CONFIG, ...DIFF], deadline, { input: commits.join('\n') + '\n', out: fd }), 'diff-tree');- let commit = '', path: string | null = null, header = false, parents = 1, next = 0, bytes = 0, oversized = false;- let olds: string[] = [], blob = '', added: string[] = [], at: number[] = [];- const flush = () => {- if (path && (oversized || added.length) && !pathAllowlisted(path, allowlist)) {- if (oversized) scan.unscanned.push({ path, commit });- else scanned(path, commit, added.join('\n'), line => at[line - 1] ?? line);- }- added = []; at = []; bytes = 0; oversized = false;- };- const unexpected = (line: string) => new Unreadable(`git diff-tree printed a line the scan does not recognise in ${commit.slice(0, 12) || 'the range'}: ${JSON.stringify(line.slice(0, 80))}`);- let read = 0;- for (const { text: line, long } of fileLines(fd, SCAN_MAX_FILE_BYTES + 1)) {- if (++read % 4096 === 0 && Date.now() > deadline) throw new Unreadable('the scan ran past its time budget', true);- if (/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(line)) { flush(); commit = line; path = null; header = false; continue; }- if (line.startsWith('diff --git ') || line.startsWith('diff --cc ') || line.startsWith('diff --combined ')) {- flush();- if (!commit || long) throw unexpected(line);- if (line.startsWith('diff --git ')) {- const pair = line.slice('diff --git '.length), half = (pair.length - 1) / 2;- const left = Number.isInteger(half) && pair[half] === ' ' ? unquote(pair.slice(0, half)) : null;- const right = left === null ? null : unquote(pair.slice(half + 1));- path = left?.startsWith('a/') && right?.startsWith('b/') && left.slice(2) === right.slice(2) ? right.slice(2) : null;- } else path = unquote(line.replace(/^diff --(?:cc|combined) /, ''));- if (path === null) throw unexpected(line);- if (path === SCAN_ALLOW_FILENAME || path === '.gitattributes' || path.endsWith('/.gitattributes')) scan.gate_changes.push({ path, commit });- header = true; olds = []; blob = '';- continue;- }- const hunk = /^(@{2,}) ((?:-\d+(?:,\d+)? )+)\+(\d+)(?:,\d+)? \1(?: |$)/.exec(line);- if (hunk && path && !long) {- parents = hunk[1]!.length - 1;- if (hunk[2]!.trim().split(' ').length !== parents) throw unexpected(line);- header = false; next = Number(hunk[3]);- continue;- }- if (header && path && !long) {- const index = /^index ((?:[0-9a-f]+,)*[0-9a-f]+)\.\.([0-9a-f]+)(?: [0-7]+)?$/.exec(line);- if (index) { olds = index[1]!.split(','); blob = index[2]!; continue; }- if (/^(?:old mode|new mode|deleted file mode|new file mode|mode) [0-7,.]+$/.test(line) || line.startsWith('--- ') || line.startsWith('+++ ')) continue;- if (line === 'Binary files differ' || /^Binary files .+ differ$/.test(line)) {- if (blob && !/^0+$/.test(blob)) binaries.push({ commit, path, blob, added: olds.every(old => /^0+$/.test(old)) });- path = null;+ let patchBytes = 0;+ for (let batch = 0; batch < commits.length; batch += DIFF_BATCH) {+ report(() => `read the patches of ${batch} of ${commits.length} commit(s), ${(patchBytes / 1048576).toFixed(0)} MiB`);+ const fd = openSync(out, 'w+', 0o600);+ try {+ must(run(root, [...attrSource, ...CONFIG, ...DIFF], deadline, { input: commits.slice(batch, batch + DIFF_BATCH).join('\n') + '\n', out: fd }), 'diff-tree');+ patchBytes += fstatSync(fd).size;+ let commit = '', path: string | null = null, header = false, parents = 1, next = 0, bytes = 0, oversized = false;+ let olds: string[] = [], blob = '', added: string[] = [], at: number[] = [];+ const flush = () => {+ if (path && (oversized || added.length) && !pathAllowlisted(path, allowlist)) {+ if (oversized) scan.unscanned.push({ path, commit });+ else scanned(path, commit, added.join('\n'), line => at[line - 1] ?? line);+ }+ added = []; at = []; bytes = 0; oversized = false;+ };+ const unexpected = (line: string) => new Unreadable(`git diff-tree printed a line the scan does not recognise in ${commit.slice(0, 12) || 'the range'}: ${JSON.stringify(line.slice(0, 80))}`);+ let read = 0;+ for (const { text: line, long } of fileLines(fd, SCAN_MAX_FILE_BYTES + 1)) {+ if (++read % 4096 === 0) {+ if (Date.now() > deadline) throw new Unreadable('the scan ran past its time budget', true);+ report(() => `read the patches of ${batch} of ${commits.length} commit(s), ${(patchBytes / 1048576).toFixed(0)} MiB`);+ }+ if (/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(line)) { flush(); commit = line; path = null; header = false; continue; }+ if (line.startsWith('diff --git ') || line.startsWith('diff --cc ') || line.startsWith('diff --combined ')) {+ flush();+ if (!commit || long) throw unexpected(line);+ if (line.startsWith('diff --git ')) {+ const pair = line.slice('diff --git '.length), half = (pair.length - 1) / 2;+ const left = Number.isInteger(half) && pair[half] === ' ' ? unquote(pair.slice(0, half)) : null;+ const right = left === null ? null : unquote(pair.slice(half + 1));+ path = left?.startsWith('a/') && right?.startsWith('b/') && left.slice(2) === right.slice(2) ? right.slice(2) : null;+ } else path = unquote(line.replace(/^diff --(?:cc|combined) /, ''));+ if (path === null) throw unexpected(line);+ if (path === SCAN_ALLOW_FILENAME || path === '.gitattributes' || path.endsWith('/.gitattributes')) scan.gate_changes.push({ path, commit });+ header = true; olds = []; blob = '';continue;}- throw unexpected(line);- }- if (!path || header) throw unexpected(line);- if (line.startsWith('\\')) continue;- const prefix = line.slice(0, parents);- if (prefix.length < parents || /[^ +-]/.test(prefix)) throw unexpected(line);- if (prefix.includes('-')) continue;- if (prefix === '+'.repeat(parents)) {- bytes += Buffer.byteLength(line) - parents + 1;- if (long || bytes > SCAN_MAX_FILE_BYTES) { oversized = true; added = []; at = []; }- else { added.push(line.slice(parents)); at.push(next); }+ const hunk = /^(@{2,}) ((?:-\d+(?:,\d+)? )+)\+(\d+)(?:,\d+)? \1(?: |$)/.exec(line);+ if (hunk && path && !long) {+ parents = hunk[1]!.length - 1;+ if (hunk[2]!.trim().split(' ').length !== parents) throw unexpected(line);+ header = false; next = Number(hunk[3]);+ continue;+ }+ if (header && path && !long) {+ const index = /^index ((?:[0-9a-f]+,)*[0-9a-f]+)\.\.([0-9a-f]+)(?: [0-7]+)?$/.exec(line);+ if (index) { olds = index[1]!.split(','); blob = index[2]!; continue; }+ if (/^(?:old mode|new mode|deleted file mode|new file mode|mode) [0-7,.]+$/.test(line) || line.startsWith('--- ') || line.startsWith('+++ ')) continue;+ if (line === 'Binary files differ' || /^Binary files .+ differ$/.test(line)) {+ if (blob && !/^0+$/.test(blob)) binaries.push({ commit, path, blob, added: olds.every(old => /^0+$/.test(old)) });+ path = null;+ continue;+ }+ throw unexpected(line);+ }+ if (!path || header) throw unexpected(line);+ if (line.startsWith('\\')) continue;+ const prefix = line.slice(0, parents);+ if (prefix.length < parents || /[^ +-]/.test(prefix)) throw unexpected(line);+ if (prefix.includes('-')) continue;+ if (prefix === '+'.repeat(parents)) {+ bytes += Buffer.byteLength(line) - parents + 1;+ if (long || bytes > SCAN_MAX_FILE_BYTES) { oversized = true; added = []; at = []; }+ else { added.push(line.slice(parents)); at.push(next); }+ }+ next++;}- next++;+ flush();+ } finally {+ closeSync(fd);}- flush();- } finally {- closeSync(fd);}const sizes = new Map<string, number>();@@ -249,6 +303,7 @@ export function scanRange(root: string, base: string, head: string, timeoutMs =if ((whole.error as NodeJS.ErrnoException | undefined)?.code === 'ENOBUFS') { scan.unscanned.push({ path: b.path, commit: b.commit }); continue; }scanned(b.path, b.commit, must(whole, 'cat-file blob').toString('utf8'));}+ if (spoke) progress!(`secret scan: read ${commits.length} commit(s) in ${Math.round((Date.now() - started) / 1000)} s`);return scan;} catch (e) {if (e instanceof Unreadable) return { ...scan, unreadable: e.message, ...(e.timedOut ? { timed_out: true as const } : {}) };@@ -273,9 +328,9 @@ const STREAMED_SCAN_WRITERS: ReadonlySet<string> = new Set(['workspace_push']);* the whole history): the same scan and refusals as an automatic publish, except for what those writers' own commits* already passed (see STAGED_SCAN_WRITERS).*/-export function stagedScanPublishRefusal(root: string, base: string, target: string): OperationError | null {- const scan = scanRange(root, base, target);- if (!scan.gate_changes.length && !scan.unscanned.length) return rangeSecretRefusal(root, base, target, scan);+export function stagedScanPublishRefusal(root: string, base: string, target: string, opts: PublishScanOptions = {}): OperationError | null {+ const scan = scanRange(root, base, target, opts.timeoutMs, opts.progress);+ if (!scan.gate_changes.length && !scan.unscanned.length) return rangeSecretRefusal(root, base, target, scan, opts);const own = new Map<string, string>();try {const common = must(run(root, ['rev-parse', '--path-format=absolute', '--git-common-dir'], Date.now() + 60_000), 'rev-parse').toString().trim();@@ -283,16 +338,32 @@ export function stagedScanPublishRefusal(root: string, base: string, target: str} catch { /* an unreadable ledger exempts nothing */ }return rangeSecretRefusal(root, base, target, { ...scan,gate_changes: scan.gate_changes.filter(change => !own.has(change.commit)),- unscanned: scan.unscanned.filter(item => item.path === MESSAGE_PATH || !STREAMED_SCAN_WRITERS.has(own.get(item.commit) ?? '')) });+ unscanned: scan.unscanned.filter(item => item.path === MESSAGE_PATH || !STREAMED_SCAN_WRITERS.has(own.get(item.commit) ?? '')) }, opts);}+/**+ * How a foreground publish runs its range scan: `timeoutMs` is its budget (default 300 s), `progress` gets its progress+ * lines, and `retryArgv` is the command that publishes again, so a scan that ran out of time refuses naming that command+ * with a longer `--scan-timeout`.+ */+export interface PublishScanOptions { timeoutMs?: number; progress?: (line: string) => void; retryArgv?: string[] }+/*** The automatic-publish refusal for the commits in `base..target` of `root`, shared by every publish that scans: null* when the scan read the whole range and found nothing; `publish_scan_unreadable` when it could not read it all;* otherwise `publish_secret_found` naming each finding, unscanned file and gate change (never a value).*/-export function rangeSecretRefusal(root: string, base: string, target: string, scan: RangeScan): OperationError | null {+export function rangeSecretRefusal(root: string, base: string, target: string, scan: RangeScan, opts: PublishScanOptions = {}): OperationError | null {const range = base ? `${base}..${target.slice(0, 12)}` : `${target.slice(0, 12)} and its whole history`;+ if (scan.timed_out && opts.retryArgv) {+ const seconds = Math.round((opts.timeoutMs ?? DEFAULT_SCAN_TIMEOUT_MS) / 1000);+ const argv = [...opts.retryArgv, '--scan-timeout', String(Math.max(seconds * 4, 1200))];+ return opError('publish_scan_unreadable', `The secret scan of the local commits ${range} ran past its ${seconds} s time budget before it read them all. No secret was reported. Nothing was pushed.`,+ `A long history takes longer to scan than the budget; the scan still reads every commit before anything is pushed. Rerun with a longer budget: ${shellQuote(argv)}. Never publish with a command that skips this scan.`,+ { detail: JSON.stringify({ unreadable: scan.unreadable, timed_out: true, budget_seconds: seconds }), fix: { consent: [], actor: 'agent', requires_exclusive: false, argv,+ why: 'The same publish with a longer scan budget: it still scans every commit and pushes only when the scan finds nothing.',+ docs: 'docs/guides/shared-checkout-git.md#publish_scan_unreadable' } });+ }if (scan.unreadable !== undefined) {return opError('publish_scan_unreadable', `The secret scan could not read the local commits ${range} (${scan.unreadable}). No secret was reported. Nothing was pushed.`,`The publish pushes only commits it has read in full. Check the checkout with git fsck in ${root} (a missing or corrupt object, a full disk, or a git too slow for the 300 s budget), fix what it reports, then retry. Never publish with a command that skips this scan.`,diff --git a/src/core/workspace-push.ts b/src/core/workspace-push.tsindex 993d284323..9df846fcb2 100644--- a/src/core/workspace-push.ts+++ b/src/core/workspace-push.ts@@ -89,6 +89,7 @@ export type WorkspacePushStatus =| 'blocked_tracked_deny' // a TRACKED file matches the deny globs [G6]| 'blocked_secrets' // unallowlisted secret-scan findings [D6]| 'blocked_unscannable' // a staged blob could not be scanned — fail CLOSED+ | 'blocked_history' // the range scan of the commits it would push refused (publish_secret_found / publish_scan_unreadable)| 'refused_visibility' // remote not verifiably private [G8]| 'pull_conflict' // divergenceSafePull aborted a conflicted rebase| 'push_failed' // push rejected / origin unreachable@@ -112,6 +113,10 @@ export interface WorkspacePushResult {findings?: PushSecretFinding[];/** Staged paths the secret scan could not read (fail-closed block reason). */unscannable?: string[];+ /** blocked_history: the refusal's code, what to do (a longer `--scan-timeout` after a timeout) and its findings JSON (never a value). */+ code?: string;+ suggestion?: string;+ detail?: string;}/** Troubleshooting section for push refusals (DX-8 in docs/guides/write-refusals.md). */@@ -159,6 +164,8 @@ export interface WorkspacePushOpts {allowUnverifiedRemote?: boolean;commitMessage?: string;logger?: (line: string) => void;+ /** The range secret scan's time budget (`--scan-timeout`; default 300 s). */+ scanTimeoutMs?: number;/*** TEST SEAM: hold the lock for N ms after acquisition, before any git work.* Lets a concurrency test make "N callers, 1 winner" deterministic.@@ -883,26 +890,35 @@ export function managedPushRefusal(dir: string, root: string | null | undefined,return error;}+type PushFailure = Pick<WorkspacePushResult, 'reason' | 'code' | 'suggestion' | 'detail'> & { status: 'error' | 'push_failed' | 'blocked_history' };+/*** Step 7 of {@link workspacePush}: the push carries every local commit origin lacks, including ones a script made with- * plain `git commit` that the staged scan never saw, so the exact commit pushed is range-scanned against the remote tip- * it is leased on (#8902). A scan refusal is recorded and thrown; any other failure is returned; null when pushed.+ * plain `git commit` that the staged scan never saw, so the exact commit pushed is range-scanned against origin's tip,+ * read from origin itself (the pull may have fetched another upstream remote) and leased on (#8902). Tags never ride+ * along. Returns the failure (blocked_history for a scan refusal), or null when pushed.*/-function pushScannedHead(root: string, branch: string, log: (line: string) => void): { status: 'error' | 'push_failed'; reason: string } | null {+function pushScannedHead(root: string, branch: string, log: (line: string) => void, scanTimeoutMs?: number): PushFailure | null {const target = tryGit(root, ['rev-parse', '--verify', 'HEAD^{commit}']);if (!target) return { status: 'error', reason: 'HEAD names no commit; nothing to push' };- const base = tryGit(root, ['rev-parse', '--verify', '--quiet', `refs/remotes/origin/${branch}^{commit}`]) ?? '';+ const heads = tryGit(root, [...pushSsrfFlags(), 'ls-remote', '--heads', 'origin', `refs/heads/${branch}`], { timeoutMs: 120_000, auth: true });+ if (heads === null) return { status: 'push_failed', reason: `could not read origin's ${branch}; nothing pushed` };+ const fetched = !heads || tryGit(root, [...pushSsrfFlags(), 'fetch', ...GIT_SSRF_SUBCOMMAND_FLAGS, '--no-tags', 'origin',+ `+refs/heads/${branch}:refs/remotes/origin/${branch}`], { timeoutMs: 120_000, auth: true }) !== null;+ if (!fetched) return { status: 'push_failed', reason: `could not fetch origin's ${branch}; nothing pushed` };+ const base = heads ? tryGit(root, ['rev-parse', '--verify', '--quiet', `refs/remotes/origin/${branch}^{commit}`]) ?? '' : '';+ if (heads && !base) return { status: 'push_failed', reason: `could not read origin's ${branch} after fetching it; nothing pushed` };if (base && tryGit(root, ['merge-base', '--is-ancestor', base, target]) === null) {return { status: 'push_failed', reason: `local ${branch} does not contain origin/${branch}; nothing pushed (rerun to pull first)` };}- const refusal = stagedScanPublishRefusal(root, base, target);+ const refusal = stagedScanPublishRefusal(root, base, target, { timeoutMs: scanTimeoutMs, progress: log, retryArgv: ['gbrain', 'sources', 'push', '--path', root] });if (refusal) {log(`PUSH BLOCKED: ${refusal.code}: ${refusal.message}`);- writePushStatus({ ts: new Date().toISOString(), ok: false, code: refusal.code, reason: `${refusal.code}: ${refusal.message}`, ahead: aheadCount(root, branch), repoRoot: root });- throw refusal;+ return { status: 'blocked_history', code: refusal.code, reason: `${refusal.code}: ${refusal.message}`, suggestion: refusal.suggestion,+ ...(refusal.detail !== undefined ? { detail: String(refusal.detail) } : {}) };}try {- git(root, [...pushSsrfFlags(), 'push', ...GIT_SSRF_SUBCOMMAND_FLAGS, `--force-with-lease=refs/heads/${branch}:${base}`, 'origin', `${target}:refs/heads/${branch}`], {+ git(root, [...pushSsrfFlags(), 'push', ...GIT_SSRF_SUBCOMMAND_FLAGS, '--no-follow-tags', `--force-with-lease=refs/heads/${branch}:${base}`, 'origin', `${target}:refs/heads/${branch}`], {timeoutMs: 120_000, auth: true,});return null;@@ -955,6 +971,7 @@ export async function workspacePush(opts: WorkspacePushOpts): Promise<WorkspacePwritePushStatus({ts: new Date().toISOString(),ok: r.ok,+ ...(r.code !== undefined ? { code: r.code } : {}),...(r.reason !== undefined ? { reason: r.reason } : {}),...(r.ahead !== undefined ? { ahead: r.ahead } : {}),repoRoot: root,@@ -1187,7 +1204,7 @@ export async function workspacePush(opts: WorkspacePushOpts): Promise<WorkspaceP}// 7. push — even with no new commit (a prior failure may have left local ahead).- const failed = pushScannedHead(root, branch, log);+ const failed = pushScannedHead(root, branch, log, opts.scanTimeoutMs);if (failed) return finish({ ok: false, ...failed, repoRoot: root, branch, committed, ahead: aheadCount(root, branch) });const ahead = aheadCount(root, branch) ?? 0;diff --git a/test/bootstrap-repo.test.ts b/test/bootstrap-repo.test.tsindex 4ef15ee4cf..73796b5930 100644--- a/test/bootstrap-repo.test.ts+++ b/test/bootstrap-repo.test.ts@@ -144,7 +144,7 @@ describe('createPrivateRepo', () => {expect(calls).toContainEqual(['gh', 'api', 'repos/alice/test-agent-workspace-2', '--jq', '.private']);// …and the first push ran only AFTER the verify passed (create → verify → push).const verifyIdx = calls.findIndex((c) => c.join(' ') === `gh api repos/alice/test-agent-workspace-2 --jq .private`);- const pushIdx = calls.findIndex((c) => c.join(' ') === `git -C ${ws} push -u origin main`);+ const pushIdx = calls.findIndex((c) => c.join(' ') === `git -C ${ws} push -u origin main --no-follow-tags`);expect(pushIdx).toBeGreaterThan(verifyIdx);// GITHUB.md placeholder replaced with the real URL.@@ -174,12 +174,12 @@ describe('createPrivateRepo', () => {// The commit was created before the push (no empty-remote push).expect(calls).toContainEqual(['git', '-C', ws, 'add', '-A']);expect(calls).toContainEqual(['git', '-C', ws, 'commit', '-m', 'gbrain: bootstrap workspace']);- expect(calls).toContainEqual(['git', '-C', ws, 'push', '-u', 'origin', 'main']);+ expect(calls).toContainEqual(['git', '-C', ws, 'push', '-u', 'origin', 'main', '--no-follow-tags']);const joined = calls.map((c) => c.join(' '));const verifyIdx = joined.indexOf('gh api repos/alice/test-agent-workspace-2 --jq .private');const commitIdx = joined.indexOf(`git -C ${ws} commit -m gbrain: bootstrap workspace`);- const pushIdx = joined.indexOf(`git -C ${ws} push -u origin main`);+ const pushIdx = joined.indexOf(`git -C ${ws} push -u origin main --no-follow-tags`);expect(commitIdx).toBeGreaterThan(verifyIdx); // create → verify → commit → pushexpect(pushIdx).toBeGreaterThan(commitIdx);});@@ -339,7 +339,7 @@ describe('createPrivateRepo', () => {expect(result.reused).toBe(true);expect(calls.some((c) => c.join(' ').includes('repo create'))).toBe(false);// The deferred push was completed rather than false-succeeding on empty.- expect(calls).toContainEqual(['git', '-C', ws, 'push', '-u', 'origin', 'main']);+ expect(calls).toContainEqual(['git', '-C', ws, 'push', '-u', 'origin', 'main', '--no-follow-tags']);});test('crash recovery: receipt for this workspace without repo_url adopts the origin and records it', async () => {@@ -503,7 +503,7 @@ describe('createPrivateRepo', () => {expect(calls).toContainEqual(['git', '-C', ws, 'config', 'user.name', 'alice']);expect(calls).toContainEqual(['git', '-C', ws, 'config', 'user.email', '[email protected]']);// Workspace pushed, and repo_url recorded AFTER the push.- expect(calls).toContainEqual(['git', '-C', ws, 'push', '-u', 'origin', 'main']);+ expect(calls).toContainEqual(['git', '-C', ws, 'push', '-u', 'origin', 'main', '--no-follow-tags']);expect((readReceipt(home) as RepoReceipt).repo_url).toBe(url);});diff --git a/test/brain-durability-hook.serial.test.ts b/test/brain-durability-hook.serial.test.tsindex ed94dc4bba..c805ff5db1 100644--- a/test/brain-durability-hook.serial.test.ts+++ b/test/brain-durability-hook.serial.test.ts@@ -184,9 +184,12 @@ describe('durability push remote confirmation (#5138)', () => {const bin = join(root, 'intercept-bin');mkdirSync(bin);// #6530: the CLI runs `git -C <root> -c k=v <sub> ...`, so match on the- // subcommand after the global options instead of on "$1".+ // subcommand after the global options instead of on "$1". GST-2456: a scanned+ // push never sends a doomed non-fast-forward, so the retry is the first push+ // whose commit is a merge (pushes_merge).writeFileSync(join(bin, 'git'), `#!/usr/bin/env bashset -eu+pushes_merge() { local _spec="\${@: -1}"; "$GBRAIN_TEST_REAL_GIT" rev-parse -q --verify "\${_spec%%:*}^2" >/dev/null 2>&1; }GIT_SUB=""; _i=1while [ "$_i" -le "$#" ]; do_a="\${!_i}"@@ -308,7 +311,7 @@ fi`);test.each(['initial', 'retry'])('pushes the captured SHA when HEAD moves during the %s push', (attempt) => {if (attempt === 'retry') advanceRemote();const env = interceptGit(`if [ "$1" = push ]; then- if [ "$GBRAIN_TEST_PUSH_ATTEMPT" = initial ] || [ -e "$GBRAIN_TEST_PUSH_MARKER" ]; then+ if [ "$GBRAIN_TEST_PUSH_ATTEMPT" = initial ] || pushes_merge "$@"; then"$GBRAIN_TEST_REAL_GIT" rev-parse HEAD >"$GBRAIN_TEST_PUSH_MARKER""$GBRAIN_TEST_REAL_GIT" reset --hard HEAD^ >/dev/null"$GBRAIN_TEST_REAL_GIT" "$@"@@ -337,7 +340,7 @@ fi`);if (attempt === 'retry') advanceRemote();const remoteHead = originHead(bare);const env = interceptGit(`if [ "$1" = push ]; then- if [ "$GBRAIN_TEST_PUSH_ATTEMPT" = initial ] || [ -e "$GBRAIN_TEST_PUSH_MARKER" ]; then+ if [ "$GBRAIN_TEST_PUSH_ATTEMPT" = initial ] || pushes_merge "$@"; then"$GBRAIN_TEST_REAL_GIT" rev-parse HEAD >"$GBRAIN_TEST_PUSH_MARKER""$GBRAIN_TEST_REAL_GIT" reset --hard "$GBRAIN_TEST_REMOTE_HEAD" >/dev/nullexit 1@@ -401,7 +404,7 @@ fi`);test('confirms the merged commit when the retry push lands but reports failure', () => {const remoteHead = advanceRemote();const env = interceptGit(`if [ "$1" = push ]; then- if [ ! -e "$GBRAIN_TEST_PUSH_MARKER" ]; then+ if ! pushes_merge "$@"; then: >"$GBRAIN_TEST_PUSH_MARKER"else"$GBRAIN_TEST_REAL_GIT" "$@"diff --git a/test/git-commit-push-skipped-paths-gst2116.test.ts b/test/git-commit-push-skipped-paths-gst2116.test.tsindex b2acc97646..849ffdece6 100644--- a/test/git-commit-push-skipped-paths-gst2116.test.ts+++ b/test/git-commit-push-skipped-paths-gst2116.test.ts@@ -258,7 +258,8 @@ test('helper without gbrain: a non-ASCII flagged path, a nested-repository filegit(f.brain, 'add', '--', accented, 'people/link-example.md'); git(f.brain, 'commit', '-qm', 'more'); git(f.brain, 'push', '-q', 'origin', 'main');git(f.brain, 'update-index', '--assume-unchanged', '--', 'people/link-example.md');const clean = helper(f, false, 'write pages', 'people/link-example.md');- expect(clean.status).toBe(0);+ expect(clean.status).toBe(4);+ expect(clean.stderr).not.toContain('commit_paths_skipped');editHidden(f, accented);const accentedRun = helper(f, false, 'write pages', accented);expect(accentedRun.status).not.toBe(0);@@ -270,7 +271,7 @@ test('helper without gbrain: a non-ASCII flagged path, a nested-repository fileexpect(mixed.stderr).toContain('commit_paths_skipped');expect(mixed.stderr).toContain(nested);expect(headBlob(f, 'people/bob-example.md')).toContain('Second version.');- expect(remoteTip(f)).toBe(head(f));+ expect(remoteTip(f)).not.toBe(head(f));}, 90_000);test('write-through: commitPathsLocked fails commit_paths_skipped for a nested-repository file instead of returning the commit', () => {@@ -307,14 +308,14 @@ test('classic: a skipped path still fails commit_paths_skipped when the push faiexpect(readFileSync(join(f.home, '.gbrain', 'brain-push.log'), 'utf8')).toContain('LOCAL-ONLY, NEEDS ATTENTION: main');}, 60_000);-test('helper without gbrain: a skipped path is still named when the push fails', () => {+test('helper without gbrain: a skipped path is still named when nothing is pushed', () => {const f = fixture('helper-pushfail', 'classic');writeFileSync(join(f.brain, 'people', 'bob-example.md'), page('Bob', 'Second version.'));const nested = nestedPage(f, 'carol-example.md');git(f.brain, 'remote', 'set-url', 'origin', join(dir, 'missing.git'));const r = helper(f, false, 'write pages', 'people/bob-example.md', nested);expect(r.status).toBe(4);- expect(r.stderr).toContain('PUSH FAILED');+ expect(r.stderr).toContain('NOT PUSHED');expect(r.stderr).toContain('commit_paths_skipped');expect(r.stderr).toContain(nested);expect(headBlob(f, 'people/bob-example.md')).toContain('Second version.');diff --git a/test/git-writer-safety-7381.serial.test.ts b/test/git-writer-safety-7381.serial.test.tsindex 0e286e5e7d..72c3ee618c 100644--- a/test/git-writer-safety-7381.serial.test.ts+++ b/test/git-writer-safety-7381.serial.test.ts@@ -332,27 +332,22 @@ describe('opt-in commit guard', () => {});describe('the helper\'s no-gbrain fallback', () => {- test('marks its children with the real lock path and releases the commit lock before it pushes', async () => {+ test('marks its children with the real lock path, commits under it, releases it and pushes nothing (GST-2456)', () => {const { bare, a } = setup();mkdirSync(join(a, 'scripts'), { recursive: true });writeFileSync(join(a, 'scripts', 'brain-commit-push.sh'), renderCommitPushHelper(), { mode: 0o755 });const lockPath = git(a, 'rev-parse', '--path-format=absolute', '--git-path', 'brain-commit.lock');writeFileSync(join(a, '.git', 'hooks', 'pre-commit'), `#!/bin/sh\nprintf '%s' "$BRAIN_COMMIT_LOCK_HELD" > ${JSON.stringify(join(root, 'marker'))}\n`);chmodSync(join(a, '.git', 'hooks', 'pre-commit'), 0o755);- writeFileSync(join(bare, 'hooks', 'pre-receive'), `#!/bin/sh\n: > ${JSON.stringify(join(root, 'pushing'))}\nsleep 3\n`, { mode: 0o755 });+ const before = git(bare, 'rev-parse', 'main');writeFileSync(join(a, 'x.md'), 'via the fallback\n');- const helper = spawn('bash', [join(a, 'scripts', 'brain-commit-push.sh'), 'fallback', 'x.md'], {- cwd: a, stdio: 'ignore', env: { ...process.env, PATH: '/usr/bin:/bin', GIT_CONFIG_PARAMETERS: "'protocol.file.allow=always'" } });- const exited = new Promise<number | null>(r => helper.on('exit', code => r(code)));- let freeDuringPush = false;- for (let i = 0; i < 100 && !freeDuringPush; i++) {- await new Promise(r => setTimeout(r, 50));- try { readFileSync(join(root, 'pushing')); } catch { continue; }- freeDuringPush = spawnSync('flock', ['-n', lockPath, 'true']).status === 0;- }- expect(await exited).toBe(0);- expect(freeDuringPush).toBe(true);+ const helper = spawnSync('bash', [join(a, 'scripts', 'brain-commit-push.sh'), 'fallback', 'x.md'], {+ cwd: a, encoding: 'utf8', env: { ...process.env, PATH: '/usr/bin:/bin', GIT_CONFIG_PARAMETERS: "'protocol.file.allow=always'" } });+ expect(helper.status).toBe(4);+ expect(helper.stderr).toContain('NOT PUSHED');expect(read(root, 'marker')).toBe(lockPath);- expect(git(bare, 'show', 'main:x.md')).toBe('via the fallback');+ expect(spawnSync('flock', ['-n', lockPath, 'true']).status).toBe(0);+ expect(git(a, 'show', 'HEAD:x.md')).toBe('via the fallback');+ expect(git(bare, 'rev-parse', 'main')).toBe(before);}, 30_000);});diff --git a/test/unmanaged-push-every-site-gst2456.serial.test.ts b/test/unmanaged-push-every-site-gst2456.serial.test.tsnew file mode 100644index 0000000000..568ef633db--- /dev/null+++ b/test/unmanaged-push-every-site-gst2456.serial.test.ts@@ -0,0 +1,224 @@+/**+ * GST-2456 (#8902 part 2): every push gbrain makes from an unmanaged checkout range-scans the commits it publishes:+ * `gbrain git commit-push` in commit mode and with --pending, the post-commit hook harden installs, the durability+ * helper's `_run` (and its fallback, which now pushes nothing without gbrain), with tags never riding along. Also+ * `gbrain sources push` against an upstream that is not origin, its --json refusal, and the scan's time budget. Real git+ * against local bare remotes; synthetic credentials only. HOME, GBRAIN_HOME, PATH and the file transport switch are+ * process-wide.+ */+import { afterEach, beforeEach, describe, expect, test } from 'bun:test';+import { execFileSync, spawnSync } from 'node:child_process';+import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { runSources } from '../src/commands/sources.ts';+import { hardenBrainRepo } from '../src/core/brain-repo-durability.ts';+import type { BrainEngine } from '../src/core/engine.ts';+import { notePending } from '../src/core/git/commit-push.ts';+import { stagedScanPublishRefusal } from '../src/core/git/range-secret-scan.ts';+import { workspacePush } from '../src/core/workspace-push.ts';++const T = 90_000;+const TOKEN = 'ghp_' + 'Rk3w'.repeat(9);+const CLI = join(import.meta.dir, '..', 'src', 'cli.ts');+let dir: string, root: string, remote: string, base: string;+let saved: Record<string, string | undefined>;++const git = (cwd: string, ...args: string[]) => execFileSync('git', ['-C', cwd, '-c', 'protocol.file.allow=always', ...args],+ { encoding: 'utf8', env: process.env, stdio: ['ignore', 'pipe', 'pipe'] }).trim();+const remoteTip = () => git(remote, 'rev-parse', 'refs/heads/main');+const plainCommit = (file: string, text: string, message = 'script edit') => {+ writeFileSync(join(root, file), text);+ git(root, 'add', file); git(root, 'commit', '-qm', message);+ return git(root, 'rev-parse', 'HEAD');+};+/** A credential committed by a script and removed by its next commit: only the history holds it. */+const removedSecret = () => { plainCommit('notes.md', `deploy ${TOKEN}\n`); plainCommit('notes.md', 'removed\n'); };+const cli = (args: string[], env: Record<string, string> = {}) => spawnSync(process.execPath, ['--no-env-file', CLI, ...args],+ { cwd: root, encoding: 'utf8', timeout: 60_000, env: { ...process.env, GBRAIN_SKIP_STARTUP_HOOKS: '1', ...env } });+const pushLog = () => { const p = join(dir, '.gbrain', 'brain-push.log'); return existsSync(p) ? readFileSync(p, 'utf8') : ''; };+const envelope = (stdout: string) => JSON.parse(stdout) as { code?: string; error?: string; message?: string };+const sourcesPush = () => workspacePush({ dir: root, branch: 'main', allowUnverifiedRemote: true });+/** `gbrain sources push` in-process (it needs no brain with --path): its exit code, stdout and stderr. */+async function sourcesPushCli(args: string[]): Promise<{ code: number; stdout: string; stderr: string }> {+ const out: string[] = [], err: string[] = [];+ const restore = { exit: process.exit, log: console.log, error: console.error };+ let code = 0;+ process.exit = ((c?: number) => { throw Object.assign(new Error('exit'), { exitCode: c ?? 0 }); }) as never;+ console.log = (...a: unknown[]) => { out.push(a.map(String).join(' ')); };+ console.error = (...a: unknown[]) => { err.push(a.map(String).join(' ')); };+ try { await runSources({} as BrainEngine, ['push', ...args]); }+ catch (e) { if (typeof (e as { exitCode?: number }).exitCode !== 'number') throw e; code = (e as { exitCode: number }).exitCode; }+ finally { Object.assign(process, { exit: restore.exit }); console.log = restore.log; console.error = restore.error; }+ return { code, stdout: out.join('\n'), stderr: err.join('\n') };+}+async function until(check: () => boolean, ms = 45_000): Promise<boolean> {+ for (const end = Date.now() + ms; Date.now() < end; await new Promise(r => setTimeout(r, 200))) if (check()) return true;+ return check();+}+/** A `gbrain` on PATH that runs this checkout's CLI, so harden captures it as it captures a real install. */+function installGbrainShim(): void {+ const bin = join(dir, 'gbrain-bin');+ mkdirSync(bin, { recursive: true });+ writeFileSync(join(bin, 'gbrain'), `#!/usr/bin/env bash\nexec ${JSON.stringify(process.execPath)} --no-env-file ${JSON.stringify(CLI)} "$@"\n`, { mode: 0o755 });+ process.env.PATH = `${bin}:${process.env.PATH ?? ''}`;+}++beforeEach(() => {+ dir = realpathSync(mkdtempSync(join(tmpdir(), 'gbrain-2456-')));+ saved = { HOME: process.env.HOME, GBRAIN_HOME: process.env.GBRAIN_HOME, PATH: process.env.PATH, GBRAIN_GIT_ALLOW_FILE_TRANSPORT: process.env.GBRAIN_GIT_ALLOW_FILE_TRANSPORT };+ process.env.HOME = dir;+ process.env.GBRAIN_HOME = dir;+ process.env.GBRAIN_GIT_ALLOW_FILE_TRANSPORT = '1';+ remote = join(dir, 'origin.git'); root = join(dir, 'work');+ execFileSync('git', ['init', '-q', '--bare', '-b', 'main', remote]);+ execFileSync('git', ['-c', 'protocol.file.allow=always', 'clone', '-q', remote, root], { stdio: 'ignore', env: process.env });+ git(root, 'config', 'user.name', 'Example'); git(root, 'config', 'user.email', '[email protected]');+ git(root, 'config', 'commit.gpgsign', 'false');+ plainCommit('README.md', 'initial\n', 'initial'); git(root, 'push', '-q', '-u', 'origin', 'main');+ git(root, 'remote', 'set-head', 'origin', 'main');+ base = remoteTip();+});+afterEach(() => {+ for (const [key, value] of Object.entries(saved)) {+ if (value === undefined) delete process.env[key]; else process.env[key] = value;+ }+ rmSync(dir, { recursive: true, force: true });+});++describe('gbrain git commit-push', () => {+ test('commit mode refuses the earlier commits it would push, keeps its own commit and logs the refusal', () => {+ removedSecret();+ writeFileSync(join(root, 'page.md'), 'new page\n');+ const r = cli(['git', 'commit-push', '--json', '-m', 'page', '--', 'page.md']);+ expect(r.status).not.toBe(0);+ expect(envelope(r.stdout).code ?? envelope(r.stdout).error).toBe('publish_secret_found');+ expect(r.stdout + r.stderr).not.toContain(TOKEN);+ expect(remoteTip()).toBe(base);+ expect(git(root, 'show', 'HEAD:page.md')).toBe('new page');+ expect(pushLog()).toContain('LOCAL-ONLY, NEEDS ATTENTION: main @ - the push was refused (publish_secret_found)');+ }, T);++ test('--pending refuses the earlier commits it would push', () => {+ removedSecret();+ writeFileSync(join(root, 'pending.md'), 'written through\n');+ notePending(root, ['pending.md']);+ const r = cli(['git', 'commit-push', '--pending', '--json']);+ expect(r.status).not.toBe(0);+ expect(envelope(r.stdout).code ?? envelope(r.stdout).error).toBe('publish_secret_found');+ expect(remoteTip()).toBe(base);+ expect(git(root, 'show', 'HEAD:pending.md')).toBe('written through');+ }, T);++ test('push.followTags never publishes an annotated tag, whose message nothing scans', () => {+ git(root, 'config', 'push.followTags', 'true');+ plainCommit('notes.md', 'clean\n');+ git(root, 'tag', '-a', 'v1', '-m', `release ${TOKEN}`);+ const r = cli(['git', 'commit-push', '--push-only', '--json']);+ expect(r.status).toBe(0);+ expect(remoteTip()).toBe(git(root, 'rev-parse', 'HEAD'));+ expect(git(remote, 'tag', '-l')).toBe('');+ }, T);++ test('--scan-timeout gives the scan a longer budget and is checked', () => {+ plainCommit('notes.md', 'clean\n');+ expect(cli(['git', 'commit-push', '--push-only', '--scan-timeout', '1200', '--json']).status).toBe(0);+ expect(remoteTip()).toBe(git(root, 'rev-parse', 'HEAD'));+ for (const args of [['--push-only', '--scan-timeout', 'soon'], ['--push-only', '--scan-timeout', '0'], ['--pull', '--scan-timeout', '60']]) {+ const r = cli(['git', 'commit-push', ...args, '--json']);+ expect(r.status).not.toBe(0);+ expect(envelope(r.stdout).code ?? envelope(r.stdout).error).toBe('commit_paths_invalid');+ }+ }, T);+});++describe('the post-commit hook and the durability helper', () => {+ let published: string;+ beforeEach(async () => {+ installGbrainShim();+ await hardenBrainRepo({ repoPath: root, sourceId: 'wiki', pat: 'ghp_x', installCron: false });+ published = remoteTip();+ });++ test('the hook refuses a plain git commit that carries a credential, and logs it', async () => {+ plainCommit('notes.md', `deploy ${TOKEN}\n`);+ expect(await until(() => pushLog().includes('the push was refused (publish_secret_found)'))).toBe(true);+ expect(remoteTip()).toBe(published);+ }, T);++ test('the helper refuses the earlier commits it would push', () => {+ rmSync(join(root, '.git', 'hooks', 'post-commit'));+ removedSecret();+ writeFileSync(join(root, 'page.md'), 'new page\n');+ const r = spawnSync('bash', [join(root, 'scripts', 'brain-commit-push.sh'), 'page', 'page.md'], { cwd: root, encoding: 'utf8', env: process.env, timeout: 60_000 });+ expect(r.status).not.toBe(0);+ expect(r.stderr).toContain('publish_secret_found');+ expect(r.stderr).not.toContain(TOKEN);+ expect(remoteTip()).toBe(published);+ }, T);++ test('the helper without gbrain commits locally and pushes nothing, since only gbrain scans before it pushes', () => {+ rmSync(join(root, '.git', 'hooks', 'post-commit'));+ spawnSync('git', ['-C', root, 'config', '--local', '--unset', 'gbrain.cliPath']);+ writeFileSync(join(root, 'page.md'), 'clean page\n');+ const r = spawnSync('bash', [join(root, 'scripts', 'brain-commit-push.sh'), 'page', 'page.md'],+ { cwd: root, encoding: 'utf8', timeout: 60_000, env: { ...process.env, PATH: '/usr/bin:/bin', GIT_CONFIG_PARAMETERS: "'protocol.file.allow=always'" } });+ expect(r.status).toBe(4);+ expect(r.stderr).toContain('NOT PUSHED');+ expect(git(root, 'show', 'HEAD:page.md')).toBe('clean page');+ expect(remoteTip()).toBe(published);+ expect(pushLog()).toContain('not pushed: gbrain is not installed');+ }, T);+});++describe('gbrain sources push', () => {+ test('--json prints the refusal on stdout and exits 5', async () => {+ removedSecret();+ const r = await sourcesPushCli(['--path', root, '--allow-unverified-remote', '--json']);+ expect(r.code).toBe(5);+ expect(JSON.parse(r.stdout)).toMatchObject({ ok: false, status: 'blocked_history', code: 'publish_secret_found' });+ expect(r.stdout + r.stderr).not.toContain(TOKEN);+ expect(remoteTip()).toBe(base);+ }, T);++ test('scans and leases against origin itself when the branch tracks another remote', async () => {+ const upstream = join(dir, 'upstream.git');+ execFileSync('git', ['clone', '-q', '--bare', remote, upstream]);+ git(root, 'remote', 'add', 'upstream', upstream);+ git(root, 'fetch', '-q', 'upstream');+ git(root, 'branch', '-q', '-u', 'upstream/main');+ git(root, 'update-ref', '-d', 'refs/remotes/origin/main');+ plainCommit('notes.md', 'clean earlier work\n');+ const result = await sourcesPush();+ expect(result.status).toBe('pushed');+ expect(remoteTip()).toBe(git(root, 'rev-parse', 'HEAD'));+ }, T);++ test('push.followTags never publishes an annotated tag', async () => {+ git(root, 'config', 'push.followTags', 'true');+ plainCommit('notes.md', 'clean\n');+ git(root, 'tag', '-a', 'v1', '-m', `release ${TOKEN}`);+ expect((await sourcesPush()).status).toBe('pushed');+ expect(git(remote, 'tag', '-l')).toBe('');+ }, T);+});++describe('the scan budget', () => {+ test('a scan that runs out of time refuses naming the same command with a longer --scan-timeout', () => {+ const retry = ['gbrain', 'sources', 'push', '--path', root];+ const refusal = stagedScanPublishRefusal(root, '', git(root, 'rev-parse', 'HEAD'), { timeoutMs: 1, retryArgv: retry });+ expect(refusal?.code).toBe('publish_scan_unreadable');+ expect(refusal?.message).toContain('time budget');+ expect(refusal?.suggestion).toContain('--scan-timeout 1200');+ expect(refusal?.fix).toMatchObject({ actor: 'agent', argv: [...retry, '--scan-timeout', '1200'] });+ expect(JSON.parse(String(refusal?.detail))).toMatchObject({ timed_out: true });+ }, T);++ test('a whole-history scan says what it reads on its progress channel', () => {+ plainCommit('notes.md', 'clean\n');+ const lines: string[] = [];+ expect(stagedScanPublishRefusal(root, '', git(root, 'rev-parse', 'HEAD'), { progress: line => lines.push(line) })).toBeNull();+ expect(lines[0]).toStartWith('secret scan: reading 2 commit(s), the whole history');+ expect(lines.at(-1)).toMatch(/^secret scan: read 2 commit\(s\) in \d+ s$/);+ }, T);+});diff --git a/test/unmanaged-push-history-scan-8902.serial.test.ts b/test/unmanaged-push-history-scan-8902.serial.test.tsindex 7fe7fee47d..51009351cb 100644--- a/test/unmanaged-push-history-scan-8902.serial.test.ts+++ b/test/unmanaged-push-history-scan-8902.serial.test.ts@@ -1,7 +1,8 @@/*** #8902: four pushes from an unmanaged checkout publish every local commit the remote lacks, so each scans that range,* not only what it just wrote: the access-policy commit, the durability-scaffolding commit, `gbrain sources push` and the- * first push of `gbrain bootstrap repo`. Real git against local bare remotes (bootstrap's remote must be a GitHub URL,+ * first push of `gbrain bootstrap repo`. The policy commit and sources push keep the commit and report the refusal+ * (committed_not_pushed, blocked_history; GST-2456); the other two throw it. Real git against local bare remotes (bootstrap's remote must be a GitHub URL,* so its gh calls and its push are faked and recorded); synthetic credentials only. HOME, GBRAIN_HOME and the file* transport switch are process-wide.*/@@ -15,7 +16,7 @@ import { hardenBrainRepo } from '../src/core/brain-repo-durability.ts';import { createPrivateRepo, type ExecRunner, type RepoReceipt } from '../src/core/bootstrap/repo.ts';import { writeManifest, writeReceipt } from '../src/core/bootstrap/format.ts';import { defaultRunner } from '../src/core/repo-visibility.ts';-import { workspacePush } from '../src/core/workspace-push.ts';+import { workspacePush, type WorkspacePushResult } from '../src/core/workspace-push.ts';import { SCAN_ALLOW_FILENAME } from '../src/core/secret-scan.ts';import { OperationError } from '../src/core/ops/contract.ts';@@ -42,6 +43,22 @@ const expectRedactedRefusal = (error: OperationError | null, code = 'publish_sec};const policy = () => commitPolicyFile(root, POLICY_FILE, () => 'version: 1\nrules: []\n', 'update folder policy');const sourcesPush = () => workspacePush({ dir: root, branch: 'main', allowUnverifiedRemote: true });+/** A policy commit the range scan refused: committed here, reported committed_not_pushed with the refusal (never a value) in its note. */+const keptLocal = async (p: ReturnType<typeof policy>, code = 'publish_secret_found') => {+ const receipt = await p;+ expect(receipt.outcome).toBe('committed_not_pushed');+ expect(receipt.commit).toBe(git(root, 'rev-parse', 'HEAD'));+ expect(receipt.note).toContain(code);+ expect(JSON.stringify(receipt)).not.toContain(TOKEN);+ return receipt;+};+/** A sources push the range scan refused: a blocked_history result naming the refusal, never a value. */+const blocked = async (p: Promise<WorkspacePushResult>, code = 'publish_secret_found') => {+ const result = await p;+ expect(result).toMatchObject({ ok: false, status: 'blocked_history', code });+ expect(JSON.stringify(result)).not.toContain(TOKEN);+ return result;+};beforeEach(() => {dir = realpathSync(mkdtempSync(join(tmpdir(), 'gbrain-8902-')));@@ -67,10 +84,9 @@ afterEach(() => {describe('access-policy commit', () => {test('refuses a credential an earlier commit added and a later one removed; keeps the policy commit local', async () => {const secret = removedSecret();- const error = await refusal(policy());- expectRedactedRefusal(error);- expect(error?.message).toContain(`notes.md:1`);- expect(error?.message).toContain(secret.slice(0, 7));+ const receipt = await keptLocal(policy());+ expect(receipt.note).toContain(`notes.md:1`);+ expect(receipt.note).toContain(secret.slice(0, 7));expect(remoteTip()).toBe(base);expect(git(root, 'show', `HEAD:${POLICY_FILE}`)).toBe('version: 1\nrules: []');expect(git(root, 'status', '--porcelain')).toBe('');@@ -78,9 +94,7 @@ describe('access-policy commit', () => {test('refuses a credential in an earlier commit message', async () => {plainCommit('notes.md', 'safe\n', `rotate ${TOKEN}`);- const error = await refusal(policy());- expectRedactedRefusal(error);- expect(error?.message).toContain('(commit message)');+ expect((await keptLocal(policy())).note).toContain('(commit message)');expect(remoteTip()).toBe(base);}, T);@@ -96,7 +110,7 @@ describe('access-policy commit', () => {git(root, 'remote', 'set-url', 'origin', other);git(root, 'update-ref', '-d', 'refs/remotes/origin/main');git(root, 'commit', '-q', '--amend', '-m', `policy ${TOKEN}`);- expectRedactedRefusal(await refusal(commitPolicyFile(root, POLICY_FILE, () => 'version: 1\nrules: [] # again\n', 'policy again')));+ await keptLocal(commitPolicyFile(root, POLICY_FILE, () => 'version: 1\nrules: [] # again\n', 'policy again'));expect(() => git(other, 'rev-parse', '--verify', 'refs/heads/main')).toThrow();}, T);@@ -141,7 +155,7 @@ describe('durability scaffolding commit', () => {describe('gbrain sources push', () => {test('with nothing new to commit, refuses the earlier commits it would push and keeps them local', async () => {const head = (removedSecret(), git(root, 'rev-parse', 'HEAD'));- expectRedactedRefusal(await refusal(sourcesPush()));+ await blocked(sourcesPush());expect(remoteTip()).toBe(base);expect(git(root, 'rev-parse', 'HEAD')).toBe(head);}, T);@@ -149,32 +163,27 @@ describe('gbrain sources push', () => {test('refuses when it also commits new clean work, and keeps that commit', async () => {removedSecret();writeFileSync(join(root, 'page.md'), 'new page\n');- expectRedactedRefusal(await refusal(sourcesPush()));+ await blocked(sourcesPush());expect(remoteTip()).toBe(base);expect(git(root, 'show', 'HEAD:page.md')).toBe('new page');}, T);test('refuses a credential in an earlier commit message', async () => {plainCommit('notes.md', 'safe\n', `rotate ${TOKEN}`);- const error = await refusal(sourcesPush());- expectRedactedRefusal(error);- expect(error?.message).toContain('(commit message)');+ expect((await blocked(sourcesPush())).reason).toContain('(commit message)');expect(remoteTip()).toBe(base);}, T);test('an allowlist edit it commits itself still publishes; one a script committed refuses', async () => {plainCommit('notes.md', `key ${TOKEN}\n`);- const first = await refusal(sourcesPush());- expectRedactedRefusal(first);- const fingerprint = (JSON.parse(String(first!.detail)) as { findings: Array<{ fingerprint: string }> }).findings[0]!.fingerprint;+ const first = await blocked(sourcesPush());+ const fingerprint = (JSON.parse(String(first.detail)) as { findings: Array<{ fingerprint: string }> }).findings[0]!.fingerprint;writeFileSync(join(root, SCAN_ALLOW_FILENAME), `${fingerprint}\n`);expect((await sourcesPush()).status).toBe('pushed');expect(remoteTip()).toBe(git(root, 'rev-parse', 'HEAD'));const published = remoteTip();plainCommit(SCAN_ALLOW_FILENAME, `${fingerprint}\n**/*.env\n`);- const gate = await refusal(sourcesPush());- expectRedactedRefusal(gate);- expect(gate?.message).toContain(SCAN_ALLOW_FILENAME);+ expect((await blocked(sourcesPush())).reason).toContain(SCAN_ALLOW_FILENAME);expect(remoteTip()).toBe(published);}, T);@@ -182,7 +191,7 @@ describe('gbrain sources push', () => {removedSecret();git(root, 'push', '-q');git(remote, 'update-ref', 'refs/heads/main', base);- expectRedactedRefusal(await refusal(sourcesPush()));+ await blocked(sourcesPush());expect(remoteTip()).toBe(base);}, T);@@ -247,7 +256,7 @@ describe('gbrain bootstrap repo, first push after the remote branch is gone', ()test('a clean history still completes the first push', async () => {plainCommit('notes.md', 'clean earlier work\n');expect((await bootstrap()).reused).toBe(true);- expect(pushes).toEqual([['git', '-C', root, 'push', '-u', 'origin', 'main']]);+ expect(pushes).toEqual([['git', '-C', root, 'push', '-u', 'origin', 'main', '--no-follow-tags']]);expect(readFileSync(join(root, 'GITHUB.md'), 'utf8')).toContain(url);}, T);});