# 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.

2. **Input Context** — begins with the heading `# Input Context`. All blocks are wrapped in
   `<pblock>` tags. Two block types:
   - File blocks: `<pblock filename="<name>" role="<role>" guidance="...">` — optional
     `guidance` attribute carries context-specific instructions; content is in a fenced block.
   - Metadata/section blocks: `<pblock label="<label>" kind="<kind>">` — job parameters,
     rules, instructions, or group headers.

3. **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
- TARGET: FxRates
- BUILD_DIRECTORY: /mnt/c/Users/barlo/projects/drydock/uat/FxRates/runs/20261026.202600/build/FxRates
- WORKING_DIRECTORY: /mnt/c/Users/barlo/projects/drydock/uat/FxRates/runs/20261026.202600/build/FxRates
- BUILD_BLOCK: Block 6 · Service (block-6)
- STORIES: Verify complete supplied grader conformance. (grader)
- DATE: 2026-10-26
- BUILD_SCOPE: exactly one MANIFEST.md build block

</pblock>

<pblock label="Stories in this block" kind="section">
## Stories in this block
- Verify complete supplied grader conformance. (grader) [story]

</pblock>

<pblock label="Files on disk" kind="section">
## Files on disk in the build directory
- sources/eurofxref-hist_2025-01.csv
- sources/eurofxref-hist_2025-02-03_04.csv
- sources/eurofxref-hist_bad.csv
- sources/run.sh

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/FxRates/runs/20261026.202600/workspace/targets/FxRates/COMPASS.md" guidance="Important: This is the core project intent, constraints, and guardrails. It should have presecedence in conflicts.">
```markdown
# COMPASS: FxRates

## Compass

Build a currency rates service, an executable named `fxrates` at the application root, as
described in `sources/INSTRUCTIONS.md`. A command line loads the ECB euro reference rate history
into SQLite, and a FastAPI JSON API serves the rates on a date, conversions between any two
currencies, and a currency's history with minimum, maximum, and mean.

Correctness is measured by `sources/run.sh`: it loads the supplied ECB files, starts the server on
a free local port, and makes 35 checks of command output and HTTP status and JSON body. The goal is
every check passing.

## Constraints

- Implement in Python 3.11 or newer with FastAPI and uvicorn over SQLite.
- Provide an executable named `fxrates` at the application root, invoked as `./fxrates <command>`.
  `fxrates serve` runs the server in the foreground and stops cleanly on SIGTERM.
- Read the database location from `DATABASE_URL`, then `DATABASE_PATH`, then `data/app.db`.
- Store rates as the ECB's published text; compute with `decimal`, never with floating point.
- Check a file in full before its first write.
- Tests stub the ECB download; no test opens a network connection.
- 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` or any supplied data file from application code. Data reaches the
  database only through `fxrates load` or `fxrates fetch`.
- Do not hardcode a rate, a date, a count, or a computed value. Every value comes from a query.
- Do not open a database driver outside the shipped persistence library.

## 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/FxRates/runs/20261026.202600/build/FxRates`
- Authorized Target directory: `/mnt/c/Users/barlo/projects/drydock/uat/FxRates/runs/20261026.202600/workspace/targets/FxRates`
- 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/FxRates/runs/20261026.202600/workspace/targets/FxRates/blueprint/`
  - `/mnt/c/Users/barlo/projects/drydock/uat/FxRates/runs/20261026.202600/workspace/targets/FxRates/MANIFEST.md`
  - `/mnt/c/Users/barlo/projects/drydock/uat/FxRates/runs/20261026.202600/workspace/targets/FxRates/COMPASS.md`
  - `/mnt/c/Users/barlo/projects/drydock/uat/FxRates/runs/20261026.202600/workspace/targets/FxRates/QuarterDeck/`
  - `/mnt/c/Users/barlo/projects/drydock/uat/FxRates/runs/20261026.202600/workspace/targets/FxRates/evidence/`
<!-- drydock:build-write-guardrail:end -->
```
</pblock>


## STACK - Technology HOW

<pblock filename="python_compact.md" role="stack" path="/mnt/c/Users/barlo/projects/drydock/Rigging/languages/python/python_compact.md">
```
<!-- Compacted from Rigging/languages/python/python.md sha256=fe344456a351e3237cfe3bae2408a69758d401430b935f60c15f91b9a97e8016 on 2026-10-18 by Rigging maintenance -->

## Foundation Contract

- source_root: ./
- test_command: pytest -q
- environment: `.venv`, created by `uv venv` and activated by launchers in `bin/`
- dependencies: `pyproject.toml` and committed `uv.lock`

The language foundation owns the project root, environment, dependency manifest, and test runner.
Later foundations add their packages to this tree without replacing those contracts.

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

An Acceptance Criterion (AC) is an executable check of Blueprint-required behavior. Use the
existing Programmatic Acceptance format: a Python script with assertions against the built
product. Drydock executes each criterion through `languages/python/acceptance/runner.py`; `pytest -q`
runs the project test suite. Retain the criterion ID, observed values, stdout/stderr and result;
an assertion failure fails the check. The harness reports failure operands and available case
counts. Code coverage and persistence interactions require explicit instrumentation; record
available observations as key/value data associated with the criterion. Missing observations
are unknown, not proof that code or an interaction was unused.

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

Use `stack/persistence.md`. Drydock copies `Rigging/languages/python/persistence/{db,sqlite,postgres}.py` and generates
`persistence/{schema,__init__,testing}.py` plus `schema.sql` from `DATABASE.md`. Call
`open_database(dsn)` and `db.<table>.<operation>(...)`; use `persistence.testing.db_session()`
for criteria. SQLite uses the standard library; PostgreSQL needs `psycopg[binary]` in the project
dependencies. Both engines ship together and the DSN selects the engine. Library verification
lives in `tests/test_shipped_database.py`; a Target still verifies its own schema and operations.

## Consumer Rules

- Python >=3.11; use modern type hints on public interfaces and named cross-package data shapes.
- Centralize typed runtime settings; use Blueprint names and defaults. Keep secrets out of Git and logs.
- Keep behavior in importable modules; launchers activate `.venv` and invoke modules.
- Use pytest with isolated external state; all test gates run `pytest -q`.
```
</pblock>

<pblock filename="common_compact.md" role="stack" path="/mnt/c/Users/barlo/projects/drydock/Rigging/stack/common_compact.md">
```
<!-- Compacted from /mnt/c/Users/barlo/projects/drydock/Rigging/stack/common.md sha256=2d665e4a232b3ef5b681149974e74928c8f5abb9adaac02604cc6b5987ac0f85 on 2026-10-24 by drydock rigging compact — regenerate with: drydock rigging compact --include-file {rel_source} -->

# Common Best Practices — Contract Surface

## Project Layout

### Rule: project-directory-layout

Every project must use the standard root layout and may add stack-specific directories.

Constraints: Include `bin/`, `data/` with `logs/` and `backups/`, `docs/`, `tests/`, optional `PROJECT/`, `.env`, `.env.example`, `.gitignore`, `CLAUDE.md`, and `Links.md`; keep runtime data under `data/`.

## Shell Scripts

### Rule: user-facing-operation-scripts

User-facing operations must be implemented as Bash scripts in `bin/`.

Constraints: Scripts must use standardized headers, `set -euo pipefail`, resolve project-relative paths, create `data/logs/`, log execution details, run from the project root, tee output to console and a timestamped log, and record completion.

### Rule: command-center-discovery-header

A discoverable script must begin with a Command Center header.

| Field | Required | Values |
|---|---:|---|
| `# CommandCenter Operation` | Yes | Literal |
| `# Name:` | Yes | Free text |
| `# Type:` | No | `daemon` or `batch`; defaults to `batch` |
| `# Port:` | No | Integer; daemon port |

Constraints: Scripts without `# CommandCenter Operation` remain valid but are not discoverable by Command Center.

### Rule: standard-scripts

Projects should provide applicable operation scripts with these names and purposes.

| Script | Type | Purpose |
|---|---|---|
| `bin/start.sh` | daemon | Start the development server |
| `bin/stop.sh` | batch | Stop the development server |
| `bin/test.sh` | batch | Run tests |
| `bin/build.sh` | batch | Build or compile |
| `bin/deploy.sh` | batch | Deploy to production |
| `bin/backup.sh` | batch | Back up data or databases |

### Rule: script-logging

Operation scripts must capture stdout and stderr in `data/logs/`.

Constraints: Log filenames must follow `<script>_<YYYY-MM-DD_HHMMSS>.log`; initial log lines must record timestamp, arguments, and working directory.

## Links

### Rule: links-file

Every project must provide a root-level `Links.md` containing one two-column Markdown table.

| Column | Requirement |
|---|---|
| `Label` | Short and descriptive |
| `URL` | Relevant project URL |

Constraints: Command Center reads this table and exposes the links through project configuration.

## Agent Instructions

### Rule: claude-file

Every project must provide a root-level `CLAUDE.md` with the following sections.

| Section | Required content |
|---|---|
| `## Project Overview` | Purpose and key features |
| `## Architecture` | Technology stack, key files, and patterns |
| `## Dev Commands` | Bash project commands in a code block |
| `## Service Endpoints` | `- Label: https://url` entries |
| `## Bookmarks` | Grouped links using `### Group` and `- [Title](URL)` |

Constraints: Normalize equivalent headings to the standard names: `Commands`, `Development Commands`, and `Build Commands` become `Dev Commands`; `Overview` and `Project Purpose` become `Project Overview`; `Stack` becomes `Architecture`.

## Version Control

### Rule: gitignore-and-secrets

Repositories must ignore secrets, generated files, and runtime data.

Constraints: Ignore `data/`, `*.db`, `*.log`, `.env`, `venv/`, `node_modules/`, Python caches and bytecode, `*.egg-info/`, `dist/`, `build/`, `.DS_Store`, and `Thumbs.db`; commit `.env.example` with placeholders.

### Rule: commit-message

Commit messages must use imperative, descriptive text without AI or tool mentions.

## Development Workflow

### Rule: task-commit

Completed, error-free tasks must be committed immediately.

### Rule: local-only-commit

Changes must be committed locally and must not be pushed.

### Rule: co-authorship

Commits must not contain `Co-authored-by` lines.

### Rule: restart-notice

Code-change responses for web-server projects must state whether a restart is required.

Constraints: Template, CSS, or static-only changes require the notice `No restart needed — browser refresh is enough.`; Python or JavaScript server changes require `Restart required — run the start script or equivalent.`
```
</pblock>


## CONTEXT - Read-Only Support

<pblock filename="run.sh" role="context" path="/mnt/c/Users/barlo/projects/drydock/uat/FxRates/runs/20261026.202600/workspace/targets/FxRates/blueprint/run.sh">
```
#!/bin/sh
# run.sh — FxRates grader. Do not filter, skip, or reinterpret.
#
# Runs ./fxrates against a fresh database: loads the supplied ECB files from the command line,
# starts `./fxrates serve` on a free local port, and compares every command's exit code and
# standard output, and every HTTP response's status and JSON body, with the known answer below.
# JSON bodies are compared as values, so key order and whitespace do not matter. Standard error
# and error-response bodies are never compared. No network beyond 127.0.0.1 is used.
#
#   sh sources/run.sh               from the application root (how `drydock uat` runs it)
#   sh uat/FxRates/bin/run.sh APP   from anywhere, grading the application root APP
#
# Exit 0 only when every check passes.
set -u

HERE=$(cd "$(dirname "$0")" && pwd)
APP=$(cd "${1:-.}" && pwd)
if [ -f "$HERE/eurofxref-hist_2025-01.csv" ]; then DATA=$HERE; else DATA=$(cd "$HERE/../sources" && pwd); fi
WORK=$(mktemp -d)
BIN="$APP/fxrates"
DATABASE_URL="$WORK/fxrates.db"
export DATABASE_URL
SERVER=""
PORT=$(python3 -c 'import socket; s = socket.socket(); s.bind(("127.0.0.1", 0)); print(s.getsockname()[1])')
BASE="http://127.0.0.1:$PORT"

stop_server() {
    if [ -n "$SERVER" ]; then
        pkill -TERM -P "$SERVER" 2>/dev/null
        kill -TERM "$SERVER" 2>/dev/null
        wait "$SERVER" 2>/dev/null
        SERVER=""
    fi
}
trap 'stop_server; rm -rf "$WORK"' EXIT
trap 'exit 1' INT TERM

if [ ! -x "$BIN" ]; then
    echo "error: no executable ./fxrates at the application root $APP." >&2
    echo "The deliverable is an executable named fxrates at the application root." >&2
    exit 1
fi

PASSED=0
FAILED=0

pass() { PASSED=$((PASSED + 1)); echo "PASS $1"; }
fail() { FAILED=$((FAILED + 1)); echo "FAIL $1"; }

# check <id> <expected exit> <fxrates args...>  — expected standard output on stdin.
check() {
    id=$1
    want_rc=$2
    shift 2
    cat > "$WORK/want"
    (cd "$APP" && "$BIN" "$@") > "$WORK/got" 2> "$WORK/err" < /dev/null
    rc=$?
    if [ "$rc" -eq "$want_rc" ] && cmp -s "$WORK/want" "$WORK/got"; then
        pass "$id: fxrates $*"
    else
        fail "$id: fxrates $*"
        echo "  exit: expected $want_rc, got $rc"
        diff "$WORK/want" "$WORK/got" | sed 's/^/  /'
        sed 's/^/  stderr: /' "$WORK/err"
    fi
}

# http <id> <expected status> <path>  — expected JSON body on stdin (compared only for 200).
http() {
    id=$1
    want_status=$2
    path=$3
    cat > "$WORK/want"
    if python3 - "$BASE$path" "$want_status" "$WORK/want" > "$WORK/got" 2>&1 <<'PY'
import json, sys, urllib.error, urllib.request
url, want, want_file = sys.argv[1], int(sys.argv[2]), sys.argv[3]
try:
    with urllib.request.urlopen(url, timeout=15) as r:
        status, body = r.status, r.read()
except urllib.error.HTTPError as e:
    status, body = e.code, e.read()
except Exception as e:
    print(f"request failed: {e}")
    sys.exit(1)
if status != want:
    print(f"status: expected {want}, got {status}")
    print(body.decode("utf-8", "replace")[:400])
    sys.exit(1)
if want != 200:
    sys.exit(0)
try:
    got = json.loads(body)
except ValueError:
    print("body is not JSON:", body.decode("utf-8", "replace")[:400])
    sys.exit(1)
expected = json.loads(open(want_file, encoding="utf-8").read())
if got != expected:
    print("expected:", json.dumps(expected, sort_keys=True))
    print("got:     ", json.dumps(got, sort_keys=True))
    sys.exit(1)
PY
    then
        pass "$id: GET $path"
    else
        fail "$id: GET $path"
        sed 's/^/  /' "$WORK/got"
    fi
}

# start_server — run `fxrates serve` in the background and wait up to 30 s for /health.
start_server() {
    (cd "$APP" && exec "$BIN" serve --port "$PORT") > "$WORK/server.log" 2>&1 < /dev/null &
    SERVER=$!
    tries=0
    until python3 -c "import urllib.request, sys; urllib.request.urlopen(sys.argv[1], timeout=2)" \
            "$BASE/health" 2>/dev/null; do
        tries=$((tries + 1))
        if [ "$tries" -ge 30 ] || ! kill -0 "$SERVER" 2>/dev/null; then
            echo "FAIL S1: fxrates serve --port $PORT did not answer GET /health within 30 s"
            sed 's/^/  server: /' "$WORK/server.log"
            echo "FxRates: $PASSED passed, unscored HTTP checks (server did not start)"
            exit 1
        fi
        sleep 1
    done
}

# ── A. Command line: initialize and load ───────────────────────────────────────────────
check A1 0 init < /dev/null
check A2 0 load "$DATA/eurofxref-hist_2025-01.csv" <<'EOF'
dates,rates
22,176
EOF
check A3 0 load "$DATA/eurofxref-hist_2025-01.csv" <<'EOF'
dates,rates
22,176
EOF
check A4 3 load "$DATA/eurofxref-hist_bad.csv" < /dev/null
check A5 1 load "$WORK/no-such-file.csv" < /dev/null

# ── U. Command-line usage errors ─────────────────────────────────────────────────────────
check U1 2 < /dev/null
check U2 2 frobnicate < /dev/null
check U3 2 load < /dev/null
check U4 2 serve --port notaport < /dev/null

start_server
# ── H. HTTP over January 2025 ────────────────────────────────────────────────────────────
http H1 200 '/health' <<'EOF'
{"status":"ok"}
EOF
http H2 200 '/stats' <<'EOF'
{"dates":22,"rates":176,"first":"2025-01-02","last":"2025-01-31"}
EOF
http H3 200 '/currencies' <<'EOF'
{"base":"EUR","currencies":["AUD","CAD","CHF","CNY","GBP","JPY","SEK","USD"]}
EOF
http H4 200 '/rates/2025-01-17' <<'EOF'
{"date":"2025-01-17","requested":"2025-01-17","base":"EUR","rates":{"AUD":"1.6646","CAD":"1.4864","CHF":"0.9394","CNY":"7.5474","GBP":"0.84453","JPY":"160.23","SEK":"11.506","USD":"1.0298"}}
EOF
http H5 200 '/rates/2025-01-18' <<'EOF'
{"date":"2025-01-17","requested":"2025-01-18","base":"EUR","rates":{"AUD":"1.6646","CAD":"1.4864","CHF":"0.9394","CNY":"7.5474","GBP":"0.84453","JPY":"160.23","SEK":"11.506","USD":"1.0298"}}
EOF
http H6 404 '/rates/2024-12-31' < /dev/null
http H7 422 '/rates/2025-13-01' < /dev/null
http H8 200 '/rates/latest' <<'EOF'
{"date":"2025-01-31","requested":"latest","base":"EUR","rates":{"AUD":"1.6702","CAD":"1.5035","CHF":"0.9449","CNY":"7.5363","GBP":"0.83608","JPY":"160.99","SEK":"11.474","USD":"1.0393"}}
EOF
http H9 200 '/convert?from=USD&to=GBP&amount=100&date=2025-01-17' <<'EOF'
{"date":"2025-01-17","from":"USD","to":"GBP","amount":"100","rate":"0.820091","result":"82.01"}
EOF
http H10 200 '/convert?from=EUR&to=JPY&amount=250.25&date=2025-01-05' <<'EOF'
{"date":"2025-01-03","from":"EUR","to":"JPY","amount":"250.25","rate":"161.770000","result":"40482.94"}
EOF
http H11 200 '/convert?from=GBP&to=EUR&amount=1000' <<'EOF'
{"date":"2025-01-31","from":"GBP","to":"EUR","amount":"1000","rate":"1.196058","result":"1196.06"}
EOF
http H12 200 '/convert?from=SEK&to=CNY&amount=12345.67&date=2025-01-20' <<'EOF'
{"date":"2025-01-20","from":"SEK","to":"CNY","amount":"12345.67","rate":"0.656236","result":"8101.67"}
EOF
http H13 404 '/convert?from=USD&to=XXX&amount=1' < /dev/null
http H14 422 '/convert?from=USD&to=GBP' < /dev/null
http H15 422 '/convert?from=USD&to=GBP&amount=abc' < /dev/null
http H16 404 '/convert?from=USD&to=GBP&amount=10&date=2024-12-01' < /dev/null
http H17 200 '/history/USD?start=2025-01-20&end=2025-01-24' <<'EOF'
{"currency":"USD","base":"EUR","count":5,"min":"1.0316","max":"1.0472","mean":"1.039840","points":[{"date":"2025-01-20","rate":"1.0316"},{"date":"2025-01-21","rate":"1.0357"},{"date":"2025-01-22","rate":"1.0443"},{"date":"2025-01-23","rate":"1.0404"},{"date":"2025-01-24","rate":"1.0472"}]}
EOF
http H18 200 '/history/CHF?start=2025-01-27' <<'EOF'
{"currency":"CHF","base":"EUR","count":5,"min":"0.943","max":"0.9453","mean":"0.944280","points":[{"date":"2025-01-27","rate":"0.9453"},{"date":"2025-01-28","rate":"0.9441"},{"date":"2025-01-29","rate":"0.943"},{"date":"2025-01-30","rate":"0.9441"},{"date":"2025-01-31","rate":"0.9449"}]}
EOF
http H19 404 '/history/HRK' < /dev/null
http H20 200 '/history/USD?start=2025-02-01' <<'EOF'
{"currency":"USD","base":"EUR","count":0,"min":null,"max":null,"mean":null,"points":[]}
EOF
http H21 422 '/history/GBP?start=2025-01-31-x' < /dev/null

# ── L. A load while the server runs is visible to the next request ───────────────────────
check L1 0 load "$DATA/eurofxref-hist_2025-02-03_04.csv" <<'EOF'
dates,rates
2,16
EOF
http L2 200 '/stats' <<'EOF'
{"dates":24,"rates":192,"first":"2025-01-02","last":"2025-02-04"}
EOF
http L3 200 '/rates/latest' <<'EOF'
{"date":"2025-02-04","requested":"latest","base":"EUR","rates":{"AUD":"1.6629","CAD":"1.4894","CHF":"0.9396","CNY":"7.4943","GBP":"0.83188","JPY":"160.52","SEK":"11.418","USD":"1.0335"}}
EOF
http L4 200 '/rates/2025-02-01' <<'EOF'
{"date":"2025-01-31","requested":"2025-02-01","base":"EUR","rates":{"AUD":"1.6702","CAD":"1.5035","CHF":"0.9449","CNY":"7.5363","GBP":"0.83608","JPY":"160.99","SEK":"11.474","USD":"1.0393"}}
EOF
http L5 200 '/history/AUD?start=2025-01-30' <<'EOF'
{"currency":"AUD","base":"EUR","count":4,"min":"1.6629","max":"1.6705","mean":"1.667675","points":[{"date":"2025-01-30","rate":"1.6705"},{"date":"2025-01-31","rate":"1.6702"},{"date":"2025-02-03","rate":"1.6671"},{"date":"2025-02-04","rate":"1.6629"}]}
EOF

stop_server
TOTAL=$((PASSED + FAILED))
echo "FxRates: $PASSED passed, $FAILED failed (of $TOTAL)"
[ "$FAILED" -eq 0 ]
```
</pblock>

<pblock filename="ARCHITECTURE_compact.md" role="context" path="/mnt/c/Users/barlo/projects/drydock/uat/FxRates/runs/20261026.202600/workspace/targets/FxRates/blueprint/ARCHITECTURE_compact.md">
```
<!-- Compacted from ARCHITECTURE.md sha256=c0c8a5e7a3d5142d1daf0fd898de36ed4f766fb554c0250f80d781debf599a34 on 2026-10-26 by drydock build agent -->

Python 3.11+, FastAPI, uvicorn, and SQLite. `cli` owns the root executable and dispatch, `app_server` owns the application factory and routes, `services` owns shared behavior, `persistence` owns generated storage access, and `config` owns database location resolution. HTTP handlers and CLI commands call services; only persistence accesses the database. Preserve ECB rates as text and use `Decimal` for arithmetic.
```
</pblock>

<pblock filename="DATABASE_compact.md" role="context" path="/mnt/c/Users/barlo/projects/drydock/uat/FxRates/runs/20261026.202600/workspace/targets/FxRates/blueprint/DATABASE_compact.md">
```
<!-- Compacted from DATABASE.md sha256=54097832936d2ba5b7c2f8d44ed278d915a1ad842f4bab76d284889f3ecf4a66 on 2026-10-26 by drydock build agent -->

Rates are stored in `rates(id, date, currency, rate)`, with text values and a unique `(date, currency)` key. The generated repository currently exposes `upsert`, `by_date`, `publications_through`, `history`, and `list`; history bounds are inclusive and results use their declared ordering. Application code must use the generated persistence package and resolve the store from `DATABASE_URL`, then `DATABASE_PATH`, then `data/app.db`.
```
</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-Grader.md" role="implements" path="/mnt/c/Users/barlo/projects/drydock/uat/FxRates/runs/20261026.202600/workspace/targets/FxRates/blueprint/FEATURE-Grader.md" guidance="Feature Specification">
```markdown
# FEATURE: Complete Grader Verification

| Field       | Value |
|-------------|-------|
| Version     | 20261026 V1 |
| Description | Defines the terminal verification of the supplied FxRates grader. |
| Depends On  | ARCHITECTURE.md, DATABASE.md, FEATURE-AppServer.md, FEATURE-CLI.md, FEATURE-Load.md, FEATURE-Fetch.md, FEATURE-Init.md, FEATURE-Health.md, FEATURE-Stats.md, FEATURE-Currencies.md, FEATURE-Rates.md, FEATURE-LatestRates.md, FEATURE-Convert.md, FEATURE-History.md, FEATURE-CLI-Errors.md, FEATURE-Tests.md |
| Provides    | complete supplied grader verification |
| Consumes    | sources/run.sh |

## Purpose

Run the supplied grader after all implementation and project test work is complete. The grader's exit status is the release verification result.

## Verification

- Invoke the staged `sources/run.sh` from the application root without modifying or filtering it.
- Treat its exit status as the sole acceptance verdict.

## Programmatic Acceptance

=== AC grader-complete ===
Intent: The complete supplied grader passes.
Suite: full

import subprocess

result = subprocess.run(
    ["sh", "sources/run.sh"],
    capture_output=True,
    text=True,
)
print(result.stdout)
print(result.stderr)
assert result.returncode == 0
=== END AC grader-complete ===

## User Acceptance

- None.

## Guardrails

- Keep `sources/run.sh` and all supplied scoring assets unchanged.
- Run the full grader only as terminal project verification.
```
</pblock>

<pblock label="Build instructions" kind="instructions">
### Build instructions for this block

#### Verify complete supplied grader conformance. (grader)
Run the staged, unmodified sources/run.sh as the terminal project verification. Its exit status
is the sole acceptance verdict. Do not filter or reinterpret its checks.

</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:

- `compass` — the Target's COMPASS.md orientation.
- `implements` — the Typed Specification files this step builds. These are
  authoritative; implement them exactly.
- `context` — read-only support specifications. Do not reimplement them.
- `stack` — enterprise stack and technology rules. Honor them.
- `rules` — governance and branding rules. Honor them.

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.
2. 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.
3. Implement only this step. Use `context`, `stack`, and `rules` as constraints,
   not as additional work to perform.
4. Follow the stack and rules for languages, structure, naming, and branding.
5. 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.
6. 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.
   When Drydock supplies a disposable SQLite store in DATABASE_URL/DATABASE_PATH, use those
   inherited values for development tests. Each agent call receives a fresh provisioned test
   store. Never delete a default database path to clean test failures. Project tests still need
   fixture-owned setup and cleanup so repeated tests in the same call do not depend on order.
   A managed-state violation stops the block and retains a recovery snapshot; do not restore or
   reprovision shared state yourself. Preserve published text even when a conflicting criterion
   requests formatting: report the source conflict and its evidence instead of changing semantics.
   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.
7. Treat `User Acceptance` entries as review evidence requirements. Implement
   the supporting behavior, but do not claim to have performed human judgment.
8. 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.
9. 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.
10. 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`.
11. 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.
12. 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.
13. End your response with this exact closing structure:

```text
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:

```text
<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.

14. `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.
15. 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.

```text
FAILURE_SUMMARY: <one line naming the cause>
FAILURE_DETAIL: <what happened, why, and what to change before rerunning>
```

16. 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:

```text
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.


# Repair Feedback

## Repair pass

Repair the existing implementation against the measured failures below.
Keep the specifications and staged assets fixed. Restore regressed behavior first;
preserve passing behavior while fixing the underlying cause.

The diagnostic excerpts below are truncated. Read each named `full output` log
before editing; it is the complete previous deterministic result. If no log is
available, run the failing check to obtain its diagnostics. Use section or example
filters to diagnose coherent root-cause clusters, then test the changed behavior
and its neighbors. Do not add example-specific exceptions.

Drydock runs every declared acceptance check after this call. Do not repeat all
acceptance suites merely to return a verdict. If you run a suite, wait for completion
or its declared timeout; silence alone is not evidence of a hang. Report unfinished
verification accurately. An earlier agent note is advisory; measured results govern.

If a check below cannot pass however the code is written — the command it runs
succeeds and the assertion still fails — report it with `AC_BROKEN: <check-id>`
and explain the contradiction in `FAILURE_DETAIL`. The report is recorded as
evidence and stops nothing: the repair budget is spent as for any other failure,
so keep the code correct and every other check green.

### Regression — fix this first

The criteria below belong to earlier stories that were already proven. They were
green before this block ran and are red now, so this block's edits broke them.
Restore the behavior they assert without discarding this block's own work, and do
not edit the criteria.

- init-clears-store (FEATURE-Init.md): The init command succeeds and leaves the rates repository empty.
    assertion: assert code == 0 → AssertionError
    output:
      --- drydock: end values ---
      Traceback (most recent call last):
        File "init-clears-store.py", line 8, in <module>
          assert code == 0
                 ^^^^^^^^^
      AssertionError
    full output: /mnt/c/Users/barlo/projects/drydock/uat/FxRates/runs/20261026.202600/workspace/targets/FxRates/evidence/repair/block-6/init-clears-store.log
- stats-empty-store (FEATURE-Stats.md): The statistics endpoint reports null date bounds when the rates store is empty.
    assertion: assert code == 0 → AssertionError
    output:
      --- drydock: end values ---
      Traceback (most recent call last):
        File "stats-empty-store.py", line 9, in <module>
          assert code == 0
                 ^^^^^^^^^
      AssertionError
    full output: /mnt/c/Users/barlo/projects/drydock/uat/FxRates/runs/20261026.202600/workspace/targets/FxRates/evidence/repair/block-6/stats-empty-store.log

### Files written so far
- data/app.db-shm
- data/app.db-wal
- services/rates.py

