Skip to content

[CTX-0072] feat(cli): implement inspect-only watch mode per accepted design (#121) - #129

Merged
Xuepoo merged 1 commit into
mainfrom
ctx-0072/watch-mode
Sep 18, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
ctx-0072/watch-mode

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the accepted inspect-only --watch design (issue #121, child of #72) for bitty-devtools.

Task / RFC / Issue

  • Priority: P2
  • Area: devtools
  • Labels: feat, P2, area:devtools
  • Milestone: v0.1.0
  • RFC: CTX-0067 design proposal PX-0327/PX-0328 (amendment A4)
  • Task: CTX-0072
  • Review: independent APPROVE recorded as PX-0376 (reviewer ctx-0072-reviewer-0918, checkpoint 01M2SVHN); bin-routing disposition PX-0377; follow-up risk PX-0378
  • Closes feat(cli): design inspect-only watch mode (rate/cancel) #121

Scope

Exactly 3 files (approved blobs unchanged):

File Blob
src/cli.ts 392e9918
src/inspection.ts 11a0fe48
tests/cli.test.ts 541dd08d

Behavior (A4 surface)

  • inspect (--plugins | --subscriptions --plugin | --budgets --plugin) [--generation] [--json] [--watch] [--interval-ms] [--max-ticks]; without --watch the single-shot path is unchanged.
  • Bad selector/flag/range exits 2; --watch mixed with trace flags exits 2; presence-only --watch; interval default 2000, floor 1000, ceiling 60000.
  • One inspect dispatch per tick via existing dispatch/dispatchLive; debug.inspect pinned only (src/inspection.ts narrowed to reject debug.trace/debug.control).
  • ScopeDenied exits 7 and terminates the loop with zero further ticks; RateLimited skips the tick and settles as exit 6 only when the loop ends with zero complete frames, exit 0 once >=1 frame.
  • Per-tick RateLimiter.check + peer re-verify; one AbortController bridged to SIGINT/close/disconnect; partial frames discarded, never rendered/spooled/retained; --max-ticks caps complete frames.
  • Per-tick bounds (MAX_CELL_CHARS 120, MAX_JSON_DEPTH 8, MAX_PLUGINS 256, MAX_SUBSCRIPTIONS 32, strict InvalidResult), no cross-tick retention; ±10% jitter per tick.

Evidence (qualified)

  • bun test tests/cli.test.ts: 69 pass / 0 fail, 350 expects; full bun test: 444 pass / 0 fail, 3536 expects.
  • tsc --noEmit clean; build clean (dist/cli.js, dist/cli.d.ts); prettier 3.9.6 check clean; oxlint clean (1 pre-existing inspection.ts unused-PanelId warning already at HEAD); markdownlint-cli2 0 issues; git diff --check clean.
  • Fake-transport only: all new tests use RecordingTransport / injectResponsePayload (tests/cli.test.ts:65-79 and the W-suite); no live sockets, no synthesized input, no replay/escalation; W10 prototype spies assert zero trace/control/automation calls.

Known follow-up (non-blocking, documented per PX-0377 / PX-0378)

  • The installed bin (bin/bitty-devtools.ts:9,14) calls the sync runCli, so --watch (and trace --wire-trace) is unreachable from the installed CLI until bin is routed to the async/live entry; empirically inspect --plugins --watch exits 2. Same pre-existing gap as merged [CTX-0071] feat(devtools): implement wire-trace flag per accepted design (#120) #127 (CTX-0071); correctly scoped out of CTX-0072 per PX-0377.
  • Production SIGINT wiring of WatchHooks.onSignal currently has no production caller (test-only seam); to be wired in the same follow-up task per PX-0378.

Docs sync

Tracked separately in bitty-terminal-docs CTX-0038; code merge proceeds with docs tracked separately while keeping Closes #121.

Commit hook

Lefthook pre-commit + commitlint commit-msg hooks pass (no bypass, no bunx, no installs).

@Xuepoo Xuepoo added this to the v0.1.0 milestone Sep 18, 2026
@Xuepoo Xuepoo added feat feature area:devtools devtools area P2 Priority: medium labels Sep 18, 2026
@Xuepoo
Xuepoo merged commit fe91727 into main Sep 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:devtools devtools area feat feature P2 Priority: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): design inspect-only watch mode (rate/cancel)

1 participant