@ludecker/aaac 1.1.6 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -9
- package/src/cli.mjs +0 -0
- package/src/run-engine/debug-run.mjs +0 -0
- package/src/run-engine/log-dump.mjs +0 -0
- package/src/run-engine/log-trace.mjs +0 -0
- package/templates/cursor/aaac/enforcement.json +84 -3
- package/templates/cursor/aaac/graph.project.yaml +28 -0
- package/templates/cursor/aaac/lifecycle/lifecycle.json +14 -0
- package/templates/cursor/aaac/lifecycle/phases.json +7 -1
- package/templates/cursor/aaac/ontology.json +1 -0
- package/templates/cursor/aaac/project.config.json +36 -0
- package/templates/cursor/aaac/scripts/remediation/auto-check-swarm-synthesis.mjs +75 -0
- package/templates/cursor/aaac/scripts/remediation/auto-dispatch-queue-from-health.mjs +78 -0
- package/templates/cursor/aaac/scripts/remediation/bootstrap-autonomous.mjs +113 -0
- package/templates/cursor/aaac/scripts/remediation/capture-verify-baseline.mjs +66 -0
- package/templates/cursor/aaac/scripts/remediation/capture-wave-snapshot.mjs +79 -0
- package/templates/cursor/aaac/scripts/remediation/check-swarm-raw.template.json +26 -0
- package/templates/cursor/aaac/scripts/remediation/classify-fallow-issues.mjs +77 -0
- package/templates/cursor/aaac/scripts/remediation/classify-verify-failure.mjs +176 -0
- package/templates/cursor/aaac/scripts/remediation/compute-satisfaction.mjs +344 -0
- package/templates/cursor/aaac/scripts/remediation/debt-sweep-gate.mjs +202 -0
- package/templates/cursor/aaac/scripts/remediation/dispatch-rules.json +44 -0
- package/templates/cursor/aaac/scripts/remediation/fallow-fp-rules.json +87 -0
- package/templates/cursor/aaac/scripts/remediation/fallow-scan.mjs +219 -0
- package/templates/cursor/aaac/scripts/remediation/handle-yield.mjs +240 -0
- package/templates/cursor/aaac/scripts/remediation/init-campaign.mjs +211 -0
- package/templates/cursor/aaac/scripts/remediation/lib/autonomous-mode.mjs +63 -0
- package/templates/cursor/aaac/scripts/remediation/lib/campaign-focus.mjs +87 -0
- package/templates/cursor/aaac/scripts/remediation/lib/fallow-classifier.mjs +190 -0
- package/templates/cursor/aaac/scripts/remediation/lib/fallow-health-targets.mjs +56 -0
- package/templates/cursor/aaac/scripts/remediation/lib/fallow-metrics.mjs +119 -0
- package/templates/cursor/aaac/scripts/remediation/lib/invoke-cursor-agent.mjs +51 -0
- package/templates/cursor/aaac/scripts/remediation/lib/reconcile-run-manifest.mjs +41 -0
- package/templates/cursor/aaac/scripts/remediation/lib/regression-analysis.mjs +55 -0
- package/templates/cursor/aaac/scripts/remediation/lib/remediation-config.mjs +69 -0
- package/templates/cursor/aaac/scripts/remediation/lib/remediation-progress.mjs +58 -0
- package/templates/cursor/aaac/scripts/remediation/lib/remediation-watch-loop.mjs +168 -0
- package/templates/cursor/aaac/scripts/remediation/lib/runner-exec.mjs +156 -0
- package/templates/cursor/aaac/scripts/remediation/lib/runner-state.mjs +145 -0
- package/templates/cursor/aaac/scripts/remediation/lib/verify-metrics.mjs +205 -0
- package/templates/cursor/aaac/scripts/remediation/merge-check-swarm.mjs +257 -0
- package/templates/cursor/aaac/scripts/remediation/plan-waves-from-queue.mjs +85 -0
- package/templates/cursor/aaac/scripts/remediation/prepare-check-context.mjs +148 -0
- package/templates/cursor/aaac/scripts/remediation/record-fallow-fp.mjs +107 -0
- package/templates/cursor/aaac/scripts/remediation/record-iteration-step.mjs +56 -0
- package/templates/cursor/aaac/scripts/remediation/remediation-cli.mjs +157 -0
- package/templates/cursor/aaac/scripts/remediation/remediation-cursor-watch.sh +10 -0
- package/templates/cursor/aaac/scripts/remediation/remediation-runner-daemon.sh +13 -0
- package/templates/cursor/aaac/scripts/remediation/remediation-runner.mjs +748 -0
- package/templates/cursor/aaac/scripts/remediation/remediation-yield-watcher.mjs +40 -0
- package/templates/cursor/aaac/scripts/remediation/remediator-gate.mjs +405 -0
- package/templates/cursor/aaac/scripts/remediation/repair-fallow-start-baseline.mjs +118 -0
- package/templates/cursor/aaac/scripts/remediation/runner-health-check.mjs +164 -0
- package/templates/cursor/aaac/scripts/remediation/satisfaction-loop-gate.mjs +286 -0
- package/templates/cursor/aaac/scripts/remediation/validate-campaign-complete.mjs +191 -0
- package/templates/cursor/aaac/scripts/remediation/verify-remediation-iteration.mjs +112 -0
- package/templates/cursor/aaac/scripts/run-engine/debug-run.mjs +0 -0
- package/templates/cursor/aaac/scripts/run-engine/log-dump.mjs +0 -0
- package/templates/cursor/aaac/scripts/run-engine/log-trace.mjs +0 -0
- package/templates/cursor/agents/remediation-check-app-inventory.md +32 -0
- package/templates/cursor/agents/remediation-check-app-ssot.md +24 -0
- package/templates/cursor/agents/remediation-check-app-trace.md +29 -0
- package/templates/cursor/agents/remediation-check-architecture-boundaries.md +21 -0
- package/templates/cursor/agents/remediation-check-architecture-decomposition.md +25 -0
- package/templates/cursor/agents/remediation-check-architecture-deps.md +23 -0
- package/templates/cursor/agents/remediation-check-risk.md +37 -0
- package/templates/cursor/agents/remediation-e2e-gate.md +30 -0
- package/templates/cursor/agents/remediation-remediator.md +69 -0
- package/templates/cursor/commands/remediate-app.md +212 -0
- package/templates/cursor/hooks/aaac-before-submit.sh +0 -0
- package/templates/cursor/hooks/aaac-pre-tool.sh +0 -0
- package/templates/cursor/hooks/aaac-stop.sh +0 -0
- package/templates/cursor/hooks/aaac-subagent-start.sh +0 -0
- package/templates/cursor/skills/shared/remediation/SKILL.md +51 -0
- package/templates/cursor/skills/shared/remediation/babysit/SKILL.md +223 -0
- package/templates/cursor/skills/shared/remediation/check-swarm/SKILL.md +114 -0
- package/templates/cursor/skills/shared/remediation/orchestrator/SKILL.md +275 -0
- package/templates/cursor/skills/shared/remediation/orchestrator/contract.yaml +116 -0
- package/templates/docs/agentic_architecture.md +1 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Multi-layer verification gate for remediation campaigns.
|
|
4
|
+
*
|
|
5
|
+
* Modes:
|
|
6
|
+
* wave — fast gate after each fix wave (typecheck, vitest, go test)
|
|
7
|
+
* iteration — full gate (+ build + Playwright)
|
|
8
|
+
* debt — strict full gate (same layers as iteration; used by debt_sweep)
|
|
9
|
+
* strict — alias for debt
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* node verify-remediation-iteration.mjs --campaign-id <id> --iteration <n> \
|
|
13
|
+
* --mode wave|iteration|debt [--run-id <run_id>] [--label <suffix>]
|
|
14
|
+
*/
|
|
15
|
+
import fs from "fs";
|
|
16
|
+
import path from "path";
|
|
17
|
+
import { spawnSync } from "child_process";
|
|
18
|
+
import { fileURLToPath } from "url";
|
|
19
|
+
import { REPO_ROOT, isoNow, writeJson, runDir } from "../run-engine/lib.mjs";
|
|
20
|
+
import {
|
|
21
|
+
runVerifySteps,
|
|
22
|
+
writeVerifyLogs,
|
|
23
|
+
} from "./lib/verify-metrics.mjs";
|
|
24
|
+
|
|
25
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
26
|
+
const CAMPAIGNS_ROOT = path.join(REPO_ROOT, ".cursor/aaac/state/campaigns");
|
|
27
|
+
|
|
28
|
+
function parseArgs(argv) {
|
|
29
|
+
const out = { campaignId: null, iteration: 0, mode: "iteration", runId: null, label: null };
|
|
30
|
+
for (let i = 0; i < argv.length; i++) {
|
|
31
|
+
const a = argv[i];
|
|
32
|
+
if (a === "--campaign-id") out.campaignId = argv[++i];
|
|
33
|
+
else if (a === "--iteration") out.iteration = Number(argv[++i]);
|
|
34
|
+
else if (a === "--mode") out.mode = argv[++i];
|
|
35
|
+
else if (a === "--run-id") out.runId = argv[++i];
|
|
36
|
+
else if (a === "--label") out.label = argv[++i];
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function appendJournal(campaignId, text) {
|
|
42
|
+
fs.appendFileSync(path.join(CAMPAIGNS_ROOT, campaignId, "journal.md"), text);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const args = parseArgs(process.argv.slice(2));
|
|
46
|
+
if (!args.campaignId) {
|
|
47
|
+
console.error("verify-remediation-iteration: --campaign-id required");
|
|
48
|
+
process.exit(2);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const verifyMode = args.mode === "strict" ? "debt" : args.mode;
|
|
52
|
+
const iterDir = path.join(CAMPAIGNS_ROOT, args.campaignId, "iterations", String(args.iteration));
|
|
53
|
+
const logDir = path.join(iterDir, "verify-logs");
|
|
54
|
+
fs.mkdirSync(iterDir, { recursive: true });
|
|
55
|
+
|
|
56
|
+
const stepMode = verifyMode === "wave" ? "wave" : "debt";
|
|
57
|
+
const report = await runVerifySteps(stepMode);
|
|
58
|
+
report.iteration = args.iteration;
|
|
59
|
+
report.campaign_id = args.campaignId;
|
|
60
|
+
report.label = args.label;
|
|
61
|
+
|
|
62
|
+
writeVerifyLogs(report, logDir, args.label ?? verifyMode);
|
|
63
|
+
|
|
64
|
+
const outName =
|
|
65
|
+
args.label != null
|
|
66
|
+
? `verify-${args.label}.json`
|
|
67
|
+
: verifyMode === "wave"
|
|
68
|
+
? "verify-wave.json"
|
|
69
|
+
: verifyMode === "debt"
|
|
70
|
+
? "verify-debt.json"
|
|
71
|
+
: "verify-iteration.json";
|
|
72
|
+
const outPath = path.join(iterDir, outName);
|
|
73
|
+
writeJson(outPath, report);
|
|
74
|
+
|
|
75
|
+
if (report.status === "fail") {
|
|
76
|
+
const classify = spawnSync(
|
|
77
|
+
process.execPath,
|
|
78
|
+
[
|
|
79
|
+
path.join(__dirname, "classify-verify-failure.mjs"),
|
|
80
|
+
"--report",
|
|
81
|
+
outPath,
|
|
82
|
+
"--campaign-id",
|
|
83
|
+
args.campaignId,
|
|
84
|
+
"--iteration",
|
|
85
|
+
String(args.iteration),
|
|
86
|
+
],
|
|
87
|
+
{ encoding: "utf8" },
|
|
88
|
+
);
|
|
89
|
+
try {
|
|
90
|
+
const line = classify.stdout.trim().split("\n").pop();
|
|
91
|
+
report.failure_classification = JSON.parse(line)?.classification ?? null;
|
|
92
|
+
writeJson(outPath, report);
|
|
93
|
+
} catch {
|
|
94
|
+
report.failure_classification = null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
appendJournal(
|
|
99
|
+
args.campaignId,
|
|
100
|
+
`- Verify **${verifyMode}**${args.label ? ` (${args.label})` : ""} iter ${args.iteration}: **${report.status.toUpperCase()}** — total_errors=${report.metrics?.total_errors ?? 0}\n`,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
if (args.runId) {
|
|
104
|
+
const artifactName = args.label
|
|
105
|
+
? `verify_${args.label}_iter_${args.iteration}.json`
|
|
106
|
+
: `verify_${verifyMode}_iter_${args.iteration}.json`;
|
|
107
|
+
writeJson(path.join(runDir(args.runId), "artifacts", artifactName), report);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const strictPass = report.status === "pass" && (report.metrics?.total_errors ?? 0) === 0;
|
|
111
|
+
console.log(JSON.stringify({ ok: strictPass, report, strict_pass: strictPass }));
|
|
112
|
+
process.exit(strictPass ? 0 : 1);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Agent: remediation-check-app-inventory
|
|
2
|
+
|
|
3
|
+
**Readonly.** Mirrors `/check-app` discover phase for Fallow remediation.
|
|
4
|
+
|
|
5
|
+
## Role
|
|
6
|
+
|
|
7
|
+
Map Fallow `unused_files` and `review` inventory to **live app surfaces**: Vite entry points, workers (`src/workers/**`), hooks (`*Worker*`), overlay renderer barrels, lazy routes, Playwright-critical imports.
|
|
8
|
+
|
|
9
|
+
## Inputs (mandatory)
|
|
10
|
+
|
|
11
|
+
- `iterations/{n}/check-context.json`
|
|
12
|
+
- `iterations/{n}/fallow-scan.json`
|
|
13
|
+
- `frontend/.fallowrc.json` (`dynamicallyLoaded`)
|
|
14
|
+
|
|
15
|
+
## Commands (run as needed)
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
cd frontend && fallow list --entry-points --format json --quiet 2>/dev/null || true
|
|
19
|
+
cd frontend && fallow dead-code --format json --quiet --trace-file <path> 2>/dev/null || true
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Return
|
|
23
|
+
|
|
24
|
+
Structured JSON block (see [check-swarm SKILL](../skills/shared/remediation/check-swarm/SKILL.md)) plus:
|
|
25
|
+
|
|
26
|
+
- **Answer** — are flagged unused files actually unreachable from app runtime?
|
|
27
|
+
- **protected_paths** — paths waves must never delete
|
|
28
|
+
- **false_positives** — with `reason` + `evidence` (`path:line`)
|
|
29
|
+
|
|
30
|
+
## Confidence
|
|
31
|
+
|
|
32
|
+
high | medium | low
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Agent: remediation-check-app-ssot
|
|
2
|
+
|
|
3
|
+
**Readonly.** Mirrors `/check-app` SSOT trace for Fallow remediation.
|
|
4
|
+
|
|
5
|
+
## Role
|
|
6
|
+
|
|
7
|
+
For each Fallow `review` / `true_positive` export: who owns the symbol? Is it consumed via barrel re-export, dynamic import, worker postMessage, or external package API?
|
|
8
|
+
|
|
9
|
+
## Inputs (mandatory)
|
|
10
|
+
|
|
11
|
+
- `iterations/{n}/check-context.json` — `fallow.inventory`
|
|
12
|
+
- `fallow-false-positives.json` (campaign registry)
|
|
13
|
+
|
|
14
|
+
## Method
|
|
15
|
+
|
|
16
|
+
1. Grep importers for top `review` exports
|
|
17
|
+
2. Check barrel `index.ts` re-export chains
|
|
18
|
+
3. Flag provider interface methods (`name`, `createInvoice`) as **protected** not dead
|
|
19
|
+
|
|
20
|
+
## Return
|
|
21
|
+
|
|
22
|
+
JSON block with `false_positives`, `do_not_delete`, `safe_to_fix`, `findings`, `gaps`.
|
|
23
|
+
|
|
24
|
+
Set `command_mirror: "check-app"`.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Agent: remediation-check-app-trace
|
|
2
|
+
|
|
3
|
+
**Readonly.** Mirrors `/check-app` capability trace for Fallow remediation.
|
|
4
|
+
|
|
5
|
+
## Role
|
|
6
|
+
|
|
7
|
+
Run Fallow trace CLI for every item in `check-context.fallow.top_review_for_trace`. Confirm whether static unused = actually unreachable.
|
|
8
|
+
|
|
9
|
+
## Commands (mandatory for each review item)
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
cd frontend && fallow dead-code --format json --quiet --trace-file <path> 2>/dev/null || true
|
|
13
|
+
cd frontend && fallow dead-code --format json --quiet --trace <path>:<export> 2>/dev/null || true
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Classification rules
|
|
17
|
+
|
|
18
|
+
| Trace result | Classification |
|
|
19
|
+
|--------------|----------------|
|
|
20
|
+
| Entry-point or dynamically loaded | `false_positive` |
|
|
21
|
+
| Re-export chain to live entry | `false_positive` |
|
|
22
|
+
| Zero importers, not entry | `true_positive` or `safe_to_fix` |
|
|
23
|
+
| Ambiguous (test-only import) | `review` |
|
|
24
|
+
|
|
25
|
+
## Return
|
|
26
|
+
|
|
27
|
+
JSON block with per-path trace summary in `findings`. Populate `false_positives` for confirmed runtime paths.
|
|
28
|
+
|
|
29
|
+
Set `command_mirror: "check-app"`, `agent_id: "remediation-check-app-trace"`.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Agent: remediation-check-architecture-boundaries
|
|
2
|
+
|
|
3
|
+
**Readonly.** Mirrors `/check-architecture` boundary review for remediation waves.
|
|
4
|
+
|
|
5
|
+
## Role
|
|
6
|
+
|
|
7
|
+
Evaluate whether proposed Fallow deletions or dupes extractions would cross layer boundaries (UI→fetch, domain→infrastructure, worker↔main SSOT violations).
|
|
8
|
+
|
|
9
|
+
## Inputs
|
|
10
|
+
|
|
11
|
+
- `check-context.json`
|
|
12
|
+
- `docs/architecture.md` (if present)
|
|
13
|
+
- Fallow `boundary_violations` from dead-code scan
|
|
14
|
+
|
|
15
|
+
## Return
|
|
16
|
+
|
|
17
|
+
JSON block: `command_mirror: "check-architecture"`. List boundary risks in `findings`. Add blast-radius paths to `protected_paths` / `do_not_delete`.
|
|
18
|
+
|
|
19
|
+
## Severity
|
|
20
|
+
|
|
21
|
+
critical = deletion would break boundary; suggestion = refactor-only
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Agent: remediation-check-architecture-decomposition
|
|
2
|
+
|
|
3
|
+
**Readonly.** Mirrors `/check-architecture` system decomposition for dupes remediation.
|
|
4
|
+
|
|
5
|
+
## Role
|
|
6
|
+
|
|
7
|
+
Classify dupes clone families (operations/, workers/, e2e specs) into:
|
|
8
|
+
|
|
9
|
+
- **extract-shared** — safe consolidation target
|
|
10
|
+
- **main-worker mirror** — do not delete one side; extract to shared module first
|
|
11
|
+
- **test-only dupes** — low risk extract
|
|
12
|
+
- **intentional parallel** — mark protected (e.g. provider adapters)
|
|
13
|
+
|
|
14
|
+
## Inputs
|
|
15
|
+
|
|
16
|
+
- `check-context.dupes_top_groups`
|
|
17
|
+
- `fallow-dupes.json` clone_groups
|
|
18
|
+
|
|
19
|
+
## Return
|
|
20
|
+
|
|
21
|
+
JSON block: `command_mirror: "check-architecture"`. Dupes safe targets in `safe_to_fix`. Mirrored paths in `protected_paths`.
|
|
22
|
+
|
|
23
|
+
## Anti-pattern
|
|
24
|
+
|
|
25
|
+
Never recommend deleting `src/lib/**` because worker has a copy — recommend shared extract wave instead.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Agent: remediation-check-architecture-deps
|
|
2
|
+
|
|
3
|
+
**Readonly.** Mirrors `/check-architecture` dependency analysis for remediation.
|
|
4
|
+
|
|
5
|
+
## Role
|
|
6
|
+
|
|
7
|
+
For top `true_positive` file deletions and large dupes groups: compute fan-in, import cycles, and downstream test breakage risk.
|
|
8
|
+
|
|
9
|
+
## Inputs
|
|
10
|
+
|
|
11
|
+
- `check-context.json` — `dupes_top_groups`, `fallow.inventory.true_positive`
|
|
12
|
+
- `fallow dead-code` circular_dependencies list
|
|
13
|
+
|
|
14
|
+
## Commands
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
cd frontend && fallow dead-code --format json --quiet --trace-file <path> 2>/dev/null || true
|
|
18
|
+
cd frontend && fallow dupes --format json --quiet --trace <path>:<line> 2>/dev/null || true
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Return
|
|
22
|
+
|
|
23
|
+
JSON block: `command_mirror: "check-architecture"`. High fan-in paths → `protected_paths`. Isolated leaves → `safe_to_fix`.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Agent: remediation-check-risk
|
|
2
|
+
|
|
3
|
+
**Readonly.** Remediation guard — consolidates FP traps before fix waves.
|
|
4
|
+
|
|
5
|
+
## Role
|
|
6
|
+
|
|
7
|
+
Final pass on all Fallow layers (dead-code, dupes, health). Confirm or reject classifications from other swarm agents. **This agent owns the FP registry update.**
|
|
8
|
+
|
|
9
|
+
## Mandatory actions
|
|
10
|
+
|
|
11
|
+
1. Read `check-context.json` + `fallow-classification.json`
|
|
12
|
+
2. Cross-check other agents' `false_positives` proposals
|
|
13
|
+
3. Write batch file for merge script OR confirm parent will run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
node .cursor/aaac/scripts/remediation/record-fallow-fp.mjs \
|
|
17
|
+
--campaign-id <id> --from-json iterations/<n>/check-swarm-fp-batch.json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Known FP patterns (always verify)
|
|
21
|
+
|
|
22
|
+
| Pattern | Reason |
|
|
23
|
+
|---------|--------|
|
|
24
|
+
| `src/hooks/*Worker*.ts` | worker_hook_runtime |
|
|
25
|
+
| `src/workers/**` | dynamically_loaded |
|
|
26
|
+
| `src/overlays/renderers/*/index.ts` | overlay_renderer_barrel |
|
|
27
|
+
| `LayoutSaveQueue.enqueue/cancel` | framework lifecycle |
|
|
28
|
+
| `AtlosPaymentProvider.name/createInvoice` | provider interface |
|
|
29
|
+
| `src/operations/categories/**` dupes | boilerplate — extract, don't delete ops |
|
|
30
|
+
|
|
31
|
+
## Return
|
|
32
|
+
|
|
33
|
+
JSON block with complete `false_positives[]`, `protected_paths[]`, `do_not_delete[]`. Set `agent_id: "remediation-check-risk"`.
|
|
34
|
+
|
|
35
|
+
## Rule
|
|
36
|
+
|
|
37
|
+
When uncertain → `review` + `protected_paths`, never `true_positive` delete.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Agent: remediation-e2e-gate
|
|
2
|
+
|
|
3
|
+
## Role
|
|
4
|
+
|
|
5
|
+
Run the full iteration verification gate for a remediation campaign and return structured pass/fail.
|
|
6
|
+
|
|
7
|
+
## Steps
|
|
8
|
+
|
|
9
|
+
1. Confirm `SE100_BASE_URL` (default `http://localhost:5173`) is reachable
|
|
10
|
+
2. Run:
|
|
11
|
+
```bash
|
|
12
|
+
node .cursor/aaac/scripts/remediation/verify-remediation-iteration.mjs \
|
|
13
|
+
--campaign-id <campaign_id> --iteration <n> --mode iteration --run-id <run_id>
|
|
14
|
+
```
|
|
15
|
+
3. Read output JSON — report each layer status
|
|
16
|
+
|
|
17
|
+
## Return
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
status: pass | fail
|
|
21
|
+
layers:
|
|
22
|
+
typecheck: pass | fail
|
|
23
|
+
vitest: pass | fail
|
|
24
|
+
go_test: pass | fail | skipped
|
|
25
|
+
build: pass | fail
|
|
26
|
+
playwright: pass | fail
|
|
27
|
+
artifact_path: .cursor/aaac/state/campaigns/{id}/iterations/{n}/verify-iteration.json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
On fail: include `stderr_tail` excerpts and whether rollback is recommended.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Agent: remediation-remediator
|
|
2
|
+
|
|
3
|
+
## Role
|
|
4
|
+
|
|
5
|
+
Execute the **Remediator** step when `remediator-gate.mjs` or `debt-sweep-gate.mjs` exits **3** (`action: remediate`).
|
|
6
|
+
|
|
7
|
+
## Critical rule
|
|
8
|
+
|
|
9
|
+
**Exit 3 is not a stop signal.** The parent orchestrator must:
|
|
10
|
+
|
|
11
|
+
1. Apply the handoff inline
|
|
12
|
+
2. Re-run the gate with `--attempt N+1` (or debt-sweep retry_command)
|
|
13
|
+
3. Repeat until promote (exit 0) or true block (exit 1 after debt sweep exhaustion)
|
|
14
|
+
|
|
15
|
+
Never set `campaign.status=blocked` on exit 3. Never skip remaining waves.
|
|
16
|
+
|
|
17
|
+
## Trigger
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
node .cursor/aaac/scripts/remediation/remediator-gate.mjs \
|
|
21
|
+
--campaign-id <id> --iteration <n> --mode wave|debt \
|
|
22
|
+
--wave-index <w> --run-id <run_id> --attempt 1
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Read stdout JSON. When `action === "remediate"` OR `orchestrator_must_not_stop === true`:
|
|
26
|
+
|
|
27
|
+
- Apply handoff **inside parent `execute` or `debt_sweep` phase** (same chat — no nested Run)
|
|
28
|
+
|
|
29
|
+
## Handoff fields
|
|
30
|
+
|
|
31
|
+
| Field | Use |
|
|
32
|
+
|-------|-----|
|
|
33
|
+
| `handoff.command` | `fix-module` or `fix-bug` |
|
|
34
|
+
| `handoff.domain` | e.g. `frontend`, `backend` |
|
|
35
|
+
| `handoff.intent` | Full intent including validator output |
|
|
36
|
+
| `handoff.file_paths` | Prioritize these files |
|
|
37
|
+
| `handoff.log_path` | **Read full log** — primary evidence source |
|
|
38
|
+
| `handoff.layer` | Failed layer |
|
|
39
|
+
| `retry_command` | Exact re-run command after fix |
|
|
40
|
+
|
|
41
|
+
## Evidence (mandatory)
|
|
42
|
+
|
|
43
|
+
1. Read `handoff.log_path` or `iterations/{n}/verify-logs/{mode}-{layer}.log`
|
|
44
|
+
2. Do **not** rely on truncated `stderr_tail` alone
|
|
45
|
+
3. For wave regression handoffs, fix only **introduced** layers (`introduced_layers` in payload)
|
|
46
|
+
|
|
47
|
+
## Execution
|
|
48
|
+
|
|
49
|
+
1. Load `iterations/{n}/remediator-handoff-attempt-{attempt}.json`
|
|
50
|
+
2. Run fix-module / fix-bug **inline** (discover → execute → test_execute → verify)
|
|
51
|
+
3. Re-run gate using `retry_command` from payload
|
|
52
|
+
4. Repeat until `action: promote` | `promote_wave` | `defer_to_debt_sweep` | `debt_sweep_complete`
|
|
53
|
+
|
|
54
|
+
## Wave vs debt
|
|
55
|
+
|
|
56
|
+
| Mode | Fix scope |
|
|
57
|
+
|------|-----------|
|
|
58
|
+
| `wave` | Only layers in `introduced_layers` (new regression) |
|
|
59
|
+
| `debt` | All failing layers until strict pass |
|
|
60
|
+
|
|
61
|
+
## Return
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
status: promoted | deferred | debt_sweep_complete | remediate_again
|
|
65
|
+
attempt: number
|
|
66
|
+
max_attempts: number
|
|
67
|
+
layers_fixed: []
|
|
68
|
+
remaining_failures: []
|
|
69
|
+
```
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# remediate-app
|
|
2
|
+
|
|
3
|
+
AAAC: `/remediate-app [domain] "<intent>"`
|
|
4
|
+
|
|
5
|
+
**Layer:** system
|
|
6
|
+
**Campaign loop** — Fallow suite (dead-code + dupes + health) → check swarm → ranked fix waves → **regression wave gates** → **mandatory debt sweep** → satisfaction loop.
|
|
7
|
+
|
|
8
|
+
## Dispatch
|
|
9
|
+
|
|
10
|
+
1. [.cursor/aaac/dispatch.md](../aaac/dispatch.md)
|
|
11
|
+
2. [.cursor/aaac/graph.yaml](../aaac/graph.yaml) — **`remediate-app`**
|
|
12
|
+
3. [skills/shared/remediation/orchestrator/SKILL.md](../skills/shared/remediation/orchestrator/SKILL.md)
|
|
13
|
+
|
|
14
|
+
## Hard invariants
|
|
15
|
+
|
|
16
|
+
- **Exit 3 = continue** — never stop the campaign on `remediate` handoff
|
|
17
|
+
- **Waves use regression gate** — pre-existing TS/vitest debt does not block cleanup waves
|
|
18
|
+
- **Debt sweep is mandatory** — all layers must pass before report
|
|
19
|
+
- **All planned waves must run** — no skipping on verify failure
|
|
20
|
+
- **Satisfaction exit 3 = next iteration** — never report when score < threshold and iterations remain
|
|
21
|
+
- **Fallow start baselines are immutable** — `fallow-start-baseline.json` (dead-code), `fallow-start-dupes-baseline.json`, `fallow-start-health-baseline.json` set once at campaign start (dupes/health auto-backfill on first scan if missing)
|
|
22
|
+
- **Fallow false positives excluded from satisfaction** — dead-code score uses actionable issues; dupes uses `clone_groups`; health uses `health_score`
|
|
23
|
+
|
|
24
|
+
## Intent tokens
|
|
25
|
+
|
|
26
|
+
| Token | Default | Example |
|
|
27
|
+
|-------|---------|---------|
|
|
28
|
+
| `max_iterations` | `5` | `max_iterations=8` |
|
|
29
|
+
| `max_waves_per_iteration` | `3` | `max_waves_per_iteration=2` |
|
|
30
|
+
| `max_debt_sweep_rounds` | `10` | `max_debt_sweep_rounds=15` |
|
|
31
|
+
| `max_remediator_attempts_per_wave` | `3` | `max_remediator_attempts_per_wave=5` |
|
|
32
|
+
| `max_remediator_attempts_per_debt_round` | `3` | `max_remediator_attempts_per_debt_round=5` |
|
|
33
|
+
| `satisfaction_threshold` | `85` | `satisfaction_threshold=90` |
|
|
34
|
+
| `autonomous` | auto when threshold≥100 or max_iterations≥10 | `autonomous` / `manual` |
|
|
35
|
+
| `resume` | — | `resume campaign_20260617_abc123` |
|
|
36
|
+
|
|
37
|
+
## Example
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
/remediate-app "whole repo; max_iterations=5; satisfaction_threshold=85"
|
|
41
|
+
/remediate-app cms "Fallow cleanup until regression clean"
|
|
42
|
+
/remediate-app cms "manual; max_iterations=3"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Ensure dev server is running when Playwright is enabled — see `project.config.json` → `remediation.verify.dev_server`.
|
|
46
|
+
|
|
47
|
+
## Two-tier verification
|
|
48
|
+
|
|
49
|
+
### Wave gate (regression — after each fix wave)
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
node .cursor/aaac/scripts/remediation/capture-wave-snapshot.mjs \
|
|
53
|
+
--campaign-id <id> --iteration <n> --wave-index <w>
|
|
54
|
+
|
|
55
|
+
node .cursor/aaac/scripts/remediation/remediator-gate.mjs \
|
|
56
|
+
--campaign-id <id> --iteration <n> --mode wave --wave-index <w> \
|
|
57
|
+
--run-id <run_id> --attempt 1
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Promotes when errors did **not increase** vs pre-wave snapshot. Pre-existing debt is deferred to debt sweep.
|
|
61
|
+
|
|
62
|
+
**Exit 3** → run [remediation-remediator.md](../agents/remediation-remediator.md) → `--attempt N+1` → **do not stop**.
|
|
63
|
+
|
|
64
|
+
### Debt sweep (strict — after all waves)
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
node .cursor/aaac/scripts/remediation/debt-sweep-gate.mjs \
|
|
68
|
+
--campaign-id <id> --iteration <n> --run-id <run_id> --round 1 --attempt 1
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Loops until typecheck, vitest, go test, build, and Playwright all pass.
|
|
72
|
+
|
|
73
|
+
### Satisfaction loop (after debt sweep)
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
node .cursor/aaac/scripts/remediation/compute-satisfaction.mjs \
|
|
77
|
+
--campaign-id <id> --iteration <n>
|
|
78
|
+
|
|
79
|
+
node .cursor/aaac/scripts/remediation/satisfaction-loop-gate.mjs \
|
|
80
|
+
--campaign-id <id> --iteration <n> --run-id <run_id> --advance
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
| Code | Meaning |
|
|
84
|
+
|------|---------|
|
|
85
|
+
| `0` + `complete` | Threshold met → allow `report` |
|
|
86
|
+
| `0` + `partial_complete` | Max iterations → allow partial `report` |
|
|
87
|
+
| `3` + `continue_loop` | Score below threshold → **iteration N+1, return to scan** |
|
|
88
|
+
|
|
89
|
+
### Campaign complete check
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
node .cursor/aaac/scripts/remediation/validate-campaign-complete.mjs \
|
|
93
|
+
--campaign-id <id> --iteration <n> --require-debt-sweep --require-satisfaction-loop
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Repair corrupted Fallow baseline (legacy campaigns)
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
node .cursor/aaac/scripts/remediation/repair-fallow-start-baseline.mjs \
|
|
100
|
+
--campaign-id <id> --total 1649 --dupes-clone-groups 171 --health-score 87.7
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Fallow scan suite (scan phase)
|
|
104
|
+
|
|
105
|
+
`fallow-scan.mjs` runs three Fallow commands from `frontend/`:
|
|
106
|
+
|
|
107
|
+
| Layer | Command | Artifact | Baseline file | Scoring metric |
|
|
108
|
+
|-------|---------|----------|---------------|----------------|
|
|
109
|
+
| Dead code | `fallow dead-code` | `iterations/{n}/fallow-scan.json` | `fallow-start-baseline.json` | actionable issues (excludes FP) |
|
|
110
|
+
| Dupes | `fallow dupes` | `iterations/{n}/fallow-dupes.json` | `fallow-start-dupes-baseline.json` | `clone_groups` reduction |
|
|
111
|
+
| Health | `fallow health --score` | `iterations/{n}/fallow-health.json` | `fallow-start-health-baseline.json` | `health_score` improvement |
|
|
112
|
+
|
|
113
|
+
Combined summary: `iterations/{n}/fallow-scan-bundle.json`
|
|
114
|
+
|
|
115
|
+
### Satisfaction weights (40% Fallow total)
|
|
116
|
+
|
|
117
|
+
| Component | Weight |
|
|
118
|
+
|-----------|--------|
|
|
119
|
+
| `fallow_dead_code` | 0.25 |
|
|
120
|
+
| `fallow_dupes` | 0.10 |
|
|
121
|
+
| `fallow_health` | 0.05 |
|
|
122
|
+
| `structural_clean` | 0.15 |
|
|
123
|
+
| `unit_tests` | 0.15 |
|
|
124
|
+
| `build` | 0.10 |
|
|
125
|
+
| `e2e` | 0.20 |
|
|
126
|
+
|
|
127
|
+
Regression blocks completion when actionable dead-code, `clone_groups`, or `health_score` regresses vs immutable baselines.
|
|
128
|
+
|
|
129
|
+
## Exit codes (remediator-gate / debt-sweep-gate / satisfaction-loop-gate)
|
|
130
|
+
|
|
131
|
+
| Code | Meaning | Agent action |
|
|
132
|
+
|------|---------|--------------|
|
|
133
|
+
| `0` | Promote / debt sweep complete | Continue pipeline |
|
|
134
|
+
| `1` | Blocked (max rounds / infra) | Report with handoff |
|
|
135
|
+
| `3` | Remediate / continue loop | **Fix inline or advance iteration — never stop, never report** |
|
|
136
|
+
|
|
137
|
+
## Persistence
|
|
138
|
+
|
|
139
|
+
`.cursor/aaac/state/campaigns/{campaign_id}/` — see orchestrator SKILL for layout.
|
|
140
|
+
|
|
141
|
+
Full verify logs: `iterations/{n}/verify-logs/*.log` (not stderr tails).
|
|
142
|
+
|
|
143
|
+
## Fallow false positives (SSOT)
|
|
144
|
+
|
|
145
|
+
Fallow raw counts include issues that are not real debt. The loop bridges swarm knowledge into metrics via **check-app + check-architecture mirrors** (7-agent swarm).
|
|
146
|
+
|
|
147
|
+
### check_swarm flow
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# After fallow-scan + classify
|
|
151
|
+
node .cursor/aaac/scripts/remediation/prepare-check-context.mjs \
|
|
152
|
+
--campaign-id <id> --iteration <n> --run-id <run_id>
|
|
153
|
+
|
|
154
|
+
# 7 parallel readonly Task agents (see skills/shared/remediation/check-swarm/SKILL.md)
|
|
155
|
+
# Parent collects JSON → iterations/{n}/check-swarm-raw.json
|
|
156
|
+
|
|
157
|
+
node .cursor/aaac/scripts/remediation/merge-check-swarm.mjs \
|
|
158
|
+
--campaign-id <id> --iteration <n> --run-id <run_id>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
| Agent wave | Mirrors | Purpose |
|
|
162
|
+
|------------|---------|---------|
|
|
163
|
+
| check-app (×3) | `/check-app` | Workers, barrels, lazy routes, trace-file |
|
|
164
|
+
| check-architecture (×3) | `/check-architecture` | Boundaries, blast radius, dupes families |
|
|
165
|
+
| check-risk (×1) | remediation guard | FP registry, protected paths |
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
# Auto-runs after every fallow-scan
|
|
169
|
+
node .cursor/aaac/scripts/remediation/classify-fallow-issues.mjs \
|
|
170
|
+
--campaign-id <id> --iteration <n>
|
|
171
|
+
|
|
172
|
+
# check-risk swarm records confirmed false positives
|
|
173
|
+
node .cursor/aaac/scripts/remediation/record-fallow-fp.mjs \
|
|
174
|
+
--campaign-id <id> --path src/hooks/useCryptoPriceWorker.ts \
|
|
175
|
+
--classification false_positive --reason dynamically_loaded_worker --source check-risk
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
| File | Purpose |
|
|
179
|
+
|------|---------|
|
|
180
|
+
| `fallow-fp-rules.json` | Rule SSOT (workers, overlay barrels, barrel heuristics) |
|
|
181
|
+
| `fallow-false-positives.json` | Campaign registry (swarm + manual overrides) |
|
|
182
|
+
| `iterations/{n}/fallow-classification.json` | Per-scan classified inventory |
|
|
183
|
+
| `iterations/{n}/check-context.json` | Swarm input SSOT (Fallow inventory + dupes top groups) |
|
|
184
|
+
| `iterations/{n}/check-swarm-merge.json` | Merged FP/protected paths + reclassified totals |
|
|
185
|
+
| `artifacts/check_app_validate.yaml` | check-app mirror verdict |
|
|
186
|
+
| `artifacts/check_architecture_fitness.yaml` | check-architecture mirror criteria |
|
|
187
|
+
| `artifacts/protected_paths.yaml` | Wave exclusion list (mandatory in dispatch-queue) |
|
|
188
|
+
|
|
189
|
+
**Satisfaction** uses `actionable_total` for dead-code (excludes `false_positive`), `clone_groups` for dupes, and `health_score` for health. Waves must not delete paths in `fallow-false-positives.json`.
|
|
190
|
+
|
|
191
|
+
## Autonomous platform (runner + babysit)
|
|
192
|
+
|
|
193
|
+
Long campaigns (`satisfaction_threshold=100`, many iterations) must use the **shell runner**, not chat turns alone.
|
|
194
|
+
|
|
195
|
+
| Layer | Path |
|
|
196
|
+
|-------|------|
|
|
197
|
+
| Shell runner | `.cursor/aaac/scripts/remediation/remediation-runner.mjs` |
|
|
198
|
+
| Daemon | `.cursor/aaac/scripts/remediation/remediation-runner-daemon.sh` |
|
|
199
|
+
| Health | `.cursor/aaac/scripts/remediation/runner-health-check.mjs` |
|
|
200
|
+
| Babysit skill | [skills/shared/remediation/babysit/SKILL.md](../skills/shared/remediation/babysit/SKILL.md) |
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Bootstrap (after /remediate-app creates Run + campaign)
|
|
204
|
+
node .cursor/aaac/scripts/remediation/remediation-runner.mjs \
|
|
205
|
+
--run-id <run_id> --campaign-id <campaign_id> --until-yield
|
|
206
|
+
|
|
207
|
+
# Babysit: handle exit 3 yields, then --ack-yield <type>, repeat until exit 0
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Stop-hook `loop_limit` (200) is a **guardrail** for short chat continuations — not the primary loop driver.
|
|
211
|
+
|
|
212
|
+
**Autonomous is baked into `init-campaign.mjs`:** when `campaign.config.autonomous`, the orchestrator reads `artifacts/autonomous_bootstrap.json` and follows [babysit/SKILL.md](../skills/shared/remediation/babysit/SKILL.md) — no extra user prompt required.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|