--- name: maintain-formal-verification-skill description: "Bring a project's formal verification back in line with the code after the code changes: find the commits that touched verified code, update the model, harness, or properties to describe the code as it is now, rerun, and say whether each failure is drift in the verification or a bug in the code. Use for /maintain-formal-verification-skill, \"is the model still true to the code\", or after merges and refactors that touched verified code without rechecking it." disable-model-invocation: true --- # Maintain a formal verification skill A formal check proves a property of what it describes. When the code changes and the verification does not, the check can keep passing while describing code that no longer exists. That pass is dangerous because it looks like a proof. This skill is the upkeep loop for a project-local verify skill generated by [`/create-formal-verification-skill`](../create-formal-verification-skill/SKILL.md), or for any project-local skill that runs a model checker, prover, or code-level verifier against named code. The project-local skill handles a change made while using that skill. This skill handles changes that skipped it: merges, direct edits, and drift across many commits. ## Outcomes Assign each check one outcome, and state it directly: - **in sync.** No change since the last sync alters what the check describes, and the check passes. - **updated.** The code changed, the verification now describes the new code, and the check passes. - **bug.** The verification describes the current code, and the code breaks the property. This is a code finding, not drift. - **blocked.** The check could not be brought back in line or could not run. State why. A check can be both `updated` and `bug`: updating the verification makes it describe the current code again, and then the property fails on it. ## Edit scope Edit only verification files: models, harnesses, property files, and the verify skill itself. Never edit product code during a run unless the user asks you to. When a property fails on the current code, do not weaken the property or the model to make it pass. Report the failure. ## Pass 1. **Find the checks.** A verify skill has no fixed name, so find each project-local skill (such as `.agents/skills/verify-*/SKILL.md`) that runs a model checker, prover, or verifier against named code. Read every check found, or the one the user named. Collect the property, the covered code, the bounds and assumptions, the run command, and the sync-commit SHA where the verification last matched the code. If no verify skill exists, stop and point to [`/create-formal-verification-skill`](../create-formal-verification-skill/SKILL.md). If the skill omits a sync commit, use the last commit that touched the verification files and record that fallback. 2. **Run it as it is.** Run each check once before editing anything and record the result. A pass here proves only that the old description holds, not that the code holds. A failure here can be drift or a bug. Defer classification until step 5. 3. **Read every change to covered code.** Diff the covered files from the sync commit to `HEAD`, and read every commit message. Inspect renamed, split, or relocated functions that came from covered code. Inspect new code that writes the same fields or enters the guarded state. Classify each change: - **No effect.** Formatting, comments, or paths outside what the verification models. Verify this against the model or harness, not the commit message alone. - **The verification no longer describes the code.** An indivisible step split into two, a branch changed, a guard moved, a new path reaches the guarded state, or a value's range changed. Update the model or harness. - **The promise changed on purpose.** The change alters intended behavior, backed by doc comments, tests, changelog notes, or commit messages. Update the property and cite that evidence. - **The promise may be broken.** Behavior changed without evidence of intent. Treat any resulting failure as a bug candidate. 4. **Update from the code, not from the result.** Update the model or harness so every changed part maps back to code a reviewer can open, preserving indivisible-step fidelity so one indivisible step in code stays one step in verification. Write the update from the code before rerunning, and never shape the model around what makes the check pass. Change a property only when the promise changed on purpose, recording the old wording, new wording, and evidence. Keep existing bounds unless the code change invalidates them; if you must shrink a bound, explain why in the report. 5. **Rerun and judge each result.** If the check is a TLA+ model, inspect every result with [`/statechart`](../statechart/SKILL.md). - **Pass.** Prove the updated check can still fail. Introduce a temporary scratch break in the new code targeting what the property guards (such as removing a check or reordering a step), confirm the check catches it, and revert the scratch break. - **Fail.** Replay the counterexample step by step against the real code. If a step is impossible in code, the verification has a modeling error; fix the verification and document what was wrong. If every step is reachable, report a bug: name the introducing commit, state the counterexample as steps in the code's terms, and state the harm in one sentence. Include a non-committed reproduction if one cheaply demonstrates the bug. 6. **Update the verify skill.** Update the coverage map (files and functions), commands, bounds, assumptions, and sync-commit SHA to the checked commit. Do not advance the sync commit for a `blocked` check, and note why. Run the verify skill once end to end as the next agent would to confirm its instructions still execute cleanly. ## Report Write the full maintenance report to the Antigravity Brain Artifact `/brain//formal_verification_report.md` (`ArtifactMetadata` with `UserFacing: true` and `RequestFeedback: false`). Include for each check: - The outcome and the list of commits reviewed. - Each change made to the verification and why (code shape changed, or promise changed on purpose with cited evidence). - The rerun result and the scratch-break mutation receipt showing the updated check still catches failures. - Each code bug in plain words: counterexample steps in the code's terms, harm in one sentence, and introducing commit SHA. - Remaining coverage gaps, including new code that touches guarded state but stays unverified. State explicitly which prior failures were verification drift and which were product bugs. If a check passed before your update and fails afterward, state that the earlier pass held only on a stale description. Keep verification updates in their own commit, separate from any product fix. In chat, summarize the outcomes and link `[formal_verification_report.md](file:///brain//formal_verification_report.md)` instead of pasting the full report.