Maintain formal verification skill

From jiangkoumo/pi-pstack · View interactive version

Maintain formal verification skill is an AI agent skill from the GitHub repository jiangkoumo/pi-pstack. 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

How to use this skill

Skill file

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 it describes code that no longer exists. That pass is the dangerous case, because it looks like a proof. This skill is the upkeep loop for a verify skill that /create-formal-verification-skill generated, 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 that an agent makes while it uses that skill. This skill handles the changes that skipped it: merges, edits made without the skill, and drift that builds up across many commits.

Outcomes

Give each check one outcome, and say which:

A check can be both updated and bug: the update makes the verification describe the code again, and then the property fails on it.

Edit scope

Edit only the verification: 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 it by what it does: a project skill that runs a model checker, a prover, or another verifier against named code. Read each one you find, or the one the user named. For each check, collect the property, the code it covers, the bounds and assumptions, the command that runs it, and the commit where it was last confirmed to describe the code. If no verify skill exists, stop and point at /create-formal-verification-skill. If the skill does not record a sync commit, use the last commit that changed the verification files, and say that you did.
  1. Run it as it is. Run each check once before you change anything, and record the result. A pass here does not tell you that the code is correct. It tells you that the old description still holds. A failure here can be drift or a bug. Do not decide which until step 5.
  1. Read every change to covered code. Diff the covered files from the sync commit to the current commit, and read each commit message. Also look for code that moved: a covered function that is renamed, split, or moved to another file is still covered code. Also look for new code that touches the state that a check guards, such as a new function that writes the same fields. For each change, decide which of these it is:
  1. Update from the code, not from the result. Change the model or harness so that each changed part again points to code that a reviewer can open, and keep one indivisible step in the code as one step in the verification. Write the update from the code before you rerun, and do not shape it by what makes the check pass. Change a property only for a promise that changed on purpose. Write down the old wording, the new wording, and the evidence. Keep the bounds unless the change makes them wrong. If you must reduce a bound, say so in the report.
  1. Rerun and judge each result.
  1. Update the verify skill. Update the code that each check covers, the commands, the bounds, the assumptions, and the sync commit. Set the sync commit to the commit that you checked. Do not move the sync commit for a blocked check, and say so in the report. Then follow the verify skill once as the next agent would, so that you know its steps still run.

Report

Tell the user, for each check:

Say outright which failures were drift in the verification and which were bugs in the code. For a check that passed before you updated it and fails after, say that the old pass was on a stale description.

Put the verification updates in a change of their own, separate from any product fix.

Pi execution and authority

Adapted from Lauren Tan's pstack v0.15.30, MIT, fixed revision eb4db2b55b2b7dec3d9282754cddf0a56bf4ff10. Read the Pi adapter for host mappings.

Find the checks in Pi

A verify skill in this host is project-local: .pi/skills/<verify-area>/SKILL.md. Find a check by what it does, not by its name — search the project skills for tlc, verification_exec, *.tla, or the property file — then read each candidate with read and use the one the user named if there is a choice. If no verify skill exists, stop and point at /skill:create-formal-verification-skill. If a skill records no sync commit, use the last commit that touched the verification files and say that you did. A verify skill with no runnable command is not maintainable: report it as blocked and send the user back to the create skill.

Run each check for real

Probe the tool before rerunning: Java 11 or later plus an operator-configured tla2tools.jar, declared through TLA2TOOLS_JAR (or the older TLA2TOOLS) or through tla.tla2toolsJar in a trusted .pi/pstack.json; /setup-pstack status and /poteto status expose the resulting tlc field. Run TLC only through verification_exec with {command: 'tlc', spec: 'repo/path/Spec.tla', config: 'repo/path/Spec.cfg', options: [...]} on real repository-relative .tla and .cfg paths with whitelisted options, either through pstack.verifier or, where no verifier integration is available, from the parent shell with that boundary recorded. Never download, install or repoint a JDK or a jar. A pass is TLC completing with no violation and no tool error; a stub java, a generated model file, a loaded session, or an unexecuted skill body is not a result.

With no TLC, report 未做形式化验证,原因是缺少 TLC and mark the check blocked rather than in sync or updated. A generated-input fallback can show the promise still holds on the real code, and that is worth reporting, but it is fallback test coverage, not a rerun of the formal check, and the sync commit does not move.

Verification-only edit scope in Pi

Edit only the verification: the project verify skill, its models, harnesses and property files under .pi/skills/<verify-area>/, and the model or config files that skill names. Never edit product code during a maintenance run, even when a one-line fix would clear a counterexample; report it instead. Keep drift and bug apart: a failing or stale check whose model or harness no longer describes the current code is drift, and you fix the verification; code that breaks a promise which did not change on purpose is a bug, and you report it with the introducing commit. Say outright which one each finding was.

Keep the failing run honest

After an update, rerun, then break the new real code once the way the property guards against, confirm the check fails with the counterexample in the code's words, and restore the break exactly so the tree carries nothing of it. Report that break, the command, and the exit status, because a check that passes on a new description may have lost the ability to fail. Record the new sync commit — the commit you actually re-ran at — plus the bounds and assumptions you kept or changed, and tell the reader what the verification still does not cover. Do not move the sync commit for a blocked check. Follow the verify skill once as the next agent would after updating it.

Completion self-check

Before declaring maintenance complete, execute the completion self-check. Maintenance is not complete until every item below is satisfied:

1. The verified coverage and check outcome (in sync, updated, bug, or blocked);

2. Concrete evidence of deliberate breakage: the break-and-restore cycle showing the updated check can still fail, citing the modified code, observed counterexample in code terms, and non-zero failing exit status;

3. What remains unverified or out of scope.

All of these must be completed before the maintenance task counts as finished. A run ending at a draft, with unexecuted commands, mismatched quantities, an incomplete Record section, or without the final report is incomplete.

Loading this skill grants no permission to commit, push, merge, deploy, delete, or send messages; put verification updates in their own change, separate from any product fix. A run that never executed the entry is a draft, and the report must say so.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.