feat(setup-gbrain): carve the branch-exclusive install paths into sections

Brain-init (Paths 1/2/3/4 bodies), engine remediation, transcript gate, and
CLAUDE.md persist load on demand — at most one install route ever runs.
Skeleton 75.3KB -> 57.0KB; the Step 1 detect and Step 2 path dispatch stay
always-loaded. New buildSetupGbrainFixture helper gives the periodic E2Es
extract-don't-copy fixtures with a non-empty guard; the voyage-code-3 gate
counts scan the tmpl union (the third init site lives in engine-remediation).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-08-25 17:03:12 +00:00
co-authored by Claude Fable 5
parent 6bb1996004
commit cdfe2d9074
18 changed files with 1336 additions and 1021 deletions
+14 -3
View File
@@ -83,7 +83,7 @@ exit 0
/**
* Verbatim reimplementation of the skill template's voyage-code-3
* conditional. The template (setup-gbrain/SKILL.md.tmpl Path 3, Step 1.5
* conditional. The template (setup-gbrain/sections/brain-init.md.tmpl Path 3, Step 1.5
* inside the rollback wrapper, Step 4.5 Path 4 Yes branch) instructs the
* model to execute this bash; we execute the same bash here and assert the
* argv passed to gbrain matches the contract.
@@ -202,9 +202,18 @@ gbrain init --pglite --json $GBRAIN_EMBED_FLAGS
});
it("template uses the positional-params shape, not an unquoted flags var", () => {
// Carved (token-reduction Phase 4): count across the tmpl UNION — one
// PGLite init site stays in the skeleton, the Path-3/4 sites live in the
// brain-init section.
const tmpl = readFileSync(
join(import.meta.dir, "..", "setup-gbrain", "SKILL.md.tmpl"),
"utf-8",
) + readFileSync(
join(import.meta.dir, "..", "setup-gbrain", "sections", "brain-init.md.tmpl"),
"utf-8",
) + readFileSync(
join(import.meta.dir, "..", "setup-gbrain", "sections", "engine-remediation.md.tmpl"),
"utf-8",
);
expect(tmpl).not.toContain("$GBRAIN_EMBED_FLAGS");
const sites = tmpl.match(/gbrain init --pglite --json "\$@"/g) || [];
@@ -229,8 +238,10 @@ describe("template alignment: the .tmpl actually contains the voyage gate", () =
// Belt-and-suspenders: if someone edits the template and drops the
// VOYAGE_API_KEY conditional without updating the test above, this catches
// it. The shell snippet under test must literally appear in the .tmpl.
const TEMPLATE_PATH = join(import.meta.dir, "..", "setup-gbrain", "SKILL.md.tmpl");
const tmpl = readFileSync(TEMPLATE_PATH, "utf-8");
// Carved union — see comment above.
const tmpl = readFileSync(join(import.meta.dir, "..", "setup-gbrain", "SKILL.md.tmpl"), "utf-8")
+ readFileSync(join(import.meta.dir, "..", "setup-gbrain", "sections", "brain-init.md.tmpl"), "utf-8")
+ readFileSync(join(import.meta.dir, "..", "setup-gbrain", "sections", "engine-remediation.md.tmpl"), "utf-8");
it("setup-gbrain template gates the embedding-model flag on VOYAGE_API_KEY", () => {
// Should appear at least once (currently 3 init sites use the same gate).