# Apply iterative refinement techniques for progressive improvement

Refine implementations through concrete transformations, observed failures, and verified decisions.
Use examples and measurable criteria to turn vague requirements into checkable behavior. A null-email migration demonstrates focused repair, preservation of valid inputs, and the difference between a record ready for migration and a completed persistence operation.

Author: LearningPathX Editorial Team
Content version: 1.0
Published: 2026-12-04T00:30:42.433637+00:00
HTML: https://learningpathx.com/material/CCAR-F/apply-iterative-refinement-techniques-for-progressive-improvement.html

Knowledge domain: Claude Code Configuration & Workflows
Tags: Troubleshooting / Acceptance Criteria / Iterative Refinement / Requirements Analysis

## Apply iterative refinement techniques for progressive improvement

## Learning objectives

Turn ambiguous requirements into observable behavior, use test failures to guide focused repairs, and choose a useful sequence for interacting or independent issues. Ask questions that resolve consequential unknowns before implementing.

## Demonstrate the required transformation

A concrete input and expected output can reveal a requirement that prose leaves ambiguous. “Clean up the records” does not say whether to discard, repair, or report a missing email. A small set of contrasting examples makes that decision visible.

Use examples alongside an explicit general rule. Two or three carefully chosen cases are a useful starting point, not a guarantee of complete coverage. Include a normal case, a missing or boundary case, and a case that should remain unchanged. Keep the example's field names and structure consistent with the actual output contract. Positive demonstrations clarify what to produce; explicit prohibitions remain useful for actions or inferences that must be avoided.

For a report, show the desired organization and an evidence-backed finding. For a UI, specify concrete layout, color, typography, and interaction requirements and inspect the rendered result. A vague adjective such as “professional” is difficult to verify without further criteria.

## Define checks before changing the implementation

Establish success criteria before generating a solution. Cover normal behavior, rejection paths, relevant boundary values, and any stated performance requirement. Inspect existing tests so the new checks use the project's conventions and exercise the real interface.

A performance criterion needs a workload, environment, metric, and threshold. “Make it fast” cannot produce a defensible pass result. If a requirement concerns elapsed time, define the measurement boundary and do not substitute active human effort or a different workload.

Run the checks against the current implementation to observe the failure where practical, make a focused change, and rerun the relevant checks. Preserve the failure message, input, expected result, and actual result in the feedback. A test command that never ran, timed out, or failed to discover tests is not a passing test suite.

## Diagnose causes rather than editing every failure

One defect can produce several failing tests. If `mean()` calls `add()` and `divide()`, failures in all three do not prove three separate defects. Inspect the dependencies, repair the demonstrated upstream cause, then rerun the downstream checks before changing already-correct logic.

Supply interacting issues together when their repair requires a common design decision. For example, changing a parser's missing-value representation and changing its consumer must share the same contract. Independent presentation or logging issues can be addressed sequentially with a tight check after each change. Separate working copies can support independent parallel edits, but merging them still requires integration checks.

Stop after the agreed criteria pass and relevant regressions are checked. Repeatedly modifying correct behavior to satisfy a mistaken example is not refinement. If evidence shows the requirement or test is wrong, resolve that discrepancy explicitly.

## Use an interview to resolve unknown requirements

Read the relevant code and documents first. Then ask the owner about information the implementation cannot establish: acceptable cache staleness, who may invalidate entries, failure behavior, or whether a migration may discard incomplete records. Offer concrete trade-offs and record the chosen answer.

For example, “Should a cached balance remain visible when refresh fails?” exposes a design choice. A useful follow-up asks whether a stale value must carry an age indicator or whether the operation must fail. Do not silently choose an answer because the user has not replied. An interface timeout or preselected option does not itself authorize a consequential action.

Preserve the answers in the working requirements. A continuous session can help maintain context, but the requirement is continuity of verified information, not mandatory use of one specific SDK class. If work moves to another session, provide the actual decisions and evidence rather than assuming they transfer automatically.

## Worked example: null email migration

For this teaching example, the owner specifies the following limited contract. Preserve the record identifier. A null email is skipped with a warning. A nonempty string is marked ready for a later migration step, with its value unchanged. Other input types and an empty string are rejected as invalid input. This example does not claim to validate email syntax or execute a database write.

| Input | Expected result |
| --- | --- |
| `{"id":"R1","email":null}` | `{"id":"R1","status":"skipped","warning":"missing_email"}` |
| `{"id":"R2","email":"user@example.com"}` | `{"id":"R2","status":"ready","email":"user@example.com"}` |
| `{"id":"R3","email":""}` | `{"id":"R3","status":"invalid","reason":"invalid_email_input"}` |

This pure decision function implements that contract:

```python
def classify_record(record):
    record_id = record["id"]
    email = record.get("email")
    if email is None:
        return {"id": record_id, "status": "skipped", "warning": "missing_email"}
    if not isinstance(email, str) or email == "":
        return {"id": record_id, "status": "invalid", "reason": "invalid_email_input"}
    return {"id": record_id, "status": "ready", "email": email}
```

The example assumes an upstream check has supplied `id`; missing `email` follows the same branch as null because `get()` returns `None`. If those two states must differ, change the contract and test both explicitly. The status `ready` means eligible for the later migration step, not successfully written to storage.

Suppose the first implementation calls `email.lower()` before the null check. Share the null input and the actual exception, then ask for a repair that preserves the valid record. After moving the check, verify all listed outputs and a non-string email. Then separately test the real persistence layer, including failures and duplicate execution, before claiming a migration succeeded.

## Review the artifact against evidence

A useful review request identifies the saved change, the agreed contract, and what counts as a finding. Ask for concrete incorrect behavior, a location, and a reproducing case. A separate review context can reduce attachment to the author's reasoning, but it does not guarantee independence, completeness, or correctness. Confirm findings against the actual implementation. In the supplied Context Isolation model, intermediate tool calls and results remain inside the worker's context; only its final message returns to the parent. That final message must carry the findings, supporting evidence and uncertainty the parent needs; this return boundary does not guarantee a correct review.

If repeated corrections fail, pause the loop, preserve what is known, and inspect whether stale context, conflicting requirements, an incorrect path, or a faulty test is driving the failure. A fresh session with a corrected brief can help. There is no universal “two corrections” threshold that proves a reset is required, and clearing context does not repair the underlying code.

When the same correction recurs across tasks, update the relevant project instruction or reusable skill and retain a regression case. Keep the instruction concrete enough to check; expanding a persistent file with every transient detail can make it harder to use. In the appropriate scope, `CLAUDE.md` can hold coding standards, architectural guidelines and personal preferences as persistent instructions across sessions. Maintaining those instructions requires existing authority; persistence alone does not prove they were followed or enforced.

## Complete transfer and design examples

An example should demonstrate the new task, not merely ask the model to imitate an incomplete pattern. In the supplied pattern, input "Refactor the authentication module" has this expected planning output: (1) identify current authentication dependencies, (2) propose a modular structure, and (3) list breaking changes. For the new input "Optimize the database query layer," an illustrative expected output is:

1. Identify expensive query paths, current indexes, transaction boundaries and a representative workload; retain missing performance evidence as an open question.
2. Compare an index/query rewrite with an application-side batching approach, then propose the option consistent with observed query plans and transaction semantics.
3. List compatibility risks, including result ordering, null handling, write contention and migration/rollback steps; define before/after latency and correctness checks.

The structure transfers, but authentication dependencies do not become database facts. This is a target plan, not an implemented or measured optimization.

The source design example promises 4–6 named colors but supplies three, calls a color "serif," and both uses and criticizes cream/terracotta defaults. Reconcile the brief before reuse. For an invented archival-data dashboard brief—quiet, readable tables and clear status—this is one internally complete first-pass proposal:

| Role | Named color |
| --- | --- |
| Canvas | Archive White #F7F8FA |
| Primary text | Ink #172235 |
| Interactive accent | Cobalt #2457C5 |
| Warning/status | Amber #A15C00 |

Typography is separate: a sans-serif body face for dense tables and a monospace utility face for identifiers; a display face is optional only if the brief needs it. Use a compact table grid and persistent column labels rather than decorative layout. In the second pass, compare all four color roles, both type roles, contrast, layout and distinguishing choices against the actual brief before building; inspect the rendered artifact afterward. These are illustrative decisions, not a verified distinctive design. An error might say "The file could not be read. Choose a UTF-8 CSV file and retry." An empty state might say "No imports yet. Choose a CSV file to preview records." Each names the actual condition/action; interface voice is a contextual editing choice.

## Validate structure and behavior separately

For the migration decision objects above, the consumer contract requires string `id` and `status`; skipped adds string `warning`, ready adds string `email`, and invalid adds string `reason`. Parse actual generated JSON and validate the chosen branch's required fields/types before consuming it. Then compare values and actions against the declared input policy. A well-formed object can still choose the wrong branch or invent a fact. Invalid syntax, missing fields and semantically wrong results need distinct failures, not a generic pass.

Use exact-match checks for deterministic expected objects. Use a declared rubric when assessing qualities such as report evidence or relevance, with the criterion, grader input and pass threshold fixed before evaluation. An LLM-based grader is another assessment with its own reliability limits, not an unquestionable oracle. A requested but unevaluated rubric is not a passed check.

The source also supplies a separate illustrative email-validation target. The raw inputs and expected booleans are `"user@example.com" → true`, `"invalid" → false`, and `"user@.com" → false`. These are string values, not rendered `mailto:` Markdown. For this limited demonstration, accept an ordinary nonempty local part and a domain with nonempty labels separated by a dot; the latter two cases fail that stated policy. This is not a complete email-address specification and does not establish deliverability. Declare further accepted/rejected syntax and test it rather than generalizing from three cases.

## Preserve platform and interview boundaries

The supplied snapshot distinguishes Managed Agents resource handling from ordinary Claude Code test iteration. Its conceptual flow is: upload the intended actual source/test files through the supported Files API, obtain their IDs, mount those IDs on the intended session, then read the observed failing checks. The provided Python block is comments only, not executable API code. Exact methods, resource identity, credentials and permissions need actual support. The source also mentions `sessions.resources.add` to supply grounding; adding a resource does not prove freshness, successful mounting or a passing rerun. No upload, mount or runtime operation was performed here. The supplied material is a local compiled snapshot; its original citation-anchor attachments were not provided or independently verified here.

An interview should preserve a custom "Other" answer faithfully, including "wait" or "explain before continuing." Neutral relay must retain substance. Clarifying a design choice does not by itself grant implementation or tool authority. Keep required unanswered choices pending.

The source-scoped `AskUserQuestion` interface describes `askUserQuestionTimeout` values `60s`, `5m` and `10m` in user settings or the `/config` Question auto-continue row. It does not establish an unset default here. It describes submitting previously selected options when the dialog closes, indicating possible absence, a countdown during the last 20 seconds and restarting through a key or supported terminal-focus event. This applies to the described choice prompts; permission and plan approvals never idle-resolve. A closed question, absent answer or elapsed timer creates no new authority. These are snapshot details, not tested behavior in the current host.

For an unfamiliar-system bootstrap, inspect authorized target code and record known assets, entry points, trust boundaries and questions the code cannot answer. For a cache, an open question might be who may invalidate which tenant's entries and what stale/failure behavior the owner accepts. Retain the bootstrap evidence through the owner interview, then update risk likelihood/impact and the model from actual answers. The source illustrates one `ClaudeSDKClient` session for continuity; another mechanism must transfer the same actual evidence. Hardware-specific or sparse-documentation claims remain uncertain until supported; confidence labels and a completed interview do not prove them.

Later triage can independently re-verify and re-score a finding in a fresh/stateless query if it receives the actual finding, relevant code/evidence, criteria and unanswered questions. A stateless API name does not make missing context adequate. After a supported correction, re-review the affected artifact and run the needed regression before counting it complete.

## Work interacting changes through a concrete contract

Suppose issue A changes a parser's missing email from an absent key to explicit null; issue B changes a consumer that currently calls a string method unconditionally. They interact: changing only the parser can expose the consumer's null failure. Present both issues, retained valid-record behavior and null-warning policy together. First define the shared input/output contract, then change the parser and guarded consumer, then run joint checks: missing/null skips and warns, valid string remains unchanged, invalid type rejects. Those are expected checks until actually run. An unrelated heading typo and logging-label typo can be fixed separately in isolated changes with their own checks and a combined diff inspection; their outputs do not determine the other's contract.

The earlier pure classifier intentionally returns ready rather than claiming persistence. Complete the successful migration target separately. In an invented in-memory storage fixture initially containing no R2, the declared persistence policy is insert-once by id. Input `{"id":"R2","email":"user@example.com"}` is expected to produce action `insert`, stored record `{"id":"R2","email":"user@example.com"}`, and result `{"id":"R2","status":"migrated"}`. Null input R1 produces action `skip`, no stored R1 and warning `{"id":"R1","code":"missing_email"}`. A repeated identical R2 is expected to produce `already_present` without a second insert; a conflicting stored R2 or storage error remains a failure requiring a declared resolution. These are complete expected fixture outcomes under an explicit added teaching policy, not actual database writes or measured success.

For fan-out, discover and record the complete intended file set first, preserve source bytes, transform isolated authorized copies, and record each expected/actual comparison. Reconcile shared schema, record counts, identity and duplicate rules before batch completion. A failed/uninspected file remains in the declared batch; successful siblings cannot erase it.

## Bound the iteration loop

The source append/return fragment does not implement the maximum-iteration claim surrounding it. This application-control pseudocode makes the distinction explicit:

```text
maximum_steps = 8  # illustrative application policy, not a product default
for step from 1 through maximum_steps:
    obtain the next decision from the supported interface
    if decision declares completion:
        require actual declared checks to pass; otherwise return pending verification
        return completed with the captured evidence
    if no valid authorized tool request exists: return pending with the concrete gap
    execute only the authorized request through its supported adapter
    capture success/error, request identity and actual result
    if the result is missing/malformed or its request identity does not match: return pending with the concrete gap
    append/deliver that associated result in the supported message form for the next decision
    if the error requires unavailable input/authority: return pending with that error
    otherwise continue to the next bounded iteration
return pending: step limit reached, with unresolved work and actual outcomes
```

The bound is a declared example, not a guarantee that eight steps suffice. Exhaustion, missing output and failure are distinct from success. Stop wrong-direction work early. The source's Escape, `/rewind`/double Escape and `/clear` suggestions apply only to the actual supported checkpoint/context scope; preserve accepted requirements, failures and unresolved effects before a new attempt. Replacing prose with hooks/skills or shortening CLAUDE.md still requires actual authorized implementation and checks; keep necessary safeguards.

## An explicit faulty-consumer comparison

To make the null failure inspectable, assume the same upstream string id contract and no upstream email guard. This intentionally faulty fixture dereferences email before its policy check:

```python
def faulty_classify_record(record):
    record_id = record["id"]
    email = record.get("email")
    normalized = email.lower()
    if email is None:
        return {"id": record_id, "status": "skipped", "warning": "missing_email"}
    return {"id": record_id, "status": "ready", "email": normalized}
```

| Exact input | Faulty expected outcome | Guarded classify\_record expected outcome |
| --- | --- | --- |
| {"id":"R1","email":null} | AttributeError before a decision object | {"id":"R1","status":"skipped","warning":"missing\_email"} |
| {"id":"R2","email":"User@Example.com"} | {"id":"R2","status":"ready","email":"user@example.com"} | {"id":"R2","status":"ready","email":"User@Example.com"} |
| {"id":"R3","email":7} | AttributeError before a decision object | {"id":"R3","status":"invalid","reason":"invalid\_email\_input"} |

The uppercase valid string matters: this contract preserves its actual value, so silently lowercasing it is also a policy violation. The earlier guarded function checks null/type before returning and preserves the string; it does not execute persistence. These are expected pure-fixture outcomes until actual local execution is recorded separately. The real caller may have another allowed type or transformation contract; inspect it before declaring an actual defect. No model finding or external migration is established by this fixture.

## Make the iteration sequence and review entry explicit

Use the source's sequence deliberately: define fixed measurable success criteria and the appropriate tests or evaluation, draft an initial task prompt containing the actual target files, inputs, constraints and expected outputs, then implement incrementally. Run the real checks, read their actual pass/fail evidence and refine against the same accepted behavior. A written prompt or expected table is not a completed check. Include the independent review and affected regressions before counting the result complete.

The snapshot names the bundled /code-review skill as one supported way to review the actual current diff in a fresh worker and return findings. Where that surface is unavailable, an explicitly supported custom review prompt can instead name the actual saved work, accepted plan and finding criteria. Supply relevant surrounding code and unresolved assumptions, inspect returned findings, make only supported repairs and re-review. Neither invoking a command name nor requesting a fresh context proves a reviewer ran, was unbiased or found every defect; retain the actual result and its limits.

## Summary

Refine through explicit examples, measurable checks, and evidence from actual failures. Resolve important unknowns before implementation, repair shared causes before downstream symptoms, and carry verified decisions into every iteration.

## Complete static validation and migration fixtures

The following cases extend this teaching application's contract. They are expected outcomes derived from the stated rules, not observed model output, Python execution or database writes. The pure classifier above retains its limited purpose. The separate migration adapter accepts its decision only after structural validation and then follows this explicitly added persistence policy; none of these fields is a platform API guarantee.

For the classifier consumer, parse the full generated JSON first. Require an object with string id and status. Status must be skipped, ready or invalid; require the corresponding string warning, email or reason. Reject an undeclared status or missing/wrongly typed required value before using any branch. Next compare id, branch and values with the original input policy. Failure leaves the record unprocessed. Complete contrasts for input {"id":"R1","email":null} are:

| Generated text | Expected consumer outcome |
| --- | --- |
| {"id":"R1", | {"accepted":false,"stage":"syntax","reason":"invalid\_json","action":"none"} |
| {"id":"R1","status":"skipped"} | {"accepted":false,"stage":"structure","reason":"missing\_warning","action":"none"} |
| {"id":"R1","status":"skipped","warning":7} | {"accepted":false,"stage":"structure","reason":"warning\_type","action":"none"} |
| {"id":"R1","status":"ready","email":"fabricated@example.com"} | {"accepted":false,"stage":"semantics","reason":"wrong\_branch\_for\_null","action":"none"} |
| {"id":"R1","status":"skipped","warning":"missing\_email"} | {"accepted":true,"stage":"semantics","decision":{"id":"R1","status":"skipped","warning":"missing\_email"},"action":"none"} |

For this separate in-memory migration fixture, id is a supplied string. Missing email and null skip with missing\_email; empty or non-string email rejects with invalid\_email\_input. A nonempty string is an eligible value carried unchanged; this adapter does not validate email syntax. For an eligible value, an absent id is inserted once; an identical existing record returns already\_present. A differing existing record returns identity\_conflict without overwriting. A simulated storage failure returns storage\_error and retains the original store. Each row is an independent case, not a shared sequential database. Store values are arrays of complete records, and logs are arrays of the complete relevant warning/error objects; a valid insert or identical replay has no warning/error log.

| Complete input envelope | Complete expected outcome |
| --- | --- |
| {"record":{"id":"R1","email":null},"store":\[\],"simulate\_storage\_error":false} | {"action":"skip","store":\[\],"result":{"id":"R1","status":"skipped"},"logs":\[{"id":"R1","code":"missing\_email"}\]} |
| {"record":{"id":"R1"},"store":\[\],"simulate\_storage\_error":false} | {"action":"skip","store":\[\],"result":{"id":"R1","status":"skipped"},"logs":\[{"id":"R1","code":"missing\_email"}\]} |
| {"record":{"id":"R3","email":""},"store":\[\],"simulate\_storage\_error":false} | {"action":"reject","store":\[\],"result":{"id":"R3","status":"invalid","reason":"invalid\_email\_input"},"logs":\[{"id":"R3","code":"invalid\_email\_input"}\]} |
| {"record":{"id":"R3","email":7},"store":\[\],"simulate\_storage\_error":false} | {"action":"reject","store":\[\],"result":{"id":"R3","status":"invalid","reason":"invalid\_email\_input"},"logs":\[{"id":"R3","code":"invalid\_email\_input"}\]} |
| {"record":{"id":"R2","email":"User@Example.com"},"store":\[\],"simulate\_storage\_error":false} | {"action":"insert","store":\[{"id":"R2","email":"User@Example.com"}\],"result":{"id":"R2","status":"migrated"},"logs":\[\]} |
| {"record":{"id":"R2","email":"User@Example.com"},"store":\[{"id":"R2","email":"User@Example.com"}\],"simulate\_storage\_error":false} | {"action":"already\_present","store":\[{"id":"R2","email":"User@Example.com"}\],"result":{"id":"R2","status":"already\_present"},"logs":\[\]} |
| {"record":{"id":"R2","email":"User@Example.com"},"store":\[{"id":"R2","email":"other@example.com"}\],"simulate\_storage\_error":false} | {"action":"none","store":\[{"id":"R2","email":"other@example.com"}\],"result":{"id":"R2","status":"failed","reason":"identity\_conflict"},"logs":\[{"id":"R2","code":"identity\_conflict"}\]} |
| {"record":{"id":"R2","email":"User@Example.com"},"store":\[\],"simulate\_storage\_error":true} | {"action":"none","store":\[\],"result":{"id":"R2","status":"failed","reason":"storage\_error"},"logs":\[{"id":"R2","code":"storage\_error"}\]} |

The parser/consumer repair example has a concrete ordering: first agree on explicit null and preserved valid strings, then modify the parser and guarded consumer together, then compare missing/null, unchanged valid and invalid-type results with these targets. Only then test the authorized persistence adapter. An isolated heading typo and logging-label typo have no such data dependency; check each isolated edit and then the combined diff. Expected table outcomes become measured passes only after actual execution and comparison, including failures and repeated calls.

## Bounded results and recovery comparisons

The loop's eight-step limit counts each next-decision attempt, including one with an error result. These complete illustrative input/expected pairs use an application-owned trace envelope: `maximum_steps`, ordered `decisions`, received `outcomes` and `captured_checks`. They are synthetic fixtures; their supplied check records are invented inputs, not evidence that a real suite or model ran. A live completion needs the corresponding actual valid check evidence. `inspect_fixture` and the trace keys below are teaching names, not vendor API methods.

`appended_request_ids` names only correctly associated results delivered in the supported next-decision message form. `retained_outcomes` also preserves unmatched received evidence for diagnosis without appending it as another request's result. Application authorization to attempt a call does not guarantee effective runtime permission; the denied example preserves that real error and creates no new authority.

```json
[
  {"case_id":"complete_with_evidence","input":{"maximum_steps":8,"decisions":[{"step":1,"kind":"declare_completion"}],"outcomes":[],"captured_checks":[{"check_id":"fixture-identity-check","result":"passed","expected_fixture_id":"I1","observed_fixture_id":"I1","evidence_id":"synthetic-check-1"}]},"expected":{"status":"completed","step":1,"reason":"declared_checks_passed","appended_request_ids":[],"retained_outcomes":[],"check_results":[{"check_id":"fixture-identity-check","result":"passed","expected_fixture_id":"I1","observed_fixture_id":"I1","evidence_id":"synthetic-check-1"}]}},
  {"case_id":"missing_result","input":{"maximum_steps":8,"decisions":[{"step":1,"kind":"tool_request","request_id":"q1","tool":"inspect_fixture","arguments":{"fixture_id":"I1"},"application_authorized":true}],"outcomes":[],"captured_checks":[]},"expected":{"status":"pending","step":1,"reason":"missing_result","appended_request_ids":[],"retained_outcomes":[],"check_results":[]}},
  {"case_id":"mismatched_result","input":{"maximum_steps":8,"decisions":[{"step":1,"kind":"tool_request","request_id":"q1","tool":"inspect_fixture","arguments":{"fixture_id":"I1"},"application_authorized":true}],"outcomes":[{"request_id":"q2","status":"success","data":{"fixture_id":"I2","inspected":true},"more_work":true}],"captured_checks":[]},"expected":{"status":"pending","step":1,"reason":"result_request_mismatch","appended_request_ids":[],"retained_outcomes":[{"request_id":"q2","status":"success","data":{"fixture_id":"I2","inspected":true},"more_work":true}],"check_results":[]}},
  {"case_id":"permission_denied","input":{"maximum_steps":8,"decisions":[{"step":1,"kind":"tool_request","request_id":"q1","tool":"inspect_fixture","arguments":{"fixture_id":"I1"},"application_authorized":true}],"outcomes":[{"request_id":"q1","status":"error","code":"permission_denied","requires_unavailable_authority":true,"data":null}],"captured_checks":[]},"expected":{"status":"pending","step":1,"reason":"permission_denied","appended_request_ids":["q1"],"retained_outcomes":[{"request_id":"q1","status":"error","code":"permission_denied","requires_unavailable_authority":true,"data":null}],"check_results":[]}},
  {"case_id":"eight_nonterminal_steps","input":{"maximum_steps":8,"decisions":[{"step":1,"kind":"tool_request","request_id":"q1","tool":"inspect_fixture","arguments":{"fixture_id":"I1"},"application_authorized":true},{"step":2,"kind":"tool_request","request_id":"q2","tool":"inspect_fixture","arguments":{"fixture_id":"I2"},"application_authorized":true},{"step":3,"kind":"tool_request","request_id":"q3","tool":"inspect_fixture","arguments":{"fixture_id":"I3"},"application_authorized":true},{"step":4,"kind":"tool_request","request_id":"q4","tool":"inspect_fixture","arguments":{"fixture_id":"I4"},"application_authorized":true},{"step":5,"kind":"tool_request","request_id":"q5","tool":"inspect_fixture","arguments":{"fixture_id":"I5"},"application_authorized":true},{"step":6,"kind":"tool_request","request_id":"q6","tool":"inspect_fixture","arguments":{"fixture_id":"I6"},"application_authorized":true},{"step":7,"kind":"tool_request","request_id":"q7","tool":"inspect_fixture","arguments":{"fixture_id":"I7"},"application_authorized":true},{"step":8,"kind":"tool_request","request_id":"q8","tool":"inspect_fixture","arguments":{"fixture_id":"I8"},"application_authorized":true}],"outcomes":[{"request_id":"q1","status":"success","data":{"fixture_id":"I1","inspected":true},"more_work":true},{"request_id":"q2","status":"success","data":{"fixture_id":"I2","inspected":true},"more_work":true},{"request_id":"q3","status":"success","data":{"fixture_id":"I3","inspected":true},"more_work":true},{"request_id":"q4","status":"success","data":{"fixture_id":"I4","inspected":true},"more_work":true},{"request_id":"q5","status":"success","data":{"fixture_id":"I5","inspected":true},"more_work":true},{"request_id":"q6","status":"success","data":{"fixture_id":"I6","inspected":true},"more_work":true},{"request_id":"q7","status":"success","data":{"fixture_id":"I7","inspected":true},"more_work":true},{"request_id":"q8","status":"success","data":{"fixture_id":"I8","inspected":true},"more_work":true}],"captured_checks":[]},"expected":{"status":"pending","step":8,"reason":"step_limit_reached","appended_request_ids":["q1","q2","q3","q4","q5","q6","q7","q8"],"retained_outcomes":[{"request_id":"q1","status":"success","data":{"fixture_id":"I1","inspected":true},"more_work":true},{"request_id":"q2","status":"success","data":{"fixture_id":"I2","inspected":true},"more_work":true},{"request_id":"q3","status":"success","data":{"fixture_id":"I3","inspected":true},"more_work":true},{"request_id":"q4","status":"success","data":{"fixture_id":"I4","inspected":true},"more_work":true},{"request_id":"q5","status":"success","data":{"fixture_id":"I5","inspected":true},"more_work":true},{"request_id":"q6","status":"success","data":{"fixture_id":"I6","inspected":true},"more_work":true},{"request_id":"q7","status":"success","data":{"fixture_id":"I7","inspected":true},"more_work":true},{"request_id":"q8","status":"success","data":{"fixture_id":"I8","inspected":true},"more_work":true}],"check_results":[]}},
  {"case_id":"completion_without_checks","input":{"maximum_steps":8,"decisions":[{"step":1,"kind":"declare_completion"}],"outcomes":[],"captured_checks":[]},"expected":{"status":"pending_verification","step":1,"reason":"missing_required_check_evidence","appended_request_ids":[],"retained_outcomes":[],"check_results":[]}},
  {"case_id":"completion_with_failed_check","input":{"maximum_steps":8,"decisions":[{"step":1,"kind":"declare_completion"}],"outcomes":[],"captured_checks":[{"check_id":"fixture-identity-check","result":"failed","expected_fixture_id":"I1","observed_fixture_id":"I2","evidence_id":"synthetic-check-2"}]},"expected":{"status":"pending_verification","step":1,"reason":"declared_check_failed","appended_request_ids":[],"retained_outcomes":[],"check_results":[{"check_id":"fixture-identity-check","result":"failed","expected_fixture_id":"I1","observed_fixture_id":"I2","evidence_id":"synthetic-check-2"}]}}
]
```

In the denied case the correctly identified error is captured/delivered, then the unavailable-authority guard stops further work. In the mismatch case q2 remains diagnostic evidence and is never delivered as q1\. Eight accepted nonterminal results consume all eight next-decision attempts; a ninth attempt is outside this policy. Neither a missing result nor absent/failed completion checks becomes a successful run.

A completion declaration with absent or failing checks instead returns pending\_verification. An error that the authorized adapter can actually resolve may lead to another decision within the remaining budget; its label alone does not authorize retries or effects. Missing/malformed outcomes and exhausted budgets are never counted as completed work.

Consider an explicitly hypothetical checkpoint containing src/consumer.py with the null guard and tests/test\_consumer.py with the accepted null/valid assertions. A later wrong edit removes the guard; a separate already-sent notification is recorded as an external effect. Before recovery, stop and record the chosen checkpoint identity, the actual changed-file diff, original requirements, failure evidence and notification receipt. After a supported rewind, compare the restored bytes of both named files with that actual checkpoint and inspect the remaining diff; then rerun affected checks. Do not infer the notification was unsent or a database change reversed from restoration of local files. Any unverified file/effect stays pending. If only conversation state was restored, the files still require their own actual verification or repair.

For a fresh context, carry these file targets, accepted null/valid policy, original failures, actual restoration findings and outstanding external effect into the new brief. More than two corrections is only the source's restart heuristic. Put a recurring confirmed guard requirement in the relevant project CLAUDE.md or narrowly scoped skill/hook only under existing configuration authority, retain a concrete regression case, and preserve the material guard and permission controls. A shorter instruction file or suggested hook is neither an authorized global settings change nor proof enforcement was implemented. For any resource access or cross-context recovery described here, preserve only the non-secret workspace/worktree, revision and execution identities needed to identify the actual work. If the access requires an account or credential, retain only the needed non-secret account/credential identity or an approved secret-store reference. Never put actual keys, tokens or passwords in prompts, logs or handoffs. Knowing a reference or sharing configuration does not itself authorize retrieving, sharing or using credentials or accessing a resource. If required identity, evidence or authorization is missing or unverified, keep continuation blocked and identify the gap; do not silently switch accounts.
