Evidence: Block 4 ยท Service (block-4)
- block type: block
- date: 2026-10-23
- resulting state: closed/verified
- story points (combined assembled cost): 6407
- execution id: 20261023.145659.297Z-79985802
Stories built
- Let a reader add a book with a title and an author. (add-book) [story]
Stacked context
- stack: python_compact.md (SP 921)
- compass: COMPASS.md (SP 781)
- implements: FEATURE-AddBook.md (SP 1332)
- context: ARCHITECTURE_compact.md (SP 281)
- context: DATABASE.md (SP 2302)
- stack: flask.md (SP 691)
Build directory changes
- app_server/init.py
- app_server/book_service.py
- app_server/books.py
- tests/test_add_book.py
- tests/test_create_app_wiring.py
Pre-build acceptance observation
- UNVERIFIED: add-book-redirects (FEATURE-AddBook.md)
intent: A valid submission is accepted with a 303 redirect. return code: 1 error: malformed check: the assertion itself raised TypeError ('NoneType' object is not iterable) in its own frame, before reaching the code under test. No implementation can satisfy it. Each check runs as its own script in its own process, so a name bound by another check is not in scope. Repair the assertion in the Blueprint specification. stderr: --- drydock: values at failure --- marker = 'ac-add-redirect' client = <FlaskClient <Flask 'app_server'>> --- drydock: end values --- Traceback (most recent call last): File "add-book-redirects.py", line 11, in <module> cleanup() File "add-book-redirects.py", line 7, in cleanup for row in client.get("/books").get_json(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable
- UNVERIFIED: add-book-round-trip (FEATURE-AddBook.md)
intent: An added book is read back through GET /books with the supplied title and author. return code: 1 error: malformed check: the assertion itself raised TypeError ('NoneType' object is not iterable) in its own frame, before reaching the code under test. No implementation can satisfy it. Each check runs as its own script in its own process, so a name bound by another check is not in scope. Repair the assertion in the Blueprint specification. stderr: --- drydock: values at failure --- marker = 'ac-add-roundtrip' client = <FlaskClient <Flask 'app_server'>> --- drydock: end values --- Traceback (most recent call last): File "add-book-round-trip.py", line 13, in <module> cleanup() File "add-book-round-trip.py", line 9, in cleanup for row in client.get("/books").get_json(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable
- UNVERIFIED: add-book-persists-in-store (FEATURE-AddBook.md)
intent: An added book is present in the configured store when read through the persistence package. return code: 1 error: malformed check: the assertion itself raised TypeError ('NoneType' object is not iterable) in its own frame, before reaching the code under test. No implementation can satisfy it. Each check runs as its own script in its own process, so a name bound by another check is not in scope. Repair the assertion in the Blueprint specification. stderr: --- drydock: values at failure --- marker = 'ac-add-store' client = <FlaskClient <Flask 'app_server'>> --- drydock: end values --- Traceback (most recent call last): File "add-book-persists-in-store.py", line 14, in <module> cleanup() File "add-book-persists-in-store.py", line 10, in cleanup for row in client.get("/books").get_json(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable
Post-build programmatic acceptance
- UNVERIFIED: add-book-redirects (FEATURE-AddBook.md)
intent: A valid submission is accepted with a 303 redirect. provisioning: not required error: excluded check: ERROR malformed
- UNVERIFIED: add-book-round-trip (FEATURE-AddBook.md)
intent: An added book is read back through GET /books with the supplied title and author. provisioning: not required error: excluded check: ERROR malformed
- UNVERIFIED: add-book-persists-in-store (FEATURE-AddBook.md)
intent: An added book is present in the configured store when read through the persistence package. provisioning: not required error: excluded check: ERROR malformed
Agent self-report (advisory)
The build agent declared a failure. This is advisory only; the programmatic acceptance above is the authority for this block's outcome.
- summary: Declared add-book criteria call GET /books in cleanup, which is the list-books story and is not implemented in this block.
- detail:
The three criteria (add-book-redirects, add-book-round-trip, add-book-persists-in-store) each begin with cleanup(), which calls client.get("/books").get_json(). GET /books is not registered, so it returns 404 and get_json() returns None, raising TypeError before the POST assertions run. The add-book behavior itself is verified: the POST returns 303 and the stored row reads back, and empty submissions return 400. To pass these criteria, the list-books story (GET /books returning JSON) must be built, or the list story must be placed in the same block. bin/test.sh is also absent, which COMPASS requires for sources/full_test.sh; this belongs to a later block.
Build summary
Now I'll register the blueprint in the application factory.Adding POST /books intentionally changes the wiring test that asserted no book routes exist, so I'll update that assertion to the new route set.Project suite is green (46 passed). Now I'll run the three declared add-book acceptance criteria, scripts kept outside the build directory.All three criteria fail at their own cleanup step, before reaching the add-book assertions. Their setup calls GET /books, which belongs to the list-books story and isn't part of this block. To confirm the POST behavior itself, I'll run the same assertions against a throwaway store with the cleanup calls removed as a diagnostic (the criteria stay untouched).POST /books is implemented and the project suite passes (46 tests), but all three add-book acceptance criteria fail. Their setup calls GET /books, which belongs to the list-books story and is not part of this block. I did not add it, since this block is scoped to add-book.
What I built
app_server/book_service.py:add_book(database, title, author)stores throughdb.books.create. It has no Flask dependency and refuses an empty title or author with a reason, before touching the store.app_server/books.py: thebooksblueprint withPOST /books. It trimstitleandauthor, then answers303to/on success. On rejection it answers400and puts the reason in thebase.htmlalert region.app_server/__init__.py: registers the blueprint increate_app().tests/test_add_book.py: 25 tests on a temporary store, covering the redirect, storage read back through the persistence package, trimming, append order, the rejection cases, and the service. Each test uses its own store, so none touchdata/app.db.tests/test_create_app_wiring.py: I changedtest_create_app_registers_no_book_routesto expectbooks.create_bookbesidestatic, since adding the route made the old assertion false.
Acceptance criteria
add-book-redirects,add-book-round-trip,add-book-persists-in-store: all fail in theircleanup()withTypeError: 'NoneType' object is not iterable, becauseGET /booksreturns 404 here. These criteria are not broken, so I did not emitAC_BROKEN.- Diagnostic: with the cleanup calls removed, on a throwaway store, the POST returns
303, the row is read back throughcommitted_session()with the right title and author, and an empty title returns400. The criteria files are unchanged.
Choices I made
- Empty or absent fields get a
400with the reason and nothing is stored. The rejection stories own this behavior, but storing an empty book would break COMPASS's guardrail. - Repeated identical submissions are stored as separate rows, since the spec declares no idempotence.
Not in this block
bin/test.shdoes not exist. COMPASS requires it, andsources/full_test.shwill fail until it is added.
RESULT: FAILED
FILES CHANGED:
- app_server/init.py
- app_server/book_service.py
- app_server/books.py
- tests/test_add_book.py
- tests/test_create_app_wiring.py
SUMMARY: POST /books is implemented as a thin blueprint over a Flask-free service. Trimmed valid submissions store through db.books.create and answer 303 to /. Empty or absent fields answer 400 with a reason and store nothing. Project suite: pytest -q 46 passed (26 baseline + 20 new add-book tests; the 25 cases in test_add_book.py are parametrized). Declared criteria: 0 of 3 pass, because their cleanup needs GET /books. Diagnostic POST checks pass on a throwaway store.
<blueprint-decisions> [{"spec":"FEATURE-AddBook.md","severity":"Material","subject":"Empty or absent title/author on POST /books","decision":"Rejection stories own validation, but COMPASS forbids storing empty values. I refuse with 400 and the reason rendered in the base.html alert region, and store nothing. Is that acceptable, or should the rejection stories own the response shape and this should only refuse without rendering?"}] </blueprint-decisions>
FAILURE_SUMMARY: Declared add-book criteria call GET /books in cleanup, which is the list-books story and is not implemented in this block.
FAILURE_DETAIL: The three criteria (add-book-redirects, add-book-round-trip, add-book-persists-in-store) each begin with cleanup(), which calls client.get("/books").get_json(). GET /books is not registered, so it returns 404 and get_json() returns None, raising TypeError before the POST assertions run. The add-book behavior itself is verified: the POST returns 303 and the stored row reads back, and empty submissions return 400. To pass these criteria, the list-books story (GET /books returning JSON) must be built, or the list story must be placed in the same block. bin/test.sh is also absent, which COMPASS requires for sources/full_test.sh; this belongs to a later block.