mirror of https://github.com/garrytan/gstack.git
freshDetectEngineTier() in lib/gstack-memory-helpers.ts returned engine:
"unknown" for every Supabase user on gbrain ≥0.25. Two stacking bugs:
1. execSync("gbrain doctor --json --fast 2>/dev/null") threw on non-zero
exit. gbrain doctor exits 1 whenever health_score < 100, which is
essentially every fresh install due to resolver_health warnings. The
JSON output never reached the parser.
2. gbrain ≥0.25 shipped schema_version:2 doctor output that dropped the
top-level 'engine' field entirely.
Result: every /sync-gbrain on Supabase logged 'engine=unknown' and skipped
all sync stages silently.
Fix:
- Replace execSync with execFileSync (no shell, no bash-specific 2>/dev/null
redirect; portable to Windows).
- Recover stdout from the thrown error object so non-zero exits still parse.
- Fall back to reading gbrain's config.json (respecting GBRAIN_HOME env var,
defaulting to ~/.gbrain/config.json) when doctor output doesn't surface
an engine field.
- Add logGbrainError() helper that appends one-line JSONL to
~/.gstack/.gbrain-errors.jsonl on parse failure, so future regressions
leave a forensic trail.
The "supabase" tier here means "remote postgres" in practice — gbrain
config uses engine:"postgres" for both real Supabase and any other
remote postgres (e.g. local-postgres-for-testing). Downstream sync code
treats them identically, so the label compression is intentional and
documented inline.
Regression test: existing detectEngineTier suite now isolates HOME +
GBRAIN_HOME + PATH to temp dirs (closes a flake source where the prior
tests would read whatever was on the reviewer's machine). New test
forces gbrain off PATH, writes a synthetic config.json with
engine:"postgres", asserts detectEngineTier() returns
engine:"supabase".
Fixes #1415. Patch shape contributed by Shiv @shivasymbl (tested on
gstack v1.31.0.0 + gbrain v0.31.3 + Supabase).
|
||
|---|---|---|
| .. | ||
| gbrain-sources.ts | ||
| gstack-memory-helpers.ts | ||
| worktree.ts | ||