# 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: LayersTesting
- BUILD_DIRECTORY: /mnt/c/Users/barlo/projects/drydock/uat/LayersTesting/runs/20261027.135355/build/LayersTesting
- WORKING_DIRECTORY: /mnt/c/Users/barlo/projects/drydock/uat/LayersTesting/runs/20261027.135355/build/LayersTesting
- BUILD_BLOCK: Block 1 · Foundational (block-1)
- STORIES: Stand up the Python project tree, environment, dependency manifest, pytest runner, and bin/test.sh. (foundation-python)
- DATE: 2026-10-27
- BUILD_SCOPE: exactly one MANIFEST.md build block

</pblock>

<pblock label="Stories in this block" kind="section">
## Stories in this block
- Stand up the Python project tree, environment, dependency manifest, pytest runner, and bin/test.sh. (foundation-python) [story]

</pblock>

<pblock label="Files on disk" kind="section">
## Files on disk in the build directory
- sources/run.sh
- sources/seed_accounts.csv
- sources/seed_categories.csv
- sources/seed_transactions.csv
- sources/seed_transactions_bad.csv

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

## Compass

Build a command-line cash ledger, an executable named `ledger` at the application root, as
described in `sources/INSTRUCTIONS.md`. It keeps accounts, categories, and cash transactions in a
relational database reached only through the shipped persistence library, rejects a failing command
before it writes, enforces non-negative balances, and reports balances, category totals, and monthly totals.

Correctness is measured by `sources/run.sh`: 43 checks of exit code and standard output against
known answers computed from the seed files. The goal is every check passing.

## Constraints

- Implement in the language and database named under `## Stack` in `sources/INSTRUCTIONS.md`.
- Provide an executable named `ledger` at the application root, invoked as `./ledger <command>`.
- Read the database location from `DATABASE_URL`, then `DATABASE_PATH`, then `data/app.db`.
- Store amounts as integer cents.
- Check every command in full before its first write.
- Run without network access.
- 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 seed file from application code. Seed files reach the
  database only through `ledger load`.
- Do not hardcode a report row, a count, or a total. Every value comes from a query.
- Do not open a database driver outside the shipped persistence library.
- Do not use floating point for money at any layer.

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


## STACK - Technology HOW

<pblock filename="common.md" role="stack" path="/mnt/c/Users/barlo/projects/drydock/Rigging/stack/common.md">
````
# Common Best Practices

**Type:** guidance
**Version:** 20260320 V1  
**Category:** Technologies
**Description:** Common development patterns shared across all stack configurations

Always included regardless of technology stack. Covers project structure conventions, shell scripts, metadata files, git hygiene, and development workflow. This file does not change between projects.

---

## 1. Project Directory Layout

**Rule**: Every project follows a predictable directory structure.

```
project-name/
├── bin/                # Operation scripts (see Shell Scripts section)
├── data/               # Runtime data (DB, logs, backups) — gitignored
│   ├── logs/           # Script and process output logs
│   └── backups/        # Database and file backups
├── docs/               # Project documentation
├── tests/              # Test suite
├── PROJECT/            # Build specification (optional, for specification-driven projects)
├── .env                # Environment config — gitignored
├── .env.example        # Template with placeholder values — committed
├── .gitignore
├── CLAUDE.md           # AI agent instructions
└── Links.md            # External links
```

Additional directories depend on the stack (e.g., `templates/`, `static/`, `migrations/`).

**Why**: Consistent layout lets any developer or AI agent locate files instantly.

---

## 2. Shell Scripts (bin/ Directory)

**Rule**: All user-facing operations live in `bin/` as bash scripts with standardized headers, logging, and error handling.

### Script Template

```bash
#!/bin/bash
# CommandCenter Operation
# Name: Human Readable Name
# Type: daemon|batch
# Port: 8000

# --- Standard Preamble ---
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
LOG_DIR="$PROJECT_DIR/data/logs"
mkdir -p "$LOG_DIR"

TIMESTAMP=$(date '+%Y-%m-%d_%H%M%S')
SCRIPT_NAME=$(basename "$0" .sh)
LOG_FILE="$LOG_DIR/${SCRIPT_NAME}_${TIMESTAMP}.log"

echo "=== $SCRIPT_NAME started at $(date '+%Y-%m-%d %H:%M:%S') ===" | tee "$LOG_FILE"
echo "Arguments: $*" | tee -a "$LOG_FILE"
echo "Working dir: $PROJECT_DIR" | tee -a "$LOG_FILE"
echo "---" | tee -a "$LOG_FILE"

cd "$PROJECT_DIR"

# --- Your Commands Here ---
# All output goes to both console and log file via tee
your_command 2>&1 | tee -a "$LOG_FILE"

echo "=== $SCRIPT_NAME finished at $(date '+%Y-%m-%d %H:%M:%S') ===" | tee -a "$LOG_FILE"
```

### Header Fields

The first comment block is parsed by Command Center's scanner for auto-discovery:

| Field | Required | Values | Description |
|-------|----------|--------|-------------|
| `# CommandCenter Operation` | Yes | literal | Marks script as discoverable |
| `# Name:` | Yes | free text | Display name in UI |
| `# Type:` | No | `daemon` or `batch` | Default: `batch`. Daemons stay running. |
| `# Port:` | No | integer | Port number for daemon services |

Scripts without the `# CommandCenter Operation` header are still valid scripts but won't appear in Command Center's UI.

### Standard Scripts

Every project should have these scripts (where applicable):

| Script | Type | Purpose |
|--------|------|---------|
| `bin/start.sh` | daemon | Start the dev server |
| `bin/stop.sh` | batch | Stop the dev server |
| `bin/test.sh` | batch | Run test suite |
| `bin/build.sh` | batch | Build/compile the project |
| `bin/deploy.sh` | batch | Deploy to production |
| `bin/backup.sh` | batch | Backup data/database |

### Logging Pattern

- All stdout and stderr captured via `tee` to `data/logs/`
- Log filename includes script name and timestamp: `start_2026-03-07_143022.log`
- First lines of log always record: timestamp, arguments, working directory
- These logs are viewable from Command Center's Process Monitor

**Why**: Standardized scripts make every project operable the same way. Log capture enables monitoring, alerting, and post-mortem analysis.

---

## 3. External Links (Links.md)

**Rule**: Every project maintains a `Links.md` file at its root with a markdown table of relevant URLs.

```markdown
| Label | URL |
|-------|-----|
| Local Dev | http://localhost:5001 |
| Production | https://example.com |
| Docs | https://docs.example.com |
| GitHub | https://github.com/user/repo |
```

Rules:
- One table, two columns: Label and URL
- Labels are short and descriptive
- Command Center's scanner reads this on startup and stores links in the project's `extra` JSON
- Links appear in the project's configuration page

**Why**: Centralizes all project URLs in one discoverable, parseable location. Both AI agents and Command Center consume it.

---

## 4. CLAUDE.md Convention

**Rule**: Every project has a `CLAUDE.md` at its root following this section structure:

1. `## Project Overview` — What the project does, key features
2. `## Architecture` — Tech stack, key files, patterns
3. `## Dev Commands` — Bash commands to run the project (in a code block)
4. `## Service Endpoints` — URLs: `- Label: https://url`
5. `## Bookmarks` — Grouped links: `### Group` then `- [Title](URL)`

Section rename rules — always use the standard name:
- `## Commands` / `## Development Commands` / `## Build Commands` → `## Dev Commands`
- `## Overview` / `## Project Purpose` → `## Project Overview`
- `## Stack` → `## Architecture`

**Why**: Consistent structure lets AI agents parse project context reliably.

---

## 5. Git Hygiene

**Rule**: Maintain a comprehensive `.gitignore`. Never commit secrets, generated files, or runtime data.

```gitignore
# Runtime
data/
*.db
*.log

# Environment
.env
venv/
node_modules/

# Python
__pycache__/
*.pyc
*.egg-info/
dist/
build/

# OS
.DS_Store
Thumbs.db
```

Rules:
- `data/` — runtime databases, logs, backups, uploads
- `.env` — secrets and local config
- Commit `.env.example` with placeholder values
- Write imperative commit messages: "Add health endpoint" not "Added health endpoint"

**Why**: Clean repos are cloneable and runnable. No secrets in history.

---

## 6. Development Workflow

**Rule**: Follow these rules when working in any git-managed project.

1. **Always commit changes immediately** after completing a task if the task has no errors
2. **Commit messages** should have descriptive text (no AI/tool mentions)
3. **DO NOT push** — only commit to local git
4. **NO co-authored-by lines** in commits
5. **Always end code change responses with a restart notice** for any project that runs a web server:
   - If only templates/CSS/static files changed: "No restart needed — browser refresh is enough."
   - If any Python/JS server files changed: "Restart required — run the start script or equivalent."

**Why**: Consistent workflow prevents accidental pushes, keeps commit history clean, and ensures developers know when to restart.

---

## Summary Checklist

- [ ] Standard directory layout with `bin/`, `data/`, `docs/`, `tests/`
- [ ] Shell scripts in `bin/` with CommandCenter headers and tee logging
- [ ] `Links.md` for external URLs
- [ ] `CLAUDE.md` following section convention
- [ ] `.env.example` committed, `.env` gitignored
- [ ] Comprehensive `.gitignore`
- [ ] Commit immediately, don't push, no AI mentions
````
</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="python.md" role="implements" path="/mnt/c/Users/barlo/projects/drydock/Rigging/languages/python/python.md">
```
# Python Foundation

**Type:** language
**Version:** 20261018 V5
**Foundation:** language
**Tier:** language
**Category:** Language
**Description:** Python project foundation and cross-package contracts

Prerequisite: `stack/common.md`

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

## Rules

- Target Python 3.11 or newer. Declare the supported version in `pyproject.toml`.
- Keep runtime settings in one typed configuration boundary. Document supported environment
  variables in `.env.example`; keep `.env` and secrets out of Git. Use project-specific names and
  defaults from the Blueprint rather than examples in Rigging.
- Use modern type hints on public interfaces and named types for data exchanged between packages.
- Put application behavior in importable modules; launchers in `bin/` activate `.venv` and invoke
  those modules. Launchers do not contain business logic.
- Use named Python loggers for application events. Never log secrets.
- Use pytest for behavior and acceptance tests. Isolate external state and dependencies in tests.
  Every launcher and CI test gate runs the published `test_command`.
- Use `uv` for environment and dependency management. Commit `pyproject.toml` and `uv.lock`;
  do not commit `.venv/`.
```
</pblock>

<pblock filename="ARCHITECTURE.md" role="implements" path="/mnt/c/Users/barlo/projects/drydock/uat/LayersTesting/runs/20261027.135355/workspace/targets/LayersTesting/blueprint/ARCHITECTURE.md" guidance="Foundational Architecture Specification">
```markdown
# ARCHITECTURE: LayersTesting

| Field | Value |
|-------|-------|
| Version | 20261027 V1 |
| Description | Modules, boundaries, and technical decisions for the LayersTesting command-line cash ledger. |
| Provides | project tree, bin/test.sh |

## Purpose

The product is an executable named `ledger` at the application root. It keeps accounts, categories, and cash transactions in SQLite through the generated `persistence` package. Every command either completes in full or changes nothing. This file states the module layout and boundaries every other Blueprint builds into.

## Technology Stack

Derived from `TECHNOLOGY_STACK.md`, which remains the decision of record.

| Technology | Where it applies |
|---|---|
| Python 3.11+ | All application code, the `ledger` launcher target, and the tests. |
| SQLite | The only store, reached through the generated `persistence` package. |
| CLI | The `ledger` executable and the `cli` package. |
| pytest | Test runner behind `bin/test.sh`. |
| POSIX sh | `bin/test.sh` and the `ledger` launcher. |

## Project Tree

| Path | Owner story | Purpose |
|---|---|---|
| `pyproject.toml`, `uv.lock` | foundation-python | Dependency manifest and committed lock. |
| `bin/test.sh` | foundation-python | POSIX launcher: activates `.venv`, runs `pytest -q` from the application root, exits zero only when every test passes. |
| `conftest.py` | foundation-python | Exposes the `db_session` and `cli_runner` fixtures. |
| `ledger_core/` | foundation-python and later services | Domain logic: `config`, `errors`, then `validation`, `money`, `balances`, `csvio`, `accounts`, `transactions`, `reports` added by their own stories. |
| `persistence/` | Drydock (generated) | Repository layer generated from `DATABASE.md`. |
| `cli/` | foundation-cli | `main`, registry, command modules, `testing.cli_runner`. |
| `ledger` | foundation-cli | Executable launcher at the application root. |
| `tests/` | each story | The project's own test suite. |

## Module Ownership

| Boundary | Owning module | May access |
|---|---|---|
| Persistence | `persistence` (generated) | The SQLite driver, the only module that does. |
| Configuration | `ledger_core.config` | `DATABASE_URL`, `DATABASE_PATH`, process environment. |
| Domain errors | `ledger_core.errors` | Nothing external. |
| Money and validation | `ledger_core.money`, `ledger_core.validation` | Nothing external; pure functions. |
| Command dispatch and output | `cli` | stdout, stderr, `ledger_core`, `persistence.open_database`. |
| File stores | none | The only files read are CSV files named on a command line, through `ledger_core.csvio`. |
| External services | none | No network access. |

No module outside `persistence` imports `sqlite3` or any other database driver. Callers use `db.<table>.<operation>(...)`.

## Configuration

`ledger_core.config.database_path() -> str` resolves `DATABASE_URL` first, with an optional leading `sqlite://` removed, then `DATABASE_PATH`, then `data/app.db`. An unset or empty value is skipped. A database location that cannot be opened is an operational failure: exit `1`, nothing written.

## Errors and Exit Codes

`ledger_core.errors` defines `LedgerError` with an integer `exit_code` attribute and three subclasses.

| Class | exit_code | Meaning |
|---|---|---|
| `Rejected` | 3 | Invalid input, duplicate key, unknown reference, account in use, negative balance. |
| `NotFound` | 4 | Absent account or transaction on get, rename, delete, or amend. |
| `Operational` | 1 | Unreadable file or unopenable database. |

Usage errors (exit `2`) are produced by `cli` dispatch and are not domain errors.

## Money

Amounts are integer cents at every layer: parsing, storage, arithmetic, and reports. Floating point is never used for money. Text is produced only at output by `ledger_core.money.format_cents`.

## Atomicity

Every writing command validates all inputs and rules, including the no-negative-balance rule, before its first write. A rejected command writes nothing.

## Test Command

`sh bin/test.sh` runs `pytest -q` and is the verification command for every behavioral story.

## Programmatic Acceptance

=== AC arch-project-files ===
Intent: The project root carries the dependency manifest, lock, pytest conftest, and a test launcher that runs pytest.

from pathlib import Path

for name in ["pyproject.toml", "uv.lock", "conftest.py", "bin/test.sh"]:
    assert Path(name).is_file(), name
launcher = Path("bin/test.sh").read_text()
assert "pytest" in launcher
=== END AC arch-project-files ===

=== AC arch-packages-import ===
Intent: The ledger_core package and its foundation modules import.

import ledger_core
import ledger_core.config
import ledger_core.errors

assert callable(ledger_core.config.database_path)
=== END AC arch-packages-import ===

=== AC arch-config-precedence ===
Intent: DATABASE_URL wins over DATABASE_PATH, an empty URL falls through, and with both unset the default path is used.

from drydock_acceptance import database_environment
from ledger_core.config import database_path

with database_environment(url="sqlite://primary.db", path="fallback.db") as root:
    assert str(database_path()) == str(root / "primary.db")
with database_environment(url="plain.db", path="fallback.db") as root:
    assert str(database_path()) == str(root / "plain.db")
with database_environment(url="", path="fallback.db") as root:
    assert str(database_path()) == str(root / "fallback.db")
with database_environment(path="fallback.db") as root:
    assert str(database_path()) == str(root / "fallback.db")
with database_environment() as root:
    assert str(database_path()) == "data/app.db"
=== END AC arch-config-precedence ===

=== AC arch-error-exit-codes ===
Intent: The three domain error classes derive from LedgerError and carry the exit codes 3, 4, and 1.

from ledger_core.errors import LedgerError, Rejected, NotFound, Operational

expected = {Rejected: 3, NotFound: 4, Operational: 1}
for cls, code in expected.items():
    assert issubclass(cls, LedgerError)
    err = cls("probe")
    assert err.exit_code == code
=== END AC arch-error-exit-codes ===

=== AC arch-driver-boundary ===
Intent: No application module outside the generated persistence package imports a database driver.

import ast
from pathlib import Path

banned = {"sqlite3", "psycopg", "psycopg2"}
checked = 0
assert Path("ledger_core").is_dir()
for root in ["ledger_core", "cli"]:
    base = Path(root)
    if not base.is_dir():
        continue
    for path in base.rglob("*.py"):
        tree = ast.parse(path.read_text())
        for node in ast.walk(tree):
            if isinstance(node, ast.Import):
                names = [a.name.split(".")[0] for a in node.names]
            elif isinstance(node, ast.ImportFrom):
                names = [(node.module or "").split(".")[0]]
            else:
                continue
            assert not (banned & set(names)), (str(path), names)
        checked += 1
print(checked, "files scanned")
assert checked >= 1
=== END AC arch-driver-boundary ===

=== AC arch-no-float ===
Intent: Domain code contains no float call and no float literal, so money never uses floating point.

import ast
from pathlib import Path

checked = 0
for path in Path("ledger_core").rglob("*.py"):
    tree = ast.parse(path.read_text())
    for node in ast.walk(tree):
        if isinstance(node, ast.Call) and isinstance(node.func, ast.Name):
            assert node.func.id != "float", str(path)
        if isinstance(node, ast.Constant):
            assert not isinstance(node.value, float), str(path)
    checked += 1
print(checked, "files scanned")
assert checked >= 1
=== END AC arch-no-float ===

## User Acceptance

- None.

## Guardrails

- Do not modify any file under `sources/`.
- Application code never reads `sources/run.sh` or any seed file; seed files reach the database only through `ledger load`.
- Do not hardcode a report row, a count, or a total; every value comes from a query.
- Do not open a database driver outside the generated persistence package.
- Do not use floating point for money at any layer.
- The ledger runs without network access.
- Diagnostics go to standard error and are never compared.
```
</pblock>

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

#### Stand up the Python project tree, environment, dependency manifest, pytest runner, and bin/test.sh. (foundation-python)
Build the Python 3.11+ project root: pyproject.toml, committed uv.lock, `.venv` launchers in bin/,
conftest.py, and a POSIX `bin/test.sh` that runs pytest -q from the application root and exits zero
only when every test passes.

Create the `ledger_core` package that later stories fill (validation, money, balances, csvio,
accounts, transactions, reports). State the module ownership table: only the generated
`persistence` package touches the database; no driver is imported elsewhere. Money is integer
cents at every layer; no floating point.

Configuration resolves DATABASE_URL (optional `sqlite://` prefix), then DATABASE_PATH, then
`data/app.db`. An unopenable database path is an operational failure, exit 1, with no writes.

</pblock>

<pblock label="Reusable compact request" kind="section">
## Reusable compacts

The Blueprint sources below are consumed as context by later Manifest blocks.
In this same response, extract their consumer-facing contract surface. Preserve
interfaces, schemas, constraints, configuration, and cross-file obligations; drop
implementation narrative and repetition. Do not write these files yourself.

Before the required RESULT block, emit one optional payload per source exactly as:
<reusable-compact filename="SOURCE.md">
compact content
</reusable-compact>

Emit no payload when a source has no useful technical surface. These payloads are
advisory and do not change the required build result or file-change report.

Sources eligible for reusable compaction:
- ARCHITECTURE.md

</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.
   During repair, select a failing example, reproduce it before editing, and trace its actual
   execution branch. Add a regression that fails on the current code, fix the cause, and run
   that regression plus a passing neighbor. Revise an ineffective edit within this call.
   Report only tests actually executed, with their command and result; label unrun tests unrun.
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.

