Skip to content

CLI port: the TypeScript pnpm run cli surface as Rust subcommands (family (c) of #867) #1184

Closed

Description

@chappie-daemon

Parent: #867 (family (c) of three; slice 1 — HTTP admin routes + console parity — is the job that carries #867 itself)
Milestone: Phase 5 · Labels: rewrite, rust, factory

Port the TypeScript CLI surface (pnpm run cli) to nostream-cli as Rust subcommands: help text, exit codes, and the --all/--force/--older-than/--kinds clean-db semantics ported exactly.

Measured at f01cb5f3 (recon for job 032-admin-console-parity):

  • 3,216 LOC across 28 files in src/cli/ — the issue's own figure, confirmed.
  • 19 test files under test/**/cli*; the suite runs as pnpm test:cli → mocha 'test/unit/cli/**/*.spec.ts'.
  • crates/nostream-cli exists with four integration targets (config_cli.rs, import_cli.rs, migrate_cli.rs, migrate_cli_unsupported.rs) and covers three commands only: config validate, import, migrate pg-to-lmdb. There is no start, stop, setup, info, update, export, seed or invite.
  • Oracle it inherits: the 19 TS CLI specs re-expressed as Rust integration tests, plus scripts/verify-cli-build.js — the pattern the three existing targets already use.

Not blocked on slice 1 of #867; it may run in parallel, but it will collide with #867 in crates/nostream-cli only if that job touches the CLI (it does not).

Estimate basis: 3,216 LOC across 28 files with 19 inheritable specs — price it as its own job from the measured units in .factory/estimates.md; #867's $5.00 headline covers all three families and must not be inherited.

Note on closing: this repository's default branch is main, so Closes #N is inert on a PR targeting rewrite/main — the issue is closed by hand with the merge sha.

Activity

  1. added
    rewrite
    rust
    factory
    on Nov 19, 2026
  2. chappie-daemon commented on Nov 19, 2026

    @chappie-daemon
    CollaboratorAuthor

    Filed from the #867 scope gate in job 032; estimated pending its own scoping job.

  3. victrvondoom commented on Nov 19, 2026

    @victrvondoom

    I can take a bounded slice of this CLI port; please assign me if useful. An efficient path is to reuse the existing Rust subcommand structure, map one command family at a time against the 19 TypeScript CLI specs, and preserve help text and exit-code behavior with integration tests before removing any legacy entry point. The less-obvious factor is that parity is not just matching command names: clean-db option interactions and process exit codes are observable API behavior, so the existing tests are a better oracle than a bulk rewrite of the 3,216 LOC.

  4. chappie-daemon commented on Nov 20, 2026

    @chappie-daemon
    CollaboratorAuthor

    Job 034-cli-port opened at base 982e6759 (post-#1197). Recon dispatched; the estimate is set at spec stage from the measured units and will not inherit #867's $5.00 headline.

    Two cost constraints carry into this job from 033, both measured rather than precautionary: a separate CARGO_TARGET_DIR per stage (rounds sharing one cost 033 real time), and CARGO_PROFILE_TEST_DEBUG=0 CARGO_PROFILE_DEV_DEBUG=0 before the first build (44 GB of debug symbols for one job).

  5. cameri commented on Nov 20, 2026

    @cameri
    Owner

    @victrvondoom Thank you for your interest but at this time the issue is being handled by a coding agent automatically.

  6. chappie-daemon commented on Nov 20, 2026

    @chappie-daemon
    CollaboratorAuthor

    Scope decision, taken from the recon rather than absorbed into the estimate.

    In scope — the operator surface: config (list, get, set, validate, env), start, stop, setup, info, update, export, import, seed, invite, clean-db, --version, and the usage-error class at exit 2.

    Out of scope — dev's nine subcommands. src/cli/commands/dev.ts is a wrapper around the TypeScript toolchain: db:reset shells to pnpm run db:migrate:rollback, seed:relay to pnpm run db:seed, docker:clean to docker system prune and docker volume prune, and six of the nine are pnpm run test:*. That is this repository's development loop, not the relay's operator interface. It stops existing when the TypeScript line is retired at #869, so porting it to Rust would be porting scaffolding in order to delete it — a second implementation of commands whose only purpose is to drive the first one.

    The one real operation hiding inside it keeps its semantics: dev db:clean calls runCleanDb, and it becomes clean-db, the top-level command that deletes events by predicate. That is why the storage seam this job has to build — delete-by-predicate where the retention API takes a keep-list — stays in scope.

    What the port therefore promises: every command an operator runs to install, configure, start, inspect, export, seed, invite into, upgrade and clean a relay, with the capture's exit codes and output streams, and nothing that exists only to drive the toolchain being replaced.

    The estimate is being re-priced against this cut before the build starts.

  7. chappie-daemon commented on Nov 20, 2026

    @chappie-daemon
    CollaboratorAuthor

    Spec written — 1,198 lines, 29 requirements, 58 acceptance criteria, 62 Values rows; cost re-based to $17.40 (lifecycle half $11.96 / storage half $11.10 if it were split, which costs about $5.66 more). Red-team pass running against 982e6759.

    Scope, after the cut: the eight commands, clean, clean-db as a top-level command, config list/get/set/validate/env, --version and the usage-error class at exit 2. dev's nine subcommands are out — six are pnpm run test:* and the rest shell pnpm db:* and docker prune, the TypeScript development loop that retires at #869.

    Two compatibility claims are decided and priced rather than inherited: which stream and exit code each error class uses (help and Unknown command: on stdout at 0/2, a command's own validation on stderr at 2 or 1 by the capture's split), and why clean-db's delete predicate cannot be served by the retention keep-list.

  8. chappie-daemon commented on Nov 20, 2026

    @chappie-daemon
    CollaboratorAuthor

    Job 034-cli-port: review rounds exhausted, extension requested. Round 3 at f552d493 returned security PASS, ux PASS, with code and architecture CHANGES; the builder budget (5 resumes) is spent. Every record-level finding is repaired and pushed (ca92b835): the ADR now carries D1–D14 — including the clean-up delete's batch curve with its measured ends and the bootstrap's legacy-settings.json guard — and V45/AC56 name the same set.

    Outstanding, all measured in round-3/review-code.md: the restart's spawn failure drops the Updated line; the NODE_ENV=production warning still exits 101 on a full stderr; StorageError::Partial's two remaining arms are untested; PostgresBackend::from_env is now uncalled; config set lacks the capture's --validate/--no-validate; four branches un-inverted.

    Gate at the head: 1 709 passed / 0 failed / 7 ignored, fmt, both clippy passes, release build, static-review 0 findings, and the capture's docs spec 6 passing.

  9. chappie-daemon commented on Nov 20, 2026

    @chappie-daemon
    CollaboratorAuthor

    Extension granted by the operator (/extend_034, 2026-11-20T22:24:26Z). The job returns to build with a fresh resume budget (5) at round 3; the builder continues in its own context, not a fresh start, and the next review is round 4.

    The pass is scoped to five measured code items and four inversions (rework-4.md in the job folder). One is narrowed by an independent measurement at ca92b835: the NODE_ENV=production warning's exit 101 is a panic before the delete — three rows survive it — so the fix is the write path alone and the warning's ordering stays as the capture has it.

  10. chappie-daemon commented on Nov 21, 2026

    @chappie-daemon
    CollaboratorAuthor

    PR opened: #1203 — the CLI port is built, reviewed over five rounds and approved. Head fe62cdc4, 60 files, +11,432/−409.

    The approver's verdict is APPROVE at fe62cdc4: 108 targets, 1 714 passed / 0 failed / 7 ignored on its own run, 21 criteria probed by hand, AC56 judged against all fourteen decisions, and git merge-tree clean against origin/rewrite/main. Two obligations carry to the merge job rather than blocking it: CI's Postgres parity step is where AC53's arm runs, and AC58's PR-title half is satisfied by the title. Merging is the operator's call.

  11. chappie-daemon commented on Nov 21, 2026

    @chappie-daemon
    CollaboratorAuthor

    Review budget spent with two lenses holding CHANGES — extension requested. PR #1203 is open at 9d718744; round 8's five lenses returned code PASS, ux PASS, performance PASS, with security and architecture holding CHANGES and no builder resume left.

    What remains is small and precise: one false sentence about unterminated quotes in env_file.rs (node keeps A="abc # def whole where the port answers "abc) plus one pin; the three config env readers building a second Environment the context already holds; the pool rule for is_vanished living in an impl comment instead of the trait; and the .env two-view decision sitting under D8's --data-dir heading unnamed by the preamble. Gap: 1 724 passed / 0 failed / 7 ignored over 108 targets at the head.

  12. chappie-daemon commented on Nov 21, 2026

    @chappie-daemon
    CollaboratorAuthor

    Approver: ESCALATE on the dependency surface; every criterion it could exercise passes at 7c5c53ea. PR #1203.

    The approver ran the oracle itself (108 targets, 1 725 passed / 0 failed / 7 ignored), fmt, both clippy passes, the release build, git merge-tree against the base (clean), probed the criteria that can be run against the built binary (AC1–AC14, AC25, AC36–AC39, AC41, AC44, AC49, AC55, AC57, AC58, AC59), read the rest against their cases, and re-measured the five external findings — each closed and each answering the finding rather than its wording.

    What it escalated: bech32, flate2 and xz2 (lzma-sys compiles C), the Cargo.lock they bring, the two CI steps that run the parity and Windows targets, and three import_cli expectations rewritten for R1 and R5. All required by the spec; a dependency surface is a person's call.

    Nine rounds; the last three produced no code defects, only false sentences about code. AC53's Postgres arm is CI's (checks.yml:281), and AC44's own 5/4 fixture is not what the branch's case builds — the path and counts are verified, the fixture is recorded as a gap rather than claimed.

  13. chappie-daemon commented on Nov 21, 2026

    @chappie-daemon
    CollaboratorAuthor

    Merged as ff04544 into rewrite/main. The CLI surface — eight commands, clean/clean-db, config list|get|set|env — ships in crates/nostream-cli with 1 725 tests passing over 108 targets, one Environment::load per command, and ADR 0015 carrying fourteen decisions.

    Nine review rounds, an operator extension, and one external review's five findings, all closed. Deferred and tracked rather than carried: #1205 (the NOSTREAM_XZ_THREADS gap), #1201, #1193, #1194.

  14. chappie-daemon commented on Nov 21, 2026

    @chappie-daemon
    CollaboratorAuthor

    Cost: expected $17.40, actual $13.04 (−25.1%) — 52 sessions, 9.6M in / 3.8M out / 929.5M cache-read, 33.18h summed wall.

    What was measured: nine review rounds and eleven builder passes. Rounds 1–5 found 21 real defects (an overflow panic at i64::MAX, a hard delete from a fabricated kind, a lost exit code, a write transaction holding LMDB's writer for 18.5 s at 160 001 rows). Rounds 6–9 found no code defects and eleven false sentences about code — three of them in the ADR and module docs, one a pin that could not fail. The five findings of the external review were all real and all closed.

    Why the estimate was 26% high: it priced a round at $0.85, which only a cold five-lens round reaches. A scoped round costs $0.20–0.35, and builder passes came in at $0.10–0.30 — so nine rounds ran for the price of seven.

    Process notes worth keeping: (1) a claim-heavy pass should write only what it measured, because every inferred claim is a round waiting to be spent — build.md:214 is where one was born; (2) spend an inversion on the newest pin before the newest paragraph, since that is what caught a test that could never fail; (3) the external review arrived after the first approval and cost four extra rounds — sequence an external read before the approve stage, not after.

  15. removed their assignment
    on Nov 21, 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

    factoryrewriterust

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions