codex/skills/invariant-ace/SKILL.md
Turn should-never-happen into cannot-happen with authority-gated invariant design. Define owned inductive invariants, separate predicates from pre/postconditions and derived facts, require counterexample traces, owner/scope/source-of-truth proof, transition preservation, policy/exception authority, witness parity, enforcement-boundary choice, and verification. Use for invariants, impossible states, validation sprawl, cache/index drift, idempotency/versioning, retries/duplicates/out-of-order events, races, loop correctness, policy-owned exceptions, generator/validator parity, descriptor-vs-occurrence identity, certificate/proof witness drift, fixture precondition alignment, or invariant-first hardening. Not for generic refactors, broad architecture essays, or implementation without an invariant gate.
npx skillsauth add tkersey/dotfiles invariant-aceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Turn "should never happen" into "cannot happen" with minimal, high-leverage changes: name the real state owner, define owned inductive predicates, prove a counterexample trace, choose the strongest cheap enforcement boundary, and attach verification that can falsify the invariant and the proposed enforcement.
This skill is discriminative, not decorative. An invariant proposal is a claim to adjudicate, not a mandate to add checks. A property may be true, useful, or reviewer-sounding and still be the wrong invariant, wrong owner, wrong scope, wrong phase, wrong witness, or wrong boundary.
Use Authority-Gated v1 when invariant analysis can affect implementation, review adjudication, proof closure, validation, or downstream handoff.
Authority-Gated v1 requires:
Compact mode is allowed only for exploratory invariant sketches, and it must block implementation handoff unless the Invariant Gate passes.
Operate in OWNER-FIRST, COUNTEREXAMPLE-DRIVEN, INDUCTIVE, AUTHORITY-GATED, SOURCE-OF-TRUTH-SEEKING, POLICY-OWNED, WITNESS-PARITY, FIXTURE-AWARE, FAIL-CLOSED, ACCRETIVE, and PROOF-BEARING mode.
enforce-now.validate-only, proof-only, defer, no-change, or blocked invariant rows into implementation.enforce-now; clear the veto or stay non-permissive.For consequential invariant work, use custom Codex authority agents. They solve both bandwidth and authority: independent lanes gather evidence in parallel, and each lane owns a decision dimension.
Required lanes when an invariant can become implementation work or block closure:
| Role | Owns |
|---|---|
| inv-counterexample-authority | concrete bad trace, reachability, falsifier |
| inv-owner-scope-authority | state owner, scope, source of truth, same-objective fit |
| inv-induction-authority | transition set and preservation/induction closure |
| inv-boundary-authority | enforcement boundary and why local/stronger/weaker cuts are wrong |
| inv-witness-parity-authority | generator/validator/projection/certificate/fixture/witness parity |
| inv-verification-authority | proof signal tied to each predicate |
| inv-skeptic-authority | strongest no-invariant/no-enforce countercase |
Authority rules:
enforce-now requires all required authority lanes clear and the skeptic lane defeated.enforce-now.blocked unless a same-schema root-equivalent packet is emitted.See references/authority-fanout.md and references/CODEX_SUBAGENTS.md.
Before declaring an invariant, record:
artifact_state_id:
branch:
base:
head:
diff_digest:
proof_state:
direction_state_id:
source:
source_ref:
same_objective:
non_goals:
compatibility_posture:
Then ask:
Classify each candidate:
accepted: owned, inductive, enforceable, currently material, and cleared by authority lanes.candidate: plausible but missing route-changing evidence.downgraded: useful property, but it is a pre/postcondition, liveness goal, derived check, test-only guard, or non-material convention.rejected: wrong owner, wrong scope, wrong identity rule, ungrounded, duplicate boundary, or direction-conflicting.unresolved: material uncertainty; validation or artifact search required.blocked: missing artifact state, direction state, authority packet, identity proof, or verification path prevents safe routing.Allowed routes:
enforce-now: implement/handoff allowed only after gate passes.validate-only: add proof/probe/test before mutation.proof-only: current artifacts already satisfy the invariant; only cite proof.defer: real invariant but wrong owner/timing/scope.no-change: reject/downgrade; no implementation work.blocked: fail closed.Emit these sections, in order, for consequential runs:
Review BasisCandidate Invariant InventoryCounterexample LedgerInvariant LedgerOwner and Scope LedgerTransition / Induction MatrixEnforcement Boundary DecisionPolicy / Exception LedgerWitness and Fixture Parity LedgerVerification PlanAuthority Packet ReceiptsAuthority Clearance MatrixAuthority Veto LedgerAccepted InvariantsValidate OnlyProof OnlyDefer / No ChangeChange AgendaAcceptance Skew AuditAll-Invariant Accepted Justification when every substantive candidate is accepted or enforce-nowInvariant GateAce Bottom Line- candidate_count:
- accepted_count:
- validate_only_count:
- proof_only_count:
- defer_or_no_change_count:
- blocked_count:
- candidate_ids:
- accepted_ids:
- validate_only_ids:
- proof_only_ids:
- defer_or_no_change_ids:
- blocked_ids:
- missing_candidate_ids:
- duplicate_candidate_ids:
| id | predicate | owner | scope | holds when | source of truth | acceptance status | enforcement boundary | verification signal | evidence ref | route | |---|---|---|---|---|---|---|---|---|---|---|
| id | counterexample | owner/scope | induction | boundary | witness/parity | verification | skeptic | authority status | packet refs | |---|---|---|---|---|---|---|---|---|---|
Allowed clearance values: clear, veto, unresolved, not-needed, not-in-scope. Skeptic values: defeated, veto, unresolved, not-needed. Authority status: cleared-for-enforcement, cleared-for-validation, proof-only, defer, no-change, blocked.
| id | veto source | veto class | veto claim | evidence ref | required to clear | final route | |---|---|---|---|---|---|---|
Veto classes include: no-counterexample, wrong-owner, wrong-scope, not-inductive, wrong-boundary, policy-bypass, identity-drift, witness-missing, fixture-precondition-mismatch, duplicate-boundary, validation-needed, proof-only, direction-conflicting, missing-packet.
| id | route | change | proof or validation required | next | owner | |---|---|---|---|---|---|
The Change Agenda must be an exact projection of route in the Invariant Ledger. It must not use broad words like all when explicit IDs are required.
Required fields:
artifact_state_coverage: pass / failcandidate_inventory_coverage: pass / failcounterexample_coverage: pass / failowner_scope_coverage: pass / failinduction_coverage: pass / failboundary_decision_coverage: pass / failpolicy_exception_coverage: pass / failwitness_fixture_parity_coverage: pass / failverification_coverage: pass / failauthority_packet_coverage: pass / failauthority_clearance_coverage: pass / failauthority_veto_coverage: pass / failchange_agenda_consistency: pass / failacceptance_skew_audit: pass / failinvariant_gate_complete: pass / failimplementation_handoff_allowed: yes / novalidation_handoff_allowed: yes / noproof_only_handoff_allowed: yes / noinvariant_gate_complete may be pass only when all preceding required gate fields pass. implementation_handoff_allowed: yes requires at least one enforce-now row whose authority status is cleared-for-enforcement and no unresolved veto exists for that ID.
When automation is available, run:
python codex/skills/invariant-ace/tools/invariant_ace_gate.py invariant-output.md
A failed checker means no implementation handoff.
tools
Convert markdown plans into beads with dependencies using br CLI. Use when creating task graphs, polishing beads before implementation, or bridging planning to agent swarm execution.
development
Orchestrate Codex skill optimization during active sessions through $cas goal control, $shadow single-session evidence, $tune diagnosis/refinement briefs, and the skill-optimizer custom subagent. Trigger for $opt, skill optimization loops, session-driven skill tuning, meta-skill audits, or explicit validated skill edits. Do not use for general code optimization, product optimization, or performance tuning.
development
Run a targeted fresh-eyes blunder pass over code, specs, plans, adjudications, closure gates, skill edits, or negative-evidence ledgers. Trigger when asked to reread with fresh eyes, find obvious bugs, catch mistakes/oversights/omissions, check for embarrassing misses, or perform a second independent blunder pass before closure. Do not use as a substitute for implementation, adjudication, or verification; use it as the final falsification/check pass for those workflows.
development
Explicitly shadow, tail, watch, follow, monitor, supervise, or companion exactly one Codex session id/path through `$seq`, then apply a named target skill as an interpretation/reporting/proposal/action lens until the watched session stops.