The block needs `cli.Run` and `cli.Register`, six named tests, and `main.go` wired to call `Run`. The existing `ParseArgs`, `logread.Read`, and filter functions already provide the pieces. Writing the implementation now.Now the tests. The six named acceptance tests go in one file, plus a few finer cases (writer error, success-path output, unregistered report). They read state back through the writer and the exit code rather than matching message text.Next, `main.go` becomes the only `os.Exit` caller, delegating to `cli.Run`.The cli-exit step is implemented. All six declared acceptance tests pass, and `sh bin/test.sh` exits 0. `sh sources/run.sh` exits 1, but only because the report writers belong to later blocks. **Changes** - `internal/cli/run.go` (new): `Run(args, stdout, stderr) int` and `Register(name, fn)`. - A usage error writes one line to stderr and returns 2. - A log that cannot be opened or read writes one line and returns 1. - Otherwise it applies `ByTarget` then `ByDateRange` and calls the registered writer. The writer's output is buffered and flushed to stdout only on success. A writer error returns 1 with stdout untouched. - An unregistered report returns 0 with no output. - Skipped count is the whole-file count, so filters do not change it. - `internal/cli/run_test.go` (new): the six declared tests, plus finer tests for skipped count vs. filters, stdout on success, writer error, and unregistered reports. They check exit codes, stdout bytes, and the records and skipped count the writer receives. - `cmd/ddkstat/main.go`: now `os.Exit(cli.Run(os.Args[1:], os.Stdout, os.Stderr))`. It is still the only `os.Exit` caller. The spec makes `main` the entry point, so I wired it here. **Checks** - `gofmt -l`: clean. `go vet ./...`: clean. - `go test -race ./internal/cli -run TestRun -v`: all 9 `TestRun*` tests pass. - `sh bin/test.sh`: exit 0. - `sh sources/run.sh`: 7 passed, 13 failed (of 20). The 7 passing checks are E1 and U1 through U6. The 13 failing checks are A1–A6, B1–B5, and C1–C2. They fail because no report writer is registered yet, so nothing is written to stdout. Those reports are the work of later blocks. The grader's stderr also confirms the expected skip count of 3 for the sample log. **Choices I made** - `Register` overwrites an existing writer for the same name rather than panicking. Duplicate registration is therefore silent. - The usage line is a fixed one-line summary and does not include the `ParseArgs` error text. - The unregistered-report test uses `daily`, and the writer-error test uses `targets`. Tests share the global registry, so this assumes no test in this package registers `daily`. RESULT: SUCCESS FILES CHANGED: - cmd/ddkstat/main.go - internal/cli/run.go - internal/cli/run_test.go SUMMARY: Implemented `cli.Run` and `cli.Register` with exit codes 0, 1, and 2. Buffered report output is written to stdout only on writer success. `main` delegates to `Run`. The six declared acceptance tests pass, along with finer tests. `bin/test.sh` exits 0. `sources/run.sh` still fails 13 of 20 checks because report writers from later blocks are not yet registered. BLOCKERS: - None for this step. The remaining `sources/run.sh` failures depend on the report stories in later blocks. [{"spec":"FEATURE-CliExit.md","severity":"Low","subject":"Register behavior on duplicate report name","decision":"Register overwrites any writer already registered under the same name, without panicking. Duplicate registration is silent. Is that acceptable, or should it fail loudly on replan?"}]