Skip to content

fix(workflow): stop e2e-slot mangling the stack session name - #4836

Merged
iscekic merged 1 commit into
mainfrom
fix-e2e-slot-stack-session
Jul 28, 2026
Merged

fix(workflow): stop e2e-slot mangling the stack session name#4836
iscekic merged 1 commit into
mainfrom
fix-e2e-slot-stack-session

Conversation

@iscekic

@iscekic iscekic commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Problem

stack_session() sanitises a worktree basename with tr -c 'A-Za-z0-9_-' '_'. basename emits a trailing newline, the newline is outside the preserved set, so tr rewrites it to _ — and $(...) can no longer strip it. Every session name came back with a spurious trailing underscore:

$ basename /Users/igor/Projects/.worktrees/mobile-ui-ddc7 | tr -c 'A-Za-z0-9_-' '_'
mobile-ui-ddc7_          # wanted: mobile-ui-ddc7

Why it matters

The slot/stack unification promises that release frees the slot and stops the worktree's stack, so a stack can never outlive the slot that entitled it. That guarantee was not holding. Three silent failures:

  1. release never stopped the dev stack. stop_stack looked up kilo-dev-<name>_, tmux has-session failed, and it returned early treating the stack as already gone. Stacks outlived their slots — the exact over-subscription the cap exists to prevent.
  2. status always reported stack=none, even with the stack plainly up.
  3. stack_is_covered never matched on the recorded worktree, so coverage worked only via the owner-name-prefix fallback. A slot whose owner name does not begin with the worktree basename would make a live stack look uncovered — and stacks --reap would then pnpm dev:stop a running E2E.

Observed on a live host: slot-1 … [/Users/igor/Projects/.worktrees/mobile-ui-ddc7 stack=none] while tmux has-session -t kilo-dev-mobile-ui-ddc7 exited 0.

Fix

Keep \n in the preserved set so tr leaves the newline alone for $(...) to strip. Other unsafe characters are still replaced (weird.name/xweird_name_x).

Verification

Against live slot state, before and after:

before: slot-1: … [/Users/igor/Projects/.worktrees/mobile-ui-ddc7 stack=none]
after:  slot-1: … [/Users/igor/Projects/.worktrees/mobile-ui-ddc7 stack=up]

bash -n clean. stacks still reports every running stack as covered, now on the worktree path rather than by accident of the fallback.

Found while enforcing the new slot rules across running dev stacks after #4826.

basename emits a trailing newline, and tr -c 'A-Za-z0-9_-' '_' rewrote it
to an underscore, so stack_session always returned a name with a spurious
trailing '_' that $(...) could no longer strip.

Consequences, all silent:

- stop_stack looked up the wrong tmux session, found nothing and returned
  early, so 'release' never actually stopped the worktree's dev stack --
  the guarantee the slot/stack unification was added to provide. Stacks
  outlived their slots.
- status always printed 'stack=none' even with the stack up.
- stack_is_covered never matched on the recorded worktree, leaving only
  the owner-name-prefix fallback. A slot whose owner name does not start
  with the worktree basename made a live stack look uncovered, so
  'stacks --reap' would pnpm dev:stop a running E2E.

Keeping \n in the preserved set fixes all three; other unsafe characters
are still replaced.
@iscekic iscekic self-assigned this Jul 28, 2026
@kilo-code-bot

kilo-code-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The one-line fix correctly keeps \n in the tr preserved set so the trailing newline from basename is stripped by $(...) instead of being rewritten to _, restoring correct behavior for stop_stack, status, and stack_is_covered.

Files Reviewed (1 files)
  • .kilo_workflow/e2e-slot.sh

Reviewed by claude-sonnet-5 · Input: 12 · Output: 2.4K · Cached: 200.8K

Review guidance: REVIEW.md from base branch main

@iscekic
iscekic enabled auto-merge (squash) July 28, 2026 16:42
@iscekic
iscekic merged commit e5fb4f2 into main Jul 28, 2026
15 checks passed
@iscekic
iscekic deleted the fix-e2e-slot-stack-session branch July 28, 2026 16:43
iscekic added a commit that referenced this pull request Jul 28, 2026
…stack (#4842)

stop_stack set a global $wt, then called stack_is_covered, whose loop
reassigns the same global once per slot directory. On return $wt held the
LAST slot's worktree, so '(cd $wt && pnpm dev:stop)' stopped whichever
section sorted last. $sess stayed correct, so the has-session guard
confirmed our own stack was up and then stopped someone else's.

Observed live: releasing file-preview-2975's slot killed
kilo-dev-hermes-mem-c716 while leaving kilo-dev-file-preview-2975 up,
with that section's verifier still mid-round.

dev:stop is not at fault - it resolves its target from
'git rev-parse --show-toplevel' in the process cwd. It was handed the
wrong cwd.

Latent until #4836: stack_session previously returned a mangled name, so
has-session always failed and stop_stack returned before the cd. Fixing
the name made the guard pass and exposed the shadowing.

Declares local in stack_is_covered, stop_stack and reap, and records the
incident under learnings/.
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.

2 participants