Run artifact

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

Evidence: Block 4 ยท Service (block-4)

Stories built

Stacked context

Build directory changes

Pre-build acceptance observation

intent: Codes of 1 to 12 characters from A-Z and 0-9 are returned unchanged; empty, lowercase, too long, and other characters are rejected with exit code 3. return code: 1 stderr: Traceback (most recent call last): File "validation-code.py", line 1, in <module> from ledger_core.validation import validate_code
ModuleNotFoundError: No module named 'ledger_core.validation'

intent: Names of 1 to 40 characters without comma or newline are accepted; empty, 41 characters, comma, and newline are rejected. return code: 1 stderr: Traceback (most recent call last): File "validation-name.py", line 1, in <module> from ledger_core.validation import validate_name
ModuleNotFoundError: No module named 'ledger_core.validation'

intent: Memos of 0 to 60 characters without comma or newline are accepted, including the empty memo; 61 characters, comma, and newline are rejected. return code: 1 stderr: Traceback (most recent call last): File "validation-memo.py", line 1, in <module> from ledger_core.validation import validate_memo
ModuleNotFoundError: No module named 'ledger_core.validation'

intent: Real calendar dates in YYYY-MM-DD form are accepted, including a leap day; impossible dates and other layouts are rejected. return code: 1 stderr: Traceback (most recent call last): File "validation-date.py", line 1, in <module> from ledger_core.validation import validate_date
ModuleNotFoundError: No module named 'ledger_core.validation'

intent: Valid amount text parses to the integer cents it denotes, as an int and not a float. return code: 1 stderr: Traceback (most recent call last): File "money-parse-valid.py", line 1, in <module> from ledger_core.money import parse_amount
ModuleNotFoundError: No module named 'ledger_core.money'

intent: Zero, three or more decimals, and text outside -?DIGITS[.D[D]] are rejected with exit code 3. return code: 1 stderr: Traceback (most recent call last): File "money-parse-invalid.py", line 1, in <module> from ledger_core.money import parse_amount
ModuleNotFoundError: No module named 'ledger_core.money'

intent: Integer cents format with exactly two decimals, a leading minus when negative, and no thousands separator. return code: 1 stderr: Traceback (most recent call last): File "money-format.py", line 1, in <module> from ledger_core.money import format_cents
ModuleNotFoundError: No module named 'ledger_core.money'

intent: Parsing the formatted text of any nonzero cents value returns the same cents. return code: 1 stderr: Traceback (most recent call last): File "money-round-trip.py", line 1, in <module> from ledger_core.money import parse_amount, format_cents
ModuleNotFoundError: No module named 'ledger_core.money'

intent: current_balance sums an account's stored amounts and is zero for an account with no transactions. return code: 1 stderr: Traceback (most recent call last): File "balance-current.py", line 2, in <module> from ledger_core.balances import current_balance
ModuleNotFoundError: No module named 'ledger_core.balances'

intent: An insert that lands the balance at zero passes, one cent below zero is rejected with exit 3, and nothing is written either way. return code: 1 stderr: Traceback (most recent call last): File "balance-insert.py", line 2, in <module> from ledger_core.balances import check_no_negative, Insert
ModuleNotFoundError: No module named 'ledger_core.balances'

intent: An account with no transactions accepts a positive insert and rejects a negative one. return code: 1 stderr: Traceback (most recent call last): File "balance-insert-new-account.py", line 2, in <module> from ledger_core.balances import check_no_negative, Insert
ModuleNotFoundError: No module named 'ledger_core.balances'

intent: Editing the larger credit below what the debits need is rejected; editing it to exactly cover them passes. return code: 1 stderr: Traceback (most recent call last): File "balance-edit.py", line 2, in <module> from ledger_core.balances import check_no_negative, Edit
ModuleNotFoundError: No module named 'ledger_core.balances'

intent: Deleting the credit that funds a debit is rejected; deleting the debit passes. return code: 1 stderr: Traceback (most recent call last): File "balance-delete.py", line 2, in <module> from ledger_core.balances import check_no_negative, Delete
ModuleNotFoundError: No module named 'ledger_core.balances'

intent: Several changes to one account are judged by their net effect regardless of order; a credit and a debit that net to a non-negative balance pass in either order. return code: 1 stderr: Traceback (most recent call last): File "balance-combined.py", line 2, in <module> from ledger_core.balances import check_no_negative, Insert
ModuleNotFoundError: No module named 'ledger_core.balances'

intent: When one of several affected accounts would go negative the whole set is rejected and nothing is written. return code: 1 stderr: Traceback (most recent call last): File "balance-multi-account.py", line 2, in <module> from ledger_core.balances import check_no_negative, Insert
ModuleNotFoundError: No module named 'ledger_core.balances'

Post-build programmatic acceptance

intent: Codes of 1 to 12 characters from A-Z and 0-9 are returned unchanged; empty, lowercase, too long, and other characters are rejected with exit code 3. 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: Names of 1 to 40 characters without comma or newline are accepted; empty, 41 characters, comma, and newline are rejected. 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: Memos of 0 to 60 characters without comma or newline are accepted, including the empty memo; 61 characters, comma, and newline are rejected. 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: Real calendar dates in YYYY-MM-DD form are accepted, including a leap day; impossible dates and other layouts are rejected. 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: Valid amount text parses to the integer cents it denotes, as an int and not a float. 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: Zero, three or more decimals, and text outside -?DIGITS[.D[D]] are rejected with exit code 3. 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: Integer cents format with exactly two decimals, a leading minus when negative, and no thousands separator. 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: Parsing the formatted text of any nonzero cents value returns the same cents. 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: current_balance sums an account's stored amounts and is zero for an account with no transactions. 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 insert that lands the balance at zero passes, one cent below zero is rejected with exit 3, and nothing is written either way. 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 account with no transactions accepts a positive insert and rejects a negative one. 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: Editing the larger credit below what the debits need is rejected; editing it to exactly cover them passes. 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: Deleting the credit that funds a debit is rejected; deleting the debit passes. 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: Several changes to one account are judged by their net effect regardless of order; a credit and a debit that net to a non-negative balance pass in either order. 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: When one of several affected accounts would go negative the whole set is rejected and nothing is written. target interpreter: /mnt/c/Users/barlo/projects/drydock/uat/LayersTesting/runs/20261027.135355/build/LayersTesting/.venv/bin/python provisioning: not required return code: 0

Build summary

I'll start by inspecting the build directory and the existing files.The ledger_core package exists, so I'll add validation.py, money.py, and balances.py alongside it. Next I need the persistence row shape and the test-isolation fixture.Rows come back as dataclasses, so balance code should read attributes such as .amount. Before writing tests, I'll check how existing tests use the db_session fixture and the rollback context.I have what I need. I'll write the three domain modules first, then tests. Validation comes first.Next, the money module: integer-only parsing and formatting.The or "0" in the fraction expression is dead code, since "".ljust(2, "0") is already "00". I'll remove it.Now the balance rule. Edits and deletes take their account and stored amount from the database, so the check judges the net effect per account.Now the tests. I'll start with validation, covering the declared boundaries and the rejection paths.Balance tests follow. They use the rollback session from persistence.testing, as the acceptance criteria do, and check results by reading the store back.One test has a sloppy argument (0 + 1) and doesn't cover what its name claims. I'll make it deliberately net to zero for its own account while another account is already negative.Next I'll run the project's declared test command, bin/test.sh, which runs the whole suite.All 155 tests pass. I'll confirm the set of files I changed in the working tree, and check the ledger_core boundary rules are covered by the passing foundation tests.The Validation and Balance Rule stories are built, and the project suite passes: 155 tests, exit 0, run with sh bin/test.sh.

I did not run the spec's acceptance blocks verbatim. The new tests cover the same cases, so Drydock's run is the check on the declared text. Nothing is committed.

<blueprint-decisions>
[{"spec":"FEATURE-BalanceRule.md","severity":"Low","subject":"Edit or Delete of a missing transaction","decision":"The spec does not say what happens when txn_id is absent. I raise NotFound (exit 4), matching the CLI error table for absent transactions on amend and delete. Is that acceptable?"},{"spec":"FEATURE-Validation.md","severity":"Low","subject":"Carriage return in names and memos","decision":"The spec forbids only comma and newline. I also reject carriage return (\\r), because it would break the CSV output. Is that acceptable?"}]
</blueprint-decisions>

RESULT: SUCCESS

FILES CHANGED:

SUMMARY: Implemented validate_code, validate_name, validate_memo, validate_date, parse_amount, and format_cents in ledger_core, plus Insert/Edit/Delete, current_balance, and check_no_negative in ledger_core/balances.py. Violations raise Rejected (exit 3). Missing transactions on Edit/Delete raise NotFound (exit 4). Checks were run with sh bin/test.sh: 155 passed, exit 0. The new tests mirror the declared acceptance cases and add boundary and negative-path coverage. The spec's acceptance blocks were not run verbatim.

BLOCKERS: