Run artifact

workspace/targets/LayersTesting/evidence/block-3.md

Evidence: Block 3 · Foundational (block-3)

Stories built

Reusable compacts

Stacked context

Build directory changes

Pre-build acceptance observation

intent: Registry loading is idempotent and every key is a tuple of words. error: foundation not built: cli is the package the cli foundation (cli.md) builds, and the build directory has no cli/. The criterion exercises the built application, so it was not run.

intent: An unknown command, or no command at all, exits 2 with an empty stdout and exactly one stderr line. error: foundation not built: cli is the package the cli foundation (cli.md) builds, and the build directory has no cli/. The criterion exercises the built application, so it was not run.

intent: A registered command receives its arguments and its rows print as unquoted CSV with newline endings. error: foundation not built: cli is the package the cli foundation (cli.md) builds, and the build directory has no cli/. The criterion exercises the built application, so it was not run.

intent: A wrong argument count, a bare group word, and a group word with an unknown sub-word each exit 2 with empty stdout. error: foundation not built: cli is the package the cli foundation (cli.md) builds, and the build directory has no cli/. The criterion exercises the built application, so it was not run.

intent: Handlers raising Rejected, NotFound, or Operational exit 3, 4, or 1 and print nothing to stdout. error: foundation not built: cli is the package the cli foundation (cli.md) builds, and the build directory has no cli/. The criterion exercises the built application, so it was not run.

intent: A database location that cannot be opened exits 1 with empty stdout. error: foundation not built: cli is the package the cli foundation (cli.md) builds, and the build directory has no cli/. The criterion exercises the built application, so it was not run.

intent: The ledger launcher at the application root is executable and exits 2 for an unknown command with empty stdout. return code: 1 stderr: Traceback (most recent call last): File "cli-launcher.py", line 4, in <module> assert os.access("ledger", os.X_OK) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError

Post-build programmatic acceptance

intent: Registry loading is idempotent and every key is a tuple of words. target interpreter: /mnt/c/Users/barlo/projects/drydock/uat/LayersTesting/runs/20261027.135355/build/LayersTesting/.venv/bin/python provisioning: not required return code: 0

intent: An unknown command, or no command at all, exits 2 with an empty stdout and exactly one stderr line. target interpreter: /mnt/c/Users/barlo/projects/drydock/uat/LayersTesting/runs/20261027.135355/build/LayersTesting/.venv/bin/python provisioning: not required return code: 0 stdout: 2 '' "usage: unknown command 'zzfrobnicate'\n" 2 '' 'usage: no command given\n'

intent: A registered command receives its arguments and its rows print as unquoted CSV with newline endings. target interpreter: /mnt/c/Users/barlo/projects/drydock/uat/LayersTesting/runs/20261027.135355/build/LayersTesting/.venv/bin/python provisioning: not required return code: 0 stdout: 0 'h1,h2\nalpha,v\n' ''

intent: A wrong argument count, a bare group word, and a group word with an unknown sub-word each exit 2 with empty stdout. target interpreter: /mnt/c/Users/barlo/projects/drydock/uat/LayersTesting/runs/20261027.135355/build/LayersTesting/.venv/bin/python provisioning: not required return code: 0 stdout: ('zzgrp2', 'ok') 2 '' "usage: wrong number of arguments for 'zzgrp2 ok'\n" ('zzgrp2', 'ok', 'a', 'b') 2 '' "usage: wrong number of arguments for 'zzgrp2 ok'\n" ('zzgrp2',) 2 '' "usage: unknown command 'zzgrp2'\n" ('zzgrp2', 'nosuch') 2 '' "usage: unknown command 'zzgrp2 nosuch'\n"

intent: Handlers raising Rejected, NotFound, or Operational exit 3, 4, or 1 and print nothing to stdout. target interpreter: /mnt/c/Users/barlo/projects/drydock/uat/LayersTesting/runs/20261027.135355/build/LayersTesting/.venv/bin/python provisioning: not required return code: 0 stdout: rej 3 '' 'error: probe failure\n' nf 4 '' 'error: probe failure\n' op 1 '' 'error: probe failure\n'

intent: A database location that cannot be opened exits 1 with empty stdout. target interpreter: /mnt/c/Users/barlo/projects/drydock/uat/LayersTesting/runs/20261027.135355/build/LayersTesting/.venv/bin/python provisioning: not required return code: 0 stdout: 1 '' 'error: cannot open database: database directory does not exist: /tmp/drydock-database-config-h_l6e9jp/missing\n'

intent: The ledger launcher at the application root is executable and exits 2 for an unknown command with empty stdout. target interpreter: /mnt/c/Users/barlo/projects/drydock/uat/LayersTesting/runs/20261027.135355/build/LayersTesting/.venv/bin/python provisioning: not required return code: 0 stdout: usage: unknown command 'zzfrobnicate'

Build summary

I'll start by inspecting the build directory and the existing files.The cli package doesn't exist yet. I'll read the persistence layer and existing tests to see what the CLI will depend on.The cli package is missing, and the ledger launcher with it. Before writing dispatch I need to confirm how open_database behaves on a bad path and what the Database close API is.I have what I need. The plan:

Starting with the package.Next, the registry, the command package, the in-process runner, and the launcher.The launcher and usage paths behave. Now the test suite, using the project's cli_runner and asserting on return values and streams rather than log text.One cleanup before running: an unused rows variable in the partial-work test.The failure is real: open_database returns without touching the file, so a bad location exits 0. I need to see when Database actually connects.Connections open lazily on first use, so open_database cannot report an unopenable store by itself. I'll check whether the persistence library exposes a public way to force the connection, rather than reaching into the driver from the CLI.The SQLite driver calls mkdir on the parent directory before connecting. So missing-directory/app.db is not unopenable under the shipped library. I'll confirm that and clean up the directory my test run may have created.Opening is lazy, so the directory isn't created until a connection is made. I'll force a connection from a scratch directory so the build tree stays clean.The -I flag also ignores PYTHONPATH, so I'll add the build path explicitly.Confirmed: the shipped library creates a missing SQLite parent directory on connect. So under the library as written, the missing/app.db location in the acceptance criterion would open and exit 0. The CLI can't fix that inside the library, which must not be edited. The CLI can refuse a SQLite location whose directory is absent, before the library creates it. That keeps a typo from silently creating a store, and it is a bounded choice I'll record for the user.I'll tighten the unopenable test so it also proves no directory gets created, using tmp_path for isolation.Running the full suite again, then checking the ledger launcher manually for the unopenable-location case the criterion uses.All 53 tests pass through bin/test.sh (exit 0 in the log; the exit=0 line above is tail's status, not the suite's). Last, I'll check whether git will record the launcher's executable bit, since I can't stage anything myself.Everything is in place. The launcher is executable on disk, but core.fileMode is false in this repo, so git may record it as 100644 when committed. I'll flag that rather than change git config.

Result summary before the final block: the ledger story is built and the full suite passes (53 tests, bin/test.sh exit 0). I did not commit, as instructed.

<reusable-compact filename="DATABASE.md">
Database: LayersTesting (version 20261027 V1). Build order 1. Provides persistence.accounts, persistence.categories, persistence.transactions.

Access: open_database(dsn) returns Database; db.<table>.<op>(...). Money: integer cents everywhere. No aggregate operations; callers compute counts, sums, next txn_id from list results.

Operations (input -> output; * = match key):

Schema:

Config: DATABASE_URL (SQLite path, optional sqlite:// prefix, wins), DATABASE_PATH (fallback), default data/app.db.

Guardrails: only the persistence package opens a driver; amounts never float; counts/balances never hardcoded. </reusable-compact>

RESULT: SUCCESS

FILES CHANGED:

SUMMARY:

Verification run: sh bin/test.sh → 53 passed (log exit 0). This includes the existing foundation tests. I also ran ./ledger zzfrobnicate by hand and got exit 2 with empty stdout.

Choices I made for you to review:

  1. SQLite location pre-check. The shipped SQLite driver creates a missing parent directory on connect, and open_database is lazy. So missing/app.db would open and exit 0, which breaks the cli-unopenable-database criterion. I added a check in cli/__init__.py that refuses a SQLite location whose directory does not exist (exit 1). PostgreSQL DSNs skip the check. This also stops a typo from creating an empty store. If you'd rather the library create directories, this check should change on replan.
  2. Launcher changes to the project root. This makes the default data/app.db root-relative, which matches the project layout. A relative DATABASE_PATH is therefore resolved against the project root, not the caller's directory.
  3. No argparse parser. Dispatch is by command-word prefix, because argparse subcommands don't fit multi-word commands like account add.

<blueprint-decisions> [{"spec":"FEATURE-CliEntry.md","severity":"Material","subject":"Unopenable database detection","decision":"open_database is lazy and the shipped SQLite driver creates a missing parent directory on connect, so the criterion's 'missing/app.db' would open and exit 0. I refuse a non-PostgreSQL location whose parent directory does not exist, raising Operational (exit 1) before the library can create it. Is that acceptable, or should the library's directory creation be allowed?"},{"spec":"FEATURE-CliEntry.md","severity":"Low","subject":"Launcher working directory","decision":"The ledger launcher changes to the project root before running, so the default data/app.db and any relative DATABASE_PATH resolve from the root, not the caller's directory. Confirm this matches the intended layout."}] </blueprint-decisions>

BLOCKERS: