TRACE — Test Requirements Against Code & Execution
Objective
Maintain exactly one canonical UTF-8 CSV named behavior_verification.csv at the repository root. It is the source of truth for every required behavior and every externally observable repository capability, including implementation evidence, executable verification, defects, fixes, and current status.
A TRACE run succeeds only when the CSV and the executed repository behavior agree.
Required outputs
behavior_verification.csv — the only canonical verification matrix and the only required mutable record.
.scratch/ — gitignored disposable scripts, test data, logs, captures, and evidence generated during the run.
scenarios.jsonl — reusable scenarios promoted only after they pass. Create it when at least one reusable scenario exists.
Do not create a second verification CSV, a renamed copy, a backup CSV, or per-agent CSV fragments anywhere in the repository.
TRACE performs no version-control writes. Do not commit, branch, or push unless the operator explicitly instructs it; list every created and modified file in the final report instead.
Non-negotiable invariants
- The main thread is the sole CSV writer. Reviewers, subagents, and parallel workers may inspect the repository and return candidate findings, but they must never create, edit, normalize, sort, or rewrite
behavior_verification.csv.
- Preserve stable row IDs. Use
TRACE-0001, TRACE-0002, and so on. Never renumber, recycle, or repurpose an existing ID. Assign each new ID as one greater than the highest ID ever used, even after a row was removed.
- One row means one atomic observable behavior. Split compound requirements when each clause can pass or fail independently.
- Do not guess. Record ambiguity, conflicting sources, missing code, missing credentials, environment blockers, product decisions, and untestable behavior explicitly.
- Execution is the verification authority. Static reading supports discovery and test design but does not verify a required behavior. A required spec item without a practical execution path fails the spec-completion gate.
- Keep required intent distinct from current implementation. The authoritative spec defines what is required. Executable code defines what currently exists. When they conflict, record both, use code as the authority for current behavior, and log the spec/code mismatch rather than silently changing the expected behavior.
- Use real dependencies where practical. Prefer local real services, disposable data, test-mode or sandbox external services, and real authentication flows. Do not replace the behavior under test with mocks.
- Do not mutate product behavior while testing. Testing may create disposable fixtures, configuration, test accounts, or local services. Product changes belong only in the Fix step and must be tied to logged defects.
- Never expose or persist secrets. Record environment-variable names, credential requirements, and redacted identifiers—not secret values, tokens, session cookies, or private keys.
Verified is earned, not inferred. A row becomes Verified only after a passing execution, any required fix and re-test, a fresh-eyes review, and a CSV evidence audit.
Canonical CSV schema
The header must match this exact order and spelling:
ID,Area,Capability,Actor,Story,Expected behavior from spec/code,Interface / entrypoint,Source,Test method,Status,Defects,Defect type,Actual result,Notes / open questions
Allowed Status values:
Spec'd — discovered and mapped, but not yet successfully executed and reviewed.
Tested-Pass — execution passed; fresh-eyes review and CSV audit are still pending.
Tested-Fail — execution failed or observed behavior contradicted the expected behavior.
Fixed — a scoped fix was applied; passing re-test is still pending.
Verified — execution passed after any fix, review found no unresolved issue, and the CSV matches the evidence.
Allowed Defect type values:
Functional
Logistical
UX
Documentation
Testability
Environment
Unknown
Leave Defect type blank when there is no defect. Do not invent additional status or defect values.
Field contract
| Column |
Required content |
ID |
Stable TRACE-NNNN identifier. |
Area |
Product or system area, such as Auth, CLI, API, Persistence, Worker, Export, or Build. |
Capability |
Concise name for one externally observable behavior. |
Actor |
Human role, external system, operator, developer, scheduler, or other initiator. |
Story |
Actor-centered scenario, normally "As …, when …, I can …". |
Expected behavior from spec/code |
Atomic, observable pass condition. Preserve spec intent and note code behavior when it differs. |
Interface / entrypoint |
Public route, command, binary, function export, queue, event, UI path, config surface, or other callable boundary. |
Source |
Precise evidence such as spec:path:lines, code:path:symbol, test name, manifest, route registration, or code-only. Include both sides of a mismatch. |
Test method |
Strongest practical method, dependencies, setup, invocation, assertions, and cleanup. |
Status |
One allowed lifecycle value. |
Defects |
Concrete observed defect, mismatch, blocker, or empty. Avoid vague phrases such as "doesn't work." |
Defect type |
One allowed classification or empty. |
Actual result |
Executed evidence: timestamp, command or manual procedure, exit code, observed result, concise output/log summary, and evidence path when useful. |
Notes / open questions |
Ambiguity, scope disposition, attempt count, credentials, decisions, cleanup caveats, or next action. |
Use one-line cells where practical. Quote cells correctly when commas, quotes, or newlines are unavoidable. Preserve UTF-8 without a byte-order mark.
Execution evidence format
Use a compact, factual structure in Actual result:
2026-08-18T15:04:05Z | command: <exact command or manual procedure> | exit: <code or n/a> | observed: <what happened> | output: <key stdout/stderr/log summary> | evidence: <optional .scratch path>
Do not paste enormous logs into the CSV. Put full disposable logs under .scratch/evidence/<ID>/ and retain the exact command and decisive output summary in the row.
Use the actual execution time in each timestamp (for example from date -u +%Y-%m-%dT%H:%M:%SZ); never a placeholder or a rounded guess. When a row is re-tested, append a new entry; never overwrite prior failing evidence.
Status transitions
Normal no-fix path:
Spec'd -> Tested-Pass -> Verified
Normal defect path:
Spec'd -> Tested-Fail -> Fixed -> Tested-Pass -> Verified
A failed re-test returns the row to Tested-Fail. A fresh-eyes finding also returns the affected row to Tested-Fail unless a fix has already been applied, in which case use Fixed until re-tested.
Never change a failed row directly to Verified based on inspection, confidence, or a code diff.
The order is fixed: passing execution, then fresh-eyes review, then the fresh-context CSV audit. Only the audit promotes Tested-Pass to Verified.
Write each transition to the CSV as it occurs; never batch transitions. A fixed-but-not-yet-re-tested row must read Fixed in the CSV, not be held back until it can be written as Tested-Pass.
Startup procedure
- Locate the repository root.
- Search the repository for every file named
behavior_verification.csv.
- If none exists, create one at the root with the exact header.
- If exactly one exists, use it in place and preserve all IDs.
- If more than one exists, stop mutation, report the duplicate paths, and resolve which one is canonical before continuing. Do not merge by guessing.
- Read the existing CSV before assigning IDs. The next ID is one greater than the highest existing numeric suffix.
- Ensure
/.scratch/ or .scratch/ is present in the repository root .gitignore.
- Inspect any existing
scenarios.jsonl; do not overwrite passing scenarios.
- Identify the user-designated or repository-designated authoritative spec. If multiple candidates conflict and precedence is not explicit, record the ambiguity and treat it as a gate blocker.
- Run the bundled read-only validator after initial setup and after each write batch:
python3 <skill-directory>/scripts/trace_csv.py validate --repo .
The main thread may use the helper to initialize the CSV. Reviewers must use only read-only commands.
Phase 0 — Project-shape discovery
Build a factual map before extracting requirements or designing scenarios.
Inventory
Detect and record:
- languages and runtime versions;
- frameworks and generated-code systems;
- package managers, lockfiles, build tools, task runners, and test tools;
- executable entrypoints, binaries, scripts, CLIs, subcommands, and flags;
- public APIs, RPC methods, web routes, webhooks, sockets, and exported library surfaces;
- user-visible pages, forms, navigation paths, and browser workflows;
- workers, queues, schedulers, cron jobs, event consumers, and background processes;
- configuration files, environment variables, feature flags, and state directories;
- authentication, authorization, roles, tenancy, session handling, and credential boundaries;
- persistence engines, schemas, migrations, caches, files, and cleanup behavior;
- third-party integrations and their local, sandbox, emulator, or test-mode options;
- fixtures, seeds, factories, sample data, and disposable-account mechanisms;
- local services, containers, devcontainers, compose files, and service health checks;
- CI workflows, release jobs, packaging, generated artifacts, and deployment checks;
- existing unit, integration, contract, scenario, system, browser, and end-to-end tests.
Use manifests, route registration, command registration, export declarations, generated API schemas, configuration loading, and runtime introspection—not filenames alone.
Spec authority
Identify the authoritative specification and record its path or source. Use this precedence unless the user specifies another:
- Explicitly user-designated specification or acceptance contract.
- Repository file explicitly labeled canonical, normative, requirements, protocol, or acceptance criteria.
- Versioned API/schema/protocol definition used to generate or validate implementation.
- Product documentation and examples.
- Tests as evidence of intended behavior.
Executable code wins over secondary documentation when determining current behavior. It does not erase an unmet authoritative requirement.
Discovery strategy
Before Phase 1, state internally how capability coverage will be obtained. Use at least these independent passes:
- Spec pass: extract every normative statement and acceptance condition.
- Surface pass: enumerate externally callable routes, commands, exports, UI workflows, workers, events, and configuration effects from code.
- Runtime pass: start or interrogate the system where practical to discover generated routes, command help, schemas, health endpoints, plugin registries, or dynamic capabilities.
- Test pass: inspect existing tests and fixtures for behavior not obvious from registration code.
- Independent coverage pass: review the discovered surface without relying on the current CSV row order.
Decide how each dependency will run locally or in a sandbox. Record missing services, credentials, destructive risks, or unavailable platforms immediately; do not defer them until testing.
Phase 1 — Atomic behavior matrix
Extract spec requirements
For every normative requirement:
- Identify the actor and trigger.
- Identify one observable outcome.
- Split independent clauses into separate rows.
- Capture exact spec evidence in
Source.
- Locate implementation evidence. If none exists, say so explicitly.
- Identify the actual interface or entrypoint.
- Design a practical executable test path with setup, assertions, and cleanup.
- Add or update the row as
Spec'd.
Normative cues include "must," "shall," "should" when acceptance depends on it, explicit acceptance criteria, error behavior, authorization rules, data persistence rules, limits, defaults, and compatibility guarantees.
Discover code-only capabilities
Enumerate every externally observable capability exposed by the repository, even when absent from the authoritative spec. Add one row per atomic capability with Source beginning with code-only and note one of these dispositions:
Scope disposition: verify
or
Scope disposition: out-of-scope/code-only — <reason>
An out-of-scope disposition must be explicit and reasoned. It cannot conceal an open Functional, Logistical, or UX defect. An out-of-scope row keeps its current status — normally Spec'd — and is exempted from the exit criteria rather than verified.
Typical code-only surfaces include undocumented routes, flags, environment-controlled behavior, importable exports, migration commands, maintenance jobs, debug endpoints, compatibility aliases, and error modes.
Map mismatches without guessing
When spec and code disagree:
- keep the spec requirement in
Expected behavior from spec/code;
- describe current code behavior separately in the same cell or
Notes / open questions;
- cite both sources;
- classify missing or contradictory implementation as
Functional unless the discrepancy is purely documentation;
- record a product-decision blocker when the intended behavior cannot be determined;
- do not rewrite the spec expectation to make the implementation pass.
Fresh-context coverage review
After the first matrix is built, perform an independent review against the spec and repository surface.
Prefer a fresh subagent or reviewer when available. It must be read-only and return a structured list containing proposed row, evidence, and reason. The main thread decides and writes.
When no independent context is available, perform a second pass from manifests, route/command/export registration, generated schemas, and runtime help — or, when the repository lacks such artifacts, an independent re-reading of its public entrypoints — without reading rows sequentially. Compare the resulting capability list to the CSV, then add omissions and remove or qualify unsupported claims.
Spec-completion gate
Do not begin scenario testing until every required spec row has all of the following:
- authoritative spec evidence;
- implementation evidence that plausibly reaches the expected behavior;
- a concrete interface or entrypoint;
- a practical execution-based test path;
- known setup and cleanup requirements;
- no unresolved product decision;
- no missing user input, credential, secret, service, platform, or environment prerequisite.
A required row that fails this gate stays Spec'd. Record the missing evidence or blocker and report it immediately with a table:
CSV ID | Requirement | Missing evidence or implementation | Blocker | Next action
Examples of gate failures:
- required behavior has no implementation;
- implementation cannot be identified;
- spec ambiguity needs a product decision;
- only production credentials exist;
- no safe or practical execution path exists;
- a required external service has no available sandbox and cannot be exercised safely;
- required platform or hardware is unavailable.
Continue the verification loop for rows that individually pass the gate; a run with any gate-blocked required row cannot report SUCCESS. An implementation that exists but misbehaves is not a gate failure — test it and log the defect.
Do not use mocks or static inspection to force a required row through the gate.
Verification loop
Enter this loop for rows that pass the spec-completion gate. Gate-blocked required rows stay Spec'd and keep the overall run from reporting SUCCESS.
Test hierarchy
For each row not Verified, use the strongest practical method in this order:
- real scenario, end-to-end, or system test;
- CLI through the public binary or command surface;
- public API or protocol harness;
- integration test with real local or sandbox dependencies;
- unit test through the public behavior boundary;
- targeted executable harness;
- static analysis only for discovery or an explicitly out-of-scope code-only surface when execution is genuinely impossible.
Static analysis never advances a row to Tested-Pass or Verified.
Prefer black-box assertions on externally observable behavior. Use internal inspection only to explain failures or assert state that has no public observation path.
Scratch assets
Put disposable scenario scripts, captures, logs, temporary data, and local orchestration under:
.scratch/
Recommended layout:
.scratch/
evidence/<TRACE-ID>/
scripts/
fixtures/
state/
Do not commit scratch artifacts. Ensure cleanup is safe and idempotent.
1. Test
For every unverified row:
- Create isolated, disposable state.
- Start real local dependencies or approved sandbox services.
- Invoke the documented public interface.
- Assert the expected success behavior, error behavior, state transition, authorization rule, and cleanup where relevant.
- Capture the exact command or manual procedure, exit code, decisive output, log summary, and evidence path.
- Do not change product behavior during this step.
- Set
Tested-Pass or Tested-Fail and update defect fields factually.
A test is not strong merely because it passes. It must be capable of failing when the required behavior is broken.
2. Fix
For each logged Functional, Logistical, or UX defect:
- Diagnose the root cause from execution evidence.
- Make the smallest coherent product change that resolves the logged defect.
- Avoid unrelated refactors, style churn, dependency upgrades, or speculative improvements.
- Add or strengthen a regression test at the most appropriate layer.
- Mark only affected rows
Fixed.
- Record changed files and the root cause in
Defects, Actual result, or Notes / open questions.
Fix Documentation, Testability, Environment, or Unknown defects only when the correction is obvious, safe, and needs no product decision. Otherwise record the next action and stop or continue according to the gate and safety rules.
3. Re-test
Re-run the exact failing scenario and any directly affected regression or neighboring scenario.
- Pass: set
Tested-Pass, append the new execution evidence after the preserved failing evidence in Actual result, then perform fresh-eyes review.
- Fail: set
Tested-Fail, preserve the attempt evidence, increment the cycle count, and return to diagnosis if below the safety cap.
Never mark Verified merely because tests compile, a unit test passes while the public scenario still fails, or the diff appears correct.
4. Fresh-eyes review
After a passing execution, inspect the touched code, tests, scenario, and CSV row for:
- authentication and authorization bypasses;
- tenant, role, and ownership isolation;
- input validation and output encoding;
- injection, traversal, unsafe deserialization, secret leakage, and insecure defaults;
- incorrect error codes, error messages, and partial-success behavior;
- boundary values, empty values, malformed values, duplicates, retries, and idempotency;
- stale state, transactionality, race conditions, ordering, locking, and cleanup;
- persistence, migration, cache, and restart behavior;
- business-rule contradictions and spec/code drift;
- performance traps, unbounded work, resource leaks, and timeout behavior;
- flaky assertions, hidden test coupling, and tests that cannot detect regressions;
- unsupported or overstated claims in the CSV.
Log every material finding as a new row or update the affected row. Fix and re-test scoped Functional, Logistical, and UX findings. A row can advance to Verified only when this review is clear.
5. Fresh-context CSV audit
After each write batch and before final reporting:
- Validate exact headers, UTF-8, parseability, allowed enums, and unique IDs.
- Confirm every command, exit code, result, fix, source, and status matches actual evidence.
- Confirm no row says
Verified without passing execution evidence.
- Confirm failed attempts and unresolved defects were not erased.
- Confirm code-only rows have explicit scope disposition.
- Confirm no second
behavior_verification.csv exists.
- Run:
python3 <skill-directory>/scripts/trace_csv.py validate --repo .
When the audit passes, change eligible Tested-Pass rows to Verified and run the validator again.
Reusable scenarios
Promote a passing scratch scenario to root-level scenarios.jsonl when it is deterministic, safe, reusable, and exercises a public behavior boundary. Store one JSON object per line.
Recommended record shape:
{"id":"scenario-trace-0007-happy-path","capability_ids":["TRACE-0007"],"name":"Create and retrieve a record through the public API","preconditions":["service running","TEST_DATABASE_URL set"],"command":"python3 scenarios/create_and_get.py","expected":{"exit_code":0,"assertions":["created id is returned","retrieved payload matches"]},"cleanup":"scenario deletes its disposable record","last_verified":"2026-08-18T15:04:05Z"}
Rules:
- Reference one or more CSV IDs in
capability_ids.
- Store environment-variable names, never values.
- Write commands to run from the repository root.
- Store a promoted scenario's script at a committed path such as
scenarios/; a promoted scenario must never reference .scratch/.
- Include deterministic assertions and cleanup.
- Do not promote failing, flaky, destructive, environment-specific, or one-off diagnostic scripts.
- Preserve existing scenario IDs and append new records rather than silently replacing history.
Safety cap
Track failed test/fix/re-test cycles per capability in Notes / open questions:
Cycle 1/3: ...
Cycle 2/3: ...
Cycle 3/3: ...
After three failed cycles for one capability:
- Stop modifying that capability.
- Leave it
Tested-Fail.
- Preserve all three attempt summaries, root-cause analysis, commands, evidence paths, and changed files.
- Record the most specific known next action.
- Continue independent capabilities when safe, but the overall run cannot report success.
- Include the capped capability prominently in the final report.
Do not reset the attempt count by renaming the capability, creating a new row, or slightly changing the test.
Successful exit criteria
Report success only when all conditions are true:
- every required spec capability is
Verified;
- every exposed code capability is
Verified or explicitly marked Scope disposition: out-of-scope/code-only with no open Functional, Logistical, or UX defect;
- no open
Functional, Logistical, or UX defects remain;
- every reusable passing scenario is represented in
scenarios.jsonl;
- the final fresh-eyes review has no unresolved material finding;
- the final fresh-context CSV audit passes;
- exactly one canonical UTF-8
behavior_verification.csv exists;
- the CSV matches the commands and observed evidence actually produced.
Final response contract
Return:
- Overall result:
SUCCESS, BLOCKED AT SPEC-COMPLETION GATE, or INCOMPLETE — TEST FAILURES REMAIN. When gate blockers and test failures both remain, report BLOCKED AT SPEC-COMPLETION GATE and include the failures.
- CSV path and row counts by status.
- Required-spec coverage and code-only coverage.
- Tests executed, grouped by interface and method.
- Defects found, root causes, fixes, and re-test outcomes.
- Remaining blockers or safety-capped failures with CSV IDs and next actions.
- Promoted
scenarios.jsonl entries.
- Final validator result and confirmation that exactly one canonical CSV exists.
Do not claim complete verification when any success condition is unmet.
Anti-patterns
Never:
- write the CSV from multiple agents or processes;
- renumber IDs after sorting or inserting rows;
- treat documentation prose as proof of runtime behavior;
- use mocks when the real local or sandbox dependency is practical;
- weaken a test merely to make it pass;
- alter expected behavior to match a bug;
- fix unlogged or unrelated product behavior during the loop;
- hide blockers in vague notes;
- mark static inspection as execution;
- mark
Verified before re-test and review;
- erase failed evidence after a fix;
- store credentials or personal data in evidence;
- touch production data or services without explicit authorization;
- declare success with an open required row or an open Functional, Logistical, or UX defect.
1---2name: trace3description: Use when verifying a repository against its authoritative spec — spec-to-code audits, implementation-completeness reviews, release verification, behavior inventories, repo-wide acceptance testing, or when asked whether every documented requirement is implemented and actually works.4---56# TRACE — Test Requirements Against Code & Execution78## Objective910Maintain exactly one canonical UTF-8 CSV named `behavior_verification.csv` at the repository root. It is the source of truth for every required behavior and every externally observable repository capability, including implementation evidence, executable verification, defects, fixes, and current status.1112A TRACE run succeeds only when the CSV and the executed repository behavior agree.1314## Required outputs1516- `behavior_verification.csv` — the only canonical verification matrix and the only required mutable record.17- `.scratch/` — gitignored disposable scripts, test data, logs, captures, and evidence generated during the run.18- `scenarios.jsonl` — reusable scenarios promoted only after they pass. Create it when at least one reusable scenario exists.1920Do not create a second verification CSV, a renamed copy, a backup CSV, or per-agent CSV fragments anywhere in the repository.2122TRACE performs no version-control writes. Do not commit, branch, or push unless the operator explicitly instructs it; list every created and modified file in the final report instead.2324## Non-negotiable invariants25261. **The main thread is the sole CSV writer.** Reviewers, subagents, and parallel workers may inspect the repository and return candidate findings, but they must never create, edit, normalize, sort, or rewrite `behavior_verification.csv`.272. **Preserve stable row IDs.** Use `TRACE-0001`, `TRACE-0002`, and so on. Never renumber, recycle, or repurpose an existing ID. Assign each new ID as one greater than the highest ID ever used, even after a row was removed.283. **One row means one atomic observable behavior.** Split compound requirements when each clause can pass or fail independently.294. **Do not guess.** Record ambiguity, conflicting sources, missing code, missing credentials, environment blockers, product decisions, and untestable behavior explicitly.305. **Execution is the verification authority.** Static reading supports discovery and test design but does not verify a required behavior. A required spec item without a practical execution path fails the spec-completion gate.316. **Keep required intent distinct from current implementation.** The authoritative spec defines what is required. Executable code defines what currently exists. When they conflict, record both, use code as the authority for current behavior, and log the spec/code mismatch rather than silently changing the expected behavior.327. **Use real dependencies where practical.** Prefer local real services, disposable data, test-mode or sandbox external services, and real authentication flows. Do not replace the behavior under test with mocks.338. **Do not mutate product behavior while testing.** Testing may create disposable fixtures, configuration, test accounts, or local services. Product changes belong only in the Fix step and must be tied to logged defects.349. **Never expose or persist secrets.** Record environment-variable names, credential requirements, and redacted identifiers—not secret values, tokens, session cookies, or private keys.3510. **`Verified` is earned, not inferred.** A row becomes `Verified` only after a passing execution, any required fix and re-test, a fresh-eyes review, and a CSV evidence audit.3637## Canonical CSV schema3839The header must match this exact order and spelling:4041```csv42ID,Area,Capability,Actor,Story,Expected behavior from spec/code,Interface / entrypoint,Source,Test method,Status,Defects,Defect type,Actual result,Notes / open questions43```4445Allowed `Status` values:4647- `Spec'd` — discovered and mapped, but not yet successfully executed and reviewed.48- `Tested-Pass` — execution passed; fresh-eyes review and CSV audit are still pending.49- `Tested-Fail` — execution failed or observed behavior contradicted the expected behavior.50- `Fixed` — a scoped fix was applied; passing re-test is still pending.51- `Verified` — execution passed after any fix, review found no unresolved issue, and the CSV matches the evidence.5253Allowed `Defect type` values:5455- `Functional`56- `Logistical`57- `UX`58- `Documentation`59- `Testability`60- `Environment`61- `Unknown`6263Leave `Defect type` blank when there is no defect. Do not invent additional status or defect values.6465### Field contract6667| Column | Required content |68|---|---|69| `ID` | Stable `TRACE-NNNN` identifier. |70| `Area` | Product or system area, such as Auth, CLI, API, Persistence, Worker, Export, or Build. |71| `Capability` | Concise name for one externally observable behavior. |72| `Actor` | Human role, external system, operator, developer, scheduler, or other initiator. |73| `Story` | Actor-centered scenario, normally "As …, when …, I can …". |74| `Expected behavior from spec/code` | Atomic, observable pass condition. Preserve spec intent and note code behavior when it differs. |75| `Interface / entrypoint` | Public route, command, binary, function export, queue, event, UI path, config surface, or other callable boundary. |76| `Source` | Precise evidence such as `spec:path:lines`, `code:path:symbol`, test name, manifest, route registration, or `code-only`. Include both sides of a mismatch. |77| `Test method` | Strongest practical method, dependencies, setup, invocation, assertions, and cleanup. |78| `Status` | One allowed lifecycle value. |79| `Defects` | Concrete observed defect, mismatch, blocker, or empty. Avoid vague phrases such as "doesn't work." |80| `Defect type` | One allowed classification or empty. |81| `Actual result` | Executed evidence: timestamp, command or manual procedure, exit code, observed result, concise output/log summary, and evidence path when useful. |82| `Notes / open questions` | Ambiguity, scope disposition, attempt count, credentials, decisions, cleanup caveats, or next action. |8384Use one-line cells where practical. Quote cells correctly when commas, quotes, or newlines are unavoidable. Preserve UTF-8 without a byte-order mark.8586### Execution evidence format8788Use a compact, factual structure in `Actual result`:8990```text912026-08-18T15:04:05Z | command: <exact command or manual procedure> | exit: <code or n/a> | observed: <what happened> | output: <key stdout/stderr/log summary> | evidence: <optional .scratch path>92```9394Do not paste enormous logs into the CSV. Put full disposable logs under `.scratch/evidence/<ID>/` and retain the exact command and decisive output summary in the row.9596Use the actual execution time in each timestamp (for example from `date -u +%Y-%m-%dT%H:%M:%SZ`); never a placeholder or a rounded guess. When a row is re-tested, append a new entry; never overwrite prior failing evidence.9798## Status transitions99100Normal no-fix path:101102```text103Spec'd -> Tested-Pass -> Verified104```105106Normal defect path:107108```text109Spec'd -> Tested-Fail -> Fixed -> Tested-Pass -> Verified110```111112A failed re-test returns the row to `Tested-Fail`. A fresh-eyes finding also returns the affected row to `Tested-Fail` unless a fix has already been applied, in which case use `Fixed` until re-tested.113114Never change a failed row directly to `Verified` based on inspection, confidence, or a code diff.115116The order is fixed: passing execution, then fresh-eyes review, then the fresh-context CSV audit. Only the audit promotes `Tested-Pass` to `Verified`.117118Write each transition to the CSV as it occurs; never batch transitions. A fixed-but-not-yet-re-tested row must read `Fixed` in the CSV, not be held back until it can be written as `Tested-Pass`.119120## Startup procedure1211221. Locate the repository root.1232. Search the repository for every file named `behavior_verification.csv`.124 - If none exists, create one at the root with the exact header.125 - If exactly one exists, use it in place and preserve all IDs.126 - If more than one exists, stop mutation, report the duplicate paths, and resolve which one is canonical before continuing. Do not merge by guessing.1273. Read the existing CSV before assigning IDs. The next ID is one greater than the highest existing numeric suffix.1284. Ensure `/.scratch/` or `.scratch/` is present in the repository root `.gitignore`.1295. Inspect any existing `scenarios.jsonl`; do not overwrite passing scenarios.1306. Identify the user-designated or repository-designated authoritative spec. If multiple candidates conflict and precedence is not explicit, record the ambiguity and treat it as a gate blocker.1317. Run the bundled read-only validator after initial setup and after each write batch:132133```bash134python3 <skill-directory>/scripts/trace_csv.py validate --repo .135```136137The main thread may use the helper to initialize the CSV. Reviewers must use only read-only commands.138139## Phase 0 — Project-shape discovery140141Build a factual map before extracting requirements or designing scenarios.142143### Inventory144145Detect and record:146147- languages and runtime versions;148- frameworks and generated-code systems;149- package managers, lockfiles, build tools, task runners, and test tools;150- executable entrypoints, binaries, scripts, CLIs, subcommands, and flags;151- public APIs, RPC methods, web routes, webhooks, sockets, and exported library surfaces;152- user-visible pages, forms, navigation paths, and browser workflows;153- workers, queues, schedulers, cron jobs, event consumers, and background processes;154- configuration files, environment variables, feature flags, and state directories;155- authentication, authorization, roles, tenancy, session handling, and credential boundaries;156- persistence engines, schemas, migrations, caches, files, and cleanup behavior;157- third-party integrations and their local, sandbox, emulator, or test-mode options;158- fixtures, seeds, factories, sample data, and disposable-account mechanisms;159- local services, containers, devcontainers, compose files, and service health checks;160- CI workflows, release jobs, packaging, generated artifacts, and deployment checks;161- existing unit, integration, contract, scenario, system, browser, and end-to-end tests.162163Use manifests, route registration, command registration, export declarations, generated API schemas, configuration loading, and runtime introspection—not filenames alone.164165### Spec authority166167Identify the authoritative specification and record its path or source. Use this precedence unless the user specifies another:1681691. Explicitly user-designated specification or acceptance contract.1702. Repository file explicitly labeled canonical, normative, requirements, protocol, or acceptance criteria.1713. Versioned API/schema/protocol definition used to generate or validate implementation.1724. Product documentation and examples.1735. Tests as evidence of intended behavior.174175Executable code wins over secondary documentation when determining current behavior. It does not erase an unmet authoritative requirement.176177### Discovery strategy178179Before Phase 1, state internally how capability coverage will be obtained. Use at least these independent passes:1801811. **Spec pass:** extract every normative statement and acceptance condition.1822. **Surface pass:** enumerate externally callable routes, commands, exports, UI workflows, workers, events, and configuration effects from code.1833. **Runtime pass:** start or interrogate the system where practical to discover generated routes, command help, schemas, health endpoints, plugin registries, or dynamic capabilities.1844. **Test pass:** inspect existing tests and fixtures for behavior not obvious from registration code.1855. **Independent coverage pass:** review the discovered surface without relying on the current CSV row order.186187Decide how each dependency will run locally or in a sandbox. Record missing services, credentials, destructive risks, or unavailable platforms immediately; do not defer them until testing.188189## Phase 1 — Atomic behavior matrix190191### Extract spec requirements192193For every normative requirement:1941951. Identify the actor and trigger.1962. Identify one observable outcome.1973. Split independent clauses into separate rows.1984. Capture exact spec evidence in `Source`.1995. Locate implementation evidence. If none exists, say so explicitly.2006. Identify the actual interface or entrypoint.2017. Design a practical executable test path with setup, assertions, and cleanup.2028. Add or update the row as `Spec'd`.203204Normative cues include "must," "shall," "should" when acceptance depends on it, explicit acceptance criteria, error behavior, authorization rules, data persistence rules, limits, defaults, and compatibility guarantees.205206### Discover code-only capabilities207208Enumerate every externally observable capability exposed by the repository, even when absent from the authoritative spec. Add one row per atomic capability with `Source` beginning with `code-only` and note one of these dispositions:209210```text211Scope disposition: verify212```213214or215216```text217Scope disposition: out-of-scope/code-only — <reason>218```219220An out-of-scope disposition must be explicit and reasoned. It cannot conceal an open `Functional`, `Logistical`, or `UX` defect. An out-of-scope row keeps its current status — normally `Spec'd` — and is exempted from the exit criteria rather than verified.221222Typical code-only surfaces include undocumented routes, flags, environment-controlled behavior, importable exports, migration commands, maintenance jobs, debug endpoints, compatibility aliases, and error modes.223224### Map mismatches without guessing225226When spec and code disagree:227228- keep the spec requirement in `Expected behavior from spec/code`;229- describe current code behavior separately in the same cell or `Notes / open questions`;230- cite both sources;231- classify missing or contradictory implementation as `Functional` unless the discrepancy is purely documentation;232- record a product-decision blocker when the intended behavior cannot be determined;233- do not rewrite the spec expectation to make the implementation pass.234235### Fresh-context coverage review236237After the first matrix is built, perform an independent review against the spec and repository surface.238239Prefer a fresh subagent or reviewer when available. It must be read-only and return a structured list containing proposed row, evidence, and reason. The main thread decides and writes.240241When no independent context is available, perform a second pass from manifests, route/command/export registration, generated schemas, and runtime help — or, when the repository lacks such artifacts, an independent re-reading of its public entrypoints — without reading rows sequentially. Compare the resulting capability list to the CSV, then add omissions and remove or qualify unsupported claims.242243## Spec-completion gate244245Do not begin scenario testing until every required spec row has all of the following:246247- authoritative spec evidence;248- implementation evidence that plausibly reaches the expected behavior;249- a concrete interface or entrypoint;250- a practical execution-based test path;251- known setup and cleanup requirements;252- no unresolved product decision;253- no missing user input, credential, secret, service, platform, or environment prerequisite.254255A required row that fails this gate stays `Spec'd`. Record the missing evidence or blocker and report it immediately with a table:256257```text258CSV ID | Requirement | Missing evidence or implementation | Blocker | Next action259```260261Examples of gate failures:262263- required behavior has no implementation;264- implementation cannot be identified;265- spec ambiguity needs a product decision;266- only production credentials exist;267- no safe or practical execution path exists;268- a required external service has no available sandbox and cannot be exercised safely;269- required platform or hardware is unavailable.270271Continue the verification loop for rows that individually pass the gate; a run with any gate-blocked required row cannot report `SUCCESS`. An implementation that exists but misbehaves is not a gate failure — test it and log the defect.272273Do not use mocks or static inspection to force a required row through the gate.274275## Verification loop276277Enter this loop for rows that pass the spec-completion gate. Gate-blocked required rows stay `Spec'd` and keep the overall run from reporting `SUCCESS`.278279### Test hierarchy280281For each row not `Verified`, use the strongest practical method in this order:2822831. real scenario, end-to-end, or system test;2842. CLI through the public binary or command surface;2853. public API or protocol harness;2864. integration test with real local or sandbox dependencies;2875. unit test through the public behavior boundary;2886. targeted executable harness;2897. static analysis only for discovery or an explicitly out-of-scope code-only surface when execution is genuinely impossible.290291Static analysis never advances a row to `Tested-Pass` or `Verified`.292293Prefer black-box assertions on externally observable behavior. Use internal inspection only to explain failures or assert state that has no public observation path.294295### Scratch assets296297Put disposable scenario scripts, captures, logs, temporary data, and local orchestration under:298299```text300.scratch/301```302303Recommended layout:304305```text306.scratch/307 evidence/<TRACE-ID>/308 scripts/309 fixtures/310 state/311```312313Do not commit scratch artifacts. Ensure cleanup is safe and idempotent.314315### 1. Test316317For every unverified row:3183191. Create isolated, disposable state.3202. Start real local dependencies or approved sandbox services.3213. Invoke the documented public interface.3224. Assert the expected success behavior, error behavior, state transition, authorization rule, and cleanup where relevant.3235. Capture the exact command or manual procedure, exit code, decisive output, log summary, and evidence path.3246. Do not change product behavior during this step.3257. Set `Tested-Pass` or `Tested-Fail` and update defect fields factually.326327A test is not strong merely because it passes. It must be capable of failing when the required behavior is broken.328329### 2. Fix330331For each logged `Functional`, `Logistical`, or `UX` defect:3323331. Diagnose the root cause from execution evidence.3342. Make the smallest coherent product change that resolves the logged defect.3353. Avoid unrelated refactors, style churn, dependency upgrades, or speculative improvements.3364. Add or strengthen a regression test at the most appropriate layer.3375. Mark only affected rows `Fixed`.3386. Record changed files and the root cause in `Defects`, `Actual result`, or `Notes / open questions`.339340Fix `Documentation`, `Testability`, `Environment`, or `Unknown` defects only when the correction is obvious, safe, and needs no product decision. Otherwise record the next action and stop or continue according to the gate and safety rules.341342### 3. Re-test343344Re-run the exact failing scenario and any directly affected regression or neighboring scenario.345346- Pass: set `Tested-Pass`, append the new execution evidence after the preserved failing evidence in `Actual result`, then perform fresh-eyes review.347- Fail: set `Tested-Fail`, preserve the attempt evidence, increment the cycle count, and return to diagnosis if below the safety cap.348349Never mark `Verified` merely because tests compile, a unit test passes while the public scenario still fails, or the diff appears correct.350351### 4. Fresh-eyes review352353After a passing execution, inspect the touched code, tests, scenario, and CSV row for:354355- authentication and authorization bypasses;356- tenant, role, and ownership isolation;357- input validation and output encoding;358- injection, traversal, unsafe deserialization, secret leakage, and insecure defaults;359- incorrect error codes, error messages, and partial-success behavior;360- boundary values, empty values, malformed values, duplicates, retries, and idempotency;361- stale state, transactionality, race conditions, ordering, locking, and cleanup;362- persistence, migration, cache, and restart behavior;363- business-rule contradictions and spec/code drift;364- performance traps, unbounded work, resource leaks, and timeout behavior;365- flaky assertions, hidden test coupling, and tests that cannot detect regressions;366- unsupported or overstated claims in the CSV.367368Log every material finding as a new row or update the affected row. Fix and re-test scoped `Functional`, `Logistical`, and `UX` findings. A row can advance to `Verified` only when this review is clear.369370### 5. Fresh-context CSV audit371372After each write batch and before final reporting:3733741. Validate exact headers, UTF-8, parseability, allowed enums, and unique IDs.3752. Confirm every command, exit code, result, fix, source, and status matches actual evidence.3763. Confirm no row says `Verified` without passing execution evidence.3774. Confirm failed attempts and unresolved defects were not erased.3785. Confirm code-only rows have explicit scope disposition.3796. Confirm no second `behavior_verification.csv` exists.3807. Run:381382```bash383python3 <skill-directory>/scripts/trace_csv.py validate --repo .384```385386When the audit passes, change eligible `Tested-Pass` rows to `Verified` and run the validator again.387388## Reusable scenarios389390Promote a passing scratch scenario to root-level `scenarios.jsonl` when it is deterministic, safe, reusable, and exercises a public behavior boundary. Store one JSON object per line.391392Recommended record shape:393394```json395{"id":"scenario-trace-0007-happy-path","capability_ids":["TRACE-0007"],"name":"Create and retrieve a record through the public API","preconditions":["service running","TEST_DATABASE_URL set"],"command":"python3 scenarios/create_and_get.py","expected":{"exit_code":0,"assertions":["created id is returned","retrieved payload matches"]},"cleanup":"scenario deletes its disposable record","last_verified":"2026-08-18T15:04:05Z"}396```397398Rules:399400- Reference one or more CSV IDs in `capability_ids`.401- Store environment-variable names, never values.402- Write commands to run from the repository root.403- Store a promoted scenario's script at a committed path such as `scenarios/`; a promoted scenario must never reference `.scratch/`.404- Include deterministic assertions and cleanup.405- Do not promote failing, flaky, destructive, environment-specific, or one-off diagnostic scripts.406- Preserve existing scenario IDs and append new records rather than silently replacing history.407408## Safety cap409410Track failed test/fix/re-test cycles per capability in `Notes / open questions`:411412```text413Cycle 1/3: ...414Cycle 2/3: ...415Cycle 3/3: ...416```417418After three failed cycles for one capability:4194201. Stop modifying that capability.4212. Leave it `Tested-Fail`.4223. Preserve all three attempt summaries, root-cause analysis, commands, evidence paths, and changed files.4234. Record the most specific known next action.4245. Continue independent capabilities when safe, but the overall run cannot report success.4256. Include the capped capability prominently in the final report.426427Do not reset the attempt count by renaming the capability, creating a new row, or slightly changing the test.428429## Successful exit criteria430431Report success only when all conditions are true:432433- every required spec capability is `Verified`;434- every exposed code capability is `Verified` or explicitly marked `Scope disposition: out-of-scope/code-only` with no open `Functional`, `Logistical`, or `UX` defect;435- no open `Functional`, `Logistical`, or `UX` defects remain;436- every reusable passing scenario is represented in `scenarios.jsonl`;437- the final fresh-eyes review has no unresolved material finding;438- the final fresh-context CSV audit passes;439- exactly one canonical UTF-8 `behavior_verification.csv` exists;440- the CSV matches the commands and observed evidence actually produced.441442## Final response contract443444Return:4454461. Overall result: `SUCCESS`, `BLOCKED AT SPEC-COMPLETION GATE`, or `INCOMPLETE — TEST FAILURES REMAIN`. When gate blockers and test failures both remain, report `BLOCKED AT SPEC-COMPLETION GATE` and include the failures.4472. CSV path and row counts by status.4483. Required-spec coverage and code-only coverage.4494. Tests executed, grouped by interface and method.4505. Defects found, root causes, fixes, and re-test outcomes.4516. Remaining blockers or safety-capped failures with CSV IDs and next actions.4527. Promoted `scenarios.jsonl` entries.4538. Final validator result and confirmation that exactly one canonical CSV exists.454455Do not claim complete verification when any success condition is unmet.456457## Anti-patterns458459Never:460461- write the CSV from multiple agents or processes;462- renumber IDs after sorting or inserting rows;463- treat documentation prose as proof of runtime behavior;464- use mocks when the real local or sandbox dependency is practical;465- weaken a test merely to make it pass;466- alter expected behavior to match a bug;467- fix unlogged or unrelated product behavior during the loop;468- hide blockers in vague notes;469- mark static inspection as execution;470- mark `Verified` before re-test and review;471- erase failed evidence after a fix;472- store credentials or personal data in evidence;473- touch production data or services without explicit authorization;474- declare success with an open required row or an open Functional, Logistical, or UX defect.