Repository navigation
Description
What happened
When a skill starts in a directory where gstack-slug resolves an empty slug (we reproduce it with the working directory /), gstack-timeline-log writes ~/.gstack/projects/timeline.jsonl and spools the artifact path projects//timeline.jsonl (double slash). On the next drain, gstack-brain-sync stages the file as projects/timeline.jsonl, gstack-brain-sync-index.py sees a requested path that is not in the index, and the whole batch is refused. Every record in the spool is refused with it, so one bad record stops the artifacts sync for every project that shares that artifacts repository. A plain retry does not clear it.
Our part, stated first: two /codex runs that subagents of ours started outside any checkout wrote the records; starting skills there was our own choice. We did not record those runs' working directories (both timeline rows carry "branch":"unknown", which does not by itself say which directory it was); / is the only directory where we could reproduce an empty slug, and it reproduces the whole chain below. We also did not set GSTACK_SESSION_KIND=unattended for those runs; docs/unattended.md:27-33 says gstack-brain-enqueue is a no-op in such a session (the gate is bin/gstack-brain-enqueue:38), which would have kept the record out of the spool. GSTACK_PROJECT_SLUG would also have given the run a slug. The report is about what gstack does when neither is set, not about whether to run there.
What we saw on 1.99.5.0 on 2026-11-17: two runs (11:53Z and 13:06Z) left two spool records with the path projects//timeline.jsonl. From 13:06Z, gstack-brain-sync --status showed "status": "error" with staged artifact validation refused; index and queue preserved; inspect before retrying, the queue depth grew (46), gstack-doctor warned artifacts sync status error, and gstack-brain-sync --once printed BRAIN_SYNC: staged artifact validation refused: requested/index path mismatch; inspect exact path spellings and unrelated staged entries. What cleared it: gstack-brain-sync --drop-queue --yes, unstaging and deleting the stray projects/timeline.jsonl, --discover-new, then --once (status ok, pushed after rebase).
Two separate gaps are in this, and they can be fixed independently:
- An empty slug is not handled: nothing between
gstack-slugand the writers refuses or replaces it, so a path with an empty component reaches the spool. - The refusal does not name the path, and the bad record is never dropped or held, so the status does not tell the user which record to remove and the sync stays refused.
Steps to reproduce
Hermetic: a throwaway GSTACK_HOME with its own git repo, a local bare remote, a synthetic allowlist and the brain worktree pointed at an absent path inside the fixture; nothing touches a real ~/.gstack. Run on main at 169eb9c (VERSION 1.99.5.0, the same version as our install), and against the install, with the same result.
BIN=<a gstack tree>/bin
unset GSTACK_PROJECT_SLUG GSTACK_SESSION_KIND # either would hide the problem
R=$(mktemp -d); git init -q --bare -b main "$R/remote.git"
H=$(mktemp -d); git -C "$H" init -q -b main
git -C "$H" config user.email [email protected]; git -C "$H" config user.name x
git -C "$H" remote add origin "$R/remote.git"
echo seed > "$H/.seed"; git -C "$H" add .seed; git -C "$H" commit -qm seed; git -C "$H" push -q origin main
printf 'projects/*/timeline.jsonl
projects/*/learnings.jsonl
' > "$H/.brain-allowlist"
export GSTACK_HOME=$H GSTACK_STATE_ROOT=$H GSTACK_BRAIN_WORKTREE=$H/absent-worktree
"$BIN/gstack-config" set artifacts_sync_mode full
# one healthy record, then one skill start from /
mkdir -p "$H/projects/foo-bar"; echo '{"skill":"x"}' > "$H/projects/foo-bar/timeline.jsonl"
"$BIN/gstack-brain-enqueue" projects/foo-bar/timeline.jsonl
( cd / && "$BIN/gstack-slug"; "$BIN/gstack-timeline-log" '{"skill":"codex","event":"started","branch":"unknown"}' )
cat "$H"/.brain-queue.d/*
"$BIN/gstack-brain-sync" --once; "$BIN/gstack-brain-sync" --statusOutput (trimmed):
SLUG=
BRANCH=unknown
{"file":"projects/foo-bar/timeline.jsonl","ts":"..."}
{"file":"projects//timeline.jsonl","ts":"..."}
BRAIN_SYNC: staged artifact validation refused: requested/index path mismatch; inspect exact path spellings and unrelated staged entries
{"status": "error", ... "message": "staged artifact validation refused; index and queue preserved; inspect before retrying"}
{"queue_depth":2,"last_push":"never","mode":"full"}
A later healthy record (another project's learnings.jsonl, enqueued afterwards) is refused with the same message and the queue depth grows to 3. Without the seed commit the same input stops one step earlier with index verification Git command failed; that is a property of an empty throwaway repo, not part of this report.
What the code does (all at 169eb9c)
bin/gstack-slug:576:SLUG="${SLUG:-$(basename "$PROJECT_DIR" | tr -cd 'a-zA-Z0-9._-')}". For/the basename is/, and the character filter leaves an empty string. Nothing after it checks for an empty result (the marker branch at:443-454does reject"",.and.., but the main flow does not).bin/gstack-timeline-log:20-24, 68, 74:eval "$(gstack-slug)", thenmkdir -p "$GSTACK_HOME/projects/$SLUG", the append toprojects/$SLUG/timeline.jsonlandgstack-brain-enqueue "projects/$SLUG/timeline.jsonl", with no check that$SLUGis non-empty.bin/gstack-learnings-log:47,131,134andbin/gstack-review-log:34,154,172have the sameprojects/$SLUGpattern (the review log takes its slug fromgstack-slug --get REPO_SLUG, which is empty in the same case).bin/gstack-skill-start:286, :722and:731already use${SLUG:-unknown}, so a fallback name is an existing convention.bin/gstack-brain-enqueue:32-33: the only check on the path itself is that the argument is not empty.bin/gstack-brain-sync-index.py:99-114:verify()compares the requested paths with the index and refuses withrequested/index path mismatch; inspect exact path spellings and unrelated staged entrieswhenrequested - entries.keys()is not empty (:113-114). The path is not named; the handler at:155-157prints only the colliding component names (empty here) and that sentence.bin/gstack-brain-sync:1056-1059: on that refusal it writes statuserrorwithstaged artifact validation refused; index and queue preserved; inspect before retryingand prints the script's message to stderr. The queue is preserved by design, and theerrorrow ofdocs/gbrain-sync-errors.mdsays "the queue is kept and retried"; the retry hits the same record each time.
Expected
- A skill started where the slug is empty should not write or spool a
projects//...path: either a fallback slug (unknown, asgstack-skill-startalready uses) or no write at all. - A single malformed queue record should not stop the whole drain with a message that names nothing. Rejecting or holding such a path before staging (so it never reaches the index check), with a counted notice (the classification JSON already lists the paths) (as the
unmatched/invalidclassification atbin/gstack-brain-sync:312-323and:462-474already does for other bad records, and ashold()in the index script does for case collisions), would fit the existing design; the refusal for unexplained index differences can stay, since preserving the index there is deliberate. Naming the offending path in--statusand in theerrorrow would already let the user fix it without reading the script.
We do not know which of these you prefer, and a dropped record alone would not unstage Git's normalized entry, so the check has to happen before staging. (1) alone would stop this input; (2) would also cover any other path spelling the verifier cannot reconcile.
Docs
The docs at 169eb9c do not cover this case. The error row at docs/gbrain-sync-errors.md:44 lists the causes as "a git index lock, a commit hook, a git add failure"; a refused path spelling is not named there (we do not claim the row is meant to be exhaustive), and --drop-queue --yes is documented there for the blocked row (:42) and for held files (:80), not for error. docs/state-root.md does not say what happens when the slug is empty.
Related
We searched open and closed issues and PRs for projects//timeline.jsonl, requested/index path mismatch, staged artifact validation refused, empty slug and queue-stuck wording and found no report of this. Neighbours that are not the same defect: #3658 (case-collision check blocks a clone), #3220 and #3254 (case-colliding project paths, held instead of ok), #2549 (silent drop of unmatched queue entries), #4418 (an idle status after a failed push).
Readiness report
gstack-doctor run after we recovered (the incident run showed warn artifacts sync status error):
gstack doctor 1.99.5.0
ok state root ~/.gstack durable=yes (selected by default)
ok bun 1.4.4 (floor 1.3.3, tested 1.4.2)
ok hooks 15 hook(s) parse
ok artifacts sync status ok (mode full; queue 0)
ok claude code 2.1.311 (Claude Code)
13 ok, 2 warn, 0 not configured, 0 fail
(Two unrelated warns omitted: codex project unregistered; CLAUDE.md skill list. The full output is trimmed to the lines that bear on this report.)
Environment
- Host and version: Claude Code 2.1.311
- OS: Linux 7.0 (x86_64), Docker container
- gstack: installed 1.99.5.0 (
0326b144); claims checked againstmainat 169eb9c, also VERSION 1.99.5.0; the reproduction above ran against agit archiveof that commit and against the install, with the same result artifacts_sync_mode: full
Activity
capy-ai commentedon Nov 17, 2026
Thanks, and thanks for the hermetic repro. I confirmed both gaps at main e0c4136 by reading the code:
bin/gstack-slug:576can produce an empty slug with no check after it, andbin/gstack-timeline-log:24,68,74writes and enqueuesprojects/$SLUG/...unguarded. Since one bad record stops artifacts sync for every project sharing the repository, this is on our fix list. We'll link the fix here when it lands.capy-ai commentedon Nov 17, 2026
Fixed in #4455 (bc64f5e).
gstack-brain-enqueuenow refuses a path with an empty,.or..component, so an empty slug no longer queuesprojects//timeline.jsonl. A malformed record that is already queued is dropped before staging, the rest of the queue syncs, and the drop is reported in--status, on stderr and in~/.gstack/.brain-sync-drops.json. Thanks again for the hermetic repro.capy-ai commentedon Nov 17, 2026
This fix is on main as bc64f5e and ships in the next gstack release.
/sync-gbrain reports failed pushes and imports instead of OK, and one…