Skip to content

fix(sync-gbrain): Windows compat — capability check + brain-sync skip#1641

Closed
jakehann11 wants to merge 1 commit into
garrytan:mainfrom
jakehann11:feat/sync-gbrain-windows-fixes
Closed

fix(sync-gbrain): Windows compat — capability check + brain-sync skip#1641
jakehann11 wants to merge 1 commit into
garrytan:mainfrom
jakehann11:feat/sync-gbrain-windows-fixes

Conversation

@jakehann11
Copy link
Copy Markdown

Summary

Two Windows-only failures surfaced running /sync-gbrain on Git Bash from a freshly-set-up local-stdio gbrain install. Both trace to the same family of issues — Node/Bun spawnSync can't directly execute bash scripts on Windows (ENOENT). Same shape as #1571 (different code path).

1. Capability check fails on Windows. The ## Step 4: Refresh ## GBrain Search Guidance block capability check uses:

echo "ping" | gbrain put "$SLUG" >/dev/null 2>&1

Windows Git Bash treats this as writing to /dev/stdin, which gbrain rejects with ENOENT: no such file or directory, open '/dev/stdin'. CAPABILITY_OK always reports 0 on Windows even when the engine is healthy and search works — so the skill removes the ## GBrain Search Guidance block from CLAUDE.md on every run, defeating the whole point of the workflow.

Switching to gbrain put "$SLUG" --content "ping" works on both Windows and Unix, and matches the v1.42.0.0 wave (#1571 era) that rewrote all 10 user-facing put_page instruction templates to the put + --content canonical shape.

2. runBrainSyncPush produces spurious ERR rows when artifacts_sync_mode=off. The orchestrator didn't check the user's opt-out before invoking gstack-brain-sync (also a bash script). On Windows the spawn fails with result.status === undefined, producing this verdict row even with a healthy install + intentional opt-out:

ERR    brain-sync   gstack-brain-sync exited undefined (0.0s)

New readArtifactsSyncMode() parses ~/.gstack/config.yaml directly via readFileSync — no process spawn, fully portable across all platforms. When the key reads off (the default), the stage returns ran=false ok=true summary="skipped (artifacts_sync_mode=off — user opt-out)".

Verified on Windows Git Bash

Before:

gstack-gbrain-sync (incremental):
  OK    code         synced gstack-code-… (page_count=386) (7.4s)
  OK    memory       gbrain import: 3 imported, 0 unchanged, 0 failed (2.9s)
  ERR   brain-sync   gstack-brain-sync exited undefined (0.0s)

  2 ok, 1 error, 0 skipped

After:

gstack-gbrain-sync (incremental):
  OK    code         synced gstack-code-… (page_count=386) (7.0s)
  OK    memory       gbrain import: 1 imported, 0 unchanged, 0 failed (2.7s)
  SKIP  brain-sync   skipped (artifacts_sync_mode=off — user opt-out) (0.0s)

  3 ok, 0 error, 0 skipped

Capability check: CAPABILITY_OK=1 (was 0).

Test plan

  • Manual verification on Windows Git Bash (alumni-watch repo, local-stdio gbrain v0.35.8.0, pglite engine)
  • bun test test/gstack-gbrain-sync.test.ts — same 31 pass / 6 fail before and after this PR. The 6 failures (sourceLocalPath describe block) are pre-existing Windows-specific test issues — the tests use bash-script shims that Windows Node spawnSync can't execute via ENOENT. Same root cause family, separate fix needed.
  • Unix sanity check — would appreciate a maintainer running /sync-gbrain once on macOS/Linux to confirm both paths still behave (no regression expected; the YAML-parse helper is just a readFileSync + regex and the --content flag has been the canonical shape since v0.18+).

🤖 Generated with Claude Code

Two Windows-only failures surfaced when running /sync-gbrain on Git Bash
from a freshly-set-up local-stdio gbrain install:

1) Capability check used `echo "ping" | gbrain put "$SLUG"` which fails
   with `ENOENT /dev/stdin` on Windows. Switching to `gbrain put "$SLUG"
   --content "ping"` works on both Windows and Unix (and matches the
   v1.42.0.0 wave that rewrote all 10 user-facing put_page templates to
   the put + --content shape).

2) `runBrainSyncPush` in gstack-gbrain-sync.ts did not check
   artifacts_sync_mode before invoking gstack-brain-sync. When the user
   set the mode to "off" (the default + opt-out value), the orchestrator
   still tried to run the bash script, which Node/Bun spawnSync can't
   execute directly on Windows (ENOENT, returns status === undefined).
   Verdict showed "ERR brain-sync gstack-brain-sync exited undefined"
   despite a healthy install.

   New `readArtifactsSyncMode()` helper parses ~/.gstack/config.yaml
   directly via readFileSync — no process spawn, fully portable. When
   the key reads "off", the stage returns ran=false ok=true with summary
   "skipped (artifacts_sync_mode=off — user opt-out)".

Verified on Windows Git Bash:
- Capability check: CAPABILITY_OK=1 (was 0)
- Sync verdict: "3 ok, 0 error, 0 skipped" (was "2 ok, 1 error")

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant