Skip to content

fix(setup): serve rendered sections/, not the checkout copy (#2706) - #2707

Closed
jonahberg wants to merge 1 commit into
garrytan:mainfrom
jonahberg:fix/install-serves-rendered-sections
Closed

jonahberg wants to merge 1 commit into
garrytan:mainfrom
jonahberg:fix/install-serves-rendered-sections

Conversation

@jonahberg

Copy link
Copy Markdown
Contributor

Fixes #2706.

Why (in your own words)

On a gbrain install, /ship, /office-hours and the four plan-*-review skills silently stopped saving anything to the brain. The blocks were being generated correctly — they just never reached the agent.

#2569 moved the brain-aware render out of the tracked checkout and made the installers prefer the rendered SKILL.md. Runtime assets kept coming from the checkout, so an installed skill ended up served from two different trees: SKILL.md from ~/.gstack/render/claude, sections/ from the source. The rendered section files are the only copies carrying the injected Save Results to Brain block, so that block was written to disk and then never read.

The comment above the call says the opposite — "the rendered file's section-base paths point into the render dir, so section reads resolve there too". That's true of the absolute Read directives, but the Section index and the carved-skill footer route via relative sections/<name>.md refs, and those resolve through the installed dir. So the render preference has to cover runtime assets too, not just SKILL.md.

gstack-config gbrain-refresh doesn't heal it either: it calls gstack-relink to "repoint installed skills at the render", and relink only ever repointed SKILL.md. That's the path someone hits when they install gbrain after gstack, and it's why re-running refresh looks successful while changing nothing.

Live evidence

Before — on a real v1.71.0.0 install with gbrain: every diverging section file is served from the checkout, i.e. without its block.

$ for d in ~/.gstack/render/claude/*/; do s=$(basename "$d"); [ -d "$d/sections" ] || continue
    for f in "$d/sections"/*.md; do b=$(basename "$f"); src=~/.claude/skills/gstack/$s/sections/$b
      [ -f "$src" ] && ! cmp -s "$f" "$src" && { served=~/.claude/skills/$s/sections/$b
        cmp -s "$served" "$f" && echo "$s/$b serves RENDER" || echo "$s/$b serves SOURCE (block lost)"; }
    done; done

ship/adversarial.md                       serves SOURCE (block lost)
office-hours/design-and-handoff.md        serves SOURCE (block lost)
plan-ceo-review/review-sections.md        serves SOURCE (block lost)
plan-design-review/review-sections.md     serves SOURCE (block lost)
plan-devex-review/review-sections.md      serves SOURCE (block lost)
plan-eng-review/review-sections.md        serves SOURCE (block lost)

The content that never arrives:

$ diff ~/.claude/skills/gstack/ship/sections/adversarial.md \
       ~/.gstack/render/claude/ship/sections/adversarial.md
> ## Save Results to Brain
> **Skip this entire section if `gbrain` is not on PATH.**
> ... gbrain put "releases/<feature-slug>" ...

Red on unpatched main — new tests run against a clean 394db32 worktree, before the fix:

$ bun test test/render-sections-provenance.test.ts     # on upstream/main

(fail) installed skills serve rendered sections (#2706) > setup's _link_skill_runtime_assets
       serves the rendered section, keeping checkout-only assets
  Expected to contain: "## Save Results to Brain"
  Received: "body\n"

(fail) installed skills serve rendered sections (#2706) > gstack-relink repoints sections
       at the render (the gbrain-refresh path)
  Expected to contain: "## Save Results to Brain"
  Received: "body\n"

 1 pass
 2 fail

The one that passes on main is the control: the no-render path must stay byte-identical for installs without gbrain.

Green after the fix:

$ bun test test/render-sections-provenance.test.ts
 3 pass
 0 fail
 9 expect() calls

No regressions in the surrounding area — every suite that touches linking, relink, render isolation, team mode and uninstall:

$ bun test test/relink.test.ts test/setup-claude-skill-assets.test.ts \
    test/user-render-out-dir-install.test.ts test/setup-windows-rerun-refresh.test.ts \
    test/gbrain-refresh-install-render.test.ts test/dev-setup-render-isolation.test.ts \
    test/setup-sections-linking.test.ts test/render-sections-provenance.test.ts \
    test/team-mode.test.ts test/uninstall.test.ts

 126 pass
 0 fail
 644 expect() calls

Full free suite, branch vs clean main on the same machine: 19 failures on this branch, 22 on upstream/main — the failures are identical pre-existing local-environment ones (bun-polyfill, findPort, bump/DRIFT REPAIR, gstack-gbrain-sync, browse node --check), caused by node here being a Bun shim at ~/.bun/bin/node rather than real Node. My diff touches no file any of those suites exercise.

Scope

  • Changed: setup (_link_skill_runtime_assets takes the render dir and overlays per file; corrected the comment whose premise caused this), bin/gstack-relink (same overlay, so gbrain-refresh actually repoints), test/setup-sections-linking.test.ts (its :34 assertion matched the two-arg shape and so pinned the bug in place), plus the new test/render-sections-provenance.test.ts.
  • Verified live by: the real-install sweep above on a gbrain-enabled v1.71.0.0 global-git install (macOS), red-then-green on the new tests against a clean 394db32 worktree, and the 126-test surrounding-area run.
  • Did NOT test: Windows (_link_or_copy's copy path — the overlay routes through the same helper, but I have no Windows box); the paid/eval tiers; ShellCheck (not installed locally — bash -n passes on both scripts, and CI gates setup at --severity=error).

Design note

The overlay is per file, not per directory. Render dirs carry only the generated *.md, so repointing the whole sections/ symlink at the render would drop manifest.json and the *.tmpl files that exist only in the checkout.

In relink there's one sharp edge worth flagging: on an existing install sections/ is already a symlink into the checkout, so linking children through it would write into the tracked install and dirty it. The helper drops that symlink and rebuilds a real directory first; a test asserts the checkout is byte-unchanged afterwards.

Related but distinct from #2692 (which is the absolute refs pointing at the deleted claude.tmp.$$ dir). On this install both routes to ship/sections/adversarial.md fail — 9 dead tmp refs and 9 relative refs into un-rendered content in the same file. #2692 repairs the absolute route; this repairs the relative one. They compose.

If you'd rather remove the two-tree split at the source than overlay it, the alternative in #2706 stands: have gen-skill-docs --out-dir emit the full sections/ payload so the whole directory can be linked from the render dir. Happy to redo it that way.

Liveness proof

Checklist

  • Liveness screenshot attached: GSTACK PR typed live into a real surface (not edited onto the image)

…#2706)

link_claude_skill_dirs prefers the gbrain-rendered SKILL.md (garrytan#2569) but
installed every other runtime asset from the source checkout, so SKILL.md was
served from ~/.gstack/render/claude while sections/ was served from the tracked
tree. The rendered section files — the only copies carrying the injected
"Save Results to Brain" blocks — were generated and never read.

Six skills lost their brain-write step on a gbrain install: ship,
office-hours, and all four plan-*-review.

The comment above the call asserted the opposite ("section reads resolve there
too"). That holds only for the absolute Read directives; the Section index and
the carved-skill footer route via relative sections/<name>.md refs, which
resolve through the installed dir. Comment corrected to say why the asset
overlay is required.

Pass the render dir into _link_skill_runtime_assets and overlay per FILE, not
per directory: render dirs carry only the generated *.md, so a directory-level
repoint would drop manifest.json and other checkout-only assets.

bin/gstack-relink had the same split — it repoints SKILL.md and never touched
runtime assets — so `gstack-config gbrain-refresh`, which calls relink to
"repoint installed skills at the render", left every rendered section
unreachable. Same per-file overlay added there, including a guard that rebuilds
a still-symlinked sections/ as a real directory rather than linking children
through it into the tracked checkout.

Tests: new test/render-sections-provenance.test.ts pins the delivery side (what
the installed dir actually serves) for both install paths; the generator side
was already pinned by gen-skill-docs-out-dir.test.ts. Both behavior tests
verified RED on v1.71.0.0 (394db32) before the fix. The no-render case is
pinned unchanged. setup-sections-linking.test.ts:34 previously matched the
two-arg shape and so locked the bug in — updated to require the render arg.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NyCDYEW1GsdhZq9r8i5kRV
@trunk-io

trunk-io Bot commented Aug 27, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

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

@capy-ai

capy-ai Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Thank you, @jonahberg. Your fix is folded into v1.91.19.0 (#3025), which is now merged, and you're credited as a co-author on the release commit and in the CHANGELOG. Closing this PR because the change is on main now.

@capy-ai capy-ai Bot closed this Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Installed <skill>/sections is linked from the checkout, not the render dir — gbrain section blocks never reach the agent (v1.71.0.0)

1 participant