Run artifact

evidence/prompts/20261026.155116.930Z_drydockstats_build_claude.prompt.md

System Instructions

This prompt is divided into three sections:

  1. System Instructions (this section) — structural orientation only. Do not treat this

section as task input.

  1. Input Context — begins with the heading # Input Context. All blocks are wrapped in

<pblock> tags. Two block types:

guidance attribute carries context-specific instructions; content is in a fenced block.

rules, instructions, or group headers.

  1. Agent Task — begins with the heading # Agent Task. Defines your persona, constraints,

and required outputs. Read all input context before acting on this section.

Input Context

<pblock label="Build block job" kind="job">

Build block job

</pblock>

<pblock label="Stories in this block" kind="section">

Stories in this block

</pblock>

<pblock label="Files on disk" kind="section">

Files on disk in the build directory

These are the only imported files present on disk. Every other file named in this prompt is supplied as prompt context and is not on disk; read it here and do not report it as a missing input.

</pblock>

COMPASS - Target Orientation

<pblock filename="COMPASS.md" role="compass" path="/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats/COMPASS.md" guidance="Important: This is the core project intent, constraints, and guardrails. It should have presecedence in conflicts.">

# COMPASS: DrydockStats

## Compass

Build a command-line reporter for Drydock's LLM execution log, the Go executable `./cmd/ddkstat`,
as described in `sources/INSTRUCTIONS.md`. It reads a JSON Lines log, skips malformed and
duplicate lines without failing, and writes six CSV reports (summary, commands, targets, models,
daily, failures), each narrowed by optional Target and date filters.

Correctness is measured by `sources/run.sh`: it builds the executable with `go build` and makes
20 checks of exit code and standard output against `sources/llm_sample.jsonl`. The goal is every
check passing. The finished tool also runs against a real `logs/llm.jsonl`.

## Constraints

- Implement in Go 1.22 or newer with the standard library only. No third-party modules.
- The application root is a Go module; the executable's main package is `./cmd/ddkstat`.
- Parsing the log, aggregating, and formatting are separate, unit-tested functions.
- Diagnostics go to standard error and are never compared.

## Guardrails

- Do not modify, rewrite, regenerate, or substitute any file under `sources/`.
- Do not read `sources/run.sh` from application code, and do not hardcode a report row, a count,
  or a total. Every value comes from the log being read.
- Never write to the log being read.

## Verification Protocol

| Story kind | Command | Asserts |
|---|---|---|
| Every behavioral story | `sh bin/test.sh` | exit `0` |
| Terminal story (once, last) | `sh sources/run.sh` | exit `0` |

<!-- drydock:build-write-guardrail:start -->
## Build Write Guardrail

- Authorized build directory: `/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/build/DrydockStats`
- Authorized Target directory: `/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats`
- Build agents have permission to create, modify, and remove files required by the active build block inside these authorized directories.
- No path outside these authorized directories may be modified.
- Protected Drydock artifacts:
  - `/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats/blueprint/`
  - `/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats/MANIFEST.md`
  - `/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats/COMPASS.md`
  - `/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats/QuarterDeck/`
  - `/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats/evidence/`
<!-- drydock:build-write-guardrail:end -->

</pblock>

STACK - Technology HOW

<pblock filename="go_compact.md" role="stack" path="/mnt/c/Users/barlo/projects/drydock/Rigging/languages/go/go_compact.md">

<!-- Compacted from Rigging/languages/go/go.md sha256=aa96c7155b26f091e4f2ee9b7a47ff2202fc7c162254f2b8676779198c7147da on 2026-10-18 by Rigging maintenance -->

## Foundation Contract

The published shape of this foundation. It is built before every other foundation: a web server,
a database, or a CLI is built *into* this tree, this environment, and this test runner. Carried
verbatim into `go_compact.md`.

- source_root: internal/
- test_command: go test ./...
- environment: the module declared in `go.mod`; no vendored toolchain
- dependencies: `go.mod`

```
project/
  go.mod                  # module path; the Go toolchain version
  cmd/                    # one directory per binary, each package main
  internal/               # application packages; not importable outside this module
  bin/                    # launchers; each runs the toolchain, never a vendored copy
```

Application foundations add packages under `internal/`. The generated persistence library is a
separate module at `persistence/`, linked by the root `go.mod`.

### Native application layouts and fixtures

Initialize the root `go.mod` in the language foundation before the DATABASE block.
Use `cmd/app/main.go` for process startup, `internal/cli` for CLI behavior, and
`internal/appserver` for HTTP behavior. The root application module requires
`drydock.local/persistence v0.0.0` with `replace drydock.local/persistence => ./persistence`;
the generated persistence directory owns its nested module. Run both module test suites.

For a CLI, expose `Run(args []string, stdout, stderr io.Writer) int`, use a local
`flag.FlagSet` with `flag.ContinueOnError`, and test with `bytes.Buffer`. Only main calls
`os.Exit`. For HTTP, expose `NewHandler(...) http.Handler` using `net/http.ServeMux`.
Use `httptest.NewRecorder` and `httptest.NewRequest` for handler tests, or
`httptest.NewServer` with `t.Cleanup(server.Close)` when testing a real HTTP client.
Keep business logic in application packages and persistence access in the shipped library.

### How do we execute and measure Acceptance Criteria in this language?

An Acceptance Criterion (AC) is an executable check of Blueprint-required behavior. Native tests
use `testing` in `*_test.go`; the project gate is `go test ./...`. Within the existing Blueprint
Python AC container, execute a named test through the shipped helper:

```python
from drydock_go import run_test
result = run_test("./internal/orders", "TestCreateOrder")
assert result.passed, (result.status, result.stdout, result.stderr)
```

Drydock stages this helper beside the criterion. It runs `go test -json -count=1 -run` with an
exact test name, retains output and per-test outcomes, and rejects absent/skipped tests as proof.
The enclosing AC provides identity, timeout, result storage and repair state. Compilation errors
remain distinct from assertion failures in `result.status`. Coverage and persistence observations
require explicit instrumentation per criterion; unavailable observations are unknown.

A criterion that exercises the command line runs the built executable through the same helper,
never `go run`, which reports every non-zero program exit as 1:

```python
from drydock_go import cli_runner
code, out, err = cli_runner("--top", "0", "data.csv")
assert code == 2, (code, out, err)
```

`cli_runner` builds the single `./cmd/<name>` main package once with `go build` and returns
`(exit_code, stdout, stderr)`; pass `package="./cmd/<name>"` when there are several, and `input=`
for standard input. A failed build settles the criterion as `execution-error`.

### How does this language provide the shared persistence contract?

Use the shipped module in `Rigging/languages/go/persistence/`. Drydock copies it to the Target's
`persistence/`, generates `schema.go`, `testing.go` and a schema command from `DATABASE.md`, and
links it into the existing root `go.mod` as `drydock.local/persistence`. Driver versions and sums
are shipped; SQLite uses `go-sqlite3` (a C compiler and CGO are required), PostgreSQL uses `lib/pq`.
Run `go mod download` during dependency provisioning; execution requires these modules available.

Call `persistence.OpenDatabase(ctx, dsn)`, then typed methods such as
`db.Tickets.List(ctx, persistence.TicketsListInput{Status: "open"})`. Methods return a value and
an error. Optional inputs use pointers; read results are generated structs. Undeclared operations
and unsupported field types fail explicitly. Use `OpenSession(ctx, dsn)` for native database criteria;
empty DSN selects the configured, provisioned application store. Defer its cleanup and check the
returned error: it rolls back on success and failure, never applies schema or deletes the store.
Pass the same Store to the feature. Other connections and external effects require committed,
idempotent criteria with owned records and supported cleanup. Both engines retain autocommit
outside explicit rollback scopes.

The Go library and generator are verified on SQLite and PostgreSQL. Keep application SQL inside
the library; agents write callers. The language foundation must create `go.mod` before the
DATABASE step. Python Blueprint AC containers invoke the native Go tests through `run_test`.

---

## Consumer Rules

- Use `gofmt`, explicit errors, small consumer-owned interfaces and owned goroutine lifetimes.
- Keep business logic in `internal/` and entry points in `cmd/`; commit `go.mod` and `go.sum`.
- Gate with `go vet ./...`, `go build ./...` and `go test -race ./...`.

</pblock>

CONTEXT - Read-Only Support

<pblock filename="ARCHITECTURE_compact.md" role="context" path="/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats/blueprint/ARCHITECTURE_compact.md">

<!-- Compacted from ARCHITECTURE.md sha256=50e4c308b6e72eb915ea39843b4bfe2277ccd8adc8f1a3b1c07e6688d66829cb on 2026-10-26 by drydock build agent -->

Module `ddkstat`, go 1.22+, no `require` lines, no go.sum entries, no vendor/.
Packages: cmd/ddkstat (only os.Exit caller), internal/logread, internal/filter, internal/format, internal/report, internal/cli.
logread.Read(r io.Reader, warn io.Writer) (Result, error); Result{Records []Record, Skipped int}; error only on reader failure.
logread.Record: ExecutionID, StartedAt, Date (first 10 chars), Status, Failed (status != "succeeded"), Command, Target, Provider, Model, InputTokens, CachedTokens, OutputTokens (int64), CostUSD (float64), ElapsedMS (int64), ReturnCode (*int, nil if null/absent), TimedOut (bool).
cli.Run(args []string, stdout, stderr io.Writer) int; exit 0 ok, 1 unreadable log, 2 usage. Report writers: cli.Register(name, fn func(w io.Writer, records []logread.Record, skipped int) error).
Reports: summary, commands, targets, models, daily, failures. Options: --target, --since, --until, then one log path.
Only cmd/ddkstat/main.go calls os.Exit. Output buffered; stdout written only on success. Diagnostics to stderr, never compared.
Never write to the log; never read sources/run.sh; no hardcoded report values.

</pblock>

IMPLEMENTS - Authoritative Step Specifications

<pblock label="Implementation recency anchor" kind="section"> The files in this section are the load-bearing specifications for this build block. Build these files exactly. Treat earlier sections as constraints and context.

</pblock>

<pblock filename="FEATURE-ReportSummary.md" role="implements" path="/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats/blueprint/FEATURE-ReportSummary.md" guidance="Feature Specification">

# FEATURE: Report Summary

| Field       | Value |
|-------------|-------|
| Version     | 20261026 V1 |
| Description | The summary report: one CSV row of totals over the filtered records plus the whole-file skipped count. |
| Depends On  | FEATURE-CliExit.md, FEATURE-ValueFormat.md |
| Provides    | ddkstat summary |
| Consumes    | cli.Register, format.Minutes, format.Cost, logread.Record |

## Purpose

`ddkstat summary [options] <log>` answers how many calls ran, how many were skipped, and what they used and cost.

## Behavior

- Header: `records,skipped,succeeded,failed,first,last,input_tokens,cached_tokens,output_tokens,cost_usd,minutes`.
- One data row over the filtered records, `\n` line endings.
- `records` is the filtered record count; `succeeded` and `failed` split it by the failed rule; token columns are sums; `cost_usd` uses `format.Cost`; `minutes` uses `format.Minutes` of the summed `elapsed_ms`.
- `skipped` is the whole-file skipped-line count and ignores every filter.
- `first` and `last` are the earliest and latest start dates of the filtered records, empty when none match.
- Aggregation (`SummaryAggregate`) and writing (`WriteSummary(w io.Writer, records []logread.Record, skipped int) error`) are separate functions in `internal/report`; `internal/cli` registers the writer as `summary` with `cli.Register`.

## Programmatic Acceptance

=== AC summary-aggregate ===
Intent: SummaryAggregate sums counts, tokens, cost and duration over records built by the test.

from drydock_go import run_test

result = run_test("./internal/report", "TestSummaryAggregate")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC summary-aggregate ===

=== AC summary-empty-first-last ===
Intent: With no matching record, first and last are empty and counters are zero.

from drydock_go import run_test

result = run_test("./internal/report", "TestSummaryEmptyFirstLast")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC summary-empty-first-last ===

=== AC summary-skipped-ignores-filters ===
Intent: The skipped count stays the whole-file count regardless of target and date filters.

from drydock_go import run_test

result = run_test("./internal/report", "TestSummarySkippedIgnoresFilters")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC summary-skipped-ignores-filters ===

=== AC summary-write ===
Intent: WriteSummary writes the declared header and one row with the declared column order.

from drydock_go import run_test

result = run_test("./internal/report", "TestSummaryWrite")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC summary-write ===

=== AC summary-run-via-cli ===
Intent: cli.Run dispatches the summary report over a test-written log and exits zero with a parseable CSV.

from drydock_go import run_test

result = run_test("./internal/cli", "TestRunSummaryReport")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC summary-run-via-cli ===

## User Acceptance

- None.

## Guardrails

- Standard library only; no database; the log is never written.
- No report value is hardcoded; every number comes from the log being read.
- Skipped-line warnings go to standard error, never into the CSV.

</pblock>

<pblock filename="FEATURE-ReportTargets.md" role="implements" path="/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats/blueprint/FEATURE-ReportTargets.md" guidance="Feature Specification">

# FEATURE: Report Targets

| Field       | Value |
|-------------|-------|
| Version     | 20261026 V1 |
| Description | The targets report: one CSV row per Target with cost and a TOTAL row. |
| Depends On  | FEATURE-CliExit.md, FEATURE-ValueFormat.md |
| Provides    | ddkstat targets |
| Consumes    | cli.Register, format.Minutes, format.Cost, logread.Record |

## Purpose

`ddkstat targets [options] <log>` shows what each Target consumed and cost.

## Behavior

- Header: `target,calls,failed,input_tokens,cached_tokens,output_tokens,cost_usd,minutes`.
- One row per `job.target`, ordered by target ascending by byte value.
- Final row `TOTAL,...` over all filtered records, with total cost.
- Cost uses `format.Cost`; minutes use `format.Minutes`.
- When no record matches, the output is the header and a TOTAL row of zeros with `0.0000` cost and `0.0` minutes.
- `internal/report` holds the aggregate and write functions; `internal/cli` registers the writer as `targets`.

## Programmatic Acceptance

=== AC targets-ordering ===
Intent: Rows are ordered by target ascending in byte order.

from drydock_go import run_test

result = run_test("./internal/report", "TestTargetsOrdering")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC targets-ordering ===

=== AC targets-total-cost ===
Intent: The TOTAL row carries the summed cost formatted to four places.

from drydock_go import run_test

result = run_test("./internal/report", "TestTargetsTotalCost")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC targets-total-cost ===

=== AC targets-empty ===
Intent: With no matching record the report is the header plus a zero TOTAL row.

from drydock_go import run_test

result = run_test("./internal/report", "TestTargetsEmpty")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC targets-empty ===

=== AC targets-write ===
Intent: The writer emits the declared header and columns.

from drydock_go import run_test

result = run_test("./internal/report", "TestTargetsWrite")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC targets-write ===

=== AC targets-run-via-cli ===
Intent: cli.Run dispatches the targets report over a test-written log, exits zero and writes parseable CSV.

from drydock_go import run_test

result = run_test("./internal/cli", "TestRunTargetsReport")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC targets-run-via-cli ===

## User Acceptance

- None.

## Guardrails

- Standard library only; no database; the log is never written.
- No row, count, cost or total is hardcoded; all values come from the log being read.
- Target names are written unquoted and unescaped.

</pblock>

<pblock filename="FEATURE-ReportCommands.md" role="implements" path="/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats/blueprint/FEATURE-ReportCommands.md" guidance="Feature Specification">

# FEATURE: Report Commands

| Field       | Value |
|-------------|-------|
| Version     | 20261026 V1 |
| Description | The commands report: one CSV row per Drydock command with a TOTAL row. |
| Depends On  | FEATURE-CliExit.md, FEATURE-ValueFormat.md |
| Provides    | ddkstat commands |
| Consumes    | cli.Register, format.Minutes, logread.Record |

## Purpose

`ddkstat commands [options] <log>` shows how often each Drydock command called an LLM and what it consumed.

## Behavior

- Header: `command,calls,failed,input_tokens,cached_tokens,output_tokens,minutes`.
- One row per `job.command_name`, ordered by calls descending, then command ascending by byte value.
- Final row `TOTAL,...` over all filtered records.
- Minutes use `format.Minutes` of the group's summed `elapsed_ms`.
- When no record matches, the output is the header and `TOTAL,0,0,0,0,0,0.0`.
- Text values are written unquoted and unescaped.
- `internal/report` holds the aggregate and write functions; `internal/cli` registers the writer as `commands`.

## Programmatic Acceptance

=== AC commands-ordering ===
Intent: Rows are ordered by calls descending then command ascending, including ties.

from drydock_go import run_test

result = run_test("./internal/report", "TestCommandsOrdering")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC commands-ordering ===

=== AC commands-total ===
Intent: The TOTAL row sums calls, failures, tokens and minutes over all filtered records.

from drydock_go import run_test

result = run_test("./internal/report", "TestCommandsTotal")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC commands-total ===

=== AC commands-empty ===
Intent: With no matching record the report is the header plus a zero TOTAL row.

from drydock_go import run_test

result = run_test("./internal/report", "TestCommandsEmpty")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC commands-empty ===

=== AC commands-write ===
Intent: The writer emits the declared header and columns.

from drydock_go import run_test

result = run_test("./internal/report", "TestCommandsWrite")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC commands-write ===

=== AC commands-run-via-cli ===
Intent: cli.Run dispatches the commands report over a test-written log, exits zero and writes parseable CSV.

from drydock_go import run_test

result = run_test("./internal/cli", "TestRunCommandsReport")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC commands-run-via-cli ===

## User Acceptance

- None.

## Guardrails

- Standard library only; no database; the log is never written.
- No row, count or total is hardcoded; all values come from the log being read.
- Text values are never quoted or escaped.

</pblock>

<pblock filename="FEATURE-ReportModels.md" role="implements" path="/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats/blueprint/FEATURE-ReportModels.md" guidance="Feature Specification">

# FEATURE: Report Models

| Field       | Value |
|-------------|-------|
| Version     | 20261026 V1 |
| Description | The models report: one CSV row per provider and executed-model pair with a TOTAL row. |
| Depends On  | FEATURE-CliExit.md, FEATURE-ValueFormat.md, FEATURE-LogModel.md |
| Provides    | ddkstat models |
| Consumes    | cli.Register, format.Cost, logread.Record |

## Purpose

`ddkstat models [options] <log>` shows which providers and models ran the calls and what they consumed and cost.

## Behavior

- Header: `provider,model,calls,failed,input_tokens,cached_tokens,output_tokens,cost_usd`.
- One row per pair of provider (`job.llm`) and `Record.Model` (the executed model when present and non-empty, otherwise the requested model), ordered by provider then model ascending by byte value.
- Final row is `TOTAL,,...` with an empty model column, over all filtered records.
- Cost uses `format.Cost`. There is no minutes column.
- When no record matches, the output is the header and a TOTAL row of zeros with `0.0000` cost.
- `internal/report` holds the aggregate and write functions; `internal/cli` registers the writer as `models`.

## Programmatic Acceptance

=== AC models-grouping-executed-model ===
Intent: Records group under the executed model, falling back to the requested model.

from drydock_go import run_test

result = run_test("./internal/report", "TestModelsGroupingUsesExecutedModel")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC models-grouping-executed-model ===

=== AC models-ordering ===
Intent: Rows are ordered by provider then model ascending in byte order.

from drydock_go import run_test

result = run_test("./internal/report", "TestModelsOrdering")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC models-ordering ===

=== AC models-total-empty-model-column ===
Intent: The TOTAL row leaves the model column empty and sums every numeric column.

from drydock_go import run_test

result = run_test("./internal/report", "TestModelsTotalEmptyModelColumn")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC models-total-empty-model-column ===

=== AC models-empty ===
Intent: With no matching record the report is the header plus a zero TOTAL row.

from drydock_go import run_test

result = run_test("./internal/report", "TestModelsEmpty")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC models-empty ===

=== AC models-write ===
Intent: The writer emits the declared header and columns.

from drydock_go import run_test

result = run_test("./internal/report", "TestModelsWrite")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC models-write ===

=== AC models-run-via-cli ===
Intent: cli.Run dispatches the models report over a test-written log, exits zero and writes parseable CSV.

from drydock_go import run_test

result = run_test("./internal/cli", "TestRunModelsReport")
print(result.stdout)
print(result.stderr)
assert result.passed, (result.status, result.stdout, result.stderr)
=== END AC models-run-via-cli ===

## User Acceptance

- None.

## Guardrails

- Standard library only; no database; the log is never written.
- No row, count, cost or total is hardcoded; all values come from the log being read.
- Provider and model names are written unquoted and unescaped.

</pblock>

<pblock filename="FEATURE-ReportFailures.md" role="implements" path="/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats/blueprint/FEATURE-ReportFailures.md" guidance="Feature Specification">

# FEATURE: Report Failures

| Field       | Value |
|-------------|-------|
| Version     | 20261026 V1 |
| Description | Writes the failures CSV report listing each failed record in start order. |
| Depends On  | ARCHITECTURE.md, FEATURE-CliExit.md, FEATURE-ValueFormat.md |
| Provides    | ddkstat failures |
| Consumes    | cli.Register, logread.Record |

## Purpose

The `failures` report lists every failed call so the operator can see which command, Target and model failed, and how.

## Behavior

- Header: `started_at,target,command,model,returncode,timed_out`.
- One row per failed record (status is not `succeeded`) among the filtered records.
- Rows are ordered by `started_at`, then `execution_id`, ascending by byte value.
- `started_at` is written exactly as logged.
- `model` is `Record.Model`: the executed model when present and non-empty, otherwise the requested model.
- `returncode` is empty when null or absent, otherwise the integer.
- `timed_out` is `true` or `false`.
- There is no `TOTAL` row. When no failed record matches, only the header is written.
- Selection and ordering (`SelectFailures`) and writing (`WriteFailures`) are separate functions in `internal/report`.
- The writer is registered with `cli.Register("failures", ...)`.

## Programmatic Acceptance

=== AC report-failures-unit ===
Intent: The native unit tests for failure selection, ordering, null returncode, timed_out text and empty output all pass.
Requires: executable=go; scope=test

from drydock_go import run_test

for name in (
    "TestFailuresOrdering",
    "TestFailuresNullReturncodeEmpty",
    "TestFailuresTimedOutText",
    "TestFailuresOnlyFailed",
    "TestFailuresEmpty",
):
    result = run_test("./internal/report", name)
    print(name, result.status)
    assert result.passed, (name, result.status, result.stdout, result.stderr)
=== END AC report-failures-unit ===

=== AC report-failures-rows ===
Intent: The failures command lists only failed records ordered by started_at then execution_id, with model fallback, empty null returncode and true/false timed_out.
Requires: executable=go; scope=test

import csv
import io
import json
import os
import tempfile

from drydock_go import cli_runner


def rec(eid, started, target, cmd, status, rc, timed_out, stats_model):
    stats = {"input_tokens": 1, "elapsed_ms": 1000}
    if stats_model is not None:
        stats["model"] = stats_model
    return {
        "schema_version": 1,
        "execution_id": eid,
        "started_at": started,
        "status": status,
        "job": {"command_name": cmd, "target": target, "llm": "claude", "model": "requested-model"},
        "result": {"returncode": rc, "timed_out": timed_out, "stats": stats},
    }


recs = [
    rec("zz-9", "2026-10-15T06:00:00.000Z", "Beta", "diagnose", "failed", None, True, "executed-model"),
    rec("aa-1", "2026-10-14T02:00:00.000Z", "Alpha", "build", "succeeded", 0, False, "executed-model"),
    rec("bb-2", "2026-10-14T02:00:00.000Z", "Alpha", "build", "failed", 1, False, None),
    rec("aa-3", "2026-10-14T02:00:00.000Z", "Alpha", "plan", "failed", 2, False, "executed-model"),
    rec("cc-4", "2026-10-13T23:00:00.000Z", "Beta", "build", "timeout", 124, True, "executed-model"),
]

work = tempfile.mkdtemp()
path = os.path.join(work, "log.jsonl")
with open(path, "w", encoding="utf-8") as fh:
    for r in recs:
        fh.write(json.dumps(r) + "\n")

code, out, err = cli_runner("failures", path)
print(out)
print(err)
assert code == 0
rows = list(csv.reader(io.StringIO(out)))
assert rows[0] == ["started_at", "target", "command", "model", "returncode", "timed_out"]

failed = sorted(
    [r for r in recs if r["status"] != "succeeded"],
    key=lambda r: (r["started_at"], r["execution_id"]),
)
body = rows[1:]
assert len(body) == len(failed)
for row, r in zip(body, failed):
    model = r["result"]["stats"].get("model") or r["job"]["model"]
    rc = r["result"]["returncode"]
    assert row[0] == r["started_at"]
    assert row[1] == r["job"]["target"]
    assert row[2] == r["job"]["command_name"]
    assert row[3] == model
    assert row[4] == ("" if rc is None else str(rc))
    assert row[5] == str(r["result"]["timed_out"]).lower()
=== END AC report-failures-rows ===

=== AC report-failures-filters ===
Intent: The failures command honours --target and the inclusive --since/--until date range.
Requires: executable=go; scope=test

import csv
import io
import json
import os
import tempfile

from drydock_go import cli_runner


def rec(eid, started, target):
    return {
        "schema_version": 1,
        "execution_id": eid,
        "started_at": started,
        "status": "failed",
        "job": {"command_name": "build", "target": target, "llm": "claude", "model": "m"},
        "result": {"returncode": 1, "timed_out": False, "stats": {"elapsed_ms": 1}},
    }


recs = [
    rec("id-1", "2026-10-14T01:00:00.000Z", "Alpha"),
    rec("id-2", "2026-10-15T01:00:00.000Z", "Alpha"),
    rec("id-3", "2026-10-15T02:00:00.000Z", "Beta"),
    rec("id-4", "2026-10-16T01:00:00.000Z", "Alpha"),
]
work = tempfile.mkdtemp()
path = os.path.join(work, "log.jsonl")
with open(path, "w", encoding="utf-8") as fh:
    for r in recs:
        fh.write(json.dumps(r) + "\n")

target = "Alpha"
since = "2026-10-15"
until = "2026-10-15"
kept = [
    r for r in recs
    if r["job"]["target"] == target and since <= r["started_at"][:10] <= until
]

code, out, err = cli_runner("failures", "--target", target, "--since", since, "--until", until, path)
print(out)
print(err)
assert code == 0
rows = list(csv.reader(io.StringIO(out)))
assert [row[0] for row in rows[1:]] == [r["started_at"] for r in kept]
=== END AC report-failures-filters ===

=== AC report-failures-empty ===
Intent: When no failed record matches, the failures command exits 0 and writes only the header row.
Requires: executable=go; scope=test

import csv
import io
import json
import os
import tempfile

from drydock_go import cli_runner

record = {
    "schema_version": 1,
    "execution_id": "id-1",
    "started_at": "2026-10-14T01:00:00.000Z",
    "status": "succeeded",
    "job": {"command_name": "build", "target": "Alpha", "llm": "claude", "model": "m"},
    "result": {"returncode": 0, "timed_out": False},
}
work = tempfile.mkdtemp()
path = os.path.join(work, "log.jsonl")
with open(path, "w", encoding="utf-8") as fh:
    fh.write(json.dumps(record) + "\n")

code, out, err = cli_runner("failures", path)
print(out)
print(err)
assert code == 0
rows = list(csv.reader(io.StringIO(out)))
assert len(rows) == 1
assert rows[0] == ["started_at", "target", "command", "model", "returncode", "timed_out"]
=== END AC report-failures-empty ===

## User Acceptance

- None.

## Guardrails

- The report has no `TOTAL` row.
- Every row comes from the log being read; none is hardcoded.
- The report never writes to the log.
- Text values are written without quoting or escaping.

</pblock>

<pblock filename="FEATURE-ReportDaily.md" role="implements" path="/mnt/c/Users/barlo/projects/drydock/uat/DrydockStats/runs/20261026.152123/workspace/targets/DrydockStats/blueprint/FEATURE-ReportDaily.md" guidance="Feature Specification">

# FEATURE: Report Daily

| Field       | Value |
|-------------|-------|
| Version     | 20261026 V1 |
| Description | Writes the daily CSV report with one row per start date and a TOTAL row. |
| Depends On  | ARCHITECTURE.md, FEATURE-CliExit.md, FEATURE-ValueFormat.md |
| Provides    | ddkstat daily |
| Consumes    | cli.Register, format.Minutes, logread.Record |

## Purpose

The `daily` report shows, for each start date, how many calls ran, how many failed, how many tokens they used, and how many minutes they took.

## Behavior

- Header: `date,calls,failed,tokens,minutes`.
- The report covers the records that remain after the filters are applied.
- One row per start date (the first 10 characters of `started_at`), in ascending byte order.
- `calls` is the record count. `failed` is the count of records whose status is not `succeeded`.
- `tokens` is input plus cached plus output tokens, summed over the group.
- `minutes` is the group's summed `elapsed_ms` formatted by `format.Minutes`.
- A final `TOTAL` row covers all filtered records.
- When no record matches, the report writes the header and a `TOTAL` row of zeros with `0.0` minutes.
- Aggregation (`AggregateDaily`) and writing (`WriteDaily`) are separate functions in `internal/report`.
- The writer is registered with `cli.Register("daily", ...)`.
- Output is CSV, `\n` line endings, values unquoted.

## Programmatic Acceptance

=== AC report-daily-unit ===
Intent: The native unit tests for daily aggregation, ordering, totals, empty input and writing all pass.
Requires: executable=go; scope=test

from drydock_go import run_test

for name in (
    "TestDailyOrdering",
    "TestDailyTokensSum",
    "TestDailyTotal",
    "TestDailyEmpty",
    "TestDailyWrite",
):
    result = run_test("./internal/report", name)
    print(name, result.status)
    assert result.passed, (name, result.status, result.stdout, result.stderr)
=== END AC report-daily-unit ===

=== AC report-daily-rows ===
Intent: The daily command emits one row per start date with calls, failed, tokens and minutes derived from the log, followed by a TOTAL row.
Requires: executable=go; scope=test

import csv
import io
import json
import os
import tempfile
from decimal import Decimal

from drydock_go import cli_runner


def rec(n, started, cmd, target, status, tin, tc, tout, ms):
    return {
        "schema_version": 1,
        "execution_id": "id-%03d" % n,
        "started_at": started,
        "status": status,
        "job": {"command_name": cmd, "target": target, "llm": "claude", "model": "haiku"},
        "result": {
            "returncode": 0 if status == "succeeded" else 1,
            "timed_out": False,
            "stats": {
                "input_tokens": tin,
                "cached_input_tokens": tc,
                "output_tokens": tout,
                "elapsed_ms": ms,
                "cost_usd": 0.5,
                "model": "claude-haiku-5-5",
            },
        },
    }


recs = [
    rec(1, "2026-10-15T08:00:00.000Z", "build", "Alpha", "succeeded", 10, 200, 30, 95000),
    rec(2, "2026-10-14T09:00:00.000Z", "plan", "Beta", "failed", 1, 2, 3, 20000),
    rec(3, "2026-10-14T10:00:00.000Z", "build", "Alpha", "succeeded", 100, 0, 7, 61000),
    rec(4, "2026-10-16T11:00:00.000Z", "analyze", "Beta", "succeeded", 5, 5, 5, 0),
    rec(5, "2026-10-15T12:00:00.000Z", "build", "Beta", "succeeded", 0, 40, 0, 125000),
]

work = tempfile.mkdtemp()
path = os.path.join(work, "log.jsonl")
with open(path, "w", encoding="utf-8") as fh:
    for r in recs:
        fh.write(json.dumps(r) + "\n")


def expected(group):
    total_ms = sum(r["result"]["stats"]["elapsed_ms"] for r in group)
    tenths = (total_ms + 3000) // 6000
    return (
        len(group),
        sum(1 for r in group if r["status"] != "succeeded"),
        sum(
            r["result"]["stats"]["input_tokens"]
            + r["result"]["stats"]["cached_input_tokens"]
            + r["result"]["stats"]["output_tokens"]
            for r in group
        ),
        Decimal(tenths) / Decimal(10),
    )


code, out, err = cli_runner("daily", path)
print(out)
print(err)
assert code == 0
rows = list(csv.reader(io.StringIO(out)))
header, body = rows[0], rows[1:]
assert header == ["date", "calls", "failed", "tokens", "minutes"]

dates = sorted({r["started_at"][:10] for r in recs})
assert [row[0] for row in body[:-1]] == dates
for row in body[:-1]:
    group = [r for r in recs if r["started_at"][:10] == row[0]]
    calls, failed, tokens, minutes = expected(group)
    assert int(row[1]) == calls
    assert int(row[2]) == failed
    assert int(row[3]) == tokens
    assert Decimal(row[4]) == minutes

total = body[-1]
calls, failed, tokens, minutes = expected(recs)
assert total[0] == "TOTAL"
assert int(total[1]) == calls
assert int(total[2]) == failed
assert int(total[3]) == tokens
assert Decimal(total[4]) == minutes
=== END AC report-daily-rows ===

=== AC report-daily-filters ===
Intent: The daily command honours --target, --since and --until, computing every row and the TOTAL over only the matching records.
Requires: executable=go; scope=test

import csv
import io
import json
import os
import tempfile
from decimal import Decimal

from drydock_go import cli_runner


def rec(n, started, target, status, tin, ms):
    return {
        "schema_version": 1,
        "execution_id": "id-%03d" % n,
        "started_at": started,
        "status": status,
        "job": {"command_name": "build", "target": target, "llm": "claude", "model": "haiku"},
        "result": {
            "returncode": 0,
            "timed_out": False,
            "stats": {
                "input_tokens": tin,
                "cached_input_tokens": 0,
                "output_tokens": 0,
                "elapsed_ms": ms,
                "cost_usd": 0.1,
                "model": "claude-haiku-5-5",
            },
        },
    }


recs = [
    rec(1, "2026-10-14T01:00:00.000Z", "Alpha", "succeeded", 11, 60000),
    rec(2, "2026-10-15T01:00:00.000Z", "Alpha", "failed", 22, 60000),
    rec(3, "2026-10-15T02:00:00.000Z", "Beta", "succeeded", 33, 60000),
    rec(4, "2026-10-16T01:00:00.000Z", "Alpha", "succeeded", 44, 60000),
]

work = tempfile.mkdtemp()
path = os.path.join(work, "log.jsonl")
with open(path, "w", encoding="utf-8") as fh:
    for r in recs:
        fh.write(json.dumps(r) + "\n")

target = "Alpha"
since = "2026-10-15"
until = "2026-10-16"
kept = [
    r for r in recs
    if r["job"]["target"] == target and since <= r["started_at"][:10] <= until
]

code, out, err = cli_runner("daily", "--target", target, "--since", since, "--until", until, path)
print(out)
print(err)
assert code == 0
rows = list(csv.reader(io.StringIO(out)))
body = rows[1:]
assert [row[0] for row in body[:-1]] == sorted({r["started_at"][:10] for r in kept})
assert body[-1][0] == "TOTAL"
assert int(body[-1][1]) == len(kept)
assert int(body[-1][2]) == sum(1 for r in kept if r["status"] != "succeeded")
assert int(body[-1][3]) == sum(r["result"]["stats"]["input_tokens"] for r in kept)
tenths = (sum(r["result"]["stats"]["elapsed_ms"] for r in kept) + 3000) // 6000
assert Decimal(body[-1][4]) == Decimal(tenths) / Decimal(10)
=== END AC report-daily-filters ===

=== AC report-daily-empty ===
Intent: When no record matches the filter, the daily command exits 0 and writes the header and a TOTAL row of zeros.
Requires: executable=go; scope=test

import csv
import io
import json
import os
import tempfile
from decimal import Decimal

from drydock_go import cli_runner

record = {
    "schema_version": 1,
    "execution_id": "id-001",
    "started_at": "2026-10-14T01:00:00.000Z",
    "status": "succeeded",
    "job": {"command_name": "build", "target": "Alpha", "llm": "claude", "model": "haiku"},
    "result": {"returncode": 0, "timed_out": False, "stats": {"input_tokens": 9, "elapsed_ms": 60000}},
}
work = tempfile.mkdtemp()
path = os.path.join(work, "log.jsonl")
with open(path, "w", encoding="utf-8") as fh:
    fh.write(json.dumps(record) + "\n")

code, out, err = cli_runner("daily", "--target", "NoSuchTarget", path)
print(out)
print(err)
assert code == 0
rows = list(csv.reader(io.StringIO(out)))
assert rows[0] == ["date", "calls", "failed", "tokens", "minutes"]
assert len(rows) == 2
total = rows[1]
assert total[0] == "TOTAL"
assert int(total[1]) == 0
assert int(total[2]) == 0
assert int(total[3]) == 0
assert Decimal(total[4]) == Decimal(0)
=== END AC report-daily-empty ===

## User Acceptance

- None.

## Guardrails

- The report reads only values computed from the log; no row, count or total is hardcoded.
- The report never writes to the log.
- Text values are written without quoting or escaping.

</pblock>

<pblock label="Build instructions" kind="instructions">

Build instructions for this block

Write the one-row summary report. (report-summary)

Header records,skipped,succeeded,failed,first,last,input_tokens,cached_tokens,output_tokens,cost_usd,minutes. One row over the filtered records; skipped is the whole-file count regardless of filters; first and last are the earliest and latest start dates (empty when no record matches); cost via format.Cost, minutes via format.Minutes. Aggregation and formatting are separate functions with Go tests. Register as "summary".
Required Go tests: TestSummaryAggregate, TestSummaryEmptyFirstLast, TestSummarySkippedIgnoresFilters, TestSummaryWrite. Reachability check goes through drydock_go.cli_runner with a log written by the test.

Write the targets report with cost and a TOTAL row. (report-targets)

Header target,calls,failed,input_tokens,cached_tokens,output_tokens,cost_usd,minutes. One row per target ordered by target ascending (byte order), then TOTAL. Empty match writes the header and a zero TOTAL (0.0000 cost, 0.0 minutes). Register as "targets". Required Go tests: TestTargetsOrdering, TestTargetsTotalCost, TestTargetsEmpty, TestTargetsWrite.

Write the commands report with a TOTAL row. (report-commands)

Header command,calls,failed,input_tokens,cached_tokens,output_tokens,minutes. One row per command ordered by calls descending then command ascending (byte order), then TOTAL over all filtered records. An empty match writes the header and a TOTAL row of zeros with 0.0 minutes. Text values are written unquoted. Register as "commands". Required Go tests: TestCommandsOrdering, TestCommandsTotal, TestCommandsEmpty, TestCommandsWrite.

Write the models report grouped by provider and model with a TOTAL row. (report-models)

Header provider,model,calls,failed,input_tokens,cached_tokens,output_tokens,cost_usd. One row per provider (job.llm) and Record.Model pair ordered by provider then model ascending (byte order), then a TOTAL row whose model column is empty (TOTAL,,...). Empty match writes the header and a zero TOTAL row. Register as "models".
Required Go tests: TestModelsGroupingUsesExecutedModel, TestModelsOrdering, TestModelsTotalEmptyModelColumn, TestModelsEmpty, TestModelsWrite.

Write the failures report listing each failed record. (report-failures)

Header started_at,target,command,model,returncode,timed_out. One row per failed record ordered by started_at then execution_id ascending (byte order). returncode is empty when null or absent; timed_out is true or false; model is Record.Model. No TOTAL row; an empty match writes the header only. Register as "failures". Required
Go tests: TestFailuresOrdering, TestFailuresNullReturncodeEmpty, TestFailuresTimedOutText, TestFailuresOnlyFailed, TestFailuresEmpty.

Write the daily report with token totals and a TOTAL row. (report-daily)

Header date,calls,failed,tokens,minutes. One row per start date ascending; tokens is input plus cached plus output tokens; then TOTAL. Empty match writes the header and a zero TOTAL row. Register as "daily". Required
Go tests: TestDailyOrdering, TestDailyTokensSum, TestDailyTotal, TestDailyEmpty, TestDailyWrite.

</pblock>

Agent Task

You are a Drydock build agent implementing exactly one build step of a larger plan. The build job block below names the target, the build working directory, and the step. Everything you need is stacked into this prompt under role headings:

authoritative; implement them exactly.

Operating contract:

  1. Follow the write authorization and protected paths in the stacked COMPASS.md exactly.

That persisted guardrail is the sole authority for paths this build may modify.

  1. Start by inspecting the build working directory. Read the current contents of each file before

applying a contextual patch. If patch verification fails, re-read that file and rebuild the patch against its current text; do not repeat stale context or overwrite unrelated changes. Preserve existing application files unless this step's specifications require a change. Its sources/ subdirectory holds staged build assets — imported test corpora, conformance harnesses, and fixtures — placed there for you. They are read-only inputs: run them, import them, and write code against them, but never create, rewrite, trim, regenerate, or substitute one, even to make a check pass. A step that modifies a staged asset fails and the asset is restored. If an asset you expect is absent, report that; do not author a replacement.

  1. Implement only this step. Use context, stack, and rules as constraints,

not as additional work to perform.

  1. Follow the stack and rules for languages, structure, naming, and branding.
  2. The programmatic acceptance assertions in the implements specifications are

this step's Definition of Done — human-owned, declared before the build, and fixed. Build the story and, in this same step, write the deterministic tests that prove each declared assertion, as a TDD master would; add finer tests for coverage. Every test you write follows the same rule the acceptance assertions do: act on the system, read the state back, compare to expected. The oracle is a return value, parsed JSON, a status code, a stored row, file contents read back, or an exit status — never a substring of captured stdout or stderr, a test-runner tally, or a log line. Write tests in the project's own language using that language's libraries; an in-language HTTP client yields a status code and a parsed body, where curl yields text to scrape. Round-trip anything that stores state: act, then read back through the public interface. Assert declared failure signals on negative paths, never message wording. You may add tests but must never remove, soften, or weaken a declared acceptance assertion. A Suite: full conformance check gates on the entire imported test suite: the step is done only when it passes in full, never on a representative subset — reproduce the standard exactly rather than wrapping a third-party library that approximates it. For a suite, the runner's exit status is the verdict and the whole verdict: print its captured output for diagnosis, never assert on the text of its summary. When an assertion is a static or filesystem scan (import boundary, "X never appears outside Y," grep/AST gate), honor the scope the specification states and never widen it: scan production source only, exclude .venv/, site-packages, and vendored or generated code, and do not flag test doubles or fixtures that use the guarded dependency. Run targeted tests for the behavior you change and preserve existing passing behavior. Drydock executes every declared acceptance assertion after your call and owns the verdict. Use available failure logs before rerunning suites to rediscover failures; use section or example filters to diagnose the underlying behavior, never example-specific exceptions. If you run a suite, wait for completion or its declared timeout; silence is not a hang.

  1. Grow the project's own test suite as you write the code, and treat it as the project's

real coverage. The acceptance assertions in implements are gates: few, fixed, and written before any code existed, so every expectation in them is a prediction. The tests you write are written beside the finished code, so their expected values are observed rather than predicted — which is why exhaustive coverage belongs here and not there. Extend the suite in the project's established location and runner, keep it runnable by the project's declared test command, and leave it green when you return. Cover, at minimum: every public entry point and every verb it declares, including declared error paths; the boundaries — empty, exactly one, many, absent optional fields, declared maxima; declared idempotence, applied twice; one behavior per test, named for the behavior; and isolation — database criteria use the provisioned application store and the shipped rollback fixture, passing its connection into the feature. Other connections and durability tests use criterion-owned records, idempotent setup and checked cleanup through supported interfaces. Never replace the configured store, reapply schema, or delete unrelated business records. Where a staged authoritative suite already covers a surface, use it as the coverage; do not duplicate its cases. Any invocation must respect this step's declared scope. Do not run the unscoped entry point for a Suite: scoped story, or run a suite this step does not declare. Report only completed checks and their observed results.

  1. Treat User Acceptance entries as review evidence requirements. Implement

the supporting behavior, but do not claim to have performed human judgment.

  1. The implements section is authoritative and intentionally stacked late in

the prompt as the recency anchor. Build that WHAT exactly; do not substitute generic framework defaults.

  1. Before adding or installing Python dependencies, verify each package name

against the declared registry. Do not invent package names. If a needed package cannot be verified or appears newly published, fail explicitly instead of installing it.

  1. Use the stack's required package manager workflow for dependency changes.

When the stack requires uv, update manifests through uv conventions rather than bare pip install.

  1. Do not claim success unless you actually created or modified project files in

the build working directory. If you cannot write files or cannot complete the step, report failure explicitly.

  1. Do not run git add, git commit, create branches, create tags, rewrite

history, or otherwise mutate Git history. Drydock checkpoints application changes and Target evidence after each execution and completed step. File lineage comes from Git and the Manifest's implements: entries; no additional attribution response is required.

  1. End your response with this exact closing structure:
RESULT: SUCCESS | FAILED

FILES CHANGED:
- relative/path

SUMMARY:
<brief reviewable summary>

BLOCKERS:
- <only if any>

Before RESULT, you may emit one optional JSON payload when implementation required a bounded choice not already settled by the owning specification. This records what you did; it does not ask permission, create a questionnaire, or excuse incomplete work:

<blueprint-decisions>
[{"spec":"FEATURE-Example.md","severity":"Material","subject":"Chosen behavior","decision":"Options A and B were available. I implemented B because ... Is that acceptable, or should this change on replan?"}]
</blueprint-decisions>

Name only a specification implemented by this build block. Use Low or Material; Build never emits a Blocking decision. Omit the payload when no implementation decision was necessary.

  1. FILES CHANGED must list only files actually written in the build working

directory. When the existing implementation already satisfies this step, report RESULT: SUCCESS, list no changed files, and state the checks performed and their results. A verification-only step requires no application changes. Drydock runs the declared deterministic checks and decides the outcome independently of this report.

  1. On RESULT: FAILED, append two additional lines so the failure is actionable

without opening logs. FAILURE_SUMMARY is one line naming the cause; FAILURE_DETAIL states what happened, why, and what to change before a rerun. Name concrete conditions when they apply: token or context limit exceeded, could not execute commands in this environment, a required input was missing, or a specific tool or command failed.

FAILURE_SUMMARY: <one line naming the cause>
FAILURE_DETAIL: <what happened, why, and what to change before rerunning>
  1. When a declared acceptance criterion cannot pass no matter how the code is written,

say so with this exact token. You may not edit the criterion — it is staged and restored before grading:

AC_BROKEN: <check-id>[, <check-id>]

This is a report, not a verdict, and it stops nothing. A criterion reaches you only when its expected value is one its author could not have invented — a status code, a staged suite's exit status, a value the criterion itself supplied as input — so your claim that the criterion rather than the code is at fault is the less likely explanation, and the budget is spent as it would be for any other failure. A criterion whose expectation was hand-typed already settles DISPUTED on its own, without you naming it. Emit the token only after running the criterion and confirming the underlying command succeeded while the assertion still failed. Name the affected check ids, emit it alongside your normal RESULT line, state the reasoning in FAILURE_DETAIL, and emit it even when RESULT: SUCCESS. Do not use it for a criterion you merely failed to satisfy.