Skill Tracer
Skills › gstack › setup-gbrain › engine-remediation.md

engine-remediation.md

71 lines · setup-gbrain/sections/engine-remediation.md at 3f79d81

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1<!-- AUTO-GENERATED from engine-remediation.md.tmpl — do not edit directly -->
2<!-- Regenerate: bun run gen:skill-docs -->

<!-- AUTO-GENERATED from engine-remediation.md.tmpl — do not edit directly --> <!-- Regenerate: bun run gen:skill-docs -->

Raw lines 1 to 2
3### Step 1.5 remediation: broken-engine AskUserQuestion + repair branches
4
5The user has a non-working local engine (for example, `~/.gbrain/config.json`
6points at a dead Postgres URL). Fire a targeted AskUserQuestion BEFORE Step 2:
7
8> D# — Your local gbrain engine isn't responding. How do you want to fix it?
9> Project/branch/task: <one-sentence grounding using detected slug + branch>
10> ELI10: gbrain has a config at `~/.gbrain/config.json` but the engine it points
11> at isn't reachable. That could be a transient outage (Postgres container
12> stopped, Tailscale down) OR a stale config you want to abandon. Different
13> remediation for each case.
14> Stakes if we pick wrong: "Switch to PGLite" overwrites your existing config
15> (one-way door if the user actually wanted the broken engine). "Retry" preserves
16> existing state for transient cases.
17> Recommendation: A (Retry) — always try the cheap option first; if engine is
18> just temporarily down it'll come back without any destructive change.
19> Note: options differ in kind, not coverage — no completeness score.
20> A) Retry — re-probe the engine (recommended; ~80ms)
21> ✅ Cheapest test: re-runs `gbrain sources list` to see if engine is back
22> ✅ Zero side effects; existing config preserved
23> ❌ If engine is permanently dead, retries forever; user must choose another option
24> B) Switch to local PGLite (one-way — moves existing config to .bak)
25> ✅ Fastest path to a working local engine if user has abandoned the old one
26> ✅ ~30s; no accounts; private to this machine
27> ❌ Destructive — existing config moved to ~/.gbrain/config.json.gstack-bak-{ts}
28> C) Switch brain mode (continue to Step 2 path picker)
29> ✅ Lets user pick Path 1/2/3/4 to re-init from scratch
30> ✅ Preserves existing config until they explicitly init the new one
31> ❌ Longer flow if user just wants to repair to PGLite
32> D) Quit (do nothing)
33> ✅ No cons — this is a hard-stop choice
34> ❌ N/A
35> Net: A is the right starting move; B/C are explicit destructive paths; D bails.
37**If A (Retry)**: re-run `~/.claude/skills/gstack/bin/gstack-gbrain-detect`
38with `GSTACK_DETECT_NO_CACHE=1` (busts the 60s cache). If the new
39`gbrain_local_status` is `ok`, continue to Step 2. If still `broken-db` or
40`broken-config`, fire the same AskUserQuestion again (the user picks again).
42**If B (Switch to PGLite)** — execute the rollback-safe init sequence:
44```bash
45BACKUP="$HOME/.gbrain/config.json.gstack-bak-$(date +%s)"
46mv "$HOME/.gbrain/config.json" "$BACKUP"
47# gstack default: voyage-code-3 (1024d) when VOYAGE_API_KEY is set — best for
48# code retrieval. Without the key, fall back to gbrain's own auto-selected
49# embedding provider chain (OpenAI 1536d when OPENAI_API_KEY is present, etc.).
50# Never select gbrain's legacy zeroentropyai recipe for a new brain: its hosted
51# API's sunset date (September 4, 2026) has passed; the wireup helper warns existing installs.
52set -- # flags ride the positional params — unquoted $VAR breaks under zsh word-splitting
53if [ -n "${VOYAGE_API_KEY:-}" ]; then
54 set -- --embedding-model voyage:voyage-code-3 --embedding-dimensions 1024
55fi
56if ! gbrain init --pglite --json "$@"; then
57 # Restore on failure
58 mv "$BACKUP" "$HOME/.gbrain/config.json"
59 echo "gbrain init failed. Your previous config was restored at $HOME/.gbrain/config.json." >&2
60 echo "PGLite directory at ~/.gbrain/pglite/ may be in a partial state — \`rm -rf ~/.gbrain/pglite\` if needed before retrying." >&2
61 exit 1
62fi
63echo "Switched to local PGLite. Previous config saved at $BACKUP — review before deleting."
64```
66Then jump to Step 5a (MCP registration; the new PGLite engine is registered as
67local-stdio).
69**If C (Switch brain mode)**: continue to Step 2's normal path picker.
71**If D (Quit)**: STOP the skill cleanly.

Step 1.5 remediation: broken-engine AskUserQuestion + repair branches

The user has a non-working local engine (for example, ~/.gbrain/config.json points at a dead Postgres URL). Fire a targeted AskUserQuestion BEFORE Step 2:

D# — Your local gbrain engine isn't responding. How do you want to fix it? Project/branch/task: <one-sentence grounding using detected slug + branch> ELI10: gbrain has a config at ~/.gbrain/config.json but the engine it points at isn't reachable. That could be a transient outage (Postgres container stopped, Tailscale down) OR a stale config you want to abandon. Different remediation for each case. Stakes if we pick wrong: "Switch to PGLite" overwrites your existing config (one-way door if the user actually wanted the broken engine). "Retry" preserves existing state for transient cases. Recommendation: A (Retry) — always try the cheap option first; if engine is just temporarily down it'll come back without any destructive change. Note: options differ in kind, not coverage — no completeness score. A) Retry — re-probe the engine (recommended; ~80ms) ✅ Cheapest test: re-runs gbrain sources list to see if engine is back ✅ Zero side effects; existing config preserved ❌ If engine is permanently dead, retries forever; user must choose another option B) Switch to local PGLite (one-way — moves existing config to .bak) ✅ Fastest path to a working local engine if user has abandoned the old one ✅ ~30s; no accounts; private to this machine ❌ Destructive — existing config moved to ~/.gbrain/config.json.gstack-bak-{ts} C) Switch brain mode (continue to Step 2 path picker) ✅ Lets user pick Path 1/2/3/4 to re-init from scratch ✅ Preserves existing config until they explicitly init the new one ❌ Longer flow if user just wants to repair to PGLite D) Quit (do nothing) ✅ No cons — this is a hard-stop choice ❌ N/A Net: A is the right starting move; B/C are explicit destructive paths; D bails.

If A (Retry): re-run ~/.claude/skills/gstack/bin/gstack-gbrain-detect with GSTACK_DETECT_NO_CACHE=1 (busts the 60s cache). If the new gbrain_local_status is ok, continue to Step 2. If still broken-db or broken-config, fire the same AskUserQuestion again (the user picks again).

If B (Switch to PGLite) — execute the rollback-safe init sequence:

BACKUP="$HOME/.gbrain/config.json.gstack-bak-$(date +%s)"
mv "$HOME/.gbrain/config.json" "$BACKUP"
# gstack default: voyage-code-3 (1024d) when VOYAGE_API_KEY is set — best for
# code retrieval. Without the key, fall back to gbrain's own auto-selected
# embedding provider chain (OpenAI 1536d when OPENAI_API_KEY is present, etc.).
# Never select gbrain's legacy zeroentropyai recipe for a new brain: its hosted
# API's sunset date (September 4, 2026) has passed; the wireup helper warns existing installs.
set --  # flags ride the positional params — unquoted $VAR breaks under zsh word-splitting
if [ -n "${VOYAGE_API_KEY:-}" ]; then
  set -- --embedding-model voyage:voyage-code-3 --embedding-dimensions 1024
fi
if ! gbrain init --pglite --json "$@"; then
  # Restore on failure
  mv "$BACKUP" "$HOME/.gbrain/config.json"
  echo "gbrain init failed. Your previous config was restored at $HOME/.gbrain/config.json." >&2
  echo "PGLite directory at ~/.gbrain/pglite/ may be in a partial state — \`rm -rf ~/.gbrain/pglite\` if needed before retrying." >&2
  exit 1
fi
echo "Switched to local PGLite. Previous config saved at $BACKUP — review before deleting."

Then jump to Step 5a (MCP registration; the new PGLite engine is registered as local-stdio).

If C (Switch brain mode): continue to Step 2's normal path picker.

If D (Quit): STOP the skill cleanly.

Raw lines 3 to 71
Involves a person AskUserQuestion :3
Runs code bin/gstack-gbrain-detect :37
Uses an outside tool MCP :66