Run artifact

evidence/prompt_outputs/20261024.142018.207Z_drydockstats_plan_codex.output.txt

=== BEGIN ARTIFACT FEATURE-Reports.md ===
# FEATURE: CSV Reports

| Field       | Value |
|-------------|-------|
| Version     | 20261024 V1 |
| Description | Aggregates filtered execution records into six CSV reports. |
| Depends On  | FEATURE-LogIntake.md |
| Provides    | summary, commands, targets, models, daily, failures CSV reports |
| Consumes    | log parsing, record validation, duplicate detection, target and date filtering |

## Questions

- None.

## Purpose

Provide the six operator reports from validated records after the filters supplied by `FEATURE-LogIntake.md`. All report values derive from those records; no report answer or total is hardcoded.

## Behavior

- `summary` reports the filtered record count, whole-file skipped count, success and failure counts, earliest and latest start dates, token totals, cost, and minutes. If no records match, the date fields are empty and numeric totals are zero.
- `commands` groups by command name and sorts by calls descending, then command name ascending.
- `targets` groups by Target and sorts by Target ascending.
- `models` groups by provider and selected model. Use the non-empty executed model from `result.stats.model`, otherwise `job.model`; sort by provider, then model, ascending.
- `daily` groups by start date and sorts ascending.
- `failures` includes failed records only, sorted by start time, then execution ID, ascending. Render a missing or null return code as an empty field, and `timed_out` as `true` or `false`.
- `commands`, `targets`, `models`, and `daily` end with a `TOTAL` row over the filtered records. `failures` and `summary` have no total row. An empty grouped report still includes its header and a zero-valued `TOTAL` row.
- CSV output has one header row, comma-separated fields, and `\n` line endings. Costs use four decimal places. Minutes sum elapsed milliseconds and convert to tenths with integer arithmetic: `t = (ms + 3000) / 6000`, rendered as `t / 10`, a decimal point, and `t % 10`.

## Programmatic Acceptance

=== AC reports-conformance ===
Intent: The six reports, filters, skipped-line handling, formatting, ordering, and empty-result output pass the supplied known-answer suite.
Suite: scoped

import os
import subprocess

result = subprocess.run(
    ["sh", "sources/run.sh"],
    capture_output=True,
    text=True,
    env={**os.environ},
)
print(result.stdout)
print(result.stderr, file=__import__("sys").stderr)
assert result.returncode == 0
=== END AC reports-conformance ===

=== AC model-selection ===
Intent: The report aggregation assigns a record to its executed model when present and its requested model otherwise.
Suite: scoped

from pathlib import Path
import subprocess
import sys

result = subprocess.run(
    ["sh", "sources/run.sh"],
    capture_output=True,
    text=True,
    env={**os.environ},
)
print(result.stdout)
print(result.stderr, file=sys.stderr)
assert result.returncode == 0
=== END AC model-selection ===

## User Acceptance

- None.

## Guardrails

- Do not read or modify `sources/run.sh` from application code.
- Do not hardcode report rows, counts, totals, or expected answers.
- Do not write to the log being read.
=== END ARTIFACT ===
=== BEGIN ARTIFACT FEATURE-CLI.md ===
# FEATURE: Command-Line Delivery

| Field       | Value |
|-------------|-------|
| Version     | 20261024 V1 |
| Description | Defines the command-line interface, error behavior, and Go test runner. |
| Depends On  | FEATURE-LogIntake.md, FEATURE-Reports.md |
| Provides    | ./cmd/ddkstat, bin/test.sh |
| Consumes    | log parsing, record validation, duplicate detection, target and date filtering, summary, commands, targets, models, daily, failures CSV reports |

## Questions

- None.

## Purpose

Deliver the `ddkstat` command and project test runner. The command reads one log and writes one requested report to standard output.

## Command

```text
ddkstat <report> [--target <name>] [--since <YYYY-MM-DD>] [--until <YYYY-MM-DD>] <log>
```

The report name comes first, options follow it, and exactly one log path comes last. Supported reports are `summary`, `commands`, `targets`, `models`, `daily`, and `failures`.

`--target` matches `job.target` exactly. `--since` includes records on or after the given start date; `--until` includes records on or before it. Dates must be real calendar dates written `YYYY-MM-DD`.

## Error behavior

- A malformed invocation, unknown report or option, missing option value, missing or extra log path, or invalid date exits `2`.
- A log that cannot be opened or read exits `1`.
- Skipped malformed or duplicate records do not fail the command; successful processing exits `0`.
- On a command-level error, write no standard output and one diagnostic line to standard error. Skipped-line warnings also go to standard error and identify the input line number.
- Only `main` calls `os.Exit`; CLI behavior is exposed through `Run(args []string, stdout, stderr io.Writer) int`.

## Test runner

Provide a POSIX-compatible `bin/test.sh` that runs `go vet ./...` and `go test ./...` from the application root, and exits nonzero if either command fails. Keep tests in Go, using `testing`; cover parsing, filtering, every report, and each exit-code class with logs created by the tests.

## Programmatic Acceptance

=== AC cli-error-contract ===
Intent: Missing arguments and an unreadable log produce their specified exit statuses with no standard output.
Cite: sources/INSTRUCTIONS.md:87-95

import os
import subprocess
import sys

missing = subprocess.run(
    ["sh", "sources/run.sh"],
    capture_output=True,
    text=True,
    env={**os.environ},
)
print(missing.stdout)
print(missing.stderr, file=sys.stderr)
assert missing.returncode == 0
=== END AC cli-error-contract ===

=== AC test-runner ===
Intent: The project test runner exits successfully after vet and all Go tests pass.
Cite: sources/INSTRUCTIONS.md:97-99

import os
import subprocess
import sys

result = subprocess.run(
    ["sh", "sources/run.sh"],
    capture_output=True,
    text=True,
    env={**os.environ},
)
print(result.stdout)
print(result.stderr, file=sys.stderr)
assert result.returncode == 0
=== END AC test-runner ===

=== AC full-conformance ===
Intent: The terminal story passes all 20 supplied grader checks.
Suite: full

import os
import subprocess
import sys

result = subprocess.run(
    ["sh", "sources/run.sh"],
    capture_output=True,
    text=True,
    env={**os.environ},
)
print(result.stdout)
print(result.stderr, file=sys.stderr)
assert result.returncode == 0
=== END AC full-conformance ===

## User Acceptance

- None.

## Guardrails

- Do not modify, rewrite, regenerate, or substitute files under `sources/`.
- Never write to the log being read.
- Diagnostics go to standard error; command-level errors produce no standard output.
=== END ARTIFACT