Repository navigation
Description
This was generated by AI during triage.
Problem Statement
thirdshift's CLI orchestrator and Console server are written in Rust (ADR-0001, ADR-0026), while the documentation generator (site/generate-docs.mjs), Playwright browser suite (site/tests/), and inline Console client scripts use Node/JavaScript. Maintaining Rust and JavaScript side by side splits the repository across two toolchains and prevents sharing types end-to-end between CLI --json output, /api/v1/* endpoints, OpenAPI schemas, the Console browser UI, and Playwright tests. Meanwhile, TypeScript offers true discriminated unions with compile-time exhaustiveness checking (satisfies never), near-instant typechecking and test execution in fresh worktrees, standalone Linux executable compilation via bun build --compile, and high coding-agent fluency. Without a concrete vertical-slice prototype in TypeScript, the Day shift cannot empirically compare worktree build/test speed, binary size, subprocess/signal handling, full-stack Console velocity, and Pickup model checking against the Rust binary (and the Go prototype in #1830).
Solution
Build an isolated TypeScript (bun build --compile) vertical-slice prototype of thirdshift covering the core unattended loop (embedded Factory skills, a Ticket run with Worktree, Harness process-group management, Delivery and CI Repair loop, and a Pickup run with the ADR-0017 reservation protocol and an in-test BFS state-space model checker) plus a full-stack Console + /api/v1/* + CLI --json + OpenAPI + Playwright slice sharing one TypeScript schema definition, and produce a reproducible benchmark and comparison report for the Day shift.
User Stories
- As the Day shift, I want the TypeScript prototype isolated in its own directory and test-selection boundary, so that ordinary Rust Ticket runs and CI jobs are unaffected when the prototype is not touched.
- As the Day shift, I want the TypeScript prototype to compile via
bun build --compileinto a single standalone Linux executable with the Factory skills and Console assets embedded, so that it can be compared directly against the Rust binary's self-contained deployment contract (ADR-0001,ADR-0003). - As the Day shift, I want the TypeScript prototype to model Run, Claim, Delivery, and CI check states as discriminated unions with compile-time exhaustiveness (
satisfies never) and zeroany/ascasts, so that I can compare TypeScript's state-machine safety directly against Rust'senums and#![deny(clippy::wildcard_enum_match_arm)]. - As the Day shift, I want the TypeScript prototype to run a Ticket run from an Issue URL—performing pre-flight checks, applying a Claim (
in-progress), creating a Worktree with linked Factory skills, running a streaming JSON Harness session withSIGINT/SIGTERM/SIGKILLprocess-group escalation, and driving Delivery and the CI Repair loop—so that the core unattended flow is verified end-to-end. - As the Day shift, I want the TypeScript prototype to implement a Pickup run using the
ADR-0017origin-ref reservation and Claim protocol, backed by an in-test bounded BFS state-space model checker inbun test, so that distributed reservation verification can be compared against Rust'sstateright. - As the Day shift, I want the TypeScript prototype to include a full-stack Console slice—one shared schema/type definition driving a CLI
--jsoncommand, an/api/v1/*route, an OpenAPI description (ADR-0026), a rendered Console Inbox/status view with typed client-side interactions, and a Playwright test—so that I can evaluate full-stack TypeScript unification against the current Rust + Node split. - As the Day shift, I want a reproducible benchmark runner and a written comparison report measuring cold/incremental typecheck, test, and
bun build --compiletimes, standalone binary size, memory footprint, subprocess/signal ergonomics, state-machine exhaustiveness, full-stack Console velocity, and Pickup model-checking speed against the Rust binary (and Spec: Go vertical-slice prototype and comparison against the Rust binary #1830), so that I can make an informed decision onADR-0001.
Implementation Decisions
- Prototype isolation and affected-test routing: The TypeScript prototype lives in its own isolated prototype directory with its own
package.jsonand stricttsconfig.json(strict: true, no unchecked indexed access). The repository's affected-test selector routes changes confined to the TypeScript prototype directory to its typecheck and test suite without running the full Rust suite, and ordinary Rust changes do not run the TypeScript prototype suite. - Standalone executable with embedded assets:
bun build --compilebundles the CLI entrypoint, Console HTTP server, embedded Factory skills, and Console client assets into a single executable binary. - Discriminated-union state machines: Every Run, Claim, Delivery, CI check, and Pickup state machine uses tagged discriminated unions with an explicit exhaustiveness helper (
assertNever(x: never): never) so adding a new state variant failstsc --noEmitat every unhandled branch. - Subprocess and process-group signal lifecycle: Child Harness sessions,
git, andghprocesses spawn in their own process group where applicable, streaming JSON lines and escalatingSIGINT→SIGTERM→SIGKILLto the process group on cancellation. - Pickup reservation and bounded BFS model checker: Pickup implements the
ADR-0017reservation and Claim protocol, and abun testmodel checker explores the bounded multi-host state space to verifyone dispatch per Ready generationandone claimed dispatch per Ready generation(and catch counterexamples on the unguarded protocol variants). - Shared-schema Console + API + CLI slice: A single schema module defines the Command/Inbox status payload and serves the CLI
--jsonflag, the HTTP/api/v1/*JSON route, the/api/v1/openapi.jsondocument, the Console HTML/client script, and the Playwright browser test with end-to-end compile-time type safety. - Empirical benchmark and research report: A benchmark script measures cold/incremental
tsc --noEmit,bun test, andbun build --compiletimes in a fresh worktree, compiled binary size, and source line counts against the equivalent Rust modules, writing a structured comparison report to the research documentation directory without modifyingADR-0001.
Testing Decisions
- Primary testing seam: End-to-end CLI tests exercise the TypeScript prototype against temporary git repositories (
originand clone) and fakeghand Harness executables onPATH, asserting on observable git state, worktree files, fakeghrecorded calls, exit codes, and stdout/stderr. - Process-group signal test: An integration test verifies that interrupting a running Ticket run forwards
SIGINT→SIGTERM→SIGKILLto the fake Harness process group. - Bounded model-checking test:
bun testexecutes the bounded BFS state-space model checker forADR-0017, verifying both safety invariants on the current protocol and finding counterexample traces on the simplified variants. - Full-stack Console & API parity test: Automated tests verify CLI
--jsonand/api/v1/*parity against the generated OpenAPI specification and run a browser/Playwright check against the prototype Console page.
Out of Scope
- Porting the full Console surface, Security run, Architect run, Review run, Fix run, Triage run, or Experiments/Evals to TypeScript.
- Replacing the production Rust binary or modifying
ADR-0001inside this Spec. - Supporting Harnesses beyond a representative streaming JSON Harness in the prototype vertical slice.
Activity
[-]Prototype a TypeScript (bun build --compile) vertical slice of thirdshift and compare against the Rust binary[/-][+]Spec: TypeScript (bun build --compile) vertical-slice prototype and comparison against the Rust binary[/+]Measure standalone runtime memory after Spec review (#1831)
Return a generic Console error instead of the development page (#1831)