Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(git): commit-push fails loudly when git leaves a named path uncommitted (GST-2116)
garrytan7cd409243b6f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8cadb056cf..b4ef4b72ce 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,29 @@ credits are retained; no result has been reassigned to another provider. Originaidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [Unreleased]++**`gbrain git commit-push` and `scripts/brain-commit-push.sh` no longer report success when git left a named path uncommitted.** `git add` stages nothing and still exits 0 for a modified file flagged assume-unchanged or skip-worktree and for a file inside a nested Git repository, so the helper answered "nothing to commit" (or pushed the other paths) with exit 0, and the write sat uncommitted with nothing in any log. Now the other named paths are still committed (and, on a classic checkout, pushed), and the run exits 1 naming each skipped path and its reason: `writer_coordinator_required` for a page in a managed canonical worktree, which belongs to the persistence owner (save it through `put_page`), and the new `commit_paths_skipped` for anything else. The helper's own managed-checkout refusal now prints the operator contract (code, why, fix, next) instead of one line.++| Situation | Before | After |+| --- | --- | --- |+| A named file is flagged assume-unchanged (or skip-worktree under a named directory) and modified | `nothing to commit`, exit 0; the edit stays uncommitted | `commit_paths_skipped` (reason `assume_unchanged` / `skip_worktree`), exit 1; fix (ask the user): `git update-index --no-assume-unchanged -- <paths>`, and a separate `git update-index --no-skip-worktree -- <paths>` (given both flags, git clears only the first) |+| A named file sits inside an untracked nested repository | exit 0 with nothing committed; beside other paths, `git_unavailable` and nothing committed | the other paths are committed, then `commit_paths_skipped` (reason `not_staged`), exit 1 |+| The same on a managed canonical worktree, for a page | `nothing to commit; not pushed`, exit 0 | `writer_coordinator_required`, exit 1, naming each page; fix (ask the user): save it through `put_page` |+| `scripts/brain-commit-push.sh` without gbrain on the machine | `nothing to commit`, push, exit 0 | the push still runs, then `Error [commit_paths_skipped]` with each path, exit 1 |+| `scripts/brain-commit-push.sh` on a checkout marked managed | one line, `writer_coordinator_required: submit managed changes through persistence`, exit 1 | `Error [writer_coordinator_required]` with `Why:`, `Fix:` (put_page; `gbrain git commit-push` for files that are not pages) and `Next: ask_user`, exit 1 |++A skip-worktree file absent from disk (a sparse checkout) and ignored files under a named directory are not reported; a named ignored file was already refused by `git add` (`commit_paths_invalid`). Existing brains get the new helper on the next `gbrain sources harden`.++### Itemized changes++- `src/core/git/commit-push.ts`: after the commit step, `commitPaths` reads which named paths HEAD still lacks (flagged entries whose bytes on disk differ from HEAD, named files git did not index, and status entries with unstaged changes) and leaves an unindexed file out of `commit --only`, so it no longer fails the other paths. `commitAndPush` (classic, managed and remoteless) throws `commit_paths_skipped` or, for a page in a managed worktree, `writer_coordinator_required`, after committing and publishing the rest; `detail` carries the skipped paths, the commit and the pushed head.+- `src/core/brain-repo-durability.ts`: the rendered `scripts/brain-commit-push.sh` prints the operator contract on its managed refusal, and its fallback (no gbrain) runs the same check after its commit (NUL-separated listings, so a non-ASCII or quoted name is read exactly; a symlink is compared by its link text), leaves a file git did not index out of `commit --only`, and exits 1 with `commit_paths_skipped` after the push.+- `src/commands/git.ts`: when the run fails after the other paths were pushed, the push log still records that push.+- `src/core/error-registry.ts`: new code `commit_paths_skipped` (reasons `assume_unchanged`, `skip_worktree`, `not_staged`).+- Docs: `docs/guides/shared-checkout-git.md` (the `commit_paths_skipped` row, the `writer_coordinator_required` row, the fallback paragraph), `docs/guides/error-codes.md` (regenerated).+- Tests: `test/git-commit-push-skipped-paths-gst2116.test.ts` (the real CLI and the rendered helper against temp repositories, a bare remote and a managed-root registry: an assume-unchanged page, a nested-repository page beside a committable one, a skip-worktree entry under a named directory, a managed page and a managed non-page file, a remoteless checkout, a named directory inside a nested repository, a run with both flags, the helper's fallback (a non-ASCII path, a nested-repository file beside a committable page, a clean flagged symlink), the helper handing over to gbrain on a managed root, its managed refusal; a named directory beside a sparse entry and an ignored draft still commits with exit 0). Twelve of its thirteen cases fail on master; the one that passes there is the control.+## [0.60.620.0] - 2026-11-09**A diverged managed checkout now publishes its local commits on refresh by default when Git durability is on, after a secret scan of those commits.** Commits a script made with plain `git commit` in a managed checkout used to strand there whenever the remote moved: every `gbrain sources refresh` refused `refresh_diverged` and asked the user, unless `sources.refresh_publish_diverged` was set to `true`. With the setting unset, a worktree whose Git durability is on (`gbrain sources writer git-durability <source> --enable`, or the legacy hook) now publishes them itself: the local commits merged with the upstream in memory, never a rebase or force-push, then the fast-forward. The publish child scans, under its publish lock and for the exact commits it pushes, what they add: commit messages, added lines (including a value a later commit removed) and merge-commit conflict resolutions. A value that looks like a secret, added text too large to scan, or a commit that changes `.gbrain-scan-allow` or a `.gitattributes` refuses the new `publish_secret_found` naming the file, line, rule and commit, never the value, with nothing pushed; commits the scan cannot read in full refuse `publish_scan_unreadable` instead. The rewritten-upstream refusal and the `--expect-remote` bound are unchanged. `false` turns it off; `true` still publishes with durability off.diff --git a/docs/guides/error-codes.md b/docs/guides/error-codes.mdindex 917a8556ba..d220e3cf7a 100644--- a/docs/guides/error-codes.md+++ b/docs/guides/error-codes.md@@ -840,6 +840,18 @@ More: [docs/guides/shared-checkout-git.md#source-roots](../../docs/guides/sharedMore: [docs/guides/shared-checkout-git.md#outcomes](../../docs/guides/shared-checkout-git.md#outcomes)+### commit_paths_skipped++<a id="commit_paths_skipped"></a>++| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |+|---|---|---|---|---|---|---|+| gbrain git commit-push (or the brain's committed commit-push helper) committed the other named paths but git left the listed ones out: a modified file flagged assume-unchanged or skip-worktree, or a file inside a nested Git repository. | git add stages nothing for those and still exits 0, so reporting success would leave the write uncommitted with nothing in any log. | Read each skipped path and its reason in the message. Clear an assume-unchanged or skip-worktree flag after the user agrees, one flag per call (git update-index --no-assume-unchanged -- <path>, git update-index --no-skip-worktree -- <path>), or move a file out of a nested repository, then rerun the same commit-push. | agent | `repeat the read that failed` | 1 | no |++Reasons: `assume_unchanged`, `skip_worktree`, `not_staged`.++More: [docs/guides/shared-checkout-git.md#outcomes](../../docs/guides/shared-checkout-git.md#outcomes)+### commit_prestaged_paths<a id="commit_prestaged_paths"></a>diff --git a/docs/guides/shared-checkout-git.md b/docs/guides/shared-checkout-git.mdindex 36e8520cb5..d56f8b9fc7 100644--- a/docs/guides/shared-checkout-git.md+++ b/docs/guides/shared-checkout-git.md@@ -120,7 +120,9 @@ with 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 lockedpath-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.+the fallback never integrates remote commits itself. A named path git left out+of the commit fails it with `commit_paths_skipped` (exit 1), the same as+`gbrain git commit-push`.In a managed canonical worktree (`gbrain sources writer git-durability`) itspersistence owner is the only Git publisher. Save pages with `put_page`,@@ -179,6 +181,7 @@ Follow the error's `fix.next` as the| `commit_lock_busy` | 1 | Another writer held the lock for the whole wait; nothing was committed. Retry once. If it is still busy, tell the user which checkout and lock path the message names and stop. || <a id="checkout_not_a_source"></a>`checkout_not_a_source` | 1 | The checkout commit-push resolved from the working directory (no `--path`) is not one of the brain's source checkouts on this host, typically a wrapper that changed into another repository; nothing was staged. The message lists the brain's checkouts. Tell the user to make the script pass `--path` with the absolute brain checkout. A repository that only encloses a source checkout (a brain cloned inside another repository) is not one; a source registered at a subdirectory its checkout tracks is. A host whose brain records no source checkout, or a checkout with `gbrain.sourceRoot` set, is never refused this way. || `commit_paths_invalid` | 1 | No paths, a path outside the checkout, the checkout root itself, or a path git would not stage. Name the explicit files you wrote and rerun. |+| <a id="commit_paths_skipped"></a>`commit_paths_skipped` | 1 | Git left a named path out of the commit although `git add` exited 0: a modified file flagged assume-unchanged or skip-worktree (`reason` `assume_unchanged`, `skip_worktree`) or a file inside a nested Git repository (`not_staged`). The other named paths were committed (and, on a classic checkout, pushed); `detail` lists each skipped path, the commit and the pushed head. Check the flags with `git ls-files -v -- <path>`; clear them only after the user agrees, one flag per call (`git update-index --no-assume-unchanged -- <path>`, `git update-index --no-skip-worktree -- <path>`; given both, git clears only the first), and remember skip-worktree is often set on purpose to keep local edits out of commits, or move the file out of the nested repository, then rerun. A skip-worktree file absent from disk (a sparse checkout) and ignored files under a named directory are not reported. || `commit_prestaged_paths` | 1 | Another writer staged files under a directory you named; nothing was staged or committed. Name your own files explicitly. Unstage the others (`git restore --staged -- <file>`, which keeps their bytes) only after the user agrees. || `commit_outside_source_root` | 1 | The commit, or a local commit about to be published, changes files outside the brain's [source root](#source-roots); nothing was pushed. Show the user `git show --stat <sha>`; rerun with `--allow-outside-source-root` only if they want it published. || `git_index_locked` | 1 | A git command that does not take the writer lock held `index.lock`. Retry once after a few seconds. |@@ -189,7 +192,7 @@ Follow the error's `fix.next` as the| <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. Never publish with a command that skips the scan. || `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. |+| `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`: it replaces the stored page with the file's content. || `git_unavailable` | 1 | A git command failed, often a missing `user.name`/`user.email` or a refusing pre-commit hook. Read the message, fix that, rerun. When the branch names a remote that does not exist (a typo or a broken clone), the run stops before committing: fix the name or add the remote, then rerun. A checkout with no remote at all commits locally instead (`committed_local`). |`--pull` reports `up_to_date`, `advanced`, `ahead` (local commits not yetdiff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsvindex 91c4fa72d0..6c6680eabc 100644--- a/scripts/module-size-limits.tsv+++ b/scripts/module-size-limits.tsv@@ -47,4 +47,4 @@ 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 1526 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)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 1687 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+src/core/behavior-change-notice.ts 1688 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-2116 commit_push_skipped_paths_gst2116 row (since TBD until the merge slot; rows are data and cannot move)diff --git a/src/commands/git.ts b/src/commands/git.tsindex fc6cfc8daf..6a221b1472 100644--- a/src/commands/git.ts+++ b/src/commands/git.ts@@ -273,6 +273,13 @@ export async function runGit(args: string[]): Promise<number> {return 0;} catch (e) {const code = (e as { code?: string }).code;+ if (code === 'commit_paths_skipped' || code === 'writer_coordinator_required') {+ // GST-2116: the other named paths may have been pushed before the run failed; the push log records that push.+ try {+ const d = JSON.parse(String((e as { detail?: string }).detail ?? '{}')) as { pushed?: string; branch?: string };+ if (d.pushed && d.branch) appendPushLog('ok', d.branch, d.pushed);+ } catch { /* best-effort */ }+ }if (code === 'push_unconfirmed' || code === 'integrate_conflict' || code === 'commit_outside_source_root') {try {const bi = args.indexOf('--branch');diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex 2e82668a4c..01342054c5 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -1489,6 +1489,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;{ since: '0.60.618.0', id: 'refresh_replan_own_commits_8828', text: 'A `gbrain sources refresh` whose checkout HEAD moved while it waited for writes admitted before its fence no longer refuses `refresh_source_changed` when every commit since its start is one of gbrain\'s own (in the commit ledger) and the upstream branch holds them: it takes HEAD as its start and fast-forwards to the upstream. A HEAD move that includes a commit gbrain did not make, or gbrain\'s commits the upstream does not hold yet, still refuses as before.' },{ since: '0.60.619.0', id: 'managed_commit_push_unpublished_gst1923', text: 'On a managed checkout, `gbrain git commit-push -m <msg> -- <paths>` now reports how many commits the upstream lacks as last fetched (`unpublished` in `--json`, `null` when there is no upstream) and says nothing was pushed, instead of answering `nothing to commit; <remote>/<branch> at -` and logging `[push] ok-already-on-remote` for a commit that already existed. It writes no push-log line on a managed checkout. It still never pushes there; `gbrain git commit-push --push-only --keep-checkout --path <checkout>` publishes.' },{ since: '0.60.620.0', id: 'refresh_publish_diverged_default_gbra386', text: 'A diverged managed checkout now publishes its local commits on `gbrain sources refresh` by default when the worktree\'s Git durability is on: `sources.refresh_publish_diverged` unset now means on there (it used to mean off), merged with the upstream in memory, never rebased or forced. The refresh publish first scans what the local commits add (messages, added lines, merge resolutions) and refuses the new `publish_secret_found` naming the file, line and rule, never the value, when one looks like a secret; `gbrain git commit-push --push-only --scan-secrets` runs the same gate. Unset with durability not on still refuses, naming `gbrain sources writer git-durability <source> --enable`; `false` turns it off.' },+ { since: 'TBD', id: 'commit_push_skipped_paths_gst2116', text: '`gbrain git commit-push` and `scripts/brain-commit-push.sh` now exit 1 when git left a named path out of the commit, instead of exiting 0: a modified file flagged assume-unchanged or skip-worktree, or a file inside a nested Git repository. The other named paths are still committed (and pushed on a classic checkout); the error names each skipped path and its reason: `writer_coordinator_required` for a page in a managed canonical worktree (save it through put_page), `commit_paths_skipped` otherwise. The helper\'s managed-checkout refusal now prints the operator contract (code, why, fix, next). Existing brains get the new helper on the next `gbrain sources harden`.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */diff --git a/src/core/brain-repo-durability.ts b/src/core/brain-repo-durability.tsindex 1336df77fa..c6cdc0d589 100644--- a/src/core/brain-repo-durability.ts+++ b/src/core/brain-repo-durability.ts@@ -239,7 +239,14 @@ unset $(git rev-parse --local-env-vars) 2>/dev/null || true_managed_git="$(git rev-parse --git-dir 2>/dev/null || echo .git)"if [ -e "$_managed_git/gbrain-managed.json" ] || [ -e .gbrain-managed ]; then- echo "writer_coordinator_required: submit managed changes through persistence" >&2; exit 1+ {+ echo "Error [writer_coordinator_required]: this checkout is a managed canonical worktree; its persistence owner is the only Git writer of pages, so this helper committed nothing."+ echo "Why: a page file committed around the owner, or left uncommitted, is out of step with the database."+ echo "Fix: save pages through gbrain (put_page, edit_page, remember or capture; gbrain put <slug> with the page on stdin). Commit files that are not pages with gbrain git commit-push -m '<msg>' -- <paths>."+ echo "Next: ask_user"+ echo "Docs: docs/guides/shared-checkout-git.md#outcomes"+ } >&2+ exit 1fi_gbrain_cli() {@@ -271,6 +278,52 @@ fi# ── Fallback: no gbrain that knows \`git commit-push\` on this machine ──────────_branch="$(git symbolic-ref --quiet --short HEAD)" || { echo "detached HEAD: check out a branch first" >&2; exit 1; }+# Named paths whose bytes HEAD lacks after the commit: git add stages nothing, exit 0, for an edit flagged+# assume-unchanged or skip-worktree and for a file inside a nested repository (NUL-separated, so no path is quoted).+_unindexed() {+ local p+ for p in "$@"; do+ if [ -e "$p" ] && [ ! -d "$p" ] && ! git ls-files --error-unmatch -- "$p" >/dev/null 2>&1; then printf '%s\\n' "$p"; fi+ done+ return 0+}+_unstaged() {+ local e p d disk+ while IFS= read -r -d '' e; do+ case "$e" in+ [a-zS]\\ *) p="\${e#??}"+ if [ -L "$p" ]; then disk="$(printf '%s' "$(readlink -- "$p")" | git hash-object --stdin)"+ elif [ -e "$p" ]; then disk="$(git hash-object -- "$p")"+ else case "$e" in [sS]*) continue ;; esac; disk=""; fi+ [ "$disk" = "$(git rev-parse -q --verify "HEAD:./$p" || true)" ] || printf '%s\\n' "$p" ;;+ esac+ done < <(git ls-files -v -z -- "$@")+ while IFS= read -r -d '' e; do+ case "$e" in ?\\ *) ;; *) printf '%s\\n' "\${e#???}" ;; esac+ done < <(git status --porcelain -z --untracked-files=all --no-renames -- "$@")+ _unindexed "$@"+ for p in "$@"; do+ [ -d "$p" ] || continue+ d="$(dirname -- "$p")"+ while [ "$d" != "." ] && [ "$d" != "/" ]; do+ if [ -e "$d/.git" ]; then printf '%s\\n' "$p"; break; fi+ d="$(dirname -- "$d")"+ done+ done+ return 0+}+_skipped=""+_finish() {+ [ -z "$_skipped" ] && exit 0+ {+ echo "Error [commit_paths_skipped]: git did not commit these named path(s); the other named paths were committed and pushed:"+ printf '%s\\n' "$_skipped" | sed 's/^/ /'+ echo "Why: git add stages nothing and still exits 0 for a modified file flagged assume-unchanged or skip-worktree, or a file inside a nested Git repository."+ echo "Fix: read the flags with git ls-files -v -- <path> and ask the user (a skip-worktree flag is often set on purpose to keep local edits out of commits); to commit the edits clear them (git update-index --no-assume-unchanged -- <path>, and separately git update-index --no-skip-worktree -- <path>), or move the file out of the nested repository, then rerun."+ echo "Next: ask_user"+ } >&2+ exit 1+}echo "[brain-commit-push] gbrain git commit-push unavailable; using the minimal locked commit + push" >&2_log="\${GBRAIN_HOME:-$HOME}/.gbrain/brain-push.log"mkdir -p "$(dirname "$_log")" 2>/dev/null || true@@ -296,7 +349,11 @@ case "\${1:-}" in_msg="\${1:?usage: brain-commit-push.sh <message> <path> [paths...]}"; shift[ "$#" -gt 0 ] || { echo "refusing a repo-wide commit: pass explicit path(s)" >&2; exit 2; }git add -A -- "$@"- if git diff --cached --quiet -- "$@"; then echo "nothing to commit"; else git commit --only -m "$_msg" -- "$@"; fi ;;+ _commit=()+ _orphans="$(_unindexed "$@")"+ for _p in "$@"; do printf '%s\\n' "$_orphans" | grep -xF -- "$_p" >/dev/null || _commit+=("$_p"); done+ if [ "\${#_commit[@]}" -eq 0 ] || git diff --cached --quiet -- "\${_commit[@]}"; then echo "nothing to commit"; else git commit --only -m "$_msg" -- "\${_commit[@]}"; fi+ _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.@@ -307,7 +364,7 @@ if command -v flock >/dev/null 2>&1; thenflock -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; exit 4; }fiif 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"; exit 0+ echo "$(date -u +%FT%TZ) [push] ok $_branch $(git rev-parse --short "$_head")" >>"$_log"; _finishfiecho "$(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." >&2diff --git a/src/core/error-registry.ts b/src/core/error-registry.tsindex af6d21fed8..b2439a1bc3 100644--- a/src/core/error-registry.ts+++ b/src/core/error-registry.ts@@ -165,6 +165,7 @@ export const CODES = {commit_lock_busy: { class: 'retryable', summary: "Another writer held the checkout's commit lock for the whole wait, so nothing was committed.", docs: 'docs/guides/shared-checkout-git.md#outcomes' },commit_base_moved: { class: 'caller', summary: "A file named with --base changed at HEAD since the writer read it, so nothing was staged or committed.", why: "--base <path>=<blob> binds a commit to the bytes the writer read; another writer committed that file since, and committing now would overwrite its change.", docs: 'docs/guides/shared-checkout-git.md#base-check', suggestion: 'Read the file at HEAD again, redo the change on it, and rerun with the new --base the message names.' },commit_paths_invalid: { class: 'caller', summary: "The commit was refused before staging: no paths, a path outside the checkout, the whole checkout, or a path git would not stage.", docs: 'docs/guides/shared-checkout-git.md#outcomes' },+ commit_paths_skipped: { class: 'caller', reasons: ['assume_unchanged', 'skip_worktree', 'not_staged'], summary: "gbrain git commit-push (or the brain's committed commit-push helper) committed the other named paths but git left the listed ones out: a modified file flagged assume-unchanged or skip-worktree, or a file inside a nested Git repository.", why: 'git add stages nothing for those and still exits 0, so reporting success would leave the write uncommitted with nothing in any log.', docs: 'docs/guides/shared-checkout-git.md#outcomes', suggestion: 'Read each skipped path and its reason in the message. Clear an assume-unchanged or skip-worktree flag after the user agrees, one flag per call (git update-index --no-assume-unchanged -- <path>, git update-index --no-skip-worktree -- <path>), or move a file out of a nested repository, then rerun the same commit-push.' },commit_prestaged_paths: { class: 'consent', summary: "The commit was refused before staging: files another writer had already staged sit under a named directory, and committing them would publish that writer's work.", docs: 'docs/guides/shared-checkout-git.md#outcomes', actor: 'user' },commit_outside_source_root: { class: 'consent', summary: "The commit or publish was refused: it changes files outside the brain's configured source root (git config gbrain.sourceRoot), often a commit made without gbrain git commit-push.", docs: 'docs/guides/shared-checkout-git.md#source-roots', actor: 'user' },concurrent_write: { class: 'caller', summary: "A managed sync import raced a database-only write to the same page, so the file is held and the page keeps the database version; neither was overwritten.", why: "The page's live revision was written by a committed non-sync request after the import was frozen, so the Git file and the database genuinely diverge; choosing either silently would lose the other.", docs: 'docs/guides/write-refusals.md#concurrent_write', suggestion: 'Preview the reconciliation with gbrain sources reconcile <source> <slug> --preview, resolve it with the user, then run gbrain sources retry-held <source> and gbrain sync --source <source> --no-pull.' },diff --git a/src/core/git/commit-push.ts b/src/core/git/commit-push.tsindex 66ccfa80df..7b53df34f1 100644--- a/src/core/git/commit-push.ts+++ b/src/core/git/commit-push.ts@@ -25,7 +25,7 @@* (#7010; the owner's Git effects publish this way). CLI-only; never exposed* over MCP (it pushes with host credentials).*/-import { appendFileSync, existsSync, mkdtempSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';+import { appendFileSync, existsSync, lstatSync, mkdtempSync, readFileSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { scanRange } from './range-secret-scan.ts';import { isAbsolute, join, relative, resolve } from 'node:path';@@ -36,7 +36,8 @@ import { assertManagedFilesystemWrite, hasFilesystemPublication, managedFilesystimport { acquireNativeLock, acquireNativeLockSync, type NativeLockSyncHandle } from '../persistence/native-lock.ts';import { recordCommit, recordIntent } from './commit-ledger.ts';import { OperationError, opError } from '../ops/contract.ts';-import { shellQuote } from '../agent-output.ts';+import { shellQuote, type Action } from '../agent-output.ts';+import { isSyncable } from '../sync.ts';export const COMMIT_LOCK_NAME = 'brain-commit.lock';/** Taken by pre-#6530 helpers and hooks; held too so they still exclude us during the mixed-version window. */@@ -432,6 +433,109 @@ function restoreIndex(root: string, rel: string[], before: string[]): void {interface CommitScope { roots: string[]; lockPath: string; markHeld: boolean; bases?: ReadonlyMap<string, string> }+/** A named path `git add -A` left out of the index while still exiting 0 (GST-2116). */+export interface SkippedPath { path: string; reason: 'assume_unchanged' | 'skip_worktree' | 'not_staged' }++/**+ * GST-2116: the named paths whose bytes on disk HEAD still lacks once the commit step is done. `git add -A` stages+ * nothing and exits 0 for a modified entry flagged assume-unchanged or skip-worktree (`ls-files -v`: lower case, or S;+ * `commit --only` may still pick one up beside another path, so the check reads HEAD) and for a file inside an untracked+ * nested repository. A skip-worktree entry absent from disk is a sparse checkout, not a change. Ignored files under a+ * named directory are left out as git leaves them; a named ignored file is refused by `git add` itself.+ */+function unstagedPaths(root: string, rel: string[], listed: string[]): SkippedPath[] {+ const skipped = new Map<string, SkippedPath['reason']>();+ for (const line of listed.filter(entry => /^[a-zS] /.test(entry))) {+ const path = line.slice(2);+ const abs = join(root, path);+ const reason = /^[sS]/.test(line) ? 'skip_worktree' as const : 'assume_unchanged' as const;+ const stat = (() => { try { return lstatSync(abs); } catch { return null; } })();+ if (!stat && reason === 'skip_worktree') continue;+ const disk = !stat ? null : stat.isSymbolicLink()+ ? gitOk(root, ['hash-object', '--stdin'], 'hash-object', { input: readlinkSync(abs) })+ : gitOk(root, ['hash-object', '--', path], 'hash-object');+ const committed = git(root, ['rev-parse', '--verify', '--quiet', `HEAD:${path}`]).stdout.trim() || null;+ if (disk !== committed) skipped.set(path, reason);+ }+ for (const path of unindexedFiles(root, rel, listed)) if (!skipped.has(path)) skipped.set(path, 'not_staged');+ // Only a named directory can hide an unstaged change from the two checks above (a nested repository inside it).+ const dirs = rel.filter(path => { try { return lstatSync(join(root, path)).isDirectory(); } catch { return false; } });+ // Status lists nothing under a directory that sits inside an untracked nested repository.+ for (const path of dirs) {+ const parents = path.split('/').slice(0, -1).map((_, i, parts) => parts.slice(0, i + 1).join('/'));+ if (!skipped.has(path) && parents.some(parent => existsSync(join(root, parent, '.git')))) skipped.set(path, 'not_staged');+ }+ const status = dirs.length ? gitOk(root, ['--no-optional-locks', 'status', '--porcelain=v1', '-z', '--untracked-files=all', '--no-renames', '--', ...literalPathspecs(dirs)], 'status') : '';+ for (const entry of status.split('\0').filter(Boolean)) {+ const path = entry.slice(3);+ if ((entry[1] !== ' ' || entry.startsWith('??')) && !skipped.has(path)) skipped.set(path, 'not_staged');+ }+ return [...skipped].map(([path, reason]) => ({ path, reason })).sort((a, b) => a.path.localeCompare(b.path));+}+++/** Named paths that are files on disk yet absent from the index (`listed`: `ls-files -v` after `git add -A`), as a file inside a nested repository is. */+function unindexedFiles(root: string, rel: string[], listed: string[]): string[] {+ const indexed = new Set(listed.map(line => line.slice(2)));+ return rel.filter(path => {+ if (indexed.has(path)) return false;+ try { return !lstatSync(join(root, path)).isDirectory(); } catch { return false; }+ });+}++/**+ * GST-2116: a run that left a named path uncommitted fails, after committing (and, on a classic checkout, pushing) the+ * rest, so a write is never reported as saved when it is not. In a managed canonical worktree a skipped page is the+ * owner's to save (`writer_coordinator_required`); anything else is `commit_paths_skipped`.+ */+function skippedPathsError(root: string, skipped: SkippedPath[], result: CommitPushResult, managed?: ManagedFilesystemRoot): OperationError {+ const list = `${skipped.slice(0, 20).map(s => `${s.path} (${s.reason})`).join(', ')}${skipped.length > 20 ? ', ...' : ''}`;+ const pushed = result.committed && !result.managed && !result.no_remote && result.outcome !== 'push_deferred';+ const rest = result.committed+ ? `The other named paths were committed as ${result.committed.slice(0, 7)}${pushed ? ` and pushed to ${result.remote}/${result.branch}` : ', not pushed'}.`+ : 'Nothing was committed.';+ const detail = JSON.stringify({ skipped, committed: result.committed, ...(pushed ? { pushed: result.sha } : {}), branch: result.branch });+ const docs = 'docs/guides/shared-checkout-git.md#outcomes';+ const flagged = skipped.filter(s => s.reason !== 'not_staged');+ // One update-index call per flag: given both, git clears only the first.+ const clears = (['assume_unchanged', 'skip_worktree'] as const)+ .map(reason => ({ flag: reason === 'skip_worktree' ? '--no-skip-worktree' : '--no-assume-unchanged', paths: flagged.filter(s => s.reason === reason).map(s => s.path) }))+ .filter(c => c.paths.length)+ .map(c => ['git', '-C', root, 'update-index', c.flag, '--', ...c.paths]);+ const clearCommand = clears.map(argv => shellQuote(argv)).join(' && ');+ const flagNote = 'an assume-unchanged or skip-worktree flag; an editor, an indexer or a sparse checkout can leave one, and people also set skip-worktree on purpose to keep local edits out of commits, so clearing it commits those edits';+ const chain = (steps: string[][], last?: Action): Action | undefined => steps.reduceRight<Action | undefined>((then, argv) =>+ ({ argv, consent: [], actor: 'agent', requires_exclusive: false, why: 'Clears the flag so git sees the edit on disk; the file keeps its bytes.', ...(then ? { then } : {}) }), last);+ const pages = managed ? skipped.filter(s => isSyncable(s.path)) : [];+ if (managed && pages.length) {+ const put: Action = { argv: ['gbrain', 'put', '<slug>'], mcp: { tool: 'put_page', arguments: { slug: '<slug>', content: '<the page file>' } },+ inputs: [{ name: 'slug', how: `Each listed page path without its .md extension; pass the file's content on stdin: ${pages.slice(0, 5).map(s => s.path).join(', ')}` }],+ consent: [], actor: 'agent', requires_exclusive: false,+ why: 'put_page saves the page through the owner, which writes the file, commits only that path and pushes it.',+ verify: { argv: ['gbrain', 'sources', 'writer', 'status', managed.sourceId ?? '<source>', '--json'] } };+ return opError('writer_coordinator_required',+ `${root} is the managed canonical worktree${managed.sourceId ? ` of source ${managed.sourceId}` : ''}, and git did not commit ${skipped.length} named path(s): ${list}. ${rest}`,+ `${clears.length ? `First, with the user's agreement, clear the flags (${clearCommand}), since the owner's own Git step cannot see a flagged edit either. ` : ''}Then save those pages through gbrain (put_page, edit_page or capture; on the CLI, gbrain put with the page slug and the page on stdin): the persistence owner commits and pushes them. Never commit page files around it.`,+ { docs, detail,+ why: 'The persistence owner is the only Git writer of pages in a managed worktree; a page file written there directly and left uncommitted is neither in Git nor in the database, so reporting success would lose the write silently.',+ fix: { ...(chain(clears, put) ?? put), ask_user: true,+ user_message: `These page files were written straight into the managed checkout and git did not commit them: ${pages.slice(0, 10).map(s => s.path).join(', ')}.${clears.length ? ` Git hides their edits (${flagNote}); clear the flags first.` : ''} Save each one through gbrain (put_page), which replaces the stored page with the file's content?` } });+ }+ return opError('commit_paths_skipped', `git did not commit ${skipped.length} named path(s) in ${root}: ${list}. ${rest}`,+ flagged.length+ ? `Git hides edits to the assume_unchanged and skip_worktree paths from commits. With the user's agreement clear the flags (${clearCommand}), then rerun the same commit-push.`+ : 'Git did not stage the not_staged paths (a file inside a nested Git repository is the usual cause). Move them into the brain checkout proper, or commit them in their own repository, then rerun.',+ { docs, detail,+ why: 'git add stages nothing and still exits 0 for a modified file flagged assume-unchanged or skip-worktree, or a file inside a nested repository; reporting success would leave the write uncommitted with nothing in any log.',+ fix: flagged.length+ ? { ...chain(clears)!, ask_user: true,+ user_message: `Git is set to ignore edits to ${flagged.slice(0, 10).map(s => s.path).join(', ')} (${flagNote}), so they were not committed. Clear those flags and commit the edits?`,+ verify: { argv: ['git', '-C', root, 'ls-files', '-v', '--', ...flagged.map(s => s.path)] } }+ : { consent: [], actor: 'user', requires_exclusive: false,+ why: 'Git cannot commit a file that belongs to another repository, so only moving it or committing it there settles it.',+ user_message: `Git did not commit ${skipped.slice(0, 10).map(s => s.path).join(', ')} in ${root} (a file inside a nested Git repository is the usual cause). Where should they be committed?` } });+}+/** `--base` keyed by the repository-relative path it names; each must also be a committed path. */function scopeBases(root: string, opts: CommitPushOptions, rel: string[]): Map<string, string> | undefined {if (!opts.bases?.size) return undefined;@@ -448,9 +552,10 @@ function scopeBases(root: string, opts: CommitPushOptions, rel: string[]): Map<s* Stage and commit exactly `rel` (the caller holds the commit lock). Refused* before anything is staged: a path outside the source root(s), and a file* another writer already staged under a named directory (name it to claim- * it). A commit git refuses leaves the index as it found it.+ * it). A commit git refuses leaves the index as it found it. `skipped` lists+ * the named paths git left out (GST-2116); the rest are still committed.*/-function commitPaths(root: string, rel: string[], message: string, scope: CommitScope): string | null {+function commitPaths(root: string, rel: string[], message: string, scope: CommitScope): { sha: string | null; skipped: SkippedPath[] } {const outside = rel.filter(p => !insideSourceRoots(p, scope.roots));if (outside.length) throw outsideRootError(root, scope.roots, outside, 'Refusing to commit');for (const [path, base] of scope.bases ?? []) {@@ -479,19 +584,23 @@ function commitPaths(root: string, rel: string[], message: string, scope: Commitconst paths = withRenamePartners(root, rel);const partners = paths.filter(p => !insideSourceRoots(p, scope.roots));if (partners.length) throw outsideRootError(root, scope.roots, partners, 'A staged rename would commit');- if (git(root, ['diff', '--cached', '--quiet', '--', ...literalPathspecs(paths)]).code === 0) return null;+ // A file git did not index would fail `commit --only` for every path; it is left out here and reported as skipped.+ const listed = gitOk(root, ['ls-files', '-v', '-z', '--', ...literalPathspecs(paths)], 'ls-files -v').split('\0').filter(Boolean);+ const unindexed = new Set(unindexedFiles(root, paths, listed));+ const staged = paths.filter(p => !unindexed.has(p));+ if (!staged.length || git(root, ['diff', '--cached', '--quiet', '--', ...literalPathspecs(staged)]).code === 0) return { sha: null, skipped: unstagedPaths(root, paths, listed) };const env = { [COMMIT_VIA_ENV]: scope.lockPath, ...(scope.markHeld ? { [COMMIT_LOCK_ENV]: scope.lockPath } : {}) };// #7759: literal per path, never git's global --literal-pathspecs: Git exports that to the commit's hooks, where a// guard's glob pathspec ('*.json') then matches nothing and lets the commit through.recordIntent(root, { writer: 'commit_push', head_before: git(root, ['rev-parse', '--verify', '--quiet', 'HEAD']).stdout.trim() || null, message });- const commit = withIndexRetry(root, ['commit', '--only', '-m', message, '--', ...literalPathspecs(paths)], 'git commit', env);+ const commit = withIndexRetry(root, ['commit', '--only', '-m', message, '--', ...literalPathspecs(staged)], 'git commit', env);if (commit.code !== 0) {throw opError('git_unavailable', `git commit failed in ${root}; the paths were unstaged again and keep their bytes.`,`${commit.stderr.trim().slice(0, 300)} A missing git identity (user.name, user.email) or a refusing pre-commit hook are common causes.`);}const sha = gitOk(root, ['rev-parse', 'HEAD'], 'rev-parse HEAD');recordCommit(root, { sha, writer: 'commit_push' });- return sha;+ return { sha, skipped: unstagedPaths(root, paths, listed) };} catch (e) {try { restoreIndex(root, rel, before); } catch { /* the index lock outlasted the retries; the error below still stands */ }throw e;@@ -607,10 +716,10 @@ export function commitPathsLocked(repo: string, rel: string[], message: string,const scope = { roots, lockPath: lock.lockPath, markHeld: false };let sha: string | null;try {- sha = commitPaths(root, [...paths, ...pending], pending.length ? `${message} (+${pending.length} pending write-through file(s))` : message, scope);+ sha = commitPaths(root, [...paths, ...pending], pending.length ? `${message} (+${pending.length} pending write-through file(s))` : message, scope).sha;} catch (e) {if (!pending.length) throw e;- sha = commitPaths(root, paths, message, scope);+ sha = commitPaths(root, paths, message, scope).sha;}settlePending(root);return sha;@@ -1131,10 +1240,12 @@ function commitManagedPaths(root: string, opts: CommitPushOptions, managed: Manathrow opError('commit_paths_invalid', `${where}: commit-push there only commits the paths you name.`,`Run gbrain git commit-push with only -m and the page paths after --; gbrain sources refresh${managed.sourceId ? ` ${managed.sourceId}` : ''} brings remote commits in.`);}- const result = commitPathsOnly(root, opts, where, configuredSourceRoots(root), 'Leave the checkout to its owner; gbrain sources writer status names its state.');+ const { result: committed, skipped } = commitPathsOnly(root, opts, where, configuredSourceRoots(root), 'Leave the checkout to its owner; gbrain sources writer status names its state.');const counted = git(root, ['rev-list', '--count', '@{upstream}..HEAD']);- const upstream = git(root, ['for-each-ref', '--format=%(upstream:short)', `refs/heads/${result.branch}`]).stdout.trim();- return { ...result, managed: true, unpublished: counted.code === 0 ? Number(counted.stdout.trim()) : null, upstream: upstream || null };+ const upstream = git(root, ['for-each-ref', '--format=%(upstream:short)', `refs/heads/${committed.branch}`]).stdout.trim();+ const result: CommitPushResult = { ...committed, managed: true, unpublished: counted.code === 0 ? Number(counted.stdout.trim()) : null, upstream: upstream || null };+ if (skipped.length) throw skippedPathsError(root, skipped, result, managed);+ return result;}/** A checkout with no Git remote at all: no remote is configured and the branch names none (a named but missing remote is refused by resolveCtx). A git command that fails is not proof of "no remote". */@@ -1153,11 +1264,14 @@ function commitRemotelessPaths(root: string, opts: CommitPushOptions): CommitPusthrow opError('commit_paths_invalid', `${where}; commit-push there only commits the paths you name.`,'Run gbrain git commit-push -m <msg> -- <paths> to commit them locally, or add a remote (git remote add origin <url>) and set the branch upstream to publish.');}- return { ...commitPathsOnly(root, opts, where, opts.allowOutsideSourceRoot ? [''] : configuredSourceRoots(root), 'Check out a branch (git switch <branch>), then rerun.'), no_remote: true };+ const { result: committed, skipped } = commitPathsOnly(root, opts, where, opts.allowOutsideSourceRoot ? [''] : configuredSourceRoots(root), 'Check out a branch (git switch <branch>), then rerun.');+ const result: CommitPushResult = { ...committed, no_remote: true };+ if (skipped.length) throw skippedPathsError(root, skipped, result);+ return result;}/** Commit only the named paths under the commit lock and nothing more: no fetch, merge, push or checkout move. */-function commitPathsOnly(root: string, opts: CommitPushOptions, where: string, roots: string[], detachedFix: string): CommitPushResult {+function commitPathsOnly(root: string, opts: CommitPushOptions, where: string, roots: string[], detachedFix: string): { result: CommitPushResult; skipped: SkippedPath[] } {if (!opts.message?.trim()) throw opError('commit_paths_invalid', 'A commit message is required.', 'Pass the commit message with -m.');const rel = scopePaths(root, opts.paths ?? [], opts.cwd ?? process.cwd());if (!rel.length) throw opError('commit_paths_invalid', `${where}: name the paths to commit.`, 'Pass -- <paths> after the message.');@@ -1165,15 +1279,16 @@ function commitPathsOnly(root: string, opts: CommitPushOptions, where: string, rif (!branch) throw opError('git_detached_head', `${root} is on a detached HEAD, so there is no branch to commit to.`, detachedFix);assertNoOperationInProgress(root);const lock = acquireCommitLock(root, opts.lockWaitMs);- let committed: string | null;+ let commit: ReturnType<typeof commitPaths>;try {assertNoOperationInProgress(root);- committed = commitPaths(root, rel, opts.message.trim(), { roots, lockPath: lock.lockPath, markHeld: true, bases: scopeBases(root, opts, rel) });+ commit = commitPaths(root, rel, opts.message.trim(), { roots, lockPath: lock.lockPath, markHeld: true, bases: scopeBases(root, opts, rel) });} finally {lock.release();}+ const committed = commit.sha;const remote = git(root, ['config', '--get', `branch.${branch}.remote`]).stdout.trim();- return { outcome: committed ? 'committed_local' : 'nothing_to_commit', sha: committed, committed, branch, remote, paths: rel, integrated: 0, checkout: 'unchanged' };+ return { result: { outcome: committed ? 'committed_local' : 'nothing_to_commit', sha: committed, committed, branch, remote, paths: rel, integrated: 0, checkout: 'unchanged' }, skipped: commit.skipped };}export function commitAndPush(opts: CommitPushOptions): CommitPushResult {@@ -1197,11 +1312,12 @@ export function commitAndPush(opts: CommitPushOptions): CommitPushResult {assertNoOperationInProgress(root);let committed: string | null = null;+ let skipped: SkippedPath[] = [];if (!opts.pushOnly) {const lock = acquireCommitLock(root, opts.lockWaitMs);try {assertNoOperationInProgress(root);- committed = rel.length ? commitPaths(root, rel, opts.message!.trim(), { roots: opts.allowOutsideSourceRoot ? [''] : roots, lockPath: lock.lockPath, markHeld: true, bases: scopeBases(root, opts, rel) }) : null;+ if (rel.length) ({ sha: committed, skipped } = commitPaths(root, rel, opts.message!.trim(), { roots: opts.allowOutsideSourceRoot ? [''] : roots, lockPath: lock.lockPath, markHeld: true, bases: scopeBases(root, opts, rel) }));settlePending(root);} finally {lock.release();@@ -1219,7 +1335,9 @@ export function commitAndPush(opts: CommitPushOptions): CommitPushResult {}if (!pub) {if (unattended) {- return { outcome: 'push_deferred', sha: null, committed, branch: ctx.branch, remote: ctx.remote, paths: rel, integrated: 0, checkout: 'unchanged' };+ const deferred: CommitPushResult = { outcome: 'push_deferred', sha: null, committed, branch: ctx.branch, remote: ctx.remote, paths: rel, integrated: 0, checkout: 'unchanged' };+ if (skipped.length) throw skippedPathsError(root, skipped, deferred);+ return deferred;}throw opError('push_unconfirmed', `${committed ? 'The commit is durable locally, but another' : 'Another'} publish held this checkout's push lock for ${Math.round(waitMs / 1000)}s.`,`The running publish was asked to push HEAD too once it finishes. Rerun gbrain git commit-push --push-only to confirm; never git pull --rebase in this checkout.`,@@ -1259,13 +1377,15 @@ export function commitAndPush(opts: CommitPushOptions): CommitPushResult {}const { published, moved } = first;- return {+ const result: CommitPushResult = {outcome: moved.checkout === 'lagging' ? 'pushed_checkout_lagging' : committed || opts.pushOnly ? 'pushed' : 'nothing_to_commit',sha: published.sha, committed, branch: ctx.branch, remote: ctx.remote, paths: rel,integrated: published.integrated, confirmed: published.confirmed, checkout: moved.checkout, ...(moved.reason ? { lagging_reason: moved.reason } : {}),...(published.quarantined ? { quarantined: published.quarantined } : {}),...(published.superseded ? { superseded_remote_paths: published.superseded } : {}),};+ if (skipped.length) throw skippedPathsError(root, skipped, result);+ return result;}/**diff --git a/test/git-commit-push-skipped-paths-gst2116.test.ts b/test/git-commit-push-skipped-paths-gst2116.test.tsnew file mode 100644index 0000000000..956ef4d8d0--- /dev/null+++ b/test/git-commit-push-skipped-paths-gst2116.test.ts@@ -0,0 +1,274 @@+/**+ * GST-2116: `gbrain git commit-push` and the committed `scripts/brain-commit-push.sh` exited 0 while a path the caller+ * named was never committed. `git add -A` stages nothing and still exits 0 for a modified entry flagged assume-unchanged+ * or skip-worktree, and for a file inside an untracked nested repository, so the helper answered "nothing to commit" (or+ * pushed the other paths) and the write sat uncommitted with nothing in any log. Every named path git leaves out now+ * fails the run, after the other paths are committed: `writer_coordinator_required` for a page in a managed canonical+ * worktree (save it through put_page), `commit_paths_skipped` for anything else, each skipped path listed.+ * Seams: none; the real CLI and the rendered helper against temp repositories, a bare remote and a managed-root registry+ * under a temp GBRAIN_HOME. commit-push is DB-free, so there is no engine axis.+ */+import { afterAll, expect, test } from 'bun:test';+import { execFileSync, spawnSync } from 'node:child_process';+import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { renderCommitPushHelper } from '../src/core/brain-repo-durability.ts';+import { recordManagedRoots } from '../src/core/persistence/root-registry.ts';+import { runCli } from './helpers/cli-spawn.ts';+import { withEnv } from './helpers/with-env.ts';++const dir = realpathSync(mkdtempSync(join(tmpdir(), 'gbrain-skipped-paths-')));+afterAll(() => rmSync(dir, { recursive: true, force: true }));+const identity = { GIT_AUTHOR_NAME: 'Example', GIT_AUTHOR_EMAIL: '[email protected]', GIT_COMMITTER_NAME: 'Example', GIT_COMMITTER_EMAIL: '[email protected]' };+const git = (root: string, ...args: string[]) => execFileSync('git', ['-C', root, '-c', 'user.name=Example', '-c', '[email protected]',+ '-c', 'commit.gpgsign=false', ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();+const page = (title: string, body: string) => `---\ntitle: ${title}\n---\n${body}\n`;++interface Fixture { home: string; remote: string; brain: string }+type Kind = 'classic' | 'managed' | 'remoteless';++/** A brain checkout with two committed pages and a note; classic and managed ones track a bare remote. */+function fixture(name: string, kind: Kind): Fixture {+ const remote = join(dir, `${name}.git`), brain = join(dir, `${name}-brain`), home = join(dir, `${name}-home`);+ mkdirSync(home);+ if (kind === 'remoteless') {+ execFileSync('git', ['init', '-q', '-b', 'main', brain]);+ } else {+ execFileSync('git', ['init', '-q', '--bare', '-b', 'main', remote]);+ execFileSync('git', ['clone', '-q', remote, brain], { stdio: 'ignore' });+ git(brain, 'checkout', '-q', '-b', 'main');+ }+ mkdirSync(join(brain, 'people'));+ writeFileSync(join(brain, 'people', 'alice-example.md'), page('Alice', 'First version.'));+ writeFileSync(join(brain, 'people', 'bob-example.md'), page('Bob', 'First version.'));+ writeFileSync(join(brain, 'notes.txt'), 'First note.\n');+ git(brain, 'add', '.'); git(brain, 'commit', '-qm', 'init');+ if (kind !== 'remoteless') git(brain, 'push', '-q', '-u', 'origin', 'main');+ if (kind === 'managed') withEnv({ GBRAIN_HOME: home }, () => { recordManagedRoots('00000000-0000-4000-8000-000000002116', [{ local_path: brain, source_id: 'source-a' }]); });+ return { home, remote, brain };+}++const head = (f: Fixture) => git(f.brain, 'rev-parse', 'HEAD');+const remoteTip = (f: Fixture) => git(f.remote, 'rev-parse', 'refs/heads/main');+const headBlob = (f: Fixture, path: string) => git(f.brain, 'show', `HEAD:${path}`);+const commitPush = (f: Fixture, ...paths: string[]) =>+ runCli(['git', 'commit-push', '--json', '--path', f.brain, '-m', 'write pages', '--', ...paths], { cwd: dir, home: f.home, env: identity });+/** Edit a committed file and flag it assume-unchanged, the way an indexer or editor plugin can leave it. */+const editHidden = (f: Fixture, path: string, flag: '--assume-unchanged' | '--skip-worktree' = '--assume-unchanged') => {+ writeFileSync(join(f.brain, path), page('Hidden', 'An edit git add does not see.'));+ git(f.brain, 'update-index', flag, '--', path);+};+/** A page written into an untracked nested clone inside the checkout: git add stages nothing for it and exits 0. */+const nestedPage = (f: Fixture, name: string) => {+ mkdirSync(join(f.brain, 'imports'), { recursive: true });+ execFileSync('git', ['init', '-q', join(f.brain, 'imports')]);+ writeFileSync(join(f.brain, 'imports', name), page('Carol', 'Written into a nested clone.'));+ return `imports/${name}`;+};+const envelope = (stdout: string) => JSON.parse(stdout) as { code: string; message: string; detail?: string; fix?: { next: string; argv?: string[] } };++test('classic: a modified assume-unchanged page fails commit_paths_skipped instead of nothing to commit, and nothing is pushed', async () => {+ const f = fixture('classic-assume', 'classic');+ const before = head(f);+ editHidden(f, 'people/alice-example.md');+ const r = await commitPush(f, 'people/alice-example.md');+ expect(r.exitCode).not.toBe(0);+ const e = envelope(r.stdout);+ expect(e.code).toBe('commit_paths_skipped');+ expect(e.message).toContain('people/alice-example.md');+ expect(e.fix?.next).toBe('ask_user');+ expect(e.fix?.argv).toEqual(['git', '-C', f.brain, 'update-index', '--no-assume-unchanged', '--', 'people/alice-example.md']);+ expect(head(f)).toBe(before);+ expect(remoteTip(f)).toBe(before);+}, 60_000);++test('classic: with one committable and one skipped path, the first is committed and pushed and the run still fails naming only the second', async () => {+ const f = fixture('classic-mixed', 'classic');+ writeFileSync(join(f.brain, 'people', 'bob-example.md'), page('Bob', 'Second version.'));+ const nested = nestedPage(f, 'carol-example.md');+ const r = await commitPush(f, nested, 'people/bob-example.md');+ expect(r.exitCode).not.toBe(0);+ const e = envelope(r.stdout);+ expect(e.code).toBe('commit_paths_skipped');+ expect(e.message).toContain(nested);+ expect(e.message).not.toContain('people/bob-example.md');+ expect(e.fix?.next).toBe('report');+ expect(headBlob(f, 'people/bob-example.md')).toContain('Second version.');+ expect(remoteTip(f)).toBe(head(f));+ const detail = JSON.parse(e.detail!) as { skipped: { path: string; reason: string }[]; committed: string; pushed: string };+ expect(detail.skipped).toEqual([{ path: nested, reason: 'not_staged' }]);+ expect(detail.committed).toBe(head(f));+ expect(detail.pushed).toBe(head(f));+ expect(readFileSync(join(f.home, '.gbrain', 'brain-push.log'), 'utf8')).toContain(`[push] ok main ${head(f).slice(0, 7)}`);+}, 60_000);++test('classic: a skip-worktree entry under a named directory and a page inside a nested repository both fail the run', async () => {+ const f = fixture('classic-dir', 'classic');+ const before = head(f);+ editHidden(f, 'people/bob-example.md', '--skip-worktree');+ nestedPage(f, 'carol-example.md');+ const r = await commitPush(f, 'people/', 'imports/carol-example.md');+ expect(r.exitCode).not.toBe(0);+ const e = envelope(r.stdout);+ expect(e.code).toBe('commit_paths_skipped');+ const detail = JSON.parse(e.detail!) as { skipped: { path: string; reason: string }[] };+ expect(detail.skipped).toEqual([{ path: 'imports/carol-example.md', reason: 'not_staged' }, { path: 'people/bob-example.md', reason: 'skip_worktree' }]);+ expect(head(f)).toBe(before);+}, 60_000);++test('classic: a named directory still commits with exit 0 beside a sparse skip-worktree entry and a file git ignores', async () => {+ const f = fixture('classic-ok', 'classic');+ git(f.brain, 'update-index', '--skip-worktree', '--', 'people/bob-example.md');+ rmSync(join(f.brain, 'people', 'bob-example.md'));+ writeFileSync(join(f.brain, '.git', 'info', 'exclude'), 'people/*.draft.md\n');+ writeFileSync(join(f.brain, 'people', 'carol-example.draft.md'), page('Carol', 'A draft git ignores.'));+ writeFileSync(join(f.brain, 'people', 'alice-example.md'), page('Alice', 'Second version.'));+ const r = await commitPush(f, 'people/');+ expect(r.exitCode).toBe(0);+ expect(JSON.parse(r.stdout)).toMatchObject({ outcome: 'pushed' });+ expect(headBlob(f, 'people/alice-example.md')).toContain('Second version.');+ expect(headBlob(f, 'people/bob-example.md')).toContain('First version.');+ expect(remoteTip(f)).toBe(head(f));+}, 60_000);++test('managed: a page git skips fails writer_coordinator_required and points at put_page; nothing is committed', async () => {+ const f = fixture('managed-page', 'managed');+ const before = head(f);+ editHidden(f, 'people/alice-example.md');+ const r = await commitPush(f, 'people/alice-example.md');+ expect(r.exitCode).not.toBe(0);+ const e = envelope(r.stdout);+ expect(e.code).toBe('writer_coordinator_required');+ expect(e.message).toContain('people/alice-example.md');+ expect(r.stdout).toContain('put_page');+ expect(e.fix?.next).toBeDefined();+ expect(head(f)).toBe(before);+}, 60_000);++test('managed: a committable page is committed locally and a skipped file that is not a page fails commit_paths_skipped', async () => {+ const f = fixture('managed-mixed', 'managed');+ const before = head(f);+ writeFileSync(join(f.brain, 'people', 'bob-example.md'), page('Bob', 'Second version.'));+ mkdirSync(join(f.brain, 'imports'));+ execFileSync('git', ['init', '-q', join(f.brain, 'imports')]);+ writeFileSync(join(f.brain, 'imports', 'export.csv'), 'a,b\n');+ const r = await commitPush(f, 'people/bob-example.md', 'imports/export.csv');+ expect(r.exitCode).not.toBe(0);+ const e = envelope(r.stdout);+ expect(e.code).toBe('commit_paths_skipped');+ expect(e.message).toContain('imports/export.csv');+ expect(e.message).toContain('not pushed');+ expect(headBlob(f, 'people/bob-example.md')).toContain('Second version.');+ expect(remoteTip(f)).toBe(before);+}, 60_000);++test('remoteless: a skipped path fails commit_paths_skipped instead of nothing to commit', async () => {+ const f = fixture('remoteless', 'remoteless');+ const before = head(f);+ editHidden(f, 'people/alice-example.md');+ const r = await commitPush(f, 'people/alice-example.md');+ expect(r.exitCode).not.toBe(0);+ expect(envelope(r.stdout).code).toBe('commit_paths_skipped');+ expect(head(f)).toBe(before);+}, 60_000);++/** Run the rendered helper from the checkout; `cli` is recorded as gbrain.cliPath, otherwise no gbrain is reachable (the fallback). */+function helper(f: Fixture, cli: boolean, ...args: string[]) {+ mkdirSync(join(f.brain, 'scripts'), { recursive: true });+ const script = join(f.brain, 'scripts', 'brain-commit-push.sh');+ if (!existsSync(script)) {+ writeFileSync(script, renderCommitPushHelper()); chmodSync(script, 0o755);+ git(f.brain, 'update-index', '--add', '--cacheinfo', `100755,${git(f.brain, 'hash-object', '-w', script)},scripts/brain-commit-push.sh`);+ git(f.brain, 'commit', '-qm', 'helper', '--', 'scripts/brain-commit-push.sh');+ }+ if (f.remote && cli) git(f.brain, 'push', '-q', 'origin', 'main');+ if (cli) {+ const wrapper = join(f.home, 'gbrain');+ writeFileSync(wrapper, `#!/bin/sh\nexec "${process.execPath}" --no-env-file "${join(import.meta.dir, '..', 'src', 'cli.ts')}" "$@"\n`); chmodSync(wrapper, 0o755);+ git(f.brain, 'config', '--local', 'gbrain.cliPath', wrapper);+ }+ return spawnSync('bash', [script, ...args], { cwd: f.brain, encoding: 'utf8', timeout: 60_000,+ env: { PATH: '/usr/local/bin:/usr/bin:/bin', HOME: f.home, GBRAIN_HOME: f.home, GBRAIN_SKIP_STARTUP_HOOKS: '1', ...identity } });+}++test('helper without gbrain: a skipped path fails loudly instead of printing nothing to commit and exiting 0', () => {+ const f = fixture('helper-fallback', 'classic');+ editHidden(f, 'people/alice-example.md');+ const r = helper(f, false, 'write pages', 'people/alice-example.md');+ expect(r.status).not.toBe(0);+ expect(r.stderr).toContain('commit_paths_skipped');+ expect(r.stderr).toContain('people/alice-example.md');+ expect(headBlob(f, 'people/alice-example.md')).toContain('First version.');+}, 60_000);++test('helper delegating to gbrain on a managed checkout: a skipped page exits non-zero with writer_coordinator_required', () => {+ const f = fixture('helper-managed', 'managed');+ // The helper refuses on the Git-metadata marker itself; without it (an owner claim or the registry marks the root) it hands over to gbrain.+ rmSync(join(f.brain, '.git', 'gbrain-managed.json'));+ editHidden(f, 'people/alice-example.md');+ const r = helper(f, true, 'write pages', 'people/alice-example.md');+ expect(r.status).not.toBe(0);+ expect(r.stderr).toContain('writer_coordinator_required');+ expect(headBlob(f, 'people/alice-example.md')).toContain('First version.');+}, 90_000);++test('helper on a marked managed checkout refuses with the operator contract (code, why, fix, next)', () => {+ const f = fixture('helper-marker', 'classic');+ writeFileSync(join(f.brain, '.git', 'gbrain-managed.json'), '{}\n');+ writeFileSync(join(f.brain, 'people', 'alice-example.md'), page('Alice', 'Second version.'));+ const r = helper(f, false, 'write pages', 'people/alice-example.md');+ expect(r.status).not.toBe(0);+ expect(r.stderr).toContain('Error [writer_coordinator_required]');+ expect(r.stderr).toContain('put_page');+ expect(r.stderr).toMatch(/^Why: /m);+ expect(r.stderr).toMatch(/^Next: /m);+ expect(headBlob(f, 'people/alice-example.md')).toContain('First version.');+}, 60_000);++test('classic: a named directory inside a nested repository fails instead of nothing to commit', async () => {+ const f = fixture('classic-nested-dir', 'classic');+ nestedPage(f, 'carol-example.md');+ mkdirSync(join(f.brain, 'imports', 'pages'));+ writeFileSync(join(f.brain, 'imports', 'pages', 'dave-example.md'), page('Dave', 'Under a nested clone.'));+ const r = await commitPush(f, 'imports/pages');+ expect(r.exitCode).not.toBe(0);+ expect(JSON.parse(envelope(r.stdout).detail!)).toMatchObject({ skipped: [{ path: 'imports/pages', reason: 'not_staged' }] });+}, 60_000);++test('classic: both flags get their own update-index step, since git clears only the first flag given', async () => {+ const f = fixture('classic-both-flags', 'classic');+ editHidden(f, 'people/alice-example.md');+ editHidden(f, 'people/bob-example.md', '--skip-worktree');+ const before = head(f);+ const r = await commitPush(f, 'people/');+ expect(r.exitCode).not.toBe(0);+ const e = envelope(r.stdout) as ReturnType<typeof envelope> & { fix: { then?: { argv: string[] } } };+ expect(e.fix.argv).toEqual(['git', '-C', f.brain, 'update-index', '--no-assume-unchanged', '--', 'people/alice-example.md']);+ expect(e.fix.then?.argv).toEqual(['git', '-C', f.brain, 'update-index', '--no-skip-worktree', '--', 'people/bob-example.md']);+ expect(head(f)).toBe(before);+}, 60_000);++test('helper without gbrain: a non-ASCII flagged path, a nested-repository file beside a committable page, and a clean flagged symlink', () => {+ const f = fixture('helper-fallback-edges', 'classic');+ const accented = 'people/jos\u00e9-example.md';+ writeFileSync(join(f.brain, accented), page('Jose', 'First version.'));+ symlinkSync('alice-example.md', join(f.brain, 'people', 'link-example.md'));+ git(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);+ editHidden(f, accented);+ const accentedRun = helper(f, false, 'write pages', accented);+ expect(accentedRun.status).not.toBe(0);+ expect(accentedRun.stderr).toContain(accented);+ writeFileSync(join(f.brain, 'people', 'bob-example.md'), page('Bob', 'Second version.'));+ const nested = nestedPage(f, 'carol-example.md');+ const mixed = helper(f, false, 'write pages', 'people/bob-example.md', nested);+ expect(mixed.status).not.toBe(0);+ expect(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));+}, 90_000);+