Repository navigation
fix(windows): decisions are filed under a project named "unknown", and never sync - #2561
Closed
source-utsho wants to merge 2 commits into
Closed
source-utsho wants to merge 2 commits into
source-utsho wants to merge 2 commits into
Conversation
…ot spawn bin/gstack-slug is a `#!/usr/bin/env bash` script with no file extension. Windows honors neither the shebang nor PATHEXT for an explicit path, so spawnSync fails ENOENT and resolveSlug returned its literal fallback, "unknown". Every decision on the machine was therefore filed under ~/.gstack/projects/unknown/ -- one bucket shared by every project -- while the bash-side Context Recovery preamble resolved the real slug, found no decisions.active.json there, and skipped through a bare `if [ -f ... ]` with no else. Nothing failed. Both decision bins (log and search) missed identically, so writes and searches stayed consistent with each other, and the only component that resolved correctly was silent by design. Measured on one machine: 62 decisions accumulated over 10 days and 170 skill runs, surfaced zero times. shell:true is not the fix here, unlike garrytan#1731 -- cmd.exe cannot run a bash script either. Nor is re-spawning through `bash`: on Windows that frequently resolves to WSL, whose $HOME and /mnt/c paths yield a different slug AND a different cache directory, trading one split store for another. Instead, port gstack-slug's own three steps (cache -> git remote -> basename), keeping its alphabet and its MSYS-form cache key so both paths agree. The fallback is win32-gated, so POSIX behaviour is byte-identical. Tests exercise the fallback on every platform (only the gating is win32-specific), so POSIX CI catches a regression that would otherwise surface only on a Windows user's disk, plus a static gate pinning the platform check.
gstack-decision-log enqueues projects/<slug>/decisions.jsonl after every write, but none of the 16 managed globs matched it, so compute_paths_to_stage rejected every one at its "must match at least one allowlist glob" check. The writer and the syncer disagreed silently: enabling artifacts sync backed up learnings, plans, designs and timelines -- everything except the durable decision ledger -- and nothing reported a miss, because a dropped path prints exactly what a synced one does when the queue is otherwise empty. Add the three decisions.* globs and class them artifact so they also sync in artifacts-only mode. The test reads the heredocs out of the script rather than executing it: gstack-artifacts-init.test.ts drives the real script through #!/bin/bash shims and a colon-separated PATH, so it cannot run on Windows -- the platform where the companion slug bug bit.
|
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 |
garrytan
added a commit
that referenced
this pull request
Aug 16, 2026
… GSTACK_HOME-aware Found while closing the wave's eval gate: a test exporting GSTACK_PROJECT_SLUG from the repo root persisted the override into the cwd slug cache, silently rebinding the ENTIRE repo's session state (evals, decisions, timelines) to the test's slug for every later env-less run. The escape hatch is per-invocation by contract — it no longer writes the cache. The cache dir also hardcoded $HOME while lib/bin-context.ts's native port (#2561) reads it GSTACK_HOME-aware, so temp-home test runs littered the real ~/.gstack (observed: 2,528 stale temp-cwd entries, swept). Writer and reader now key the same GSTACK_HOME-aware cache; regression tests pin both behaviors. Also raises the cso --diff eval budget (240s/25t → 360s/40t): transcript-verified, the wave's legitimately-grown audit session completes the report and dies in closing telemetry at ~215s under the old budget; the full-audit sibling already runs at 300s. Co-Authored-By: Claude Fable 5 <[email protected]>
4 of 9 tasks
Owner
|
Thank you — this landed in v1.67.0.0 (credited in the CHANGELOG). Closing since the fix is on main. 🙏 |
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.
On Windows, every decision logged by
gstack-decision-logis filed under a project literally namedunknown, and the Context Recovery block that should read it back never fires. Separately — and onevery platform — the decision store is not in the sync allowlist, so it never leaves the machine
even with
artifacts_sync_modeon.Measured on one machine before the fix: 62 decisions accumulated across 10 days and 170 gstack
skill runs, and were surfaced zero times. Two of them were owner decisions that existed in no
other store, in a directory outside git and outside backup.
1.
resolveSlugreturns the literal string"unknown"on Windowsbin/gstack-slugis a#!/usr/bin/env bashscript with no file extension. Windows honors neitherthe shebang nor PATHEXT for an explicit path, so
CreateProcessfails ENOENT andr.stdoutisundefined.lib/bin-context.ts:12never inspectedr.error:Reproduced directly:
decisionPaths()then writes to~/.gstack/projects/unknown/— one bucket shared by everyproject on the machine. Mine mixed three.
Why it is silent
Three things had to line up, and they did:
gstack-decision-logandgstack-decision-search) call the sameresolveSlug, so they miss identically. Writes and searches agree with each other and thestore is internally consistent — just in the wrong place.
generate-context-recovery.ts→eval "$(gstack-slug)"), whichresolves the slug correctly to the real project directory.
[ -f "$_PROJ/decisions.active.json" ]with noelse. The fileisn't there, so the whole ACTIVE DECISIONS section is skipped and prints nothing.
A missing file and a working store produce identical output. Nothing logs, nothing exits non-zero.
Why
shell: trueis not the fix hereUnlike #1731, this is not a PATHEXT/shim-resolution problem —
cmd.execannot run a bash scripteither. And re-spawning through
bashis worse than it looks: on Windowsbashfrequently resolvesto
C:\WINDOWS\system32\bash.exe, i.e. WSL, whose$HOMEand/mnt/c/...paths produce adifferent slug and a different
slug-cachedirectory. That trades one split store foranother, silently.
So this ports
gstack-slug's own three steps natively — cache → git remote → basename — keeping its[a-zA-Z0-9._-]alphabet (tr -cddeletes, it does not substitute) and, critically, its MSYS-formcache key (
C:\Users\j\foo→/c/Users/j/foo→_c_Users_j_foo). Reproducing that key is whatkeeps the native path and the shell path on the same answer; getting it wrong would re-derive instead
of reusing, and could drift.
The fallback is win32-gated, so POSIX behaviour is byte-identical.
2. No allowlist glob matches the decision store
gstack-decision-log:40enqueuesprojects/<slug>/decisions.jsonlafter every write. None of the16 managed globs in
.brain-allowlistmatch it, socompute_paths_to_stagerejects every one at its"must match at least one allowlist glob" check.
The writer and the syncer disagree, silently: enabling artifacts sync backs up learnings, plans,
designs and timelines — everything except the durable decision ledger. A dropped path prints
exactly what a synced one does when the queue is otherwise empty.
Fixed by adding the three
decisions.*globs and classing themartifactso they also sync underartifacts-only.Tests
test/bin-context-windows-slug.test.ts(9) exercises the fallback on every platform — only thegating is win32-specific — so POSIX CI catches a regression that would otherwise surface only on a
Windows user's disk. Covers the MSYS cache-key derivation, all three resolution steps, https/ssh
remote forms,
tr -cddeletion semantics, cache write-back with no trailing newline, plus a staticgate pinning the platform check in the style of
gbrain-spawn-windows-shell.test.ts.test/artifacts-allowlist-decisions.test.ts(3) reads the heredocs out ofgstack-artifacts-initrather than executing it, because
gstack-artifacts-init.test.tsdrives the real script through#!/bin/bashshims and a colon-separatedPATHand therefore cannot run on Windows — the platformwhere the companion bug bites. (I confirmed that file already fails on Windows unmodified, so I left
it alone.) It applies
fnmatch.fnmatchcasesemantics, matching whatcompute_paths_to_stageuses.Both files added to
windows-free-tests.yml.Verified by planted negative, not just by passing:
resolveSlugbody only (exports kept)gstack-artifacts-initallowlistWindows CI subset, run locally on Windows 11 / bun 1.3.14: 39 pass, 6 skip, 0 fail.
Not changed here
docs/gbrain-sync.md:34still saysgstack-brain-init, renamed togstack-artifacts-initinv1.27.0.0 —
test/no-stale-gstack-brain-refs.test.tsexists but doesn't catch this one. Left out tokeep the diff focused; happy to send it separately.
Also worth a look, though out of scope:
gstack-artifacts-initcreates the repo withgh/glaband then verifies it via
git ls-remoteover SSH. On a machine where the CLI and the SSH keyauthenticate as different accounts, that aborts at line 188 before writing anything, even though
gstack-brain-synconly ever doesgit push origin HEADand works fine over HTTPS. Andgit initthere could use
core.autocrlf=false— it stores JSONL that must round-trip byte-exactly.🤖 Generated with Claude Code