Install
openclaw skills install @pinguy/invariant-guarded-debuggingGuard diagnosis and repair with falsifiable hypotheses, executable invariants, verified guard integrity, semantic boundaries, state-drift checks, rollback, adversarial checks, and trajectory resets.
openclaw skills install @pinguy/invariant-guarded-debuggingUse this skill when a diagnosis or fix could damage a known-good component, when the user says not to touch something, when prior attempts have become path-dependent, when a coding agent may confuse schema validity with an acceptable engineering change, or when repeated failures suggest the reasoning trajectory itself may be wrong.
Convert warnings, constraints, and known-good assumptions into executable acceptance conditions.
A remembered instruction is advisory.
A measured invariant is a gate.
A gate is evidence only if it is known to measure the intended boundary.
Reasoning does not directly authorize mutation. Reasoning produces proposals; verified invariants determine whether those proposals are admissible; evidence determines whether they survive.
Land the plane: once the strongest warranted conclusion is available, state it and stop.
Use the low-risk fast path only when the change is local, easily reversible, cannot reach a protected target, does not alter semantics or architecture, and the diagnosis is not already sticky:
Observe → Hypothesis → Minimal change → Check → Conclude
Otherwise use the full loop:
Observe → Model → Falsify → Challenge → Protect → Propose → Validate guards → Gate live state → Act minimally → Measure → Update or rollback → Conclude
Escalate from the fast path as soon as any low-risk assumption stops being true. Do not skip directly from a plausible explanation to a broad fix.
Before mutation:
Do not proceed merely because a change is plausible.
If the relevant state is not observable, say so explicitly.
For every protected target or behaviour, record:
Example:
Protected target:
Why protected:
Source of protection:
Before-state receipt:
Allowed mutation:
After-check:
Operational canary:
Rollback source:
Do not proceed if a protected target lacks a usable after-check or rollback and the proposed change could reach it.
User constraints and explicit contracts outrank derived requirements. Do not replace a protected boundary with an easier proxy and silently treat them as equivalent.
Protection is not limited to files. It may include:
Capture evidence before changing anything.
Useful receipts include:
sha256sum /path/to/protected-file
git status --short
git diff -- /path/to/scope
systemctl status service --no-pager
command-producing-json | jq .
curl -fsS http://localhost:PORT/health
Other valid receipts include:
Prefer deterministic receipts over prose descriptions. A receipt must identify the intended object closely enough to be checked again later.
An invariant is evidence only if its target, scope, and failure sensitivity are credible. Before relying on a guard, check that it observes the intended live object and cannot pass trivially because of a wrong path, empty glob, symlink, wrong repository or environment, stale cache, wrong service instance, or a command that masks failure.
Ask:
What exact object does this check observe?
How do we know it is the intended object?
Can it pass if the target is absent, stale, empty, redirected, or wrong?
What would make this check fail?
For high-risk boundaries, prefer a harmless canary or other evidence that the guard can detect a known-bad condition. Do not report "all invariants passed" when the guards themselves are materially unverified.
A diagnosis should be capable of losing.
For each material hypothesis, record:
Hypothesis:
Evidence supporting it:
Evidence against it:
Falsifier:
Expected result if true:
Expected result if false:
A useful falsifier is:
Avoid hypotheses that survive every possible observation.
If later evidence contradicts the hypothesis, update or discard it. Do not explain away repeated contradictions merely to preserve the original story.
Before a risky or non-trivial mutation, attack the explanation using distinct reasoning lenses.
Ask:
Ask:
Ask:
If the explanation cannot survive simplification, it may be cargo-cult reasoning.
Ask:
Ask:
Ask:
These lenses are not votes. They are adversarial transforms applied to the same problem.
Prefer the narrowest deterministic check that proves the real boundary. Record where each material invariant came from:
Invariant:
Source: user constraint | explicit contract | measured known-good baseline | derived requirement
Target:
Check:
Failure meaning:
Examples:
test "$(sha256sum /path/to/Y | cut -d' ' -f1)" = "$Y_BEFORE"
git diff --exit-code -- /foo/bar
cmp --silent known-good.conf live.conf
systemctl is-active --quiet service
command-producing-json | jq -e '.required_state == "ready"'
Use more than file hashes when behaviour matters.
Configured is not working.
A component may remain byte-identical while the surrounding runtime makes it unusable. Include a canary or real execution check when operational behaviour matters.
Do not silently replace a user-defined invariant with a derived proxy merely because the proxy is easier to test.
A change is complete only when every applicable gate passes.
The change is accepted by the formal structure.
Examples:
The change still performs the intended kind of job.
Examples:
A schema-valid workaround that changes the meaning of the system is not acceptable.
The real execution path works.
Examples:
Forbidden or known-good targets remain unchanged where required.
Examples:
"The schema accepts it" is not completion.
Choose the smallest mutation that can distinguish between competing hypotheses or repair the confirmed fault.
Prefer:
Do not combine unrelated cleanup with diagnosis.
Do not refactor merely because the code is ugly.
Do not broaden mutation scope without evidence that the fault crosses that boundary.
A proposal can become invalid between observation and action. Immediately before a material mutation, re-check the receipts and preconditions that authorized it, confirm that the target is still the same live object, and confirm that protected state has not drifted.
If live state differs materially from the state used to authorize the proposal:
STOP.
Do not apply the prepared mutation.
Re-observe the changed state.
Update the model, guards, rollback material, and proposal.
Do not treat stale authorization as permission to mutate current state. This matters especially when another user, agent, process, deployer, package manager, controller, or service may change the same state concurrently.
After each material change:
Do not wait until the end to discover that an early step crossed a boundary.
If an invariant fails:
Rollback is itself a mutation. Do not apply it blindly. If safe rollback cannot be established, stop and report the blocked state rather than improvising a broader mutation.
Do not:
A failed invariant means the proposal was inadmissible.
Treat the reasoning path itself as suspect when any of these occur:
Agreement is not evidence if every participant inherited the same mistake.
At the first strong sign of trajectory lock-in, pause mutation.
Restate only:
When the plan is sticky, do not keep arguing inside it.
Start a fresh reasoning context, agent, or session where available, using a compact factual handover that explicitly separates inherited evidence from discarded reasoning:
Objective:
INHERIT — carry forward as constraints or evidence:
Confirmed facts and logs:
Protected targets and executable invariants:
Invariant sources and validated guards:
Untouched rollback state:
Allowed mutation scope:
Required acceptance checks:
Known environmental facts still verified as current:
DISCARD — do not inherit as premises:
Failed hypotheses:
Rejected fixes or architectures:
Unsupported assumptions:
Previous agent narrative or confidence:
UNRESOLVED:
Unknowns:
Open questions:
Diagnose from scratch. Inherit only the evidence, constraints, and verified state listed above; do not inherit the previous causal story or proposed fix.
Carry forward observations, receipts, explicit constraints, validated invariants, and still-current environmental facts. Discard failed explanations, rejected designs, unsupported assumptions, persuasive narrative, and confidence derived from them.
Do not include the previous agent's persuasive narrative unless it is itself evidence being explicitly tested.
A fresh reasoning pass does not broaden authority.
The new reasoning pass may inspect and diagnose within scope. External, destructive, privileged, or materially expanded actions still require their normal approval.
Treat confidence as state, not sentiment.
Increase confidence when:
Decrease confidence when:
Do not preserve confidence merely because a hypothesis was expensive to develop.
When several next actions are available, prefer the one that most reduces uncertainty while risking the least protected state.
A useful diagnostic action should ideally:
More activity is not more progress.
Call the work complete only when:
If a fix cannot satisfy the invariants, report it as blocked using the blocked report format in §18.
Do not call a result complete because:
Completion is an evidence claim.
Use the report shape that matches the outcome. Success and blockage are equally first-class results.
Objective:
Result: COMPLETE
Confirmed cause:
Changes made:
Protected targets checked:
Acceptance checks:
Guard integrity / provenance:
Remaining uncertainty:
Rollback:
Use this whenever the requested outcome cannot be completed without violating an invariant, exceeding authority or scope, relying on an invalid guard, risking unsafe rollback, or proceeding without evidence required by this skill.
Objective:
Result: BLOCKED
Blocked at: <section, gate, or operation where progress stopped>
Blocking condition or invariant:
Evidence:
What was attempted:
What was not changed:
Protected targets checked:
Current safe state:
Rollback status:
What would unblock progress:
Remaining uncertainty:
A blocked report must identify the exact gate that prevented further action. Do not disguise blockage as partial success, and do not propose bypassing the gate merely to produce an answer.
If the cause remains uncertain, say so.
If the outcome works but the causal explanation is only inferred, distinguish those facts.
Give the strongest warranted conclusion and stop.