rungate 0.2.0 → 0.3.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/bin/rungate.ts +70 -0
- package/lib/aes-calculator.ts +66 -0
- package/lib/agent-audit.ts +139 -0
- package/lib/agent-brief-validation.ts +359 -0
- package/lib/agents-md-refs.ts +90 -0
- package/lib/bash-file-read.ts +197 -0
- package/lib/behavioral-cache.ts +78 -0
- package/lib/branch-cleanup.ts +234 -0
- package/lib/brief-context-parser.ts +35 -0
- package/lib/canary.ts +117 -0
- package/lib/check-registry.ts +226 -0
- package/lib/ci-checkout.ts +400 -0
- package/lib/cli-commands.ts +137 -0
- package/lib/compliance-backfill.ts +220 -0
- package/lib/compliance-report.ts +504 -0
- package/lib/compliance.ts +361 -0
- package/lib/config-loader.ts +255 -0
- package/lib/conformity.ts +1818 -131
- package/lib/container-provenance.ts +230 -0
- package/lib/create-brief.ts +150 -0
- package/lib/create-sc.ts +272 -0
- package/lib/deep-merge.ts +69 -0
- package/lib/dev-liveness.ts +214 -0
- package/lib/directive-extractor.ts +210 -0
- package/lib/distribution-standing.ts +113 -0
- package/lib/doc-hygiene.ts +238 -0
- package/lib/eval-criteria.ts +6 -0
- package/lib/evidence-portability.ts +123 -0
- package/lib/evidence-prevalidator.ts +390 -0
- package/lib/evidence-required.ts +150 -0
- package/lib/evidence-satisfiability.ts +288 -0
- package/lib/frontmatter.ts +163 -0
- package/lib/gap-scanner.ts +348 -0
- package/lib/gate-enforcement.ts +366 -0
- package/lib/generators/agent-briefs.ts +136 -0
- package/lib/generators/agents-md.ts +506 -0
- package/lib/generators/code-map.ts +60 -0
- package/lib/generators/types.ts +184 -0
- package/lib/git-ref-normalizer.ts +107 -0
- package/lib/github.ts +539 -0
- package/lib/harness-identity.ts +63 -0
- package/lib/hill-climb.ts +164 -0
- package/lib/instruction-effectiveness.ts +131 -0
- package/lib/issue-closure-audit.ts +225 -0
- package/lib/issue-create-override.ts +343 -0
- package/lib/js-top-level-code.ts +250 -0
- package/lib/liveness-contradiction.ts +149 -0
- package/lib/organize.ts +505 -0
- package/lib/paths.ts +197 -6
- package/lib/post-fix-verify.ts +157 -0
- package/lib/prior-branch.ts +489 -0
- package/lib/project-state-shape.ts +166 -0
- package/lib/promote-outputs.ts +156 -0
- package/lib/prove-label-gate.ts +35 -0
- package/lib/reachability.ts +302 -0
- package/lib/release-preflight.ts +186 -0
- package/lib/rule-health-pipeline.ts +264 -0
- package/lib/rule-health-trend.ts +161 -0
- package/lib/rule-provenance.ts +149 -0
- package/lib/rule-registry.ts +128 -0
- package/lib/rungate-schema.ts +114 -4
- package/lib/sc-claim-forms.ts +179 -0
- package/lib/sc-cover.ts +150 -0
- package/lib/sc-guard.ts +157 -0
- package/lib/sc-ids.ts +344 -0
- package/lib/scaffold/defaults.ts +165 -0
- package/lib/scaffold/managed-workflow.ts +370 -0
- package/lib/scaffold/owned-files.ts +265 -0
- package/lib/scaffold/steps.ts +2680 -0
- package/lib/scanner.ts +701 -0
- package/lib/screenshot-upload.ts +73 -0
- package/lib/secret-patterns.ts +112 -0
- package/lib/security-verdict.ts +616 -0
- package/lib/signal-phrases.ts +1 -0
- package/lib/spec-change-conformity.ts +80 -0
- package/lib/spec-files.ts +62 -0
- package/lib/spec-registry.ts +133 -0
- package/lib/spec-updater.ts +96 -0
- package/lib/stale-cleanup.ts +224 -0
- package/lib/stale-issue-scanner.ts +36 -0
- package/lib/strip-js-comments.ts +269 -0
- package/lib/suite-measurement.ts +228 -0
- package/lib/task-completion-checks.ts +177 -0
- package/lib/test-suite-lock.ts +1136 -0
- package/lib/transcript-checker.ts +1140 -0
- package/lib/validators/spec-validators.ts +171 -0
- package/lib/verdict-capture.ts +73 -0
- package/lib/verified-push.ts +358 -0
- package/lib/workflow-security.ts +174 -0
- package/lib/worktree-cleanup.ts +250 -0
- package/lib/worktree-collect.ts +283 -0
- package/lib/worktree-isolation.ts +82 -0
- package/package.json +36 -3
- package/prompts/ac-adversary.md +14 -2
- package/prompts/aditi.md +5 -0
- package/prompts/blast-radius.md +5 -0
- package/prompts/container-verify.md +5 -0
- package/prompts/discovery.md +4 -0
- package/prompts/environment.md +5 -0
- package/prompts/evidence-hierarchy.md +5 -0
- package/prompts/evidence-validator.md +11 -0
- package/prompts/marcus.md +5 -0
- package/prompts/prevention.md +5 -0
- package/prompts/prove-reproducer.md +12 -0
- package/prompts/quinn-decision-tree.md +5 -0
- package/prompts/quinn-ui-brief.md +5 -0
- package/prompts/quinn.md +5 -0
- package/prompts/rca.md +5 -0
- package/prompts/read-before-write.md +4 -0
- package/prompts/regression.md +5 -0
- package/prompts/serena.md +5 -0
- package/scripts/audit-specs.ts +464 -0
- package/scripts/convert-spec.ts +293 -0
- package/scripts/create-sc.ts +92 -0
- package/scripts/create-spec.ts +166 -0
- package/scripts/extract-constraints.ts +4 -3
- package/scripts/generate-code-map.ts +1 -1
- package/scripts/scaffold-project.ts +138 -1426
- package/scripts/sync-spec-tests.ts +211 -126
- package/.claude/agents/aditi.md +0 -47
- package/.claude/agents/marcus.md +0 -50
- package/.claude/agents/quinn.md +0 -58
- package/.claude/agents/rook.md +0 -47
- package/.claude/agents/serena.md +0 -46
- package/.claude/rungate.json +0 -11
- package/.fallowrc.json +0 -28
- package/.github/copilot-instructions.md +0 -20
- package/.rungate/conformity-findings.json +0 -648
- package/AGENTS.md +0 -106
- package/CODE-MAP.md +0 -50
- package/HARNESS.md +0 -88
- package/bun.lock +0 -26
- package/bunfig.toml +0 -2
- package/config/brief-policies.json +0 -28
- package/config/ceremony-profiles.json +0 -212
- package/config/consumer-cascade-map.json +0 -24
- package/config/doc-cascade-map.json +0 -24
- package/config/eval.json +0 -84
- package/config/profiles/account-plan.yaml +0 -36
- package/config/profiles/campaign.yaml +0 -94
- package/config/prove-evidence.schema.json +0 -65
- package/config/spec-policies.json +0 -36
- package/config/workflow-schema.json +0 -281
- package/gates/SCHEMA-GUIDE.md +0 -121
- package/gates/ac-quality.test.ts +0 -106
- package/gates/adversarial.test.ts +0 -274
- package/gates/brief-assembler.test.ts +0 -429
- package/gates/brief-assembler.ts +0 -334
- package/gates/bunfig.toml +0 -2
- package/gates/chain.test.ts +0 -91
- package/gates/e2e-smoke.test.ts +0 -234
- package/gates/error-classifier.test.ts +0 -249
- package/gates/error-classifier.ts +0 -89
- package/gates/orchestrator.test.ts +0 -950
- package/gates/orchestrator.ts +0 -569
- package/gates/preload.ts +0 -77
- package/gates/prompts/ac-adversary.md +0 -20
- package/gates/prompts/evidence-validator.md +0 -22
- package/gates/prompts/prove-reproducer.md +0 -53
- package/gates/prove.test.ts +0 -164
- package/gates/run-gate.ts +0 -936
- package/gates/schema-parity.test.ts +0 -197
- package/gates/schema.ts +0 -362
- package/gates/self-heal.test.ts +0 -511
- package/gates/self-heal.ts +0 -121
- package/gates/ship-orchestrator.test.ts +0 -379
- package/gates/ship-orchestrator.ts +0 -363
- package/gates/test-fixtures/broken-no-environments.json +0 -60
- package/gates/test-fixtures/valid-standard.json +0 -54
- package/gates/test-utils.ts +0 -43
- package/gates/witness.ts +0 -220
- package/gates/workflow.test.ts +0 -1053
- package/hooks/AgentBriefGuard.hook.ts +0 -586
- package/hooks/AgentVerdictCapture.hook.ts +0 -134
- package/hooks/AutoVerifyGate.hook.ts +0 -76
- package/hooks/GateEnforcement.hook.ts +0 -273
- package/hooks/IssueCloseGuard.hook.ts +0 -116
- package/hooks/MergeGuard.hook.ts +0 -55
- package/hooks/StaleTTLCleanup.hook.ts +0 -133
- package/hooks/VerifyPhaseLock.hook.ts +0 -81
- package/hooks/WorkflowStateGuard.hook.ts +0 -37
- package/hooks/lib/agentDetection.ts +0 -70
- package/hooks/lib/findWorkflow.ts +0 -101
- package/hooks/lib/parseStdin.ts +0 -37
- package/hooks/lib/paths.ts +0 -111
- package/hooks/lib/utils.ts +0 -81
- package/reference/migration-manifest.json +0 -554
- package/reference/prompts/agent-aditi.md +0 -38
- package/reference/prompts/agent-marcus.md +0 -38
- package/reference/prompts/agent-quinn.md +0 -38
- package/reference/prompts/agent-rook.md +0 -37
- package/reference/prompts/agent-serena.md +0 -37
- package/reference/prompts/council-skill.md +0 -170
- package/reference/prompts/goal-skill.md +0 -235
- package/reference/prompts/prove-skill.md +0 -283
- package/reference/prompts/quinn-standard.md +0 -246
- package/reference/prompts/ship-convergence.md +0 -65
- package/reference/prompts/ship-escalation.md +0 -43
- package/reference/prompts/ship-iteration.md +0 -382
- package/reference/prompts/ship-pending-patches.md +0 -246
- package/reference/prompts/ship-reference.md +0 -250
- package/reference/prompts/ship-skill.md +0 -347
- package/reference/prompts/ship-templates.md +0 -215
- package/reference/scripts/batch-status.sh +0 -68
- package/reference/scripts/chain-compat-check.sh +0 -67
- package/reference/scripts/context-audit.sh +0 -314
- package/reference/scripts/dead-export-check.sh +0 -61
- package/reference/scripts/generate-qc-tables.sh +0 -92
- package/reference/scripts/harness-init.sh +0 -111
- package/reference/scripts/pai-054-baseline-check.sh +0 -40
- package/reference/scripts/prove-smoke-test.sh +0 -112
- package/reference/scripts/setup-keychain-salt.sh +0 -12
- package/reference/scripts/skill-optimizer-friday.sh +0 -88
- package/reference/scripts/skill-qc-test.sh +0 -351
- package/reference/scripts/skill-synthesize-tonight.sh +0 -66
- package/reference/specs/HARNESS-EXTRACTION-SPEC.md +0 -263
- package/reference/specs/harness-v3-bash-deletion-plan.md +0 -65
- package/reference/specs/harness-v3-migration-plan.md +0 -188
- package/scripts/decision-reconcile.sh +0 -74
- package/scripts/decision-reconcile.ts +0 -152
- package/scripts/git-hooks/pre-commit +0 -76
- package/scripts/git-hooks/pre-push +0 -271
- package/scripts/harness-skill-check.sh +0 -52
- package/scripts/lib/gap-emit.sh +0 -65
- package/scripts/lib/jq-update.sh +0 -30
- package/scripts/lib/resolve-slug.sh +0 -30
- package/scripts/lib/verify-spec-compliance.sh +0 -102
- package/scripts/prove-backfill.sh +0 -87
- package/scripts/scaffold-rungate-config.ts +0 -91
- package/scripts/self-containment-check.sh +0 -109
- package/scripts/skill-qc-validator.sh +0 -402
- package/scripts/slug-resolver.sh +0 -14
- package/specs/BOOTSTRAP-DATA-FLOW-SPEC.md +0 -2493
- package/specs/BOOTSTRAP-TEST-PLAN.md +0 -571
- package/specs/HARNESS-GATES.md +0 -256
- package/specs/HARNESS-SKILL-CHAIN.md +0 -286
- package/specs/HARNESS-SKILL-CONTRACT.md +0 -93
- package/specs/HARNESS-STANDARD.md +0 -488
- package/specs/SPEC-TEMPLATE.md +0 -53
- package/specs/bootstrap-data-flow.png +0 -0
- package/specs/harness-automation-matrix.md +0 -314
- package/specs/harness-automation-matrix.rules.json +0 -64
- package/test/anti.test.ts +0 -80
- package/test/contract-negative.test.ts +0 -86
- package/test/contract.test.ts +0 -158
- package/test/external-deps.test.ts +0 -48
- package/test/fixtures/golden-project/.env.example +0 -3
- package/test/fixtures/golden-project/Makefile +0 -7
- package/test/fixtures/golden-project/docs/adr/ADR-001-framework.md +0 -23
- package/test/fixtures/golden-project/docs/setup-guide.md +0 -10
- package/test/fixtures/golden-project/package.json +0 -10
- package/test/fixtures/golden-project/specs/api-spec.md +0 -20
- package/test/fixtures/golden-project/src/auth.ts +0 -8
- package/test/fixtures/golden-project/src/db.ts +0 -11
- package/test/fixtures/golden-project/src/index.ts +0 -19
- package/test/fixtures/golden-project/src/utils/format.ts +0 -3
- package/test/fixtures/golden-project/test/auth.test.ts +0 -15
- package/test/fixtures/golden-project/tsconfig.json +0 -12
- package/test/meta-sc-coverage.test.ts +0 -159
- package/test/phase-0.test.ts +0 -846
- package/test/phase-1.test.ts +0 -617
- package/test/phase-2.test.ts +0 -620
- package/test/phase-3.test.ts +0 -99
- package/test/scaffold-conformity.test.ts +0 -8
- package/test/schema-canary.test.ts +0 -51
- package/test/spec-compliance-auto.test.ts +0 -64
- package/test/spec-compliance.test.ts +0 -295
- package/test/spec-discovery.test.ts +0 -68
- package/test/spec-drift.test.ts +0 -5
- package/test/structure.test.ts +0 -165
- package/test/unit/agent-brief-guard-ship.test.ts +0 -293
- package/test/unit/extract-constraints.test.ts +0 -145
- package/test/unit/issue-close-guard.test.ts +0 -204
- package/test/unit/scaffold-project.test.ts +0 -417
- package/test/unit/skill-cooccurrence.test.ts +0 -177
- package/test/unit/skill-sequence-logger.test.ts +0 -244
- package/test/unit/workflow-state-guard.test.ts +0 -95
- package/workflows/batch-ship.js +0 -295
- package/workflows/council.js +0 -481
- package/workflows/prove.js +0 -560
- package/workflows/ship.js +0 -789
- package/workflows/verify.js +0 -236
package/gates/orchestrator.ts
DELETED
|
@@ -1,569 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync, chmodSync, statSync, unlinkSync, appendFileSync } from "fs";
|
|
2
|
-
import { join, dirname } from "path";
|
|
3
|
-
import { createHash, createHmac, randomBytes } from "crypto";
|
|
4
|
-
import { execSync } from "child_process";
|
|
5
|
-
import { WorkflowStateSchema, ACSchema, AfkBatchPlanSchema, REJECTED_SKIP_REASONS } from "./schema";
|
|
6
|
-
import { ZodError } from "zod";
|
|
7
|
-
|
|
8
|
-
export interface GateResult {
|
|
9
|
-
check: string;
|
|
10
|
-
result: "PASS" | "FAIL" | "WARN";
|
|
11
|
-
detail: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface WorkflowState {
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function readState(sf: string): WorkflowState {
|
|
19
|
-
return JSON.parse(readFileSync(sf, "utf-8"));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function writeState(sf: string, state: WorkflowState): void {
|
|
23
|
-
const tmp = `${sf}.${process.pid}.tmp`;
|
|
24
|
-
const json = JSON.stringify(state, null, 2);
|
|
25
|
-
writeFileSync(tmp, json);
|
|
26
|
-
try {
|
|
27
|
-
JSON.parse(readFileSync(tmp, "utf-8"));
|
|
28
|
-
const { renameSync } = require("fs");
|
|
29
|
-
renameSync(tmp, sf);
|
|
30
|
-
} catch {
|
|
31
|
-
try { unlinkSync(tmp); } catch {}
|
|
32
|
-
throw new Error("writeState produced invalid JSON");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function gitSha(cwd?: string): string {
|
|
37
|
-
try {
|
|
38
|
-
return execSync("git rev-parse HEAD", { encoding: "utf-8", timeout: 5000, cwd }).trim();
|
|
39
|
-
} catch {
|
|
40
|
-
return "unknown";
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function isoNow(): string {
|
|
45
|
-
return new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const PHASE_ADVANCE: Record<string, string> = {
|
|
49
|
-
scope: "BUILD",
|
|
50
|
-
verify: "SHIP",
|
|
51
|
-
ship: "DONE",
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export function writeGateResult(
|
|
55
|
-
sf: string,
|
|
56
|
-
gate: string,
|
|
57
|
-
passes: number,
|
|
58
|
-
fails: number,
|
|
59
|
-
warns: number,
|
|
60
|
-
results: GateResult[],
|
|
61
|
-
projectRoot?: string,
|
|
62
|
-
): { resultVal: "PASS" | "FAIL"; attempt: number } {
|
|
63
|
-
const state = readState(sf);
|
|
64
|
-
let resultVal: "PASS" | "FAIL" = fails === 0 ? "PASS" : "FAIL";
|
|
65
|
-
|
|
66
|
-
// #514: Block phase advance when non-OUTCOME ACs have FAIL verdicts
|
|
67
|
-
if ((gate === "verify" || gate === "ship") && resultVal === "PASS") {
|
|
68
|
-
const failedACs = (state.acs || []).filter(
|
|
69
|
-
(ac: any) => ac.verdict === "FAIL" && ac.type !== "OUTCOME"
|
|
70
|
-
);
|
|
71
|
-
if (failedACs.length > 0) {
|
|
72
|
-
resultVal = "FAIL";
|
|
73
|
-
for (const ac of failedACs) {
|
|
74
|
-
results.push({
|
|
75
|
-
check: `ac-verdict-fail: ${ac.id}`,
|
|
76
|
-
result: "FAIL",
|
|
77
|
-
detail: `${ac.id} has FAIL verdict`,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
fails += failedACs.length;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const prev = state.gates?.[gate]?.attempt ?? 0;
|
|
85
|
-
const attempt = prev + 1;
|
|
86
|
-
const ts = isoNow();
|
|
87
|
-
const sha = gitSha(projectRoot);
|
|
88
|
-
|
|
89
|
-
const failures = results.filter(r => r.result === "FAIL");
|
|
90
|
-
|
|
91
|
-
state.gates = state.gates || {};
|
|
92
|
-
state.gates[gate] = {
|
|
93
|
-
result: resultVal,
|
|
94
|
-
attempt,
|
|
95
|
-
failures,
|
|
96
|
-
ts,
|
|
97
|
-
commitSha: sha,
|
|
98
|
-
};
|
|
99
|
-
state.updatedTs = ts;
|
|
100
|
-
state.changelog = state.changelog || [];
|
|
101
|
-
state.changelog.push({
|
|
102
|
-
ts,
|
|
103
|
-
event: `gate-${gate}`,
|
|
104
|
-
detail: `${passes} pass, ${fails} fail, ${warns} warn`,
|
|
105
|
-
actor: "gate-runner",
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// ADR-009: Record AC hash at scope PASS for cross-gate consistency
|
|
109
|
-
// Hash only AC definitions (inputs), not verdicts/evidence (outputs populated by gates)
|
|
110
|
-
if (gate === "scope" && resultVal === "PASS") {
|
|
111
|
-
const acDefs = (state.acs || []).map((ac: any) => ({
|
|
112
|
-
id: ac.id, type: ac.type, statement: ac.statement,
|
|
113
|
-
specElement: ac.specElement, threshold: ac.threshold,
|
|
114
|
-
evidenceMethod: ac.evidenceMethod,
|
|
115
|
-
}));
|
|
116
|
-
const acHash = createHash("sha256").update(JSON.stringify(acDefs)).digest("hex");
|
|
117
|
-
state.gates.scope.acHash = acHash;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (gate === "ship" && resultVal === "PASS") {
|
|
121
|
-
state.mergeCommitSha = sha;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// #514 SC-2: Ship gate failure resets phase to VERIFY for re-iteration
|
|
125
|
-
if (gate === "ship" && resultVal === "FAIL") {
|
|
126
|
-
state.phase = "VERIFY";
|
|
127
|
-
state.changelog.push({
|
|
128
|
-
ts,
|
|
129
|
-
event: "ship-fail-regression",
|
|
130
|
-
detail: "Ship gate FAIL — resetting to VERIFY for re-iteration",
|
|
131
|
-
actor: "gate-runner",
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const next = resultVal === "PASS" ? PHASE_ADVANCE[gate] : undefined;
|
|
136
|
-
if (next) {
|
|
137
|
-
state.phaseTimings = state.phaseTimings || {};
|
|
138
|
-
const currentPhase = state.phase;
|
|
139
|
-
const currentTimings = state.phaseTimings[currentPhase] || [];
|
|
140
|
-
if (currentTimings.length > 0) {
|
|
141
|
-
currentTimings[currentTimings.length - 1].exitedTs = ts;
|
|
142
|
-
}
|
|
143
|
-
state.phaseTimings[currentPhase] = currentTimings;
|
|
144
|
-
|
|
145
|
-
state.phaseTimings[next] = (state.phaseTimings[next] || []).concat([
|
|
146
|
-
{ enteredTs: ts, source: "gate-runner" },
|
|
147
|
-
]);
|
|
148
|
-
state.phase = next;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
writeState(sf, state);
|
|
152
|
-
return { resultVal, attempt };
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
import { gateSaltPath } from "../lib/paths";
|
|
156
|
-
|
|
157
|
-
const GATE_SALT_PATH = gateSaltPath();
|
|
158
|
-
|
|
159
|
-
export function generateHmac(sf: string, slug: string, issue: number, projectRoot?: string): string {
|
|
160
|
-
if (!existsSync(GATE_SALT_PATH)) {
|
|
161
|
-
mkdirSync(dirname(GATE_SALT_PATH), { recursive: true });
|
|
162
|
-
writeFileSync(GATE_SALT_PATH, randomBytes(32).toString("hex") + "\n");
|
|
163
|
-
chmodSync(GATE_SALT_PATH, 0o600);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const perms = statSync(GATE_SALT_PATH).mode & 0o777;
|
|
167
|
-
if (perms !== 0o600) {
|
|
168
|
-
chmodSync(GATE_SALT_PATH, 0o600);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const salt = readFileSync(GATE_SALT_PATH, "utf-8").trim();
|
|
172
|
-
const sha = gitSha(projectRoot);
|
|
173
|
-
const input = `${slug}:${issue}:PASS:${sha}`;
|
|
174
|
-
const hash = createHmac("sha256", salt).update(input).digest("hex").slice(0, 16);
|
|
175
|
-
|
|
176
|
-
const state = readState(sf);
|
|
177
|
-
state.gates = state.gates || {};
|
|
178
|
-
state.gates.ship = state.gates.ship || {};
|
|
179
|
-
state.gates.ship.hash = hash;
|
|
180
|
-
writeState(sf, state);
|
|
181
|
-
|
|
182
|
-
return hash;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export function runConvergence(
|
|
186
|
-
sf: string,
|
|
187
|
-
gate: string,
|
|
188
|
-
resultVal: string,
|
|
189
|
-
ceremonyProfilePath: string,
|
|
190
|
-
): { action: "circuit-break" | "stall" | "loop-back" | "skip"; iteration?: number } {
|
|
191
|
-
if (gate !== "verify" || resultVal !== "FAIL") {
|
|
192
|
-
return { action: "skip" };
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const state = readState(sf);
|
|
196
|
-
const profile = JSON.parse(readFileSync(ceremonyProfilePath, "utf-8"));
|
|
197
|
-
const tier = state.sizing?.ceremonyTier || "STANDARD";
|
|
198
|
-
const maxIter = profile.tiers?.[tier]?.maxIterations ?? 5;
|
|
199
|
-
|
|
200
|
-
const loopbacks = (state.changelog || []).filter(
|
|
201
|
-
(e: any) => e.event === "iteration-loopback",
|
|
202
|
-
);
|
|
203
|
-
const iterCount = loopbacks.length;
|
|
204
|
-
|
|
205
|
-
const failNames = (state.gates?.verify?.failures || [])
|
|
206
|
-
.map((f: any) => f.check)
|
|
207
|
-
.sort()
|
|
208
|
-
.join(",");
|
|
209
|
-
|
|
210
|
-
// Read previous hash BEFORE appending new one
|
|
211
|
-
let prevHash = "";
|
|
212
|
-
if (iterCount >= 1) {
|
|
213
|
-
prevHash = loopbacks[loopbacks.length - 1]?.failureHash || "";
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const ts = isoNow();
|
|
217
|
-
const newIter = iterCount + 1;
|
|
218
|
-
|
|
219
|
-
state.changelog = state.changelog || [];
|
|
220
|
-
state.changelog.push({
|
|
221
|
-
ts,
|
|
222
|
-
event: "iteration-loopback",
|
|
223
|
-
detail: `iteration ${newIter} — failures: ${failNames}`,
|
|
224
|
-
failureHash: failNames,
|
|
225
|
-
actor: "gate-runner",
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
// Circuit breaker
|
|
229
|
-
if (newIter >= maxIter) {
|
|
230
|
-
state.phaseTimings = state.phaseTimings || {};
|
|
231
|
-
const currentPhase = state.phase;
|
|
232
|
-
const currentTimings = state.phaseTimings[currentPhase] || [];
|
|
233
|
-
if (currentTimings.length > 0) {
|
|
234
|
-
currentTimings[currentTimings.length - 1].exitedTs = ts;
|
|
235
|
-
}
|
|
236
|
-
state.phaseTimings[currentPhase] = currentTimings;
|
|
237
|
-
state.phaseTimings["CIRCUIT_BREAK"] = [{ enteredTs: ts, source: "gate-runner" }];
|
|
238
|
-
state.phase = "CIRCUIT_BREAK";
|
|
239
|
-
writeState(sf, state);
|
|
240
|
-
return { action: "circuit-break", iteration: newIter };
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// Stall detection
|
|
244
|
-
if (prevHash && prevHash === failNames) {
|
|
245
|
-
state.changelog.push({
|
|
246
|
-
ts,
|
|
247
|
-
event: "council-recommended",
|
|
248
|
-
detail: "same failure hash in consecutive iterations — consider council review",
|
|
249
|
-
actor: "gate-runner",
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// Loop back to BUILD
|
|
254
|
-
state.phaseTimings = state.phaseTimings || {};
|
|
255
|
-
const currentPhase = state.phase;
|
|
256
|
-
const currentTimings = state.phaseTimings[currentPhase] || [];
|
|
257
|
-
if (currentTimings.length > 0) {
|
|
258
|
-
currentTimings[currentTimings.length - 1].exitedTs = ts;
|
|
259
|
-
}
|
|
260
|
-
state.phaseTimings[currentPhase] = currentTimings;
|
|
261
|
-
|
|
262
|
-
const buildTimings = state.phaseTimings["BUILD"] || [];
|
|
263
|
-
state.phaseTimings["BUILD"] = buildTimings.concat([
|
|
264
|
-
{ enteredTs: ts, source: "gate-runner", iteration: buildTimings.length + 1 },
|
|
265
|
-
]);
|
|
266
|
-
state.phase = "BUILD";
|
|
267
|
-
writeState(sf, state);
|
|
268
|
-
|
|
269
|
-
const isStall = prevHash !== "" && prevHash === failNames;
|
|
270
|
-
return { action: isStall ? "stall" : "loop-back", iteration: newIter };
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export function generateShipEvidence(
|
|
274
|
-
sf: string,
|
|
275
|
-
workDir: string,
|
|
276
|
-
issue: number,
|
|
277
|
-
issueRepo: string,
|
|
278
|
-
passes: number,
|
|
279
|
-
fails: number,
|
|
280
|
-
warns: number,
|
|
281
|
-
): string {
|
|
282
|
-
const state = readState(sf);
|
|
283
|
-
const sha = gitSha();
|
|
284
|
-
const ts = isoNow();
|
|
285
|
-
|
|
286
|
-
const loopbacks = (state.changelog || []).filter(
|
|
287
|
-
(e: any) => e.event === "iteration-loopback",
|
|
288
|
-
);
|
|
289
|
-
const iterCount = loopbacks.length + 1;
|
|
290
|
-
const predicted = state.sizing?.predicted || "unknown";
|
|
291
|
-
|
|
292
|
-
const acEvidence = (state.acs || []).map((ac: any) => ({
|
|
293
|
-
criterion: `${ac.id}: ${ac.statement}`,
|
|
294
|
-
result: ac.verdict || "SKIP",
|
|
295
|
-
detail: ac.evidence?.content || ac.evidence || "no evidence",
|
|
296
|
-
}));
|
|
297
|
-
|
|
298
|
-
const evidence = {
|
|
299
|
-
contractVersion: "1.0",
|
|
300
|
-
issueNumber: issue,
|
|
301
|
-
gateOut: { status: "PASS" as const, evidence: acEvidence },
|
|
302
|
-
mergeCommitSha: sha,
|
|
303
|
-
capturedAt: ts,
|
|
304
|
-
iterationCount: iterCount,
|
|
305
|
-
sizing: { predicted, actual: predicted },
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
const evidencePath = join(workDir, "ship-evidence.json");
|
|
309
|
-
writeFileSync(evidencePath, JSON.stringify(evidence, null, 2));
|
|
310
|
-
|
|
311
|
-
// GitHub: add shipped label + post comment (best-effort)
|
|
312
|
-
if (issueRepo && issue > 0) {
|
|
313
|
-
try {
|
|
314
|
-
execSync(`gh issue edit ${issue} --repo ${issueRepo} --add-label shipped`, {
|
|
315
|
-
timeout: 15000,
|
|
316
|
-
stdio: "pipe",
|
|
317
|
-
});
|
|
318
|
-
} catch {}
|
|
319
|
-
|
|
320
|
-
const scTable = (state.acs || [])
|
|
321
|
-
.map((ac: any) => `| ${ac.id} | ${ac.verdict || "SKIP"} | ${ac.evidence?.content || "—"} |`)
|
|
322
|
-
.join("\n");
|
|
323
|
-
|
|
324
|
-
const comment = [
|
|
325
|
-
"## Ship Complete (automated)\n",
|
|
326
|
-
`**Commit:** ${sha}`,
|
|
327
|
-
`**Gate:** ${passes} pass, ${fails} fail, ${warns} warn\n`,
|
|
328
|
-
"### SC Results",
|
|
329
|
-
"| SC | Verdict | Evidence |",
|
|
330
|
-
"|---|---|---|",
|
|
331
|
-
scTable,
|
|
332
|
-
"\nChain mode — issue stays open for /prove.",
|
|
333
|
-
].join("\n");
|
|
334
|
-
|
|
335
|
-
try {
|
|
336
|
-
execSync(`gh issue comment ${issue} --repo ${issueRepo} --body-file -`, {
|
|
337
|
-
input: comment,
|
|
338
|
-
timeout: 15000,
|
|
339
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
340
|
-
});
|
|
341
|
-
} catch {}
|
|
342
|
-
|
|
343
|
-
// Auto-push
|
|
344
|
-
try {
|
|
345
|
-
const ahead = execSync("git rev-list --count @{upstream}..HEAD", {
|
|
346
|
-
encoding: "utf-8",
|
|
347
|
-
timeout: 5000,
|
|
348
|
-
}).trim();
|
|
349
|
-
if (parseInt(ahead) > 0) {
|
|
350
|
-
execSync("git push", {
|
|
351
|
-
timeout: 30000,
|
|
352
|
-
env: { ...process.env, GATE_PASSED_PUSH: "1" },
|
|
353
|
-
stdio: "pipe",
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
} catch {}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return evidencePath;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
const GATE_PENDING_PATH = join(
|
|
363
|
-
process.env.HOME || "",
|
|
364
|
-
".claude",
|
|
365
|
-
"MEMORY",
|
|
366
|
-
"STATE",
|
|
367
|
-
"gate-pending.json",
|
|
368
|
-
);
|
|
369
|
-
|
|
370
|
-
export function writeGateSummary(
|
|
371
|
-
gate: string,
|
|
372
|
-
passes: number,
|
|
373
|
-
fails: number,
|
|
374
|
-
warns: number,
|
|
375
|
-
results: GateResult[],
|
|
376
|
-
issue: number,
|
|
377
|
-
slug: string,
|
|
378
|
-
sessionId: string,
|
|
379
|
-
): "BLOCKED" | "ALL CLEAR" {
|
|
380
|
-
console.log("-----------------------------------");
|
|
381
|
-
console.log(`${gate} GATE: ${passes} pass, ${fails} fail, ${warns} warn`);
|
|
382
|
-
|
|
383
|
-
if (fails > 0) {
|
|
384
|
-
mkdirSync(dirname(GATE_PENDING_PATH), { recursive: true });
|
|
385
|
-
const failItems = results
|
|
386
|
-
.filter(r => r.result === "FAIL")
|
|
387
|
-
.map(r => ({ check: r.check, detail: r.detail }));
|
|
388
|
-
|
|
389
|
-
const pending = {
|
|
390
|
-
session_id: sessionId || "unknown",
|
|
391
|
-
gate,
|
|
392
|
-
issue,
|
|
393
|
-
slug,
|
|
394
|
-
failures: failItems,
|
|
395
|
-
strike_count: 0,
|
|
396
|
-
max_strikes: 3,
|
|
397
|
-
outcome_ac_failure: false,
|
|
398
|
-
created_at: isoNow(),
|
|
399
|
-
expires_ts: Math.floor(Date.now() / 1000) + 14400,
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
writeFileSync(GATE_PENDING_PATH, JSON.stringify(pending, null, 2));
|
|
403
|
-
console.log("BLOCKED");
|
|
404
|
-
return "BLOCKED";
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
try { unlinkSync(GATE_PENDING_PATH); } catch {}
|
|
408
|
-
console.log("ALL CLEAR");
|
|
409
|
-
return "ALL CLEAR";
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// ── Write-time Zod validation (#453) ─────────────────────────────────────
|
|
413
|
-
|
|
414
|
-
export function writeWorkflowState(sf: string, state: object): void {
|
|
415
|
-
try {
|
|
416
|
-
WorkflowStateSchema.passthrough().parse(state);
|
|
417
|
-
} catch (err) {
|
|
418
|
-
if (err instanceof ZodError) {
|
|
419
|
-
const messages = err.issues.map(issue => {
|
|
420
|
-
if (issue.code === "invalid_enum_value") {
|
|
421
|
-
return `${issue.path.join(".")}: expected one of [${issue.options.join(", ")}], got "${issue.received}"`;
|
|
422
|
-
}
|
|
423
|
-
return `${issue.path.join(".")}: ${issue.message}`;
|
|
424
|
-
});
|
|
425
|
-
throw new Error(`Workflow state validation failed:\n${messages.join("\n")}`);
|
|
426
|
-
}
|
|
427
|
-
throw err;
|
|
428
|
-
}
|
|
429
|
-
writeState(sf, state as WorkflowState);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// ── Structured workflow authoring (#454) ─────────────────────────────────
|
|
433
|
-
|
|
434
|
-
export function initWorkflow(sf: string, opts: {
|
|
435
|
-
issue: number;
|
|
436
|
-
repo: string;
|
|
437
|
-
issueRepo?: string;
|
|
438
|
-
projectRoot: string;
|
|
439
|
-
slug: string;
|
|
440
|
-
issueGoal: string;
|
|
441
|
-
sizing?: { predicted?: string; ceremonyTier?: string };
|
|
442
|
-
sourceSpecs?: Array<{ path: string; citedInDiscovery: boolean; specElements?: string[] }>;
|
|
443
|
-
bootstrappedFrom?: string;
|
|
444
|
-
}): void {
|
|
445
|
-
const ts = isoNow();
|
|
446
|
-
const state: Record<string, any> = {
|
|
447
|
-
schemaVersion: 2,
|
|
448
|
-
issue: opts.issue,
|
|
449
|
-
repo: opts.repo,
|
|
450
|
-
issueRepo: opts.issueRepo || opts.repo,
|
|
451
|
-
projectRoot: opts.projectRoot,
|
|
452
|
-
slug: opts.slug,
|
|
453
|
-
issueGoal: opts.issueGoal,
|
|
454
|
-
phase: "GOAL",
|
|
455
|
-
acs: [],
|
|
456
|
-
gates: {},
|
|
457
|
-
changelog: [],
|
|
458
|
-
startTs: ts,
|
|
459
|
-
updatedTs: ts,
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
if (opts.sizing) state.sizing = opts.sizing;
|
|
463
|
-
if (opts.sourceSpecs) state.sourceSpecs = opts.sourceSpecs;
|
|
464
|
-
if (opts.bootstrappedFrom) state.bootstrappedFrom = opts.bootstrappedFrom;
|
|
465
|
-
|
|
466
|
-
WorkflowStateSchema.passthrough().parse(state);
|
|
467
|
-
mkdirSync(dirname(sf), { recursive: true });
|
|
468
|
-
writeState(sf, state);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
export function writeACs(sf: string, acs: Array<{
|
|
472
|
-
id: string;
|
|
473
|
-
type?: string;
|
|
474
|
-
statement: string;
|
|
475
|
-
threshold?: { op: string; value: string | number; unit?: string };
|
|
476
|
-
evidenceMethod?: { type: string; command?: string };
|
|
477
|
-
specElement?: string;
|
|
478
|
-
}>): void {
|
|
479
|
-
const state = readState(sf);
|
|
480
|
-
|
|
481
|
-
state.acs = acs.map(ac => {
|
|
482
|
-
const enriched = { ...ac, evidence: null, verdict: "PENDING" as const };
|
|
483
|
-
ACSchema.parse(enriched);
|
|
484
|
-
return enriched;
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
writeState(sf, state);
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// ── AFK batch plan helpers (#468) ──────────────────────────────────────
|
|
491
|
-
|
|
492
|
-
const AFK_BATCH_FILE = "afk-batch.json";
|
|
493
|
-
|
|
494
|
-
function readBatchPlan(dir: string): any {
|
|
495
|
-
const fp = join(dir, AFK_BATCH_FILE);
|
|
496
|
-
return JSON.parse(readFileSync(fp, "utf-8"));
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
function writeBatchPlanFile(dir: string, plan: any): void {
|
|
500
|
-
AfkBatchPlanSchema.parse(plan);
|
|
501
|
-
const fp = join(dir, AFK_BATCH_FILE);
|
|
502
|
-
writeFileSync(fp, JSON.stringify(plan, null, 2));
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
export function initBatchPlan(dir: string, planned: number[]): void {
|
|
506
|
-
mkdirSync(dir, { recursive: true });
|
|
507
|
-
const plan = {
|
|
508
|
-
approvedAt: isoNow(),
|
|
509
|
-
planned,
|
|
510
|
-
shipped: [],
|
|
511
|
-
skipped: [],
|
|
512
|
-
inProgress: null,
|
|
513
|
-
};
|
|
514
|
-
writeBatchPlanFile(dir, plan);
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
export function recordBatchShipped(dir: string, issue: number): void {
|
|
518
|
-
const plan = readBatchPlan(dir);
|
|
519
|
-
if (!plan.shipped.includes(issue)) {
|
|
520
|
-
plan.shipped.push(issue);
|
|
521
|
-
}
|
|
522
|
-
if (plan.inProgress === issue) {
|
|
523
|
-
plan.inProgress = null;
|
|
524
|
-
}
|
|
525
|
-
writeBatchPlanFile(dir, plan);
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
export function recordBatchSkipped(dir: string, issue: number, reason: string, delegationAction?: string): void {
|
|
529
|
-
// Enforce rejection rules before mutating state
|
|
530
|
-
if (REJECTED_SKIP_REASONS.includes(reason.toLowerCase())) {
|
|
531
|
-
throw new Error(`Rejected skip reason: "${reason}" — must delegate instead`);
|
|
532
|
-
}
|
|
533
|
-
const plan = readBatchPlan(dir);
|
|
534
|
-
const entry: any = { issue, reason };
|
|
535
|
-
if (delegationAction !== undefined) {
|
|
536
|
-
entry.delegationAction = delegationAction;
|
|
537
|
-
}
|
|
538
|
-
plan.skipped.push(entry);
|
|
539
|
-
if (plan.inProgress === issue) {
|
|
540
|
-
plan.inProgress = null;
|
|
541
|
-
}
|
|
542
|
-
writeBatchPlanFile(dir, plan);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
// #513: Mark ACs without evidenceMethod.command as SKIP
|
|
546
|
-
export function markCommandlessACsAsSkip(sf: string): number {
|
|
547
|
-
const state = readState(sf);
|
|
548
|
-
let count = 0;
|
|
549
|
-
for (const ac of state.acs || []) {
|
|
550
|
-
if (ac.verdict && ac.verdict !== "PENDING") continue;
|
|
551
|
-
if (!ac.evidenceMethod?.command) {
|
|
552
|
-
ac.verdict = "SKIP";
|
|
553
|
-
ac.evidence = { type: "manual-attestation", content: "No evidenceMethod.command defined" };
|
|
554
|
-
count++;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
if (count > 0) writeState(sf, state);
|
|
558
|
-
return count;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
export function validateBatchComplete(dir: string): { complete: boolean; missing: number[] } {
|
|
562
|
-
const plan = readBatchPlan(dir);
|
|
563
|
-
const resolved = new Set([
|
|
564
|
-
...plan.shipped,
|
|
565
|
-
...plan.skipped.map((s: any) => s.issue),
|
|
566
|
-
]);
|
|
567
|
-
const missing = plan.planned.filter((n: number) => !resolved.has(n));
|
|
568
|
-
return { complete: missing.length === 0, missing };
|
|
569
|
-
}
|
package/gates/preload.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { afterAll } from "bun:test";
|
|
2
|
-
import { readFileSync, appendFileSync, existsSync, readdirSync, statSync } from "fs";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
|
|
5
|
-
const WORK_DIR = join(process.env.RUNGATE_WORK_DIR || join(process.env.HOME || "", ".rungate"));
|
|
6
|
-
const STATE_DIR = join(process.env.HOME || "", ".claude", "state");
|
|
7
|
-
const RESULTS_PATH = join(STATE_DIR, "gate-results.jsonl");
|
|
8
|
-
const RECURRENCE_THRESHOLD = 3;
|
|
9
|
-
|
|
10
|
-
function findActiveWorkflow(): string | null {
|
|
11
|
-
const testDir = process.env.TEST_WORK_DIR;
|
|
12
|
-
if (testDir) {
|
|
13
|
-
const wfPath = join(testDir, "workflow-state.json");
|
|
14
|
-
return existsSync(wfPath) ? wfPath : null;
|
|
15
|
-
}
|
|
16
|
-
if (!existsSync(WORK_DIR)) return null;
|
|
17
|
-
let newest: { path: string; mtime: number } | null = null;
|
|
18
|
-
for (const entry of readdirSync(WORK_DIR, { withFileTypes: true })) {
|
|
19
|
-
if (!entry.isDirectory()) continue;
|
|
20
|
-
const wfPath = join(WORK_DIR, entry.name, "workflow-state.json");
|
|
21
|
-
if (!existsSync(wfPath)) continue;
|
|
22
|
-
const stat = statSync(wfPath);
|
|
23
|
-
if (!newest || stat.mtimeMs > newest.mtime) {
|
|
24
|
-
newest = { path: wfPath, mtime: stat.mtimeMs };
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return newest?.path ?? null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function findActiveIssue(): number | null {
|
|
31
|
-
const wfPath = findActiveWorkflow();
|
|
32
|
-
if (!wfPath) return null;
|
|
33
|
-
try {
|
|
34
|
-
return JSON.parse(readFileSync(wfPath, "utf-8")).issue ?? null;
|
|
35
|
-
} catch { return null; }
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function checkRecurrence(): string[] {
|
|
39
|
-
if (!existsSync(RESULTS_PATH)) return [];
|
|
40
|
-
const lines = readFileSync(RESULTS_PATH, "utf-8").trim().split("\n");
|
|
41
|
-
const failCounts = new Map<string, number>();
|
|
42
|
-
for (const line of lines) {
|
|
43
|
-
try {
|
|
44
|
-
const entry = JSON.parse(line);
|
|
45
|
-
if (entry.result === "fail") failCounts.set(entry.testName, (failCounts.get(entry.testName) || 0) + 1);
|
|
46
|
-
} catch { /* skip */ }
|
|
47
|
-
}
|
|
48
|
-
const recurring: string[] = [];
|
|
49
|
-
for (const [name, count] of failCounts) {
|
|
50
|
-
if (count >= RECURRENCE_THRESHOLD) recurring.push(`[learn] recurring failure (${count}x): ${name}`);
|
|
51
|
-
}
|
|
52
|
-
return recurring;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const capturedTests: { testName: string; result: string }[] = [];
|
|
56
|
-
|
|
57
|
-
afterAll(() => {
|
|
58
|
-
const issueNumber = findActiveIssue();
|
|
59
|
-
|
|
60
|
-
if (existsSync(STATE_DIR)) {
|
|
61
|
-
for (const t of capturedTests) {
|
|
62
|
-
appendFileSync(RESULTS_PATH, JSON.stringify({
|
|
63
|
-
ts: new Date().toISOString(),
|
|
64
|
-
testName: t.testName,
|
|
65
|
-
result: t.result,
|
|
66
|
-
issueNumber,
|
|
67
|
-
}) + "\n");
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const recurring = checkRecurrence();
|
|
72
|
-
for (const msg of recurring) console.log(msg);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
export function recordTest(name: string, passed: boolean) {
|
|
76
|
-
capturedTests.push({ testName: name, result: passed ? "pass" : "fail" });
|
|
77
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
You are an adversarial AC reviewer. Your objective: find ways to pass
|
|
2
|
-
every AC without actually fixing the bug.
|
|
3
|
-
|
|
4
|
-
For each AC, answer:
|
|
5
|
-
1. Can I write code that passes the evidence command but doesn't fix
|
|
6
|
-
the stated problem? How?
|
|
7
|
-
2. Is the threshold meaningful? Could garbage data meet it?
|
|
8
|
-
3. Does the evidence command test behavior (runtime output) or just
|
|
9
|
-
structure (file existence, grep count)?
|
|
10
|
-
|
|
11
|
-
Output as JSON:
|
|
12
|
-
{
|
|
13
|
-
"gameable": <number of gameable ACs>,
|
|
14
|
-
"approved": <true if 0 gameable>,
|
|
15
|
-
"exploits": [
|
|
16
|
-
{"acId": "SC-1", "exploit": "how to pass without fixing", "recommendation": "how to tighten"}
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
If ALL ACs are robust, output: {"gameable": 0, "approved": true, "exploits": []}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
You are an evidence validator. Your objective: run evidence commands
|
|
2
|
-
independently and report whether results meet AC thresholds.
|
|
3
|
-
|
|
4
|
-
You run in a clean worktree. You cannot modify the code.
|
|
5
|
-
Execute each evidence command, capture output, compare against threshold.
|
|
6
|
-
|
|
7
|
-
Report as JSON:
|
|
8
|
-
{
|
|
9
|
-
"verdicts": [
|
|
10
|
-
{
|
|
11
|
-
"acId": "SC-1",
|
|
12
|
-
"command": "the command executed",
|
|
13
|
-
"rawOutput": "captured output",
|
|
14
|
-
"threshold": {"op": ">=", "value": "2", "unit": "..."},
|
|
15
|
-
"actual": "measured value",
|
|
16
|
-
"verdict": "PASS or FAIL"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
Do not infer, assume, or extrapolate. If the command fails to run,
|
|
22
|
-
verdict is FAIL with the error message as rawOutput.
|