# CLI implementation result

## Changed files

- `src/index.ts` re-exports `validateRollups`, `scoreRollup`, and `rankRollups`, plus every public type from `src/types.ts`. It has no side effects.
- `src/cli.ts` implements guarded CLI execution and exports `main`. It accepts one JSON input path with optional `--json` on either side, handles help and invalid arguments, reads/parses/validates/ranks input, reports failures only on stderr, and renders either pretty JSON or the required padded table.
- `test/cli.test.ts` adds subprocess tests using cleaned-up fixtures under `os.tmpdir()` for table output, both JSON flag positions, help, missing files, invalid JSON, validation errors, empty arrays, and quiet public-entrypoint imports.
- `artifacts/goal/batches/implementation/items/cli/result.md` records this work and its checks.

## Exports

`src/index.ts` exposes the frozen library API only: `validateRollups` validates unknown input and returns its `ValidationResult`; `scoreRollup` returns a scored rollup and factor breakdown; and `rankRollups` returns the score-descending, name-ascending ranked array. It also type-re-exports `Stage`, `ProofSystem`, `DataAvailability`, `Upgrades`, `Rollup`, `ValidationCode`, `ValidationIssue`, `ValidationResult`, `Factor`, `FactorScore`, `ScoredRollup`, and `RankedRollup` without runtime values or I/O.

`src/cli.ts` exports `main(args?)`, which writes the documented CLI result and returns `0` or `1`; its import guard is the only call site, so importing it does not execute the program. The CLI file is executable and has the required Node shebang.

## Checks run

- `node --check src/cli.ts && node --check src/index.ts && node --check test/cli.test.ts` — passed (Node v24.21.0).
- `git diff --check` — passed.
- `node --test test/cli.test.ts` — 0 pass, 7 fail. The checkout does not yet contain parallel-owned `src/rank.ts` or `src/validate.ts`. Every CLI subprocess fails module resolution for `src/rank.ts`; the public-entrypoint import fails module resolution for `src/validate.ts`. No fixture cleanup failures remain.
- `node src/cli.ts --help` — blocked before execution by missing `src/rank.ts` static import.
- `node src/index.ts` — blocked before execution by missing `src/validate.ts` static export target.

No deviation from `docs/architecture.md`.
