Audit Code
Find concrete failures in the requested change and its affected paths. Use security, performance,
UX, DX, and edge cases as review lenses, not a requirement to launch five agents or repeat the
entire audit. Prefer a few demonstrated findings over a long list of hypothetical improvements.
Scope and authority
Before reviewing, establish a compact mission contract, or reuse the current one when it covers the same scope:
- Demonstrated failure or requested outcome, acceptance criteria, and affected paths.
- Explicit non-goals and whether the task permits edits or is review/plan only.
- Expected footprint, runtime context, and evidence that requires external access.
Classify each concern:
- Mission blocker: an acceptance criterion is unmet.
- Patch regression: this change introduces a concrete failure.
- Mandatory safety: a concrete security, authorization, privacy, or data-loss risk.
- Follow-up: worthwhile but outside the current mission.
- Non-finding: unsupported, duplicate, stale, or pre-existing without an in-scope consequence.
Only the first three can block the patch. A finding does not itself authorize edits, external
writes, publishing, workflow cancellation, or skill/memory changes. Respect the user's approval
boundary; plan-only work stops at the plan. Explain any necessary scope expansion before acting.
For a hotfix, reassess near five files, 150 non-generated changed lines, twice the expected
footprint, or an unplanned schema, queue, scheduler, protocol, or recovery mechanism. These are
tripwires, not universal size limits. Look for a smaller design before expanding the mission.
Do not demand new restrictions or infrastructure merely to satisfy a speculative scenario.
Read only the applicable guidance
Use audit-framework.md for the severity rubric, finding schema,
coverage matrix, and report template. Its technical lists are a catalog: select checks for
boundaries present in the mission, rather than loading or applying every domain to every audit.
Keep the workflow here authoritative; reference checklists do not add extra review rounds.
| When the mission touches |
Read or search |
| Access, provider callbacks, OAuth, data integrity, metrics, shared state |
Relevant invariant, role, and edge sections in audit-framework.md; search the affected boundary, such as OAuth, no-data, or mutation |
| Queues, claims, retries, locks |
Queue overlay |
| CI, deployment, artifacts, test harnesses |
CI overlay |
| SSH bootstrap and worker trust |
SSH overlay |
| macOS packaging, signing, distribution |
Release overlay and the framework's macOS module |
| Desktop preview, export, persisted editor state |
Editor overlay |
| Imports, parsing, financial reconciliation |
Import overlay |
| Forms, dashboards, list/detail views |
UI overlay |
| Bun and SQLite |
The framework's Bun + SQLite module |
| An external reviewer found a miss |
Gap reducer, when a structured miss analysis would help |
An unmatched stack is not a blocker: derive its relevant invariants from the code and state
uncertain runtime assumptions. Companion skills are optional; do not add installation promotions
to every report or require unrelated tools to complete the audit.
Decision and test proof
When a changed branch depends on a derived value such as allowed, success, ready, or found:
- Trace its producers. Enumerate the materially different ways that value can arise:
explicit choice, default, inherited value, fallback, synthetic promotion, bypass, or cache.
Trace the consumer too. The same value need not carry the same authority or prove the same work.
- Verify the selected scope. Establish the actor, resource, account/tenant, policy scope,
precedence, and freshness that actually apply. A setting existing somewhere is not proof that
it controls this decision. Reuse the canonical resolver; do not invent a parallel policy path.
- Try a controlled counterexample. Keep the final value the same and change its source or
scope. Ask whether the downstream behavior should remain the same under the actual contract.
For example, a default allow is not automatically consent, and a successful skipped job is not
proof that validation ran. Distinct sources need not be treated differently unless the contract
requires it; this is a proof obligation, not a mandate to add flags or restrictions.
- Prove the test path. Inspect the fixture's effective configuration, identity, scope, and
prerequisites through the real resolver or an observable boundary. A test name or setup comment
is not evidence. Mocks must not replace the decision being tested. Include a useful positive
case so an always-deny, always-prompt, or fallback-only implementation cannot pass unnoticed.
Use the smallest counterexample that can falsify the claim, not a speculative Cartesian test
matrix. A before/after failure must occur for the claimed reason, not a missing fixture dependency.
If a fixture changes scope or reachability, re-establish the evidence; do not carry forward the
old test's proof claim. Distinguish source inspection, focused checks, and actual runtime proof.
Audit workflow
- Map the causal paths. Read the code and product contract. Identify producers, resolvers,
consumers, mutations, and affected sibling entry points. Build a compact matrix of critical
invariants, paths, evidence, and gaps using the framework. Include relevant read/preview paths,
not only mutating endpoints. A prior missed invariant belongs in this matrix.
- Review from each applicable lens. Check security, performance, UX, DX, and edge cases against
that matrix. Trace failures through the real execution path, including wrappers, defaults,
retries, and provider boundaries. Examine shared lifecycle ownership before accepting a local
compensation helper; do not mock the canonical path away to justify the helper.
- Reconcile findings. Require a trigger, code/runtime evidence, impact, confidence, scope
disposition, and smallest useful fix. Resolve disagreement through evidence, not reviewer votes.
An implementation being stricter than a spec is not automatically correct: reconcile the
product/security requirement and document any intentional difference.
- Verify and get independent review. Run the smallest relevant check when cheap and permitted.
Use one independent reviewer when delegation is available and allowed; add specialists only for
a concrete risk or explicit request. Provide the mission, non-goals, raw artifacts, and current
diff without your desired answer or previous verdict. Ask it to challenge a consequential
assumption. Reuse current verification and independent review receipts when they cover this
exact change and scope; overlapping skills do not require duplicate review rounds. If delegation
is unavailable, perform and disclose a main-thread review instead.
- Fix only authorized, admitted findings. For report-only work, report them without editing.
After a fix, rerun the affected check and one targeted review of the changed causal path. Broaden
only when the fix changes the mission or exposes another concrete affected path. Do not restart
every specialist or rerun unrelated suites after each correction.
- Close with evidence. Do a final main-thread pass against acceptance criteria and current
feedback. Stop when no admitted in-scope finding remains, or state the exact blocker. Use the
framework's single report template. Separate verified results, unresolved findings, follow-ups,
and environment requirements that were not checked. Do not claim completion from consensus,
a submitted command, an audit alone, or a queued/skipped check.
Active PRs and external feedback
- Resolve the live PR head before collecting checks and reviews; pass that identity explicitly to
dependent readers. Collect independent evidence in parallel only after its shared inputs exist.
A cached summary is not a current-head lookup. Recheck the head before a completion or merge claim.
- Read all pages of conversation comments, submitted review bodies, and inline threads, including
unresolved/outdated state and late feedback. Review summaries are not substitutes for the original
human comments. Verify each finding against the current code and record its disposition.
- Match CI evidence to the head, actual run/attempt, and relevant jobs. Inspect failed-job logs before
assigning cause. A successful wrapper or skipped draft workflow does not prove the code was tested.
Separate superseded runs, queued jobs, infrastructure failures, and code failures. Inspect an older
blocking run before any authorized cancellation; do not cancel work just to make a status green.
- Reply to or resolve only findings actually addressed, and only when authorized. Do not dismiss an
unresolved legitimate review to enable merging. If the head changes, revisit the affected evidence.
- When an external finding exposes a miss, identify the missed invariant, evidence, assumption, and
minimal counterexample. Check whether existing guidance was absent, ambiguous, or simply not
followed. Propose the smallest reusable update; do not append the incident as another universal
rule or edit skills/memory without authorization.
Verification and reporting discipline
Require concrete evidence for findings and distinguish confirmed defects from uncertain risks.
For admitted High/Critical findings, include a focused regression check or explain the verification
blocker. Do not request broad testing merely because it is available. Ensure code, tests, docs, and
claims agree with the actual contract, including the unchanged positive path.
Keep reports useful to the operator: findings first, no repeated verdicts or empty boilerplate.
Retain a small findings-to-fixes ledger during a multi-step task so later work can resume without
inventing which checks passed or which approvals were granted. Audit harmful UX as a risk, not a
recommended tactic; do not turn a review into operational abuse instructions.
1---2name: audit-code3description: For requested code audits or deep reviews, produce evidence-ranked findings across relevant risks.4---56# Audit Code78Find concrete failures in the requested change and its affected paths. Use security, performance,9UX, DX, and edge cases as review lenses, not a requirement to launch five agents or repeat the10entire audit. Prefer a few demonstrated findings over a long list of hypothetical improvements.1112## Scope and authority1314Before reviewing, establish a compact mission contract, or reuse the current one when it covers the same scope:1516- Demonstrated failure or requested outcome, acceptance criteria, and affected paths.17- Explicit non-goals and whether the task permits edits or is review/plan only.18- Expected footprint, runtime context, and evidence that requires external access.1920Classify each concern:21221. **Mission blocker:** an acceptance criterion is unmet.232. **Patch regression:** this change introduces a concrete failure.243. **Mandatory safety:** a concrete security, authorization, privacy, or data-loss risk.254. **Follow-up:** worthwhile but outside the current mission.265. **Non-finding:** unsupported, duplicate, stale, or pre-existing without an in-scope consequence.2728Only the first three can block the patch. A finding does not itself authorize edits, external29writes, publishing, workflow cancellation, or skill/memory changes. Respect the user's approval30boundary; plan-only work stops at the plan. Explain any necessary scope expansion before acting.3132For a hotfix, reassess near five files, 150 non-generated changed lines, twice the expected33footprint, or an unplanned schema, queue, scheduler, protocol, or recovery mechanism. These are34tripwires, not universal size limits. Look for a smaller design before expanding the mission.35Do not demand new restrictions or infrastructure merely to satisfy a speculative scenario.3637## Read only the applicable guidance3839Use [audit-framework.md](references/audit-framework.md) for the severity rubric, finding schema,40coverage matrix, and report template. Its technical lists are a catalog: select checks for41boundaries present in the mission, rather than loading or applying every domain to every audit.42Keep the workflow here authoritative; reference checklists do not add extra review rounds.4344| When the mission touches | Read or search |45| --- | --- |46| Access, provider callbacks, OAuth, data integrity, metrics, shared state | Relevant invariant, role, and edge sections in [audit-framework.md](references/audit-framework.md); search the affected boundary, such as `OAuth`, `no-data`, or `mutation` |47| Queues, claims, retries, locks | [Queue overlay](references/domain-overlays.md#queues-idempotency-and-locks) |48| CI, deployment, artifacts, test harnesses | [CI overlay](references/domain-overlays.md#cicd-test-infrastructure-and-artifact-promotion) |49| SSH bootstrap and worker trust | [SSH overlay](references/domain-overlays.md#ssh-bootstrap-and-remote-worker-trust) |50| macOS packaging, signing, distribution | [Release overlay](references/domain-overlays.md#macos-release-closure) and the framework's macOS module |51| Desktop preview, export, persisted editor state | [Editor overlay](references/domain-overlays.md#swiftuiappkit-preview-export-and-editor-freshness) |52| Imports, parsing, financial reconciliation | [Import overlay](references/domain-overlays.md#parser-import-and-personal-finance-reconciliation) |53| Forms, dashboards, list/detail views | [UI overlay](references/domain-overlays.md#ui-state-persistence-and-detail-loading) |54| Bun and SQLite | The framework's Bun + SQLite module |55| An external reviewer found a miss | [Gap reducer](agents/audit-gap-reducer.md), when a structured miss analysis would help |5657An unmatched stack is not a blocker: derive its relevant invariants from the code and state58uncertain runtime assumptions. Companion skills are optional; do not add installation promotions59to every report or require unrelated tools to complete the audit.6061## Decision and test proof6263When a changed branch depends on a derived value such as `allowed`, `success`, `ready`, or `found`:64651. **Trace its producers.** Enumerate the materially different ways that value can arise:66 explicit choice, default, inherited value, fallback, synthetic promotion, bypass, or cache.67 Trace the consumer too. The same value need not carry the same authority or prove the same work.682. **Verify the selected scope.** Establish the actor, resource, account/tenant, policy scope,69 precedence, and freshness that actually apply. A setting existing somewhere is not proof that70 it controls this decision. Reuse the canonical resolver; do not invent a parallel policy path.713. **Try a controlled counterexample.** Keep the final value the same and change its source or72 scope. Ask whether the downstream behavior should remain the same under the actual contract.73 For example, a default allow is not automatically consent, and a successful skipped job is not74 proof that validation ran. Distinct sources need not be treated differently unless the contract75 requires it; this is a proof obligation, not a mandate to add flags or restrictions.764. **Prove the test path.** Inspect the fixture's effective configuration, identity, scope, and77 prerequisites through the real resolver or an observable boundary. A test name or setup comment78 is not evidence. Mocks must not replace the decision being tested. Include a useful positive79 case so an always-deny, always-prompt, or fallback-only implementation cannot pass unnoticed.8081Use the smallest counterexample that can falsify the claim, not a speculative Cartesian test82matrix. A before/after failure must occur for the claimed reason, not a missing fixture dependency.83If a fixture changes scope or reachability, re-establish the evidence; do not carry forward the84old test's proof claim. Distinguish source inspection, focused checks, and actual runtime proof.8586## Audit workflow87881. **Map the causal paths.** Read the code and product contract. Identify producers, resolvers,89 consumers, mutations, and affected sibling entry points. Build a compact matrix of critical90 invariants, paths, evidence, and gaps using the framework. Include relevant read/preview paths,91 not only mutating endpoints. A prior missed invariant belongs in this matrix.922. **Review from each applicable lens.** Check security, performance, UX, DX, and edge cases against93 that matrix. Trace failures through the real execution path, including wrappers, defaults,94 retries, and provider boundaries. Examine shared lifecycle ownership before accepting a local95 compensation helper; do not mock the canonical path away to justify the helper.963. **Reconcile findings.** Require a trigger, code/runtime evidence, impact, confidence, scope97 disposition, and smallest useful fix. Resolve disagreement through evidence, not reviewer votes.98 An implementation being stricter than a spec is not automatically correct: reconcile the99 product/security requirement and document any intentional difference.1004. **Verify and get independent review.** Run the smallest relevant check when cheap and permitted.101 Use one independent reviewer when delegation is available and allowed; add specialists only for102 a concrete risk or explicit request. Provide the mission, non-goals, raw artifacts, and current103 diff without your desired answer or previous verdict. Ask it to challenge a consequential104 assumption. Reuse current verification and independent review receipts when they cover this105 exact change and scope; overlapping skills do not require duplicate review rounds. If delegation106 is unavailable, perform and disclose a main-thread review instead.1075. **Fix only authorized, admitted findings.** For report-only work, report them without editing.108 After a fix, rerun the affected check and one targeted review of the changed causal path. Broaden109 only when the fix changes the mission or exposes another concrete affected path. Do not restart110 every specialist or rerun unrelated suites after each correction.1116. **Close with evidence.** Do a final main-thread pass against acceptance criteria and current112 feedback. Stop when no admitted in-scope finding remains, or state the exact blocker. Use the113 framework's single report template. Separate verified results, unresolved findings, follow-ups,114 and environment requirements that were not checked. Do not claim completion from consensus,115 a submitted command, an audit alone, or a queued/skipped check.116117## Active PRs and external feedback118119- Resolve the live PR head before collecting checks and reviews; pass that identity explicitly to120 dependent readers. Collect independent evidence in parallel only after its shared inputs exist.121 A cached summary is not a current-head lookup. Recheck the head before a completion or merge claim.122- Read all pages of conversation comments, submitted review bodies, and inline threads, including123 unresolved/outdated state and late feedback. Review summaries are not substitutes for the original124 human comments. Verify each finding against the current code and record its disposition.125- Match CI evidence to the head, actual run/attempt, and relevant jobs. Inspect failed-job logs before126 assigning cause. A successful wrapper or skipped draft workflow does not prove the code was tested.127 Separate superseded runs, queued jobs, infrastructure failures, and code failures. Inspect an older128 blocking run before any authorized cancellation; do not cancel work just to make a status green.129- Reply to or resolve only findings actually addressed, and only when authorized. Do not dismiss an130 unresolved legitimate review to enable merging. If the head changes, revisit the affected evidence.131- When an external finding exposes a miss, identify the missed invariant, evidence, assumption, and132 minimal counterexample. Check whether existing guidance was absent, ambiguous, or simply not133 followed. Propose the smallest reusable update; do not append the incident as another universal134 rule or edit skills/memory without authorization.135136## Verification and reporting discipline137138Require concrete evidence for findings and distinguish confirmed defects from uncertain risks.139For admitted High/Critical findings, include a focused regression check or explain the verification140blocker. Do not request broad testing merely because it is available. Ensure code, tests, docs, and141claims agree with the actual contract, including the unchanged positive path.142143Keep reports useful to the operator: findings first, no repeated verdicts or empty boilerplate.144Retain a small findings-to-fixes ledger during a multi-step task so later work can resume without145inventing which checks passed or which approvals were granted. Audit harmful UX as a risk, not a146recommended tactic; do not turn a review into operational abuse instructions.