Skip to content

Commit 81204ad

Browse files
committed
refactor(setup): group steps into four phases ordered by failure probability
setup used to interleave trivial filesystem ops, expensive compute, settings.json mutations, and network/sudo steps in whatever order the script grew. A Playwright Chromium download failing at step 2 would abort before skills got registered at step 4, hooks landed at step 10, or migrations ran at step 8. This commit groups work by where failures actually come from: Phase A — filesystem (always succeeds): ~/.gstack/, welcome, GBrain detection Phase B — local compute (low fail): bun build, skill linking, migrations, regen Phase C — settings.json mutation (medium fail, reversible): team-mode + plan-tune hooks Phase D — external network/sudo/package managers (highest fail): coreutils, font, Playwright Each phase is bracketed with a header comment; steps within are renumbered (A1, A2, B1, B2a...). The biggest behavior shift is the GBrain detect/regen split that the new order requires: detection moves to A3 (filesystem scan only, no dependencies), regen moves to B6 (runs after the binary is built and skill docs are generated). Detection persists to ~/.gstack/gbrain-detection.json so B6 can read it. A safety guard for that split: when gstack-gbrain-detect exits non-zero, A3 removes both the temp file AND any pre-existing detection file from a prior successful run. Without the guard, a stale "ok" detection file would survive a failed detect and silently apply ~250 tokens of overhead per planning skill to a user whose gbrain may no longer be installed. Behavior preservation: - bun_cmd routing in link_{codex,factory,opencode}_skill_dirs is unchanged (still buggy here). The fix is in #1898. - gen:skill-docs:user still pipes through `tail -3` in B6 (still buggy here). The fix is in #1898. - Playwright Chromium install/verify in D3 still exits 1 on failure (unchanged). The warn-don't-exit conversion is in #1900 and coordinates with #1838. Splitting those keeps this PR reviewable as "a move plus the gbrain split that the move requires," per @jbetala7's request on #1883.
1 parent 476b0ec commit 81204ad

4 files changed

Lines changed: 346 additions & 203 deletions

File tree

CHANGELOG.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,120 @@
11
# Changelog
22

3+
## [1.56.2.0] - 2026-06-07
4+
5+
## **`./setup` now runs in four phases ordered by failure probability. A bad network day or a missing `sudo` no longer leaves you with zero skills installed.**
6+
7+
`./setup` used to interleave trivial filesystem operations, expensive
8+
compute, settings.json mutations, and network/sudo steps in whatever order
9+
the script grew. That meant a Playwright Chromium download failing at step
10+
2 would abort the run before skills got registered at step 4, before hooks
11+
landed at step 10, before migrations ran at step 8. A re-run would do the
12+
same thing — die at step 2.
13+
14+
This release groups the work by where failures actually come from:
15+
16+
| Phase | What runs | Fail risk |
17+
|-------|-----------|-----------|
18+
| **A** | `~/.gstack/` directory, welcome message, GBrain detection (file scan only) | Always succeeds |
19+
| **B** | Local compute: binary build, skill linking, migrations, GBrain SKILL.md regen | Low |
20+
| **C** | `settings.json` mutation: team-mode hooks, plan-tune cathedral hooks | Medium, fully reversible |
21+
| **D** | External network / sudo / package managers: coreutils, emoji font, Playwright | Highest |
22+
23+
Each phase is bracketed with a clear header in the script so contributors
24+
can find where new work belongs. Steps inside each phase are numbered
25+
(A1, A2, A3, B1...). When something fails in Phase D, the skills, hooks,
26+
and migrations from Phases A-C are already in place. Re-running `./setup`
27+
retries only the failed phase.
28+
29+
This is intentionally a behavior-preserving move where possible. Two
30+
known follow-ups land as separate PRs:
31+
32+
- **#1898**: surgical bug fixes (`bun_cmd` routing in three `link_*_skill_dirs`
33+
helpers; `| tail -3` pipe that swallowed bun's exit code on
34+
`gen:skill-docs:user`).
35+
- **#1900**: convert Playwright Chromium install/verify from `exit 1` to
36+
best-effort warn. Coordinates with #1838.
37+
38+
Splitting those out keeps this PR reviewable as "a move plus the gbrain
39+
detect/regen split that the new order requires." The split was requested
40+
by @jbetala7 on #1883.
41+
42+
### What changed structurally
43+
44+
The biggest behavior shift forced by the phase reorder is the **GBrain
45+
detection / SKILL.md regen split**. Previously detection ran late in the
46+
script, right alongside the regen call. The new structure runs detection
47+
in **A3** (filesystem scan only, no dependencies) and regen in **B6**
48+
(after the binary is built and skill docs are generated). The detection
49+
result is persisted to `~/.gstack/gbrain-detection.json` so B6 can read it.
50+
51+
A safety guard for that split: when `gstack-gbrain-detect` exits non-zero,
52+
A3 now removes both the temp file AND any pre-existing `gbrain-detection.json`
53+
from a prior successful run. Without the guard, a stale "ok" detection file
54+
would survive a failed detect and trigger brain-aware regen in B6 — silently
55+
applying ~250 tokens of overhead per planning skill to a user whose gbrain
56+
might no longer be installed.
57+
58+
### The numbers that matter
59+
60+
Source: `bun test test/setup-*.test.ts` plus inspection of the new structure
61+
against `origin/main`.
62+
63+
| Metric | Before | After | Δ |
64+
|--------|--------|-------|---|
65+
| Setup steps numbered 1-11 in mixed order | yes | grouped A-D by fail risk | restructured |
66+
| Phase headers in script | 0 | 4 | navigability |
67+
| GBrain detection runs before bun build | no | yes (A3, file scan only) | order |
68+
| GBrain regen runs after skill docs | no | yes (B6) | order |
69+
| Stale detection file survives a failed detect | yes (silent ~250 tok overhead) | no | safety guard |
70+
| Test files covering the new structure | 0 | 1 | invariant pinned |
71+
72+
### What this means for you
73+
74+
If you re-run `./setup` you'll see the four phase headers in the output.
75+
On a clean install nothing about the outcome changes — the same skills get
76+
registered, the same hooks get installed, the same browser gets downloaded.
77+
On a flaky network or a locked-down machine you'll start seeing partial
78+
installs (skills + hooks but no Chromium) instead of mid-run aborts —
79+
that's the warn-on-Playwright story in #1900 once it lands.
80+
81+
### Itemized changes
82+
83+
#### Changed
84+
85+
- `setup`: reorganized into four phases (A: filesystem, B: local compute,
86+
C: settings.json mutation, D: external network/sudo). Each phase is
87+
bracketed with header comments. Step numbering moves from `1, 2, 3, 4...`
88+
to `A1, A2, B1, B2a, B2b, B3a...`.
89+
- `setup`: GBrain detection moves to phase A3 (filesystem scan only, runs
90+
before bun is prepared). The regen call moves to phase B6 (runs after
91+
skill docs are generated). Detection result persists to
92+
`~/.gstack/gbrain-detection.json` between phases.
93+
- `setup`: when `gstack-gbrain-detect` exits non-zero, A3 now removes both
94+
the temp file AND any pre-existing `gbrain-detection.json` from a prior
95+
successful run. This prevents a stale "ok" file from triggering
96+
brain-aware regen for a user whose gbrain may have been removed.
97+
98+
#### For contributors
99+
100+
- `test/setup-gbrain-detection.test.ts`: pins the stale-file safety guard
101+
with a static-source check (`rm -f "$DETECTION_FILE.tmp"
102+
"$DETECTION_FILE"` must appear in the failure path).
103+
104+
#### Carved out from this PR
105+
106+
To keep the move reviewable, two changes that were originally in #1883
107+
are now their own PRs:
108+
109+
- **#1898** (carved out for fast merge): `bun run` → `bun_cmd run` in
110+
three `link_*_skill_dirs` helpers; remove `| tail -3` from
111+
`gen:skill-docs:user` so its `||` warning guard actually fires on bun
112+
failure.
113+
- **#1900** (carved out, coordinates with #1838): Playwright Chromium
114+
install/verify becomes best-effort warn instead of `exit 1`.
115+
116+
Credit: structural feedback by @jbetala7 on #1883.
117+
3118
## [1.56.1.0] - 2026-06-03
4119

5120
## **`/sync-gbrain` can no longer delete your repo. Cleanup now refuses any directory it cannot prove it created.**

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.56.1.0
1+
1.56.2.0

0 commit comments

Comments
 (0)