Run artifact

evidence/prompts/20261027.141325.731Z_layerstesting_plan-repair_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="Repair job" kind="job">

Repair job

</pblock>

<pblock file="FEATURE-NoNegativeBalance.md" check_id="nonneg-load" kind="unchecked-call">
Error: calls cli_runner at line(s) 42 without asserting its exit status; bind it as code, out, err = cli_runner(...) and assert code before the next call

Intent: A transactions load whose earlier rows are individually valid but whose combined effect makes the balance negative is rejected whole with exit 3 and stores none of its rows.

import csv
import io
import os
import tempfile
from cli.testing import cli_runner
from persistence.testing import db_session

def parse(out):
    return list(csv.reader(io.StringIO(out)))

def counts():
    code, out, err = cli_runner("count")
    assert code == 0
    return {r[0]: int(r[1]) for r in parse(out)[1:]}

acct = "ZZNL1"
cat = "ZZNLC"
with db_session() as db:
    if db.categories.get(category=cat) is None:
        db.categories.create(category=cat, description="Load Probe")
code, out, err = cli_runner("account", "add", acct, "Load Probe")
assert code == 0
before = counts()
rows = [
    ["800000001", "2099-03-01", acct, cat, "50.00", "in"],
    ["800000002", "2099-03-02", acct, cat, "-30.00", "out one"],
    ["800000003", "2099-03-03", acct, cat, "-30.00", "out two"],
]
with tempfile.TemporaryDirectory() as tmp:
    path = os.path.join(tmp, "txns.csv")
    with open(path, "w", newline="") as fh:
        w = csv.writer(fh, lineterminator="\n")
        w.writerow(["txn_id", "date", "account", "category", "amount", "memo"])
        w.writerows(rows)
    code, out, err = cli_runner("load", "transactions", path)
print(out, err)
assert code == 3
assert out == ""
assert counts() == before
code, out, err = cli_runner("txn", "get", rows[0][0])
assert code == 4
code, out, err = cli_runner("account", "get", acct)
assert parse(out)[1][2] == "0"

</pblock>

<pblock file="FEATURE-NoNegativeBalance.md" check_id="nonneg-post" kind="unchecked-call">
Error: calls cli_runner at line(s) 24 without asserting its exit status; bind it as code, out, err = cli_runner(...) and assert code before the next call

Intent: Posting an outflow larger than the balance exits 3 and leaves the balance and transaction count unchanged.

import csv
import io
from decimal import Decimal
from cli.testing import cli_runner
from persistence.testing import db_session

def parse(out):
    return list(csv.reader(io.StringIO(out)))

acct = "ZZNP1"
cat = "ZZNPC"
with db_session() as db:
    if db.categories.get(category=cat) is None:
        db.categories.create(category=cat, description="Post Probe")
code, out, err = cli_runner("account", "add", acct, "Post Probe")
assert code == 0
deposit = Decimal("10.00")
code, out, err = cli_runner("txn", "post", acct, cat, str(deposit), "2099-03-01", "in")
assert code == 0
code, out, err = cli_runner("txn", "post", acct, cat, str(-(deposit + Decimal("0.01"))), "2099-03-02", "out")
print(out, err)
assert code == 3
assert out == ""
code, out, err = cli_runner("account", "get", acct)
row = parse(out)[1]
assert row[2] == "1"
assert Decimal(row[3]) == deposit

</pblock>

<pblock file="FEATURE-NoNegativeBalance.md" check_id="nonneg-amend" kind="unchecked-call">
Error: calls cli_runner at line(s) 30 without asserting its exit status; bind it as code, out, err = cli_runner(...) and assert code before the next call

Intent: Amending a deposit down so the account would go negative exits 3 and the original amount remains.

import csv
import io
from decimal import Decimal
from cli.testing import cli_runner
from persistence.testing import db_session

def parse(out):
    return list(csv.reader(io.StringIO(out)))

acct = "ZZNA1"
cat = "ZZNAC"
with db_session() as db:
    if db.categories.get(category=cat) is None:
        db.categories.create(category=cat, description="Amend Probe")
code, out, err = cli_runner("account", "add", acct, "Amend Probe")
assert code == 0
big, spend = Decimal("100.00"), Decimal("60.00")
code, out, err = cli_runner("txn", "post", acct, cat, str(big), "2099-03-01", "in")
assert code == 0
deposit_id = parse(out)[1][0]
code, out, err = cli_runner("txn", "post", acct, cat, str(-spend), "2099-03-02", "out")
assert code == 0
code, out, err = cli_runner("txn", "amend", deposit_id, "50.00")
print(out, err)
assert code == 3
assert out == ""
code, out, err = cli_runner("txn", "get", deposit_id)
assert code == 0
assert Decimal(parse(out)[1][4]) == big
code, out, err = cli_runner("account", "get", acct)
assert Decimal(parse(out)[1][3]) == big - spend

</pblock>

<pblock file="FEATURE-NoNegativeBalance.md" check_id="nonneg-delete" kind="unchecked-call">
Error: calls cli_runner at line(s) 29 without asserting its exit status; bind it as code, out, err = cli_runner(...) and assert code before the next call

Intent: Deleting a deposit that funds a later outflow exits 3, keeps the row, and leaves the balance unchanged.

import csv
import io
from decimal import Decimal
from cli.testing import cli_runner
from persistence.testing import db_session

def parse(out):
    return list(csv.reader(io.StringIO(out)))

acct = "ZZND1"
cat = "ZZNDC"
with db_session() as db:
    if db.categories.get(category=cat) is None:
        db.categories.create(category=cat, description="Delete Probe")
code, out, err = cli_runner("account", "add", acct, "Delete Probe")
assert code == 0
big, spend = Decimal("100.00"), Decimal("60.00")
code, out, err = cli_runner("txn", "post", acct, cat, str(big), "2099-03-01", "in")
assert code == 0
deposit_id = parse(out)[1][0]
code, out, err = cli_runner("txn", "post", acct, cat, str(-spend), "2099-03-02", "out")
assert code == 0
code, out, err = cli_runner("txn", "delete", deposit_id)
print(out, err)
assert code == 3
assert out == ""
code, out, err = cli_runner("txn", "get", deposit_id)
assert code == 0
code, out, err = cli_runner("account", "get", acct)
row = parse(out)[1]
assert row[2] == "2"
assert Decimal(row[3]) == big - spend

</pblock>

<pblock file="FEATURE-NoNegativeBalance.md" check_id="nonneg-transfer" kind="unchecked-call">
Error: calls cli_runner at line(s) 33, 35 without asserting its exit status; bind it as code, out, err = cli_runner(...) and assert code before the next call

Intent: A transfer larger than the source balance exits 3 and stores neither row; both balances and the table count are unchanged.

import csv
import io
from decimal import Decimal
from cli.testing import cli_runner
from persistence.testing import db_session

def parse(out):
    return list(csv.reader(io.StringIO(out)))

def txn_count():
    code, out, err = cli_runner("count")
    assert code == 0
    return {r[0]: int(r[1]) for r in parse(out)[1:]}["transactions"]

src, dst = "ZZNT1", "ZZNT2"
cat = "ZZNTC"
with db_session() as db:
    for c, d in ((cat, "Transfer Probe"), ("TRANSFER", "Internal transfer")):
        if db.categories.get(category=c) is None:
            db.categories.create(category=c, description=d)
for a in (src, dst):
    code, out, err = cli_runner("account", "add", a, "Xfer " + a)
    assert code == 0
funds = Decimal("20.00")
code, out, err = cli_runner("txn", "post", src, cat, str(funds), "2099-03-01", "in")
assert code == 0
before = txn_count()
code, out, err = cli_runner("transfer", src, dst, str(funds + Decimal("0.01")), "2099-03-02")
print(out, err)
assert code == 3
assert out == ""
assert txn_count() == before
code, out, err = cli_runner("account", "get", src)
assert Decimal(parse(out)[1][3]) == funds
code, out, err = cli_runner("account", "get", dst)
assert Decimal(parse(out)[1][3]) == Decimal("0")

</pblock>

Agent Task

Agent for: making a broken acceptance criterion runnable

You are given a batch of acceptance criteria that cannot execute as written, possibly drawn from several different Blueprint specification files in one request. Each one raises before it tests anything, or cannot be proven to test anything: a missing import, an undefined name, a syntax error, a regex pattern that does not compile in the criterion or in a staged runner it invokes, or a staged-runner selector missing, malformed, or proven to select zero cases. A criterion in this state is not a failing test. It is a test that never ran — or that runs against nothing — and the build cannot tell either apart from a genuine product defect.

Each criterion arrives as its own self-contained block:

<pblock file="<filename>" check_id="<check-id>" kind="<defect kind>">
Error: <one sentence naming the fault>

<the criterion's own Intent and Python, exactly as written>
</pblock>

Nothing else about that criterion's file, and nothing about any other criterion, is provided. For a bad-citation defect, numbered source files may also be supplied as context. Use only those sources to repair its Cite: declaration; never infer missing source text or line numbers.

Selection-probe repairs also receive the implicated staged runner source. Derive supported flags and count formats from that source; never invent a listing flag or edit the supplied runner. Probe Count: json counts JSON array elements; [] means zero, not one output line.

Your job is to make each criterion named in its own block run. Nothing else.

A second, independent job shape may also appear: when the input names a Bad acceptance container, the file has no safely addressable criterion, and the whole file's source is provided instead of a per-criterion block. Repair only its === AC <id> === and === END AC <id> === delimiter lines. Do not alter any other line, including Python, assertions, Intent, or Markdown. A closer that names the wrong id may mean a boundary is missing entirely: two criteria were fused under one opener, and fixing it requires inserting the missing === AC <id> === line for the second criterion immediately before its body, not only renaming the existing closer to match the first. Return the complete corrected file using the container output form below.

The one rule

Repair the mechanics. Never touch the assertion.

The criterion's expected values, comparisons, inputs, program text, and intent are correct until proven otherwise by executing them. You are not judging whether the criterion is right. You are removing the reason it cannot be judged at all.

Permitted:

source lines supporting the unchanged expectation. Source line numbers are one-based and inclusive; use sources/<file>:<line> or sources/<file>:<start>-<end>. Preserve every other line, including all inputs, assertions, and metadata. Never remove the citation. If the supporting source is not supplied or does not state the expectation, emit REPAIR_IMPOSSIBLE;

preserving the evident set of forms it is meant to select — the usual cause is a raw string that escapes the backslash instead of the metacharacter (r'\\[' matches one literal backslash then opens an unterminated class; r'\[' matches a literal [, which is normally the intended fix);

as a regex, preserving the intended selected forms;

line with Requires: python-package=httpx2; scope=test, and only that line;

criterion's Probe: and Probe Count: declaration lines so the selector it already invokes can be proven non-empty, and only that;

supported listing flag and count format, preserving the existing command, filter, corpus path, Suite:, Intent:, and assertions; never drop probe declarations to bypass validation;

section the criterion's Intent: names; never widen it to "select everything", and emit REPAIR_IMPOSSIBLE if the supplied evidence cannot establish a correct section;

Error: line says the staged harness expects, and correct any later assertion in the same criterion that held only because that call had the wrong outcome. The staged harness is the user's own test and outranks the criterion. Change no input and no command.

code, out, err = cli_runner(...) and add assert code == 0 directly after it — a setup call must succeed before the criterion relies on it. Change no argument and no other assert;

under an identifier no staged file holds, with the same commands the other criteria in the Blueprint use to create it, each followed by assert code == 0, and use that identifier in place of the staged one throughout the criterion. Keep every expected exit status and output.

or direct ./cmd/<name> <args...> invocation with code, out, err = cli_runner(<args...>) after from drydock_go import cli_runner, passing the same arguments, input= for the same standard input, and package="<package>" only when the package is not the sole ./cmd/<name>. Read the exit status, standard output, and standard error from code, out, and err in place of the subprocess result. The helper returns text; replace byte-stream .decode(...) calls with the returned text. Keep every expected value, including bytes comparisons by encoding the returned text when necessary. ./cmd/<name> is the Go source package directory; never chmod it or execute it directly.

launcher such as ./<name>), replace each launch with the in-process fixture the selected foundation contract below publishes — cli_runner, imported from the module its fixture_source names, for a command; web_client() for an HTTP request — passing the same command arguments without the executable. Bind code, out, err = cli_runner(...) and read the exit status, standard output, and standard error from them in place of the subprocess result. Keep every store read, expected value, and input. Remove an import the replacement leaves unused.

Go CLI client contract:

from drydock_go import cli_runner
# Signature: cli_runner(*args: str, package: str | None = None,
#                       input: str | None = None) -> tuple[int, str, str]
code, out, err = cli_runner()                    # no command arguments
code, out, err = cli_runner("--summary", ".")   # separate string arguments

Never pass a list or tuple as one positional argument. For a go-cli-args fault, unpack that sequence with * and preserve every argument and assertion.

For a configuration-only acceptance-store defect, the database_environment fixture relocation specified below is also allowed, including its necessary path-operand substitution. Preserve the same configuration cases and assertions about behavior.

Forbidden:

permitted above for a harness-exit fault, or renaming its operands to code, out, and err for a go-run, go-package-launch, or acceptance-store fault, or substituting relocated scratch path operands for a configuration-only acceptance-store fault;

permitted above for an unchecked-call, staged-value, go-run, go-package-launch, or acceptance-store fault;

testing what it claims to test;

missing-selection-probe, invalid-selection-probe, empty-selection, or probe-failed;

Preserve the product requirement and assertion intent. Mechanical repair does not decide a new expected outcome, move coverage or change dependencies. If the named defect requires those changes, follow Impossible repair and state the required source-aware authoring action.

Impossible repair

If a criterion cannot be made runnable without changing what it asserts, do not change it. Emit its block unmodified and add one line immediately after the block:

REPAIR_IMPOSSIBLE: <file> :: <check-id> — <one sentence saying what the criterion would have to change>

The separator between the id and the reason is always an em dash (—); filenames and check_ids commonly contain hyphens, so no other character can be used to tell them apart.

Output

For a Bad acceptance container, emit exactly:

=== BEGIN REPAIRED SPECIFICATION ===
<the complete original specification with only AC delimiter lines corrected>
=== END REPAIRED SPECIFICATION ===

For every defective criterion in the batch, emit one block, and nothing else:

Use no prose, no summary, and no fenced code around a criterion block. Use the exact delimiters, with the criterion's own file and id, copied exactly from its file= and check_id= attributes — this is what tells two criteria that happen to share a check_id in different files apart:

=== AC <file> :: <check-id> ===
Intent: <unchanged>

<the repaired Python>
=== END AC <file> :: <check-id> ===

Identify the criterion by its file and id; you do not need to know or reproduce its file's own internal delimiter format. Include the whole criterion — every line that was inside its block — not a patch or a diff.

Acceptance persistence lifecycle

Acceptance store lifecycle. The DATABASE step provisions and verifies the configured store once. Ordinary persistence criteria never replace DATABASE_URL/DATABASE_PATH, create a temporary database, apply DDL, or assume an empty store. Configuration behavior is tested separately using the harness fixture below. The store may hold data before any criterion runs: assert on records the criterion created, or on a count read before setup (after == before + 5), never on an absolute table count.

SQLite configuration tests (Python acceptance container). The harness supplies from drydock_acceptance import database_environment. Use it only to test configuration selection, default paths, or source-required open failures, never ordinary CRUD acceptance:

import os
from drydock_acceptance import database_environment
from <declared_config_module> 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(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"

None (the default) unsets a variable; "" sets it empty. Other arguments are relative SQLite file names within a fresh temporary working directory; only url permits the sqlite:// prefix. The fixture maps names to absolute scratch paths, yields that directory as a Path, and restores both variables and cwd on exit, including failures. It applies no schema and creates no parent directories: url="missing/app.db" exercises an unopenable path. Invoke the declared application interface inside the context, assert the source-required outcome, and do not read or write the managed store. Import the declared configuration module, never invent a module or an exit requirement absent from the source. Do not replace environment variables directly or bypass this fixture with monkeypatches.

For acceptance-store repair of an existing configuration test, move its environment setup and restoration into this fixture. Preserve URL-prefix/precedence/unset/empty conditions, command arguments, error behavior and expected results. Replace arbitrary fixture paths with relative names and derive asserted absolute paths from root; this is a mechanical fixture relocation, not permission to change which configured value wins or weaken any assertion. If the criterion needs a populated replacement store, report REPAIR_IMPOSSIBLE instead.

The acceptance harness owns isolation. It begins one transaction before each Python criterion and rolls it back when the criterion ends, pass or fail. Every database the criterion's process opens joins it: db_session(), the application behind web_client(), and commands run through cli_runner(). Setup, behavior and readback therefore see one another's writes, and none persists; leaving a with db_session() as db: block rolls nothing back. Seed with with db_session() as db: and pass that database into feature operations. Never commit, clean up, or open a transaction.

A criterion that launches a process (subprocess, a server on a port, a shell script) cannot see that transaction. It does not open the store and does not depend on rows it wrote; exercise stored behavior in-process instead. Go criteria use OpenSession(ctx, "") with checked deferred cleanup, which rolls back its own transaction. Go HTTP, CLI and restart criteria use OpenCommittedSession(ctx, "") with a criterion-owned identifier and checked defer cleanup through supported product interfaces. Database acceptance must not be replaced by a project test count: runtime catalog and row-count evidence proves provisioning, feature criteria prove behavior.