website/reference/commands/enhance/harden.md

Run xpd enhance harden to find silent failures, fixed waits, retries, and unreliable tests, and verify every fix against a determinism gate. See the hardening guide for a full walkthrough.

GroupFinding kinds
Silent failure and reliability errorsdual-key-fallback, fallback-on-exception, rule-issue
Fixed waits and retriessleep-or-retry
Disabled or unreliable testsdisabled-test, flaky-test

Every finding of this track is advice: a fix may name one, and no run or audit has to clear one. A kind blocks only after an oracle that can prove a finding wrong has labelled at least 30 of its findings and at least 90% were right, and no kind has reached that.

Go and Rust source can surface fixed waits and skipped tests.

Run xpd enhance harden --questions to read the six reliability questions and the facts that inform them. Pass --all-modules to start to review every module against the questions that --questions prints.

At each gate, xpd repeats the first check after the checks pass. The exit status and the SHA-256 digest of stdout must agree with the first execution.

Recorded run

  1. Start: record the current commit, paths, and project checks from a clean tracked tree with xpd enhance harden start . --check "your-project-check".
  2. List: read the stable ID of each finding with xpd enhance harden . --format json.
  3. Plan: record the ordered fixes, each naming the findings it removes, using xpd enhance harden plan plan.json.
  4. Approve: record approval for an interface change with xpd enhance harden approve fix-id.
  5. Gate: commit one fix and run xpd enhance harden gate fix-id.
  6. Drop: return to the run's current commit and record a reason with xpd enhance harden drop fix-id --reason "reason".
  7. Status: show the current run, its recorded answers, and the next stage with xpd enhance harden status.
  8. Finish: compare against the starting commit with xpd enhance harden finish. An open fix causes exit 1. Advice that is left needs no reason.

Example

Remove a silent fallback so that the real parse error reaches the caller.

python
1def load_count(raw):
2 try:
3 return parse_count(raw)
4 except Exception:
5 return parse_count_v1(raw)
6
7
8def parse_count(raw):
9 return int(raw)
10
11
12def parse_count_v1(raw):
13 return int(raw.split("=")[1])
console
1$ git init -q && git add loader.py && git -c user.name=xpd -c user.email=xpd@example.com -c commit.gpgsign=false commit -qm start
2$ xpd enhance harden start loader.py --check "python3 -m py_compile loader.py" --format json | jq -c '{findings: .run.was, next: .next.stage}'
3{"findings":1,"next":"plan"}
4$ xpd enhance harden loader.py --format json | jq -c '{findings: (.findings | length), advice: [.advice[].kind]}'
5{"findings":0,"advice":["fallback-on-exception"]}
6$ xpd enhance harden loader.py --format json | jq -c '{fixes: [{id: "propagate", title: "Let the parse error surface", findings: [.advice[].id]}]}' | xpd enhance harden plan - --format json | jq -c .next.stage
7"fix"
8$ sed -i -e '10,13d' -e '2,5c\ return parse_count(raw)' loader.py && git -c user.name=xpd -c user.email=xpd@example.com -c commit.gpgsign=false commit -qam "Let the parse error surface"
9$ xpd enhance harden gate propagate --format json | jq -c '.run.rounds[0][0] | {outcome, fixed: (.fixed | length)}'
10{"outcome":"kept","fixed":1}
11$ xpd enhance harden finish --format json | jq -c .run.finished
12xpd: 1 findings at the start, 0 now: 1 fixed, 0 added, 0 accepted, 0 left without a reason; lines 13 -> 6
13true

Exit status

A successful list or recorded stage exits 0. A rejected gate or a finish with an open fix exits 1. Invalid input exits 2.