refactor(setup): group steps into four phases ordered by failure probability#1903
Open
DavidMiserak wants to merge 1 commit into
Open
refactor(setup): group steps into four phases ordered by failure probability#1903DavidMiserak wants to merge 1 commit into
DavidMiserak wants to merge 1 commit into
Conversation
…ability
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 garrytan#1898.
- gen:skill-docs:user still pipes through `tail -3` in B6 (still buggy
here). The fix is in garrytan#1898.
- Playwright Chromium install/verify in D3 still exits 1 on failure
(unchanged). The warn-don't-exit conversion is in garrytan#1900 and
coordinates with garrytan#1838.
Splitting those keeps this PR reviewable as "a move plus the gbrain
split that the move requires," per @jbetala7's request on garrytan#1883.
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1902.
This is the "(3) phase reorder last, against fresh main, with an issue
describing the failure modes it fixes" split @jbetala7 asked for on #1883.
What this PR is
A behavior-preserving reorganization of
setupinto four phasesbracketed by header comments. See #1902 for the failure modes that
motivate it.
~/.gstack/, welcome, GBrain detection (scan)settings.jsonmutation: team + plan-tune hooksEach phase header is a comment block in the script. Steps inside are
renumbered (
A1, A2, A3, B1, B2a, ...).What this PR is NOT
To keep this reviewable as a structural move, the two behavior changes
that were originally bundled with the reorder on #1883 are not here:
bun_cmdrouting in threelink_*_skill_dirshelpers +removing
| tail -3fromgen:skill-docs:user. Already opened.exit 1→_PW_FAIL_REASONbest-effort warn.Coordinates with fix(setup): pin Playwright browser install to bundled version so headed browse connect works (#1829) #1838.
In this PR's diff:
bun_cmdcall sites are stillbun run(the bug — fixed in fix(setup): route gen:skill-docs through bun_cmd; drop tail -3 pipe that masks bun failures #1898).gen:skill-docs:userinvocation in B6 still pipes throughtail -3(the bug — fixed in fix(setup): route gen:skill-docs through bun_cmd; drop tail -3 pipe that masks bun failures #1898).
exit 1paths from origin/main(the design issue setup: Playwright Chromium download failure aborts setup before skills/hooks/migrations land #1902 names — fixed in fix(setup): Playwright Chromium failure becomes best-effort warn, not exit 1 #1900).
This is intentional. A reviewer can read this diff as "did anything
besides moving lines around and splitting one block?" The answer should
be: just the GBrain detect/regen split (entailed by the new order) and
one safety guard for that split (see next section).
The one behavior change this PR DOES contain
The phase reorder requires splitting GBrain detection from GBrain regen:
gstack-gbrain-detect,no dependencies). Writes the result to
~/.gstack/gbrain-detection.json.SKILL.md with brain-aware blocks (after the binary is built + skill
docs are generated).
This split is necessary because A runs before bun is prepared, so the
regen call (which needs bun) can't live in A. Splitting introduces one
new failure mode: what happens if detection fails in A3 but a stale
gbrain-detection.jsonfrom a prior successful run still exists?Without a guard, the stale "ok" file would survive a failed detect and
silently trigger brain-aware regen in B6 — applying ~250 tokens of
overhead per planning skill to a user whose gbrain may have been
removed.
The guard: A3 removes both the temp file AND any pre-existing
gbrain-detection.jsonwhengstack-gbrain-detectexits non-zero.test/setup-gbrain-detection.test.tspins this with a static-sourcecheck so a future refactor that drops the guard fails CI.
Tests
All 7 existing setup test files still green on the reordered structure.
Test plan
bun test test/setup-*.test.ts— 66 passbash -n setup— syntax OKgraph (A doesn't depend on anything in B/C/D; B doesn't depend on
C/D; C doesn't depend on D)
via grep (
bun_cmd run gen:skill-docs --host {codex,factory,opencode}= 0 in link helpers;
| tail -3still present in B6;_PW_FAIL_REASON= 0; Playwrightexit 1= 2)Relationship to #1883
This PR is the third and final split from #1883. Once this is open,
#1883 stays as the parking lot only long enough to add the three split
links and a close note.
Sibling PRs:
Recommended merge order
either can land first then the other rebases).
small and reviewable.
If preferred, this PR can land before #1898 / #1900 — they're against
fresh main with no overlap, but rebasing them on top of this would make
their diffs harder to read because they'd be against the reordered
structure. The chosen order (this PR last) keeps each diff minimal
against the structure its reviewer already knows.