Skip to content

test(web): H2 real transcript corpus + parser-fidelity tests (WI-123) - #671

Closed
thedancingdeveloper wants to merge 1 commit into
feat/terminal-attach-f2-pong-racefrom
feat/terminal-attach-h2-corpus
Closed

thedancingdeveloper wants to merge 1 commit into
feat/terminal-attach-f2-pong-racefrom
feat/terminal-attach-h2-corpus

Conversation

@thedancingdeveloper

Copy link
Copy Markdown
Contributor

Fifth PR of the terminal-attach-budget initiative (WI-121). Stacked on #670 (F2); all land on feat/terminal-attach-budget.

What this adds (H2 / WI-123)

The ground-state trimming both the server ring and the client cache rely on was only tested against synthetic line\n data. This adds a corpus of real PTY captures and a fidelity suite over it.

  • web/tests/fixtures/transcripts/ (gzipped, sanitised):
    • claude-code-tui — a curses alt-screen redraw stream (cursor addressing, SGR, OSC title, box/emoji UTF-8). It emits no line feeds — the seamless case where raw-byte trimming has nothing to align to.
    • shell-plain — coloured recursive ls + multibyte box/CJK/emoji chars.
    • cargo-build — real cargo build -v colour output with \r.
    • README.md documents the intended production source (GET /api/history/:id/download from a dev stack) and how these local stand-ins were captured.
  • scripts/capture_transcript.py — a pty.fork capture helper.
  • scripts/sanitise_transcript.py — rewrites home paths / tokens / JWTs / emails to inert placeholders and asserts no secret pattern survives before a fixture is committed.
  • src/__tests__/transcriptFidelity.test.ts — over each corpus at 4 KiB cut offsets, groundStateReplayStart / prepareReplayTail / sliceForReplay pick a start never inside an escape or on a UTF-8 continuation byte (just past a \n, or start-of-stream), and the kept tail is byte-for-byte the source suffix.

Scope note

The plan's xterm serialize()-compare fidelity and the parse-rate baseline both need @xterm/addon-serialize. Rather than add a test-only copy here, they fold into F5 (WI-129), where that addon becomes a real app dependency. This PR delivers the corpus, sanitiser, and the ground-state fidelity that F5 and H3 build on.

The alt-screen corpus makes a real limitation explicit: a newline-free stream has no seam the raw-byte trim can prove is ground state, so it falls back to replaying as-is — exactly what F5's serialized-state restore closes.

Verification

  • pnpm vitest928 passed (15 new).
  • ruff check + ruff format --check clean on the scripts; scripts/check_docs.py clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UtEFLJAhLiq4NfZCN2vuBb

The ground-state trimming that both the server ring and the client cache rely on
was only ever tested against synthetic `line\n` data. Add a corpus of real PTY
captures and a fidelity suite that exercises it against genuine escape
sequences, SGR colour, cursor moves, alt-screen switches and UTF-8.

- web/tests/fixtures/transcripts/: claude-code-tui (curses alt-screen redraws:
  cursor addressing, SGR, OSC title, box/emoji UTF-8 — a seamless, newline-free
  stream), shell-plain (coloured recursive ls + multibyte chars), cargo-build
  (real `cargo build -v` colour output with \r). Gzipped; a README documents the
  intended production source (GET /api/history/:id/download from a dev stack)
  and how these local stand-ins were captured.
- scripts/capture_transcript.py: a pty.fork capture helper.
- scripts/sanitise_transcript.py: rewrites home paths/tokens/JWTs/emails to inert
  placeholders and ASSERTS no secret pattern survives before a fixture is
  committed.
- src/__tests__/transcriptFidelity.test.ts: over each corpus at 4 KiB cut
  offsets, groundStateReplayStart / prepareReplayTail / sliceForReplay pick a
  start that is never inside an escape or on a UTF-8 continuation byte (just past
  a line feed, or start-of-stream), and the kept tail is byte-for-byte the source
  suffix. The alt-screen corpus documents the no-newline-seam case where raw-byte
  trimming can only fall back — the gap F5's serialized-state restore closes.

The xterm serialize()-compare fidelity and the parse-rate baseline (both need
@xterm/addon-serialize) fold into F5 (WI-129), where that addon becomes a real
dependency, rather than adding a test-only copy here.

Verification: pnpm vitest 928 passed (15 new); ruff check + format clean on the
scripts; scripts/check_docs.py clean. WI-123.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UtEFLJAhLiq4NfZCN2vuBb
@thedancingdeveloper

Copy link
Copy Markdown
Contributor Author

Cleanup: superseded by the single promotion PR #676. All of this work is already integrated into feat/terminal-attach-budget and is reviewable there per-commit (each commit is one initiative item with a full message). Closing to keep the initiative to one PR; the commit is preserved.

@thedancingdeveloper
thedancingdeveloper deleted the feat/terminal-attach-h2-corpus branch September 9, 2026 20:59
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