Skip to content

Add nf:harden adversarial hardening loop skill #101

@jobordu

Description

@jobordu

Description

QGSD has no adversarial test-write-fix loop. After a phase or quick task executes, code is verified against its own plan but never stress-tested by an agent actively trying to break it. nf:harden fills this gap: it runs an iterative loop where an agent writes adversarial tests, runs them, fixes failures, and repeats until convergence. A --full flag gates each iteration through nf:quorum-test for multi-model consensus. nf:quick --full will automatically invoke simple hardening (max 5 loops) after verification passes.

User Story

As a QGSD operator, I want an adversarial hardening loop I can run manually or trigger from nf:quick --full, so that latent bugs are surfaced and fixed before shipping with surviving tests as proof.

Acceptance Criteria

  • nf:harden runs up to 10 adversarial test-write-fix loops and exits early when 0 new tests and 0 fixes are reported for 2 consecutive iterations
  • nf:harden --area 'focus description' injects the area context into the adversarial prompt and constrains the executor to that scope
  • nf:harden --full gates each iteration through nf:quorum-test; BLOCK verdict triggers a fix executor before the next loop; PASS or REVIEW-NEEDED advances the loop
  • nf:harden (simple mode) uses a single nf-executor that self-reports structured convergence output (new_tests, fixes counts) per iteration
  • nf:quick --full invokes nf:harden (simple mode, max 5 loops) after verification passes, before marking the task complete
  • Each loop produces an atomic commit; a HARDENING.md summary is written to the quick/phase directory at loop end

Decomposition

  1. Create commands/nf/harden.md with objective, --area and --full argument hints, and reference to workflow
  2. Create ~/.claude/nf/workflows/harden.md with the loop controller: convergence detection, iteration cap, structured output parsing, HARDENING.md artifact
  3. Define the adversarial executor prompt template: write tests that prove parts of the system are broken, list them, fix them, output HARDENING_RESULT: {new_tests: N, fixes: N}
  4. Wire --full mode: after each executor pass, call nf:quorum-test on new test files; route BLOCK to a fix executor before looping
  5. Add hardening invocation to nf:quick --full post-verification step (after quorum reviews VERIFICATION.md, before task marked complete), max 5 loops

Design Notes

Two modes:

Mode Inner primitive Max loops
nf:harden nf-executor (self-contained) 10
nf:harden --full nf-executor + nf:quorum-test gate 10
via nf:quick --full nf:harden simple 5 (hardcoded)

Convergence signal: executor self-reports HARDENING_RESULT: {new_tests: N, fixes: N} — loop exits when both are 0 for 2 consecutive iterations.

Integration hierarchy:

nf:quick (default)     → no hardening
nf:quick --full        → nf:harden simple, max 5 loops
nf:harden              → simple adversarial loop, max 10
nf:harden --full       → quorum-gated adversarial loop, max 10

Size

M — Loop controller and convergence logic are novel but straightforward. Hardest part is the structured output contract and --full quorum-test wiring, which has an existing pattern to follow from quick.md's gap-fix loop. No new agent types needed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions