Skip to content

test(pty-tape): settle the prompt queue before Ctrl-T - #187

Merged
0thernet merged 2 commits into
mainfrom
fix/pty-tape-settle
Oct 10, 2026
Merged

0thernet merged 2 commits into
mainfrom
fix/pty-tape-settle

Conversation

@0thernet

@0thernet 0thernet commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Fixes the CI flake in real PTY: TAPE gestures echo range commands at 80x24 (expected "verse"; PR #185, Check run 38088154653). Also fixes a dawg race that turned up while proving it.

1. Test: waited on signals that arrive before the queue drains

The test typed seven lines (bars 8, two adds, two sections, track drums, track bass), then waited for:

  • the session to have 2 notes: true after line 3;
  • the header to say · bass: true from launch, because bass is the default track.

The CI frame shows exactly this: rev 3, header bass, no section row. Ctrl-T opened TAPE before section verse ran. #173's settle() was never used here. The fix: t.settle() before Ctrl-T (all input acted on, nothing running), then the old checks become plain assertions, and Ctrl-T uses t.type(). The TAPE tiles test had the same shape and gets the same fix.

I audited the other PTY tests that send several lines then wait. Each waits on the last line's effect, which is sound with the FIFO queue from #173.

2. dawg: TAPE keys typed ahead reduced from stale state

A TAPE key reduces from the landed score and playhead, but its commands go into the prompt queue. With commands still queued (an agent turn, a slow write, a loaded box), [ [ [ computed every shrink from the same loop. One press was lost, and the loop ended at 2 bars instead of 1. Typing ahead in a real session does the same. Now, while the queue is busy, a command-typing TAPE key waits its turn as a deferred step (PromptQueue items may be () => string[]). It reduces from what the lines before it left, and its commands run next. When the queue is idle, keys reduce immediately as before.

Proof

  • Deterministic adversary. A local-only 300 ms delay before each queued line, which widens the window the CI runner hit. origin/main: both TAPE-gesture tests fail with the CI error (Expected to contain: "verse"). Test fix only: those pass, but TAPE tiles fails (one-bar loop, the [ race). Final head: 6/6 pty-tape tests pass.
  • Stress (8 PTY files, 37 tests, 20 iterations, 16 CPU hogs, host-run heavy): origin/main 0/20; final head 0/20. The 37-test loop does not reach this race on this machine. The deterministic adversary above is the reproduction. Local bun run check on the final head: 4027 pass, 0 fail.

No assertions were weakened and no retries were added.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
dawg Ignored Ignored Preview Oct 10, 2026 11:01pm UTC

Request Review

@0thernet
0thernet enabled auto-merge (squash) October 10, 2026 22:09
@0thernet
0thernet force-pushed the fix/pty-tape-settle branch from 30ed262 to 837e274 Compare October 10, 2026 23:01
@0thernet
0thernet merged commit 11211f1 into main Oct 10, 2026
14 checks passed
@0thernet
0thernet deleted the fix/pty-tape-settle branch October 10, 2026 23:16
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.

1 participant