Run artifact

evidence/prompts/20261023.175350.426Z_readinglist_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/ReadingList/runs/20261023.174350/workspace/targets/ReadingList/COMPASS.md" guidance="Important: This is the core project intent, constraints, and guardrails. It should have presecedence in conflicts.">

# COMPASS: ReadingList

## Compass
A web application that lets a reader keep a personal list of books to read. The reader adds a book with a title and author, views books in the order they were added, and removes books. It serves a single reader who needs a simple, dependable reading list with clear feedback on invalid input.

## Constraints
- The application is a web application with a user-facing interface.
- The completed application must provide a POSIX-compatible `bin/test.sh` runnable from the application root with `sh bin/test.sh`.
- `bin/test.sh` must exit zero only when every automated test passes.
- The final build story runs `bin/test.sh` after every implementation story and preserves its command, exit code, stdout, and stderr as evidence.

## Guardrails
- Never accept an empty title or an empty author; reject the submission with a clear error message.
- Never present books in any order other than the order they were added.
- Never report a test run as passing unless every automated test passes.
- Never omit a removed book from the next list read only partially; a removed book must not reappear.

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

- Authorized build directory: `/mnt/c/Users/barlo/projects/drydock/uat/ReadingList/runs/20261023.174350/build/ReadingList`
- Authorized Target directory: `/mnt/c/Users/barlo/projects/drydock/uat/ReadingList/runs/20261023.174350/workspace/targets/ReadingList`
- 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/ReadingList/runs/20261023.174350/workspace/targets/ReadingList/blueprint/`
  - `/mnt/c/Users/barlo/projects/drydock/uat/ReadingList/runs/20261023.174350/workspace/targets/ReadingList/MANIFEST.md`
  - `/mnt/c/Users/barlo/projects/drydock/uat/ReadingList/runs/20261023.174350/workspace/targets/ReadingList/COMPASS.md`
  - `/mnt/c/Users/barlo/projects/drydock/uat/ReadingList/runs/20261023.174350/workspace/targets/ReadingList/QuarterDeck/`
  - `/mnt/c/Users/barlo/projects/drydock/uat/ReadingList/runs/20261023.174350/workspace/targets/ReadingList/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="flask.md" role="stack" path="/mnt/c/Users/barlo/projects/drydock/Rigging/stack/flask.md">

# Flask Foundation

**Type:** web-server
**Version:** 20260922 V3
**Tier:** platform
**Category:** Web Server
**Foundation:** web-server
**Description:** Flask application boundary and test client contract

Prerequisites: `stack/common.md`, `languages/python/python.md`

## Foundation Contract

- package: app_server
- entry: create_app() -> Flask
- fixture: web_client
- fixture_source: app_server/testing.py

```python
# app_server/__init__.py
def create_app() -> Flask: ...

# app_server/testing.py
from app_server import create_app
def web_client():
    app = create_app()
    app.config["TESTING"] = True
    return app.test_client()
```

`app_server.testing.web_client()` is a plain callable used directly by programmatic acceptance.
The pytest `web_client` fixture delegates to it. The application factory registers the selected
Blueprint routes, extensions, and error handlers; it does not invent routes or settings.

## Rules

- Group related routes in Flask Blueprints. Keep handlers focused on HTTP input and output; put
  business behavior in importable services without a Flask dependency.
- Load configuration through the Python foundation's typed boundary before use. Use the Target's
  names and defaults. Keep `SECRET_KEY` out of source control and disable debug mode in production.
- Use the Blueprint's routes, schemas, templates, and error contracts. Return sanitized errors;
  never expose tracebacks to clients. Preserve Jinja autoescaping.
- Keep request-bound resources request-scoped. Do not share a SQLite connection or other
  thread-bound object created in `create_app()` across request threads.
- Keep startup side effects out of imports and account for the development reloader's extra
  process. The Python foundation owns launchers, dependencies, and the test command.

</pblock>

CONTEXT - Read-Only Support

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

<!-- Compacted from ARCHITECTURE.md sha256=513564d05020d87c4d59bcbd40b693fe2aae86fabff2f44b9c436731980f5168 on 2026-10-23 by drydock build agent -->

Project: ReadingList (Flask, SQLite via generated `persistence`, pytest). Python >=3.11.
Layout: `pyproject.toml` + `uv.lock` (deps: flask>=3.1,<4; dev group: pytest>=9,<10); `.venv` via `uv venv`; `app_server/__init__.py` exposes `create_app() -> Flask`; `app_server/testing.py` exposes `web_client()`; `app_server/routes/{books.py,pages.py}`; `app_server/services/books.py` exposes `add_book`, `list_books`, `remove_book`, `validate_book_input`; `app_server/templates/`; `persistence/` generated from `DATABASE.md`; `tests/conftest.py` exposes `web_client` and `db_session` fixtures; `bin/test.sh` POSIX runner.
Rules: routes call services only; services call `db.<table>.<verb>(...)`; only `persistence` touches SQLite; books ordered by id ascending; rejected input -> 400; unknown book removal -> 404; server-rendered HTML forms, no client JS.
Config: `DATABASE_URL` > `DATABASE_PATH` > `data/app.db`.
Test command: `pytest -q` from application root.

</pblock>

<pblock filename="DATABASE_compact.md" role="context" path="/mnt/c/Users/barlo/projects/drydock/uat/ReadingList/runs/20261023.174350/workspace/targets/ReadingList/blueprint/DATABASE_compact.md">

<!-- Compacted from DATABASE.md sha256=ba3f2fb135480b34230597f018171e86cdb4992a5e13d7aed20ccb12d8eb8581 on 2026-10-23 by drydock build agent -->

Store: SQLite via generated `persistence` (DSN: DATABASE_URL > DATABASE_PATH > data/app.db). Schema applied only at DATABASE step, never at startup.
Table `books`: id INTEGER PK autoincrement (ascending id = order added); title TEXT NOT NULL; author TEXT NOT NULL.
Ops (`db.books.<verb>`):
- create(title, author) -> Book(id, title, author)
- get(id) -> Book | None
- list() -> list[Book], ordered id ASC
- delete(id) -> DeletedBook(id)
Row type: frozen dataclass `persistence.schema.Book`. Fixtures: `persistence.testing.db_session()` (rollback), `committed_session()`.
Guardrails: only `persistence/` touches the store; callers use `db.books.<verb>`; books ordered id ASC only.

</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-AddBook.md" role="implements" path="/mnt/c/Users/barlo/projects/drydock/uat/ReadingList/runs/20261023.174350/workspace/targets/ReadingList/blueprint/FEATURE-AddBook.md" guidance="Feature Specification">

# FEATURE: Add Book

| Field | Value |
|-------|-------|
| Version | 20261023 V1 |
| Description | Add a book with a title and author, persist it, and return the stored book. |
| Depends On | FEATURE-AppShell.md, DATABASE.md |
| Provides | POST /books |
| Consumes | books.create, books.get |

## Purpose

Let the reader add a book. A valid submission is stored and returned; the new book appears in later list reads.

## Trigger

A client sends `POST /books` with a JSON body.

## Sequence

1. The route parses the JSON body for `title` and `author`.
2. The service `app_server.services.books.add_book(db, title, author)` stores the book via `books.create`.
3. The route returns 201 with the stored book.

## Routes

| Route | Behavior |
|-------|----------|
| `POST /books` | JSON `{"title": ..., "author": ...}`. Returns 201 with JSON `{"id", "title", "author"}`. Validation of empty fields is owned by FEATURE-RejectEmptyFields.md. |

## Reads

`books.get` is used to return the stored row.

## Writes

`books.create` inserts one row per valid submission; ids ascend in insertion order.

## Database Interface

- `FEATURE-BOOK-001` — write: create a book - supplies: `title`, `author` - returns: `id`, `title`, `author`
- `FEATURE-BOOK-002` — read: retrieve a book by id - supplies: `id` - returns: `id`, `title`, `author`

## Tests

The build writes pytest tests under `tests/` covering a valid add, the 201 response fields, and a read-back of the stored row.

## Programmatic Acceptance

=== AC addbook-create ===
Intent: POST /books answers 201 and returns the title and author that were supplied, with an id.
Requires: python-package=flask; scope=test

from app_server.testing import web_client
from persistence.testing import committed_session

title = "ac-addbook-create-title"
author = "ac-addbook-create-author"
client = web_client()
created_id = None
try:
    response = client.post("/books", json={"title": title, "author": author})
    assert response.status_code == 201
    body = response.get_json()
    created_id = body["id"]
    assert isinstance(created_id, int)
    assert body["title"] == title
    assert body["author"] == author
finally:
    if created_id is not None:
        with committed_session() as db:
            db.books.delete(id=created_id)
=== END AC addbook-create ===

=== AC addbook-persisted ===
Intent: A submitted book is read back from the store with the supplied title and author.
Requires: python-package=flask; scope=test

from app_server.testing import web_client
from persistence.testing import committed_session

title = "ac-addbook-persist-title"
author = "ac-addbook-persist-author"
created_id = None
try:
    response = web_client().post("/books", json={"title": title, "author": author})
    assert response.status_code == 201
    created_id = response.get_json()["id"]
    with committed_session() as db:
        row = db.books.get(id=created_id)
        assert row.id == created_id
        assert row.title == title
        assert row.author == author
finally:
    if created_id is not None:
        with committed_session() as db:
            db.books.delete(id=created_id)
=== END AC addbook-persisted ===

=== AC addbook-ascending-ids ===
Intent: Two books added in sequence receive ascending ids, preserving insertion order.
Requires: python-package=flask; scope=test

from app_server.testing import web_client
from persistence.testing import committed_session

client = web_client()
created = []
try:
    for title in ["ac-addbook-seq-one", "ac-addbook-seq-two"]:
        response = client.post("/books", json={"title": title, "author": "ac-addbook-seq-author"})
        assert response.status_code == 201
        created.append(response.get_json()["id"])
    assert created[0] < created[1]
finally:
    with committed_session() as db:
        for book_id in created:
            db.books.delete(id=book_id)
=== END AC addbook-ascending-ids ===

## User Acceptance

- None.

## Guardrails

- The route never accesses the database directly; it calls the book service.
- A stored book keeps exactly the title and author supplied.

</pblock>

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

# FEATURE: List Books

| Field | Value |
|-------|-------|
| Version | 20261023 V1 |
| Description | Return all books in the order they were added. |
| Depends On | FEATURE-AddBook.md, DATABASE.md |
| Provides | GET /books |
| Consumes | books.list |

## Purpose

Let the reader view the books. Books are never presented in any order other than the order added.

## Trigger

A client sends `GET /books`.

## Sequence

1. The route calls `app_server.services.books.list_books(db)`.
2. The service calls `books.list`, which returns rows by id ascending.
3. The route returns 200 with a JSON array of `{"id", "title", "author"}` in that order.

## Routes

| Route | Behavior |
|-------|----------|
| `GET /books` | Returns 200 with a JSON array ordered by insertion. An empty list returns `[]`. |

## Reads

`books.list` returns every stored book ordered by id ascending.

## Writes

None.

## Database Interface


- `FEATURE-BOOK-003` — read: books.list - supplies: — - returns: `id`, `title`, `author`

## Tests

The build writes pytest tests that add several books and assert the returned order equals the order submitted, plus the empty-list case.

## Programmatic Acceptance

=== AC listbooks-order ===
Intent: GET /books returns the books added during the check in the order they were added.
Requires: python-package=flask; scope=test

from app_server.testing import web_client
from persistence.testing import committed_session

client = web_client()
titles = ["ac-listbooks-order-first", "ac-listbooks-order-second", "ac-listbooks-order-third"]
created = []
try:
    for title in titles:
        response = client.post("/books", json={"title": title, "author": "ac-listbooks-author"})
        assert response.status_code == 201
        created.append(response.get_json()["id"])
    listing = client.get("/books")
    assert listing.status_code == 200
    body = listing.get_json()
    assert isinstance(body, list)
    mine = [book["id"] for book in body if book["id"] in created]
    assert mine == created
finally:
    with committed_session() as db:
        for book_id in created:
            db.books.delete(id=book_id)
=== END AC listbooks-order ===

=== AC listbooks-fields ===
Intent: Each listed book carries the supplied title and author and its id.
Requires: python-package=flask; scope=test

from app_server.testing import web_client
from persistence.testing import committed_session

title = "ac-listbooks-fields-title"
author = "ac-listbooks-fields-author"
client = web_client()
created_id = None
try:
    response = client.post("/books", json={"title": title, "author": author})
    assert response.status_code == 201
    created_id = response.get_json()["id"]
    body = client.get("/books").get_json()
    matches = [book for book in body if book["id"] == created_id]
    assert len(matches) == 1
    assert matches[0]["title"] == title
    assert matches[0]["author"] == author
finally:
    if created_id is not None:
        with committed_session() as db:
            db.books.delete(id=created_id)
=== END AC listbooks-fields ===

=== AC listbooks-reachable ===
Intent: GET /books is reachable and returns a JSON array even when no check data exists.
Requires: python-package=flask; scope=test

from app_server.testing import web_client

response = web_client().get("/books")
assert response.status_code == 200
assert isinstance(response.get_json(), list)
=== END AC listbooks-reachable ===

## User Acceptance

- None.

## Guardrails

- Never present books in any order other than the order they were added.
- The route never reads the database directly; it calls the book service.

</pblock>

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

# FEATURE: Remove Book

| Field | Value |
|-------|-------|
| Version | 20261023 V1 |
| Description | Remove a book from the reading list so it never reappears in later reads. |
| Depends On | FEATURE-AddBook.md, FEATURE-ListBooks.md, DATABASE.md |
| Provides | DELETE /books/{book_id} |
| Consumes | books.delete, books.get, GET /books |

## Purpose

A reader removes a book they no longer want on their list. Once removed, the book must be absent from every subsequent list read, and the remaining books keep the order in which they were added.

## Trigger

An HTTP `DELETE /books/{book_id}` request, where `book_id` is the integer id returned when the book was added.

## Sequence

1. The route parses `book_id` as an integer. A non-integer id does not match the route and is answered by the framework as an unknown resource (404).
2. The service looks the book up through `books.get`. If it does not exist, the route answers 404 with a JSON error body.
3. The service removes the book through `books.delete`.
4. The route answers 204 with an empty body.

## Routes

| Route | Method | Success | Failure |
|-------|--------|---------|---------|
| `/books/{book_id}` | DELETE | 204, empty body | 404 for an unknown id, including a repeat removal of the same id |

## Reads

- `books.get` — confirms the book exists before deletion.

## Writes

- `books.delete` — permanently removes the book row.

## Database Interface

- `FEATURE-BOOK-004` — write: remove a book - supplies: `id` - returns: `id`
- `FEATURE-BOOK-002` — read: get a book by id - supplies: `id` - returns: `id`

## Operational Behavior

- Removal never alters the ids or relative order of the remaining books.
- A removed book must not reappear in any later read, including after the application restarts.
- Removing an already removed id is a no-op on state and answers 404.

## Programmatic Acceptance

=== AC remove-book-deletes ===
Intent: Removing an added book answers 204 and the book is absent from the next list read.
Suite: scoped

import uuid
from app_server.testing import web_client

client = web_client()
title = "ac-remove-" + uuid.uuid4().hex
author = "ac-remove-author"
created = client.post("/books", json={"title": title, "author": author})
assert created.status_code == 201
book_id = created.get_json()["id"]
try:
    before = [b["id"] for b in client.get("/books").get_json()]
    assert book_id in before
    removed = client.delete(f"/books/{book_id}")
    assert removed.status_code == 204
    after = [b["id"] for b in client.get("/books").get_json()]
    assert book_id not in after
finally:
    client.delete(f"/books/{book_id}")
=== END AC remove-book-deletes ===

=== AC remove-book-unknown-id ===
Intent: Removing an id that does not exist answers 404, and removing the same id twice answers 404 the second time.
Suite: scoped

import uuid
from app_server.testing import web_client

client = web_client()
title = "ac-remove-twice-" + uuid.uuid4().hex
created = client.post("/books", json={"title": title, "author": "ac-remove-author"})
assert created.status_code == 201
book_id = created.get_json()["id"]
try:
    first = client.delete(f"/books/{book_id}")
    assert first.status_code == 204
    second = client.delete(f"/books/{book_id}")
    assert second.status_code == 404
    existing = [b["id"] for b in client.get("/books").get_json()]
    unknown_id = max(existing + [book_id]) + 1000000
    unknown = client.delete(f"/books/{unknown_id}")
    assert unknown.status_code == 404
finally:
    client.delete(f"/books/{book_id}")
=== END AC remove-book-unknown-id ===

=== AC remove-book-preserves-order ===
Intent: Removing the middle book leaves the other books in the order they were added.
Suite: scoped

import uuid
from app_server.testing import web_client

client = web_client()
token = uuid.uuid4().hex
ids = []
try:
    for n in range(3):
        resp = client.post("/books", json={"title": f"ac-order-{token}-{n}", "author": "ac-remove-author"})
        assert resp.status_code == 201
        ids.append(resp.get_json()["id"])
    removed = client.delete(f"/books/{ids[1]}")
    assert removed.status_code == 204
    listed = [b["id"] for b in client.get("/books").get_json()]
    mine = [i for i in listed if i in ids]
    assert mine == [ids[0], ids[2]]
finally:
    for book_id in ids:
        client.delete(f"/books/{book_id}")
=== END AC remove-book-preserves-order ===

## User Acceptance

- None.

## Guardrails

- A removed book must never reappear in a later list read.
- Removal must not change the relative order of the remaining books.
- A request for an unknown id must not alter stored state.

</pblock>

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

# FEATURE: Reject Empty Fields

| Field | Value |
|-------|-------|
| Version | 20261023 V1 |
| Description | Reject a submission whose title or author is empty with a clear error and store nothing. |
| Depends On | FEATURE-AddBook.md |
| Provides | validate_book_input |
| Consumes | POST /books |

## Purpose

Guarantee the application never accepts an empty title or empty author. Rejection reports a clear, human-readable error naming the offending field.

## Trigger

A submission to `POST /books` (or the page form route) carries a missing, empty, or whitespace-only title or author.

## Sequence

1. The service calls `validate_book_input(title, author)` in `app_server.services.books` before any store call.
2. A value that is missing, not a string, or empty after stripping surrounding whitespace raises `ValueError` whose message names the field (`title` or `author`).
3. `POST /books` converts the error to status 400 with JSON `{"error": <message>}`.
4. Nothing is stored; the book list is unchanged.

## Routes

This feature adds no route of its own; it governs `POST /books` provided by FEATURE-AddBook.md.

## Reads

None.

## Writes

None. A rejected submission writes nothing.

## Database Interface

- None — persistence is owned by FEATURE-AddBook.md.

## Tests

The build writes pytest tests for empty title, empty author, both empty, missing keys, and whitespace-only values, asserting status 400 and that the list is unchanged.

## Programmatic Acceptance

=== AC reject-empty-title ===
Intent: POST /books with an empty title answers 400 and stores nothing.
Requires: python-package=flask; scope=test

from app_server.testing import web_client
from persistence.testing import committed_session

client = web_client()
with committed_session() as db:
    before = len(list(db.books.list()))
response = client.post("/books", json={"title": "", "author": "ac-reject-author"})
assert response.status_code == 400
assert isinstance(response.get_json()["error"], str)
with committed_session() as db:
    after = len(list(db.books.list()))
assert after == before
=== END AC reject-empty-title ===

=== AC reject-empty-author ===
Intent: POST /books with an empty author answers 400 and stores nothing.
Requires: python-package=flask; scope=test

from app_server.testing import web_client
from persistence.testing import committed_session

client = web_client()
with committed_session() as db:
    before = len(list(db.books.list()))
response = client.post("/books", json={"title": "ac-reject-title", "author": ""})
assert response.status_code == 400
assert isinstance(response.get_json()["error"], str)
with committed_session() as db:
    after = len(list(db.books.list()))
assert after == before
=== END AC reject-empty-author ===

=== AC reject-both-empty ===
Intent: POST /books with both fields empty answers 400 and stores nothing.
Requires: python-package=flask; scope=test

from app_server.testing import web_client
from persistence.testing import committed_session

client = web_client()
with committed_session() as db:
    before = len(list(db.books.list()))
response = client.post("/books", json={"title": "", "author": ""})
assert response.status_code == 400
with committed_session() as db:
    after = len(list(db.books.list()))
assert after == before
=== END AC reject-both-empty ===

=== AC reject-whitespace-and-missing ===
Intent: Whitespace-only and missing fields are rejected with 400 and nothing is stored.
Requires: python-package=flask; scope=test

from app_server.testing import web_client
from persistence.testing import committed_session

client = web_client()
payloads = [
    {"title": "   ", "author": "ac-reject-ws-author"},
    {"title": "ac-reject-ws-title", "author": "   "},
    {"author": "ac-reject-missing-author"},
    {"title": "ac-reject-missing-title"},
]
with committed_session() as db:
    before = len(list(db.books.list()))
for payload in payloads:
    response = client.post("/books", json=payload)
    assert response.status_code == 400
with committed_session() as db:
    after = len(list(db.books.list()))
assert after == before
=== END AC reject-whitespace-and-missing ===

=== AC reject-validator ===
Intent: validate_book_input raises ValueError for an empty title or author.

from app_server.services.books import validate_book_input

for title, author in [("", "ac-validator-author"), ("ac-validator-title", ""), ("", "")]:
    try:
        validate_book_input(title, author)
    except ValueError:
        continue
    raise AssertionError("empty input was accepted")
=== END AC reject-validator ===

=== AC reject-valid-still-accepted ===
Intent: A submission with both fields present is still accepted with 201 after validation is in place.
Requires: python-package=flask; scope=test

from app_server.testing import web_client
from persistence.testing import committed_session

created_id = None
try:
    response = web_client().post(
        "/books", json={"title": "ac-reject-valid-title", "author": "ac-reject-valid-author"}
    )
    assert response.status_code == 201
    created_id = response.get_json()["id"]
finally:
    if created_id is not None:
        with committed_session() as db:
            db.books.delete(id=created_id)
=== END AC reject-valid-still-accepted ===

## User Acceptance

- None.

## Guardrails

- Never accept an empty title or an empty author.
- A rejected submission stores nothing.
- The error message names the offending field and is human-readable.

</pblock>

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

Build instructions for this block

Add a book with a title and author and persist it. (add-book)

Implement a book service add function and POST /books accepting JSON with title and author. A valid submission returns 201 with the stored book (id, title, author) and persists it via books.create.

Write pytest tests under tests/ covering the add behavior, including a round trip read-back.

List books in the order they were added. (list-books)

Implement GET /books returning 200 with a JSON array of books ordered by insertion (id ascending) via books.list. An empty list returns an empty array.

Write pytest tests adding several books and asserting the returned order equals the order submitted.

Remove a book so it no longer appears in the list. (remove-book)

Implement DELETE /books/{book_id}: 204 when the book existed and is deleted, 404 for an unknown id. A removed book must never reappear in later reads.

Write pytest tests for removal, absence on the next list read, preserved order of remaining books, and the unknown-id 404.

Reject a submission with an empty title or author with a clear error. (reject-empty-fields)

Add validation in the service layer used by POST /books. A missing, empty, or whitespace-only title or author is rejected with status 400 and a JSON body carrying a clear human-readable error naming the offending field. Nothing is stored on rejection.

Write pytest tests for empty title, empty author, both empty, and whitespace-only values, asserting status and that the list is unchanged.

</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. 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 every declared acceptance assertion before returning. For a conformance suite, use its section or example filters to diagnose coherent root-cause clusters, but rerun the full declared scope before reporting the result. Treat failing examples as a work queue for fixing general behavior; never add example-specific exceptions.

  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, that suite is the coverage: run it, and do not restate its cases. Run it only through the invocation this step's acceptance criteria declare. A criterion marked Suite: scoped names the whole of this step's obligation to that suite; running the suite's unscoped entry point instead is not extra rigor, it is a different step's gate executed early. A partial capability fails most of an authoritative corpus by construction and its unimplemented cases exhaust the runner's per-case timeout rather than returning, so the unscoped run costs the most where it teaches the least, and interrupting it forfeits the step. If no criterion in this step invokes the staged suite, do not invoke it. Report the pass/fail counts of the invocations you did run in your SUMMARY so a reader can see coverage moving across steps.

  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. If no files were written, use RESULT: FAILED.

  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.