Files
gstack/docs/state-root.md
T
ac20ef1e13 v1.91.16.0 fix: safe installs and upgrades, skills start everywhere, truthful completion (parallel wave) (#3014)
* fix(make-pdf,design): real TOC page numbers and anchors; design models move to gpt-5.5 + gpt-image-2 (#2903, #2807)

* ci: pin every action to a SHA, Scorecard, checksummed Bun, scoped Codex CLI in the CI image, macOS named-regressions job (#1948, #1706, #1997)

* fix(cso,browse): Windows/macOS lease identity, retention skips bad runs, truthful 'not assessed' reports, env.kv false positive, Windows browse spawn fixes (#2894, #2912, #2048, #2637, #2805)

* fix(outside-voice): one Codex model precedence for probe and dispatch, bounded timeouts with KILL escalation, probe cache identity, guarded mktemp, skills hidden in nested Codex (#2776, #2914, #2787, #2881, #2847)

* feat(setup): install registry, ./setup --status, staged activation, per-scope migrations, host tiers and conformance kit, OpenCode/Hermes fixes, Copilot CLI (experimental), disabled_skills, slimmer CLAUDE.md (#1925, #2879, #2347, #2338, #2626, #2629, #2825, #2015, #393, #1206, #2096)

Co-authored-by: Andrey Esipov <61357035+andrey-esipov@users.noreply.github.com>
Co-authored-by: Matthew Williams <5863886+ridermw@users.noreply.github.com>
Co-authored-by: Rocky Wu <92764750+lolisaigao1234@users.noreply.github.com>

* fix(preamble): skills start in worktree-isolated Claude Code sessions — one literal skill-start line, context-recovery helper, no eval in skill blocks, $N token tripwire, honest plan-mode precedence (#2763, #2896, #2851)

* fix(setup): per-install renders for renamed, vendored and custom-config installs, space-safe alias roots, per-host /cso launcher path (#1882, #2906)

* test: free tests never write the real HOME (home-write tripwire), no orphaned browse daemons, symlinked-TMPDIR (macOS) fixes, gbrain-on-PATH isolation (#2895, #2816, #2829, #2841, #2982, #2911, #2909, #2908, #2910)

* chore: integrate wave follow-ups — regenerate all hosts, README model docs, TODOS, touchfiles, duration seeds, Bun 1.3 telemetry test fix, replay fixtures pinned to their recorded bytes

* v1.91.14.0: release metadata

* test(browse): group-kill cleanup falls back to the leader when macOS returns EPERM for a live group

* ci: Codex login steps run under bash (the CI container's default sh rejects pipefail)

* fix: full-suite repairs — private state roots for 7 real-HOME writers, truthful home-guard attribution with --attribute-home, gstack-paths shim in ship-hook fixtures, Copilot in team-init probes, test-of-test detector, cookie review fixture pinned to the approved excerpt

* fix(windows): LF for Dockerfiles, normalized home-guard exclusions, path.relative fixture containment, ship push test spawn timeouts

* test(design-detect): widen the whole-scan budget test's timing margins so a loaded macOS runner can't time out the single-batch call

* fix(evals): qa protocol names defined for the judge, async PTY judge so overlapping sessions keep their cleanup deadline, bws setup cases use the standard JUDGE_MS tier

* test(pty): the non-blocking judge case is POSIX-only (its fake judge is a shebang script, like the PTY harness it covers)

* test(evals): ship-coverage-audit names absolute skill paths, uses Read, and skips the Step 7 artifact nothing consumes (removes the mechanism behind 3 of 4 historical timeouts)

* test: deflake terminal-agent concurrent startup (write the placeholder record before spawning, like the product) and qa-evidence resumed pipe (barrier on a full high-water mark instead of a sleep)

* fix(design): daemon log stream handles open errors instead of crashing the daemon; shutdown test awaits the stubbed exit

* test(evals): skillify checks the product's resolved state root (no GSTACK_HOME bypass), negative cases check every root; tpa shims live outside the agent's cwd and answer consistently

* test(evals): coverage-audit detector splits parallel columns at │ rails and [+] groups; coverage prompts name absolute skill paths; TODOs from the gate eval census

* fix(plan-eng-review): scope gate always sends the menu (no headless 'Scope pending' exit); PTY harness ends idle turn-ends and API-error panels promptly with a precise diagnostic

* test(evals): one position-bound coverage-read rule credits read-only && chains (labels, context ranges, git displays in either order) and still rejects forged output

* fix(ship): documentation section has one saved source inserted by cat (never retyped); spawned-marker evidence is the child output; refreshed codex/factory ship goldens

* test(docsync): the byte-exact insert positive is POSIX-only (the bash-command observer refuses backslash paths by design)

* test(evals): plan-design-with-ui focus-title rule accepts the comma-less 'dimensions or focus' wording (replayed on the captured CI run, negative controls kept)

* fix(qa-callers): exploratory preflight says the scope/method Reads come after exploratory.md; design-review scan check credits an executed scan proven by one engine run over the changed files

---------

Co-authored-by: Andrey Esipov <61357035+andrey-esipov@users.noreply.github.com>
Co-authored-by: Matthew Williams <5863886+ridermw@users.noreply.github.com>
Co-authored-by: Rocky Wu <92764750+lolisaigao1234@users.noreply.github.com>
2026-10-03 07:54:09 -07:00

8.7 KiB

Where gstack keeps its state

gstack keeps everything it remembers — config, analytics, sessions, projects, learnings, review logs, the egress ledger, the trust-policy store, hook error logs — under one directory, the state root. By default that is ~/.gstack. Set GSTACK_HOME to put it somewhere else.

One rule picks the root, and every gstack script, hook and skill uses it. The rule lives in two owner files that a parity test keeps identical: bin/gstack-state-root.sh (bash) and lib/state-root.ts (TypeScript).

How the root is chosen

The first variable in this list with a non-empty value wins. Empty values count as unset.

Order Source When to use it
1 GSTACK_STATE_ROOT gstack-paths' own output. It is also honored as input, so re-reading it in the same environment returns the same root. Do not set it by hand.
2 GSTACK_HOME The one variable to set when you want your state somewhere other than ~/.gstack.
3 GSTACK_STATE_DIR Legacy alias, honored for compatibility.
4 CLAUDE_PLUGIN_DATA Only when CLAUDE_PLUGIN_ROOT contains gstack (any case), so another plugin's data directory never captures gstack state.
5 $HOME/.gstack The default. On Windows shells, USERPROFILE stands in when HOME is unset.
6 .gstack Last resort when there is no home directory at all (some containers).

See which root is in use

~/.claude/skills/gstack/bin/gstack-paths --explain

Real output with GSTACK_HOME set while ~/.gstack still holds older state:

state root: /home/you/work-state (selected by GSTACK_HOME)
chain (first non-empty wins):
  GSTACK_STATE_ROOT    unset
  GSTACK_HOME          /home/you/work-state  selected
  GSTACK_STATE_DIR     unset
  CLAUDE_PLUGIN_DATA   unset
  default              /home/you/.gstack  ignored
default root /home/you/.gstack also holds gstack state: yes
merged privacy keys (most restrictive value across roots wins):
  telemetry:        off (from /home/you/.gstack/config.yaml)
  memorable_recall: not set (default applies)
  codex_reviews:    not set (default applies)
  update_check:     not set (default applies)
docs: https://github.com/garrytan/gstack/blob/main/docs/state-root.md

--explain only reads; it writes nothing and exits 0. gstack-config list also prints a one-line note when GSTACK_STATE_ROOT, GSTACK_HOME and GSTACK_STATE_DIR name different directories.

Move your state

gstack never moves state for you. To relocate it:

cp -a ~/.gstack /new/place/gstack-state
export GSTACK_HOME=/new/place/gstack-state   # add this to your shell profile
~/.claude/skills/gstack/bin/gstack-paths --explain   # confirm: selected by GSTACK_HOME

Keep or delete the old ~/.gstack once you have checked the new root works. Until you delete it, its privacy settings still count (next section).

Privacy settings never get looser when the root moves

Four config keys are opt-outs: telemetry (off < anonymous < community), memorable_recall (off < on), codex_reviews (disabled < enabled) and update_check (false < true). gstack reads each of them from the resolved root and from ~/.gstack, and uses the most restrictive value. So turning telemetry off once in ~/.gstack keeps it off after you set GSTACK_HOME. Every other key, including proactive and founder_resources, reads the resolved root only.

When gstack-config set writes a merged key but the other root still holds a more restrictive value, it tells you which root overrides it and prints the command that changes that root, for example:

GSTACK_STATE_ROOT='/home/you/.gstack' ~/.claude/skills/gstack/bin/gstack-config set codex_reviews enabled

gstack-config list shows the winning root for merged keys, for example telemetry: off (set, /home/you/.gstack).

Trust-policy deny tiers merge the same way: a deny or read-only entry in ~/.gstack/gbrain-repo-policy.json still applies when your resolved root is elsewhere. Nothing is ever written to the other root.

Project buckets

Per-project state (checkpoints, learnings, timeline, question preferences) lives in projects/<slug>/. bin/gstack-slug picks the slug from the git origin remote:

  • A 2-segment remote (github.com/owner/repo) files under owner-repo.
  • A remote with 3 or more path segments (GitLab nested groups such as gitlab.com/customer-a/product/repo, Azure DevOps) files under product-repo-<16 hex>. The hex is a digest of the canonical remote, so customer-a/product/repo and customer-b/product/repo get separate buckets, and the ssh, https and ssh-with-port spellings of one repository share one.
  • Without a remote, the project root's directory name is used.

The first slug gstack resolves in a directory sticks (it is cached under slug-cache/), so a project keeps its bucket when it adds a remote later.

Upgrading from a version that used one bucket for nested groups. Earlier versions filed every <group>/product/repo under product-repo. That bucket stays where it is; gstack neither moves nor deletes it. The first time gstack resolves the new slug it prints one notice naming both buckets, and /context-restore reports the old bucket while it still holds checkpoints. To bring earlier files across, run this in the project:

~/.claude/skills/gstack/bin/gstack-slug --adopt-legacy

It lists every file in the old bucket. Checkpoints are marked as matching this project, another project (never copied), or unknown (saved before checkpoints recorded their project). Files with no project identity (question preferences, learnings, timeline) may belong to any project that shared the bucket, so they are listed for you to decide. On a terminal it asks per file; otherwise copy chosen files with gstack-slug --adopt-legacy --copy <path> [<path>...]. Nothing is copied without your confirmation, and nothing in the new bucket is overwritten.

Pinning a slug. Set GSTACK_PROJECT_SLUG=<name> to choose the bucket yourself, for example in the project's .claude/settings.local.json ("env": {"GSTACK_PROJECT_SLUG": "<name>"}). Use it when an ssh host alias (git@work-gitlab:group/sub/repo) gives a different host than the https remote, or for a vendored sub-repo that should be its own project. The pin is applied per run and never cached.

Uninstall

gstack-uninstall deletes state only at ~/.gstack.

  • It first refuses (exit 2) when ~/.gstack resolves — following symlinks — to /, your home directory or one of its parents, the gstack checkout, the current git repository, or a parent of either. The message names the reason and a fix: line.
  • When the resolved root is somewhere else (you set GSTACK_HOME, for example), uninstall leaves it in place and prints left in place: <path> (selected by <VAR>=<value>) plus the exact rm -rf -- '<path>' command to run after you have checked it.
  • --keep-state never deletes any state. --force only skips the prompt.

If gstack-paths is missing

Skill blocks resolve the root with

GSTACK_STATE_ROOT=$(~/.claude/skills/gstack/bin/gstack-paths --get GSTACK_STATE_ROOT); : "${GSTACK_STATE_ROOT:?gstack-paths failed; reinstall with ./setup or /gstack-upgrade}"

(No eval: worktree-isolated Claude Code sessions refuse it.)

The second half stops the block instead of writing under / if the resolver is broken. If you see gstack-paths failed or cannot resolve the gstack state root, reinstall: run ./setup in the gstack checkout, or /gstack-upgrade.

Claude Code plugin installs

gstack does not ship an official Claude Code plugin distribution today (no .claude-plugin manifest has ever been on main; some forks publish one), and telemetry does not report plugin-mode installs. When gstack does run as a plugin, CLAUDE_PLUGIN_ROOT names gstack and state lives in CLAUDE_PLUGIN_DATA, while a terminal run outside the plugin session uses ~/.gstack. Those are two different roots; run gstack-paths --explain in each environment to see which one is active. Cross-environment support (a pointer from ~/.gstack to the plugin root) is deferred until a plugin distribution exists.

For contributors

  • Bash: executables source bin/gstack-state-root.sh beside them and call gstack_state_root_select (sets $_gstack_sr_root), or eval gstack-paths with the guard above. Hooks must source the twin; never spawn gstack-paths from a hook.
  • TypeScript: resolveStateRoot() and readConfigKey() from lib/state-root.ts.
  • test/state-root-ratchet.test.ts fails on a hand-rolled chain, an executable ~/.gstack in a template bash block, an unguarded gstack-paths eval or export GSTACK_STATE_ROOT in prose. Its allowlist (test/state-root-ratchet.allowlist.json) needs a reason per entry.