Skip to content

Spec: TypeScript (bun build --compile) vertical-slice prototype and comparison against the Rust binary #1831

Closed
5 of 5 issues completed

Description

@JacobStephens2

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

  1. 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.
  2. As the Day shift, I want the TypeScript prototype to compile via bun build --compile into 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).
  3. 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 zero any/as casts, so that I can compare TypeScript's state-machine safety directly against Rust's enums and #![deny(clippy::wildcard_enum_match_arm)].
  4. 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 with SIGINT/SIGTERM/SIGKILL process-group escalation, and driving Delivery and the CI Repair loop—so that the core unattended flow is verified end-to-end.
  5. As the Day shift, I want the TypeScript prototype to implement a Pickup run using the ADR-0017 origin-ref reservation and Claim protocol, backed by an in-test bounded BFS state-space model checker in bun test, so that distributed reservation verification can be compared against Rust's stateright.
  6. As the Day shift, I want the TypeScript prototype to include a full-stack Console slice—one shared schema/type definition driving a CLI --json command, 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.
  7. As the Day shift, I want a reproducible benchmark runner and a written comparison report measuring cold/incremental typecheck, test, and bun build --compile times, 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 on ADR-0001.

Implementation Decisions

  • Prototype isolation and affected-test routing: The TypeScript prototype lives in its own isolated prototype directory with its own package.json and strict tsconfig.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 --compile bundles 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 fails tsc --noEmit at every unhandled branch.
  • Subprocess and process-group signal lifecycle: Child Harness sessions, git, and gh processes spawn in their own process group where applicable, streaming JSON lines and escalating SIGINT → SIGTERM → SIGKILL to the process group on cancellation.
  • Pickup reservation and bounded BFS model checker: Pickup implements the ADR-0017 reservation and Claim protocol, and a bun test model checker explores the bounded multi-host state space to verify one dispatch per Ready generation and one 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 --json flag, the HTTP /api/v1/* JSON route, the /api/v1/openapi.json document, 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, and bun build --compile times 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 modifying ADR-0001.

Testing Decisions

  • Primary testing seam: End-to-end CLI tests exercise the TypeScript prototype against temporary git repositories (origin and clone) and fake gh and Harness executables on PATH, asserting on observable git state, worktree files, fake gh recorded calls, exit codes, and stdout/stderr.
  • Process-group signal test: An integration test verifies that interrupting a running Ticket run forwards SIGINT → SIGTERM → SIGKILL to the fake Harness process group.
  • Bounded model-checking test: bun test executes the bounded BFS state-space model checker for ADR-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 --json and /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-0001 inside this Spec.
  • Supporting Harnesses beyond a representative streaming JSON Harness in the prototype vertical slice.

Sub-issues

Sub-issues

5 of 5 Issues completed
Loading 5 sub-issues

Activity

  1. added
    enhancement
    ready-for-human
    on Nov 6, 2026
  2. changed the title [-]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[/+] on Nov 6, 2026
  3. added
    needs-triage
    and removed
    ready-for-human
    on Nov 6, 2026
  4. added
    ready-for-agent
    in-progress
    and removed
    needs-triage
    ready-for-agent
    on Nov 6, 2026
  5. removed
    in-progress
    on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions