rungate 0.2.0 → 0.2.1

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.
Files changed (164) hide show
  1. package/package.json +14 -3
  2. package/.claude/agents/aditi.md +0 -47
  3. package/.claude/agents/marcus.md +0 -50
  4. package/.claude/agents/quinn.md +0 -58
  5. package/.claude/agents/rook.md +0 -47
  6. package/.claude/agents/serena.md +0 -46
  7. package/.claude/rungate.json +0 -11
  8. package/.fallowrc.json +0 -28
  9. package/.github/copilot-instructions.md +0 -20
  10. package/.rungate/conformity-findings.json +0 -648
  11. package/AGENTS.md +0 -106
  12. package/CODE-MAP.md +0 -50
  13. package/HARNESS.md +0 -88
  14. package/bun.lock +0 -26
  15. package/bunfig.toml +0 -2
  16. package/config/brief-policies.json +0 -28
  17. package/config/ceremony-profiles.json +0 -212
  18. package/config/consumer-cascade-map.json +0 -24
  19. package/config/doc-cascade-map.json +0 -24
  20. package/config/eval.json +0 -84
  21. package/config/profiles/account-plan.yaml +0 -36
  22. package/config/profiles/campaign.yaml +0 -94
  23. package/config/prove-evidence.schema.json +0 -65
  24. package/config/spec-policies.json +0 -36
  25. package/config/workflow-schema.json +0 -281
  26. package/gates/SCHEMA-GUIDE.md +0 -121
  27. package/gates/ac-quality.test.ts +0 -106
  28. package/gates/adversarial.test.ts +0 -274
  29. package/gates/brief-assembler.test.ts +0 -429
  30. package/gates/brief-assembler.ts +0 -334
  31. package/gates/bunfig.toml +0 -2
  32. package/gates/chain.test.ts +0 -91
  33. package/gates/e2e-smoke.test.ts +0 -234
  34. package/gates/error-classifier.test.ts +0 -249
  35. package/gates/error-classifier.ts +0 -89
  36. package/gates/orchestrator.test.ts +0 -950
  37. package/gates/orchestrator.ts +0 -569
  38. package/gates/preload.ts +0 -77
  39. package/gates/prompts/ac-adversary.md +0 -20
  40. package/gates/prompts/evidence-validator.md +0 -22
  41. package/gates/prompts/prove-reproducer.md +0 -53
  42. package/gates/prove.test.ts +0 -164
  43. package/gates/run-gate.ts +0 -936
  44. package/gates/schema-parity.test.ts +0 -197
  45. package/gates/schema.ts +0 -362
  46. package/gates/self-heal.test.ts +0 -511
  47. package/gates/self-heal.ts +0 -121
  48. package/gates/ship-orchestrator.test.ts +0 -379
  49. package/gates/ship-orchestrator.ts +0 -363
  50. package/gates/test-fixtures/broken-no-environments.json +0 -60
  51. package/gates/test-fixtures/valid-standard.json +0 -54
  52. package/gates/test-utils.ts +0 -43
  53. package/gates/witness.ts +0 -220
  54. package/gates/workflow.test.ts +0 -1053
  55. package/hooks/AgentBriefGuard.hook.ts +0 -586
  56. package/hooks/AgentVerdictCapture.hook.ts +0 -134
  57. package/hooks/AutoVerifyGate.hook.ts +0 -76
  58. package/hooks/GateEnforcement.hook.ts +0 -273
  59. package/hooks/IssueCloseGuard.hook.ts +0 -116
  60. package/hooks/MergeGuard.hook.ts +0 -55
  61. package/hooks/StaleTTLCleanup.hook.ts +0 -133
  62. package/hooks/VerifyPhaseLock.hook.ts +0 -81
  63. package/hooks/WorkflowStateGuard.hook.ts +0 -37
  64. package/hooks/lib/agentDetection.ts +0 -70
  65. package/hooks/lib/findWorkflow.ts +0 -101
  66. package/hooks/lib/parseStdin.ts +0 -37
  67. package/hooks/lib/paths.ts +0 -111
  68. package/hooks/lib/utils.ts +0 -81
  69. package/reference/migration-manifest.json +0 -554
  70. package/reference/prompts/agent-aditi.md +0 -38
  71. package/reference/prompts/agent-marcus.md +0 -38
  72. package/reference/prompts/agent-quinn.md +0 -38
  73. package/reference/prompts/agent-rook.md +0 -37
  74. package/reference/prompts/agent-serena.md +0 -37
  75. package/reference/prompts/council-skill.md +0 -170
  76. package/reference/prompts/goal-skill.md +0 -235
  77. package/reference/prompts/prove-skill.md +0 -283
  78. package/reference/prompts/quinn-standard.md +0 -246
  79. package/reference/prompts/ship-convergence.md +0 -65
  80. package/reference/prompts/ship-escalation.md +0 -43
  81. package/reference/prompts/ship-iteration.md +0 -382
  82. package/reference/prompts/ship-pending-patches.md +0 -246
  83. package/reference/prompts/ship-reference.md +0 -250
  84. package/reference/prompts/ship-skill.md +0 -347
  85. package/reference/prompts/ship-templates.md +0 -215
  86. package/reference/scripts/batch-status.sh +0 -68
  87. package/reference/scripts/chain-compat-check.sh +0 -67
  88. package/reference/scripts/context-audit.sh +0 -314
  89. package/reference/scripts/dead-export-check.sh +0 -61
  90. package/reference/scripts/generate-qc-tables.sh +0 -92
  91. package/reference/scripts/harness-init.sh +0 -111
  92. package/reference/scripts/pai-054-baseline-check.sh +0 -40
  93. package/reference/scripts/prove-smoke-test.sh +0 -112
  94. package/reference/scripts/setup-keychain-salt.sh +0 -12
  95. package/reference/scripts/skill-optimizer-friday.sh +0 -88
  96. package/reference/scripts/skill-qc-test.sh +0 -351
  97. package/reference/scripts/skill-synthesize-tonight.sh +0 -66
  98. package/reference/specs/HARNESS-EXTRACTION-SPEC.md +0 -263
  99. package/reference/specs/harness-v3-bash-deletion-plan.md +0 -65
  100. package/reference/specs/harness-v3-migration-plan.md +0 -188
  101. package/scripts/decision-reconcile.sh +0 -74
  102. package/scripts/decision-reconcile.ts +0 -152
  103. package/scripts/git-hooks/pre-commit +0 -76
  104. package/scripts/git-hooks/pre-push +0 -271
  105. package/scripts/harness-skill-check.sh +0 -52
  106. package/scripts/lib/gap-emit.sh +0 -65
  107. package/scripts/lib/jq-update.sh +0 -30
  108. package/scripts/lib/resolve-slug.sh +0 -30
  109. package/scripts/lib/verify-spec-compliance.sh +0 -102
  110. package/scripts/prove-backfill.sh +0 -87
  111. package/scripts/scaffold-rungate-config.ts +0 -91
  112. package/scripts/self-containment-check.sh +0 -109
  113. package/scripts/skill-qc-validator.sh +0 -402
  114. package/scripts/slug-resolver.sh +0 -14
  115. package/specs/BOOTSTRAP-DATA-FLOW-SPEC.md +0 -2493
  116. package/specs/BOOTSTRAP-TEST-PLAN.md +0 -571
  117. package/specs/HARNESS-GATES.md +0 -256
  118. package/specs/HARNESS-SKILL-CHAIN.md +0 -286
  119. package/specs/HARNESS-SKILL-CONTRACT.md +0 -93
  120. package/specs/HARNESS-STANDARD.md +0 -488
  121. package/specs/SPEC-TEMPLATE.md +0 -53
  122. package/specs/bootstrap-data-flow.png +0 -0
  123. package/specs/harness-automation-matrix.md +0 -314
  124. package/specs/harness-automation-matrix.rules.json +0 -64
  125. package/test/anti.test.ts +0 -80
  126. package/test/contract-negative.test.ts +0 -86
  127. package/test/contract.test.ts +0 -158
  128. package/test/external-deps.test.ts +0 -48
  129. package/test/fixtures/golden-project/.env.example +0 -3
  130. package/test/fixtures/golden-project/Makefile +0 -7
  131. package/test/fixtures/golden-project/docs/adr/ADR-001-framework.md +0 -23
  132. package/test/fixtures/golden-project/docs/setup-guide.md +0 -10
  133. package/test/fixtures/golden-project/package.json +0 -10
  134. package/test/fixtures/golden-project/specs/api-spec.md +0 -20
  135. package/test/fixtures/golden-project/src/auth.ts +0 -8
  136. package/test/fixtures/golden-project/src/db.ts +0 -11
  137. package/test/fixtures/golden-project/src/index.ts +0 -19
  138. package/test/fixtures/golden-project/src/utils/format.ts +0 -3
  139. package/test/fixtures/golden-project/test/auth.test.ts +0 -15
  140. package/test/fixtures/golden-project/tsconfig.json +0 -12
  141. package/test/meta-sc-coverage.test.ts +0 -159
  142. package/test/phase-0.test.ts +0 -846
  143. package/test/phase-1.test.ts +0 -617
  144. package/test/phase-2.test.ts +0 -620
  145. package/test/phase-3.test.ts +0 -99
  146. package/test/scaffold-conformity.test.ts +0 -8
  147. package/test/schema-canary.test.ts +0 -51
  148. package/test/spec-compliance-auto.test.ts +0 -64
  149. package/test/spec-compliance.test.ts +0 -295
  150. package/test/spec-discovery.test.ts +0 -68
  151. package/test/spec-drift.test.ts +0 -5
  152. package/test/structure.test.ts +0 -165
  153. package/test/unit/agent-brief-guard-ship.test.ts +0 -293
  154. package/test/unit/extract-constraints.test.ts +0 -145
  155. package/test/unit/issue-close-guard.test.ts +0 -204
  156. package/test/unit/scaffold-project.test.ts +0 -417
  157. package/test/unit/skill-cooccurrence.test.ts +0 -177
  158. package/test/unit/skill-sequence-logger.test.ts +0 -244
  159. package/test/unit/workflow-state-guard.test.ts +0 -95
  160. package/workflows/batch-ship.js +0 -295
  161. package/workflows/council.js +0 -481
  162. package/workflows/prove.js +0 -560
  163. package/workflows/ship.js +0 -789
  164. package/workflows/verify.js +0 -236
@@ -1,197 +0,0 @@
1
- import { test, expect, describe } from "bun:test";
2
- import { readFileSync } from "fs";
3
- import { join } from "path";
4
- import { THRESHOLD_OPS, EVIDENCE_METHOD_TYPES } from "./schema";
5
- import { parseTestResults } from "./run-gate";
6
-
7
- const GATES_DIR = __dirname;
8
- const V2_SCHEMA_PATH = join(GATES_DIR, "..", "config", "workflow-schema.json");
9
- const V3_SCHEMA_PATH = join(GATES_DIR, "schema.ts");
10
-
11
- function extractJsonSchemaPaths(obj: any, prefix = ""): string[] {
12
- const paths: string[] = [];
13
- if (!obj || typeof obj !== "object") return paths;
14
-
15
- if (obj.properties) {
16
- for (const [key, val] of Object.entries(obj.properties)) {
17
- const path = prefix ? `${prefix}.${key}` : key;
18
- paths.push(path);
19
- if ((val as any).properties) {
20
- paths.push(...extractJsonSchemaPaths(val, path));
21
- }
22
- if ((val as any).items?.properties) {
23
- paths.push(...extractJsonSchemaPaths((val as any).items, `${path}[]`));
24
- }
25
- }
26
- }
27
- return paths;
28
- }
29
-
30
- function extractZodFields(source: string): string[] {
31
- const fields: string[] = [];
32
- const patterns = [
33
- /(\w+):\s*z\./g,
34
- /(\w+):\s*(?:Agent|Environment|GateResult|SourceSpec|Threshold|EvidenceMethod|Evidence|ContextFile|Changelog|PhaseTiming)/g,
35
- ];
36
- for (const p of patterns) {
37
- for (const m of source.matchAll(p)) {
38
- fields.push(m[1]);
39
- }
40
- }
41
- return [...new Set(fields)];
42
- }
43
-
44
- describe("schema parity: v2 JSON Schema vs v3 Zod", () => {
45
- const v2 = JSON.parse(readFileSync(V2_SCHEMA_PATH, "utf-8"));
46
- const v3Source = readFileSync(V3_SCHEMA_PATH, "utf-8");
47
-
48
- const v2Paths = extractJsonSchemaPaths(v2);
49
- const v3Fields = extractZodFields(v3Source);
50
-
51
- const V2_TOP_LEVEL = [
52
- "schemaVersion", "issue", "repo", "issueRepo", "projectRoot", "slug", "phase",
53
- "issueGoal", "sourceSpecs", "sizing", "acs", "agents", "environments", "gates",
54
- "daDirectEdits", "iterationCount", "startTs", "updatedTs", "phaseTimings",
55
- "gateContract", "changelog",
56
- ];
57
-
58
- for (const field of V2_TOP_LEVEL) {
59
- test(`v2 top-level field "${field}" exists in v3 Zod schema`, () => {
60
- expect(v3Source).toContain(field);
61
- });
62
- }
63
-
64
- const V2_SIZING = ["predicted", "ceremonyTier", "actualFiles", "actualMinutes"];
65
- for (const field of V2_SIZING) {
66
- test(`v2 sizing.${field} exists in v3`, () => {
67
- expect(v3Source).toContain(field);
68
- });
69
- }
70
-
71
- const V2_AC_FIELDS = ["id", "type", "statement", "specElement", "threshold", "evidenceMethod", "contextFiles", "evidence", "verdict"];
72
- for (const field of V2_AC_FIELDS) {
73
- test(`v2 acs[].${field} exists in v3 ACSchema`, () => {
74
- expect(v3Source).toContain(field);
75
- });
76
- }
77
-
78
- const V2_AGENT_FIELDS = ["spawned", "verdict", "branch", "iterations", "comparedToSpec", "screenshots", "findings"];
79
- for (const field of V2_AGENT_FIELDS) {
80
- test(`v2 agents.*.${field} exists in v3 AgentSchema`, () => {
81
- expect(v3Source).toContain(field);
82
- });
83
- }
84
-
85
- const V2_ENV_LOCAL = ["api", "apiSkipReason", "ui", "uiSkipReason", "tests"];
86
- for (const field of V2_ENV_LOCAL) {
87
- test(`v2 environments.local.${field} exists in v3`, () => {
88
- expect(v3Source).toContain(field);
89
- });
90
- }
91
-
92
- const V2_ENV_PROD = ["rebuild", "rebuildSkipReason", "smoke", "smokeSkipReason", "quinn", "quinnSkipReason", "quinnSpot", "quinnSpotSkipReason"];
93
- for (const field of V2_ENV_PROD) {
94
- test(`v2 environments.prod.${field} exists in v3`, () => {
95
- expect(v3Source).toContain(field);
96
- });
97
- }
98
-
99
- const V2_GATE = ["result", "attempt", "failures", "ts"];
100
- for (const field of V2_GATE) {
101
- test(`v2 gates.*.${field} exists in v3 GateResultSchema`, () => {
102
- expect(v3Source).toContain(field);
103
- });
104
- }
105
-
106
- const V2_EVIDENCE_METHOD_TYPES = ["GREP_CHECK", "FILE_EXISTS", "CURL_CHECK", "BUN_TEST", "SCREENSHOT", "PLAYWRIGHT", "COMMAND", "MANUAL"];
107
- for (const t of V2_EVIDENCE_METHOD_TYPES) {
108
- test(`v2 evidenceMethod.type "${t}" in v3 enum`, () => {
109
- expect(v3Source).toContain(t);
110
- });
111
- }
112
-
113
- const V2_THRESHOLD_OPS = ["==", ">=", "<=", ">", "<", "!=", "contains", "exists"];
114
- for (const op of V2_THRESHOLD_OPS) {
115
- test(`v2 threshold.op "${op}" in v3 enum`, () => {
116
- expect(v3Source).toContain(`"${op}"`);
117
- });
118
- }
119
-
120
- test("v2 phase CIRCUIT_BREAK in v3 enum", () => {
121
- expect(v3Source).toContain("CIRCUIT_BREAK");
122
- });
123
-
124
- test("v2 verdict PENDING in v3 ACSchema", () => {
125
- expect(v3Source).toContain("PENDING");
126
- });
127
-
128
- const V2_BASELINES = ["testBaseline", "tscBaseline"];
129
- for (const field of V2_BASELINES) {
130
- test(`v2 gateContract.baselines.${field} exists in v3`, () => {
131
- expect(v3Source).toContain(field);
132
- });
133
- }
134
-
135
- const V2_CHANGELOG = ["event", "detail", "actor"];
136
- for (const field of V2_CHANGELOG) {
137
- test(`v2 changelog[].${field} exists in v3`, () => {
138
- expect(v3Source).toContain(field);
139
- });
140
- }
141
-
142
- test("v2 phaseTimings entry fields in v3", () => {
143
- expect(v3Source).toContain("enteredTs");
144
- expect(v3Source).toContain("exitedTs");
145
- expect(v3Source).toContain("iteration");
146
- });
147
- });
148
-
149
- describe("GI-1: gate failure detail includes Zod error paths", () => {
150
- test("parseTestResults captures lines after (fail) as detail", () => {
151
- const bunOutput = [
152
- "(pass) schema validation > acs-exist: at least one AC",
153
- "(fail) schema validation > workflow-state.json validates (includes threshold + behavioral superRefine)",
154
- " acs.0.threshold.op: Invalid enum value. Expected '==' | '>=' | '<=' | '>' | '<' | '!=' | 'contains' | 'exists', received 'equals'",
155
- " acs.1.statement: AC-2: statement too short (3 words, min 5)",
156
- "(pass) scope checks > sizing-declared",
157
- ].join("\n");
158
- const results = parseTestResults(bunOutput);
159
- const fail = results.find(r => r.result === "FAIL");
160
- expect(fail).toBeTruthy();
161
- expect(fail!.detail).toContain("Invalid enum value");
162
- expect(fail!.detail).toContain("acs.0.threshold.op");
163
- expect(fail!.detail).not.toBe("failed");
164
- });
165
-
166
- test("parseTestResults falls back to 'failed' when no detail lines follow (fail)", () => {
167
- const bunOutput = [
168
- "(fail) some-check",
169
- "(pass) another-check",
170
- ].join("\n");
171
- const results = parseTestResults(bunOutput);
172
- const fail = results.find(r => r.result === "FAIL");
173
- expect(fail!.detail).toBe("failed");
174
- });
175
- });
176
-
177
- describe("GI-5: DISCOVERY_SCHEMA enum parity with schema.ts", () => {
178
- const shipSource = readFileSync(join(GATES_DIR, "..", "workflows", "ship.js"), "utf-8");
179
-
180
- test("DISCOVERY_SCHEMA threshold.op has enum matching THRESHOLD_OPS", () => {
181
- const opEnumMatch = shipSource.match(/op:\s*\{\s*type:\s*'string'\s*,\s*enum:\s*\[([^\]]+)\]/);
182
- expect(opEnumMatch, "threshold.op must have enum constraint in DISCOVERY_SCHEMA").toBeTruthy();
183
- const ops = opEnumMatch![1].split(",").map(s => s.trim().replace(/'/g, ""));
184
- expect(ops.sort()).toEqual([...THRESHOLD_OPS].sort());
185
- });
186
-
187
- test("DISCOVERY_SCHEMA evidenceMethod.type has enum matching EVIDENCE_METHOD_TYPES", () => {
188
- const discoveryBlock = shipSource.slice(
189
- shipSource.indexOf("const DISCOVERY_SCHEMA"),
190
- shipSource.indexOf("const DISCOVERY_SCHEMA") + 3000
191
- );
192
- const evidenceMethodMatch = discoveryBlock.match(/evidenceMethod:\s*\{[^}]*properties:\s*\{[^}]*type:\s*\{\s*type:\s*'string'\s*,\s*enum:\s*\[([^\]]+)\]/s);
193
- expect(evidenceMethodMatch, "evidenceMethod.type must have enum constraint in DISCOVERY_SCHEMA").toBeTruthy();
194
- const types = evidenceMethodMatch![1].split(",").map(s => s.trim().replace(/'/g, ""));
195
- expect(types.sort()).toEqual([...EVIDENCE_METHOD_TYPES].sort());
196
- });
197
- });
package/gates/schema.ts DELETED
@@ -1,362 +0,0 @@
1
- import { z } from "zod";
2
-
3
- const BEHAVIORAL_PATTERN = /\b(DA should|remember to|make sure to|don't forget)\b/i;
4
-
5
- const GARBAGE_PATTERNS = [
6
- /^file exists?$/i,
7
- /^it works?$/i,
8
- /^code is (?:correct|good|done|working)$/i,
9
- /^(?:the )?(?:feature|function|code|system) (?:works?|exists?|is (?:done|complete))$/i,
10
- /^no errors?$/i,
11
- /^tests? pass(?:es)?$/i,
12
- /^changes? (?:are )?(?:made|applied|done)$/i,
13
- ];
14
-
15
- export const THRESHOLD_OPS = ["==", ">=", "<=", ">", "<", "!=", "contains", "exists"] as const;
16
- export const EVIDENCE_METHOD_TYPES = ["GREP_CHECK", "FILE_EXISTS", "CURL_CHECK", "BUN_TEST", "SCREENSHOT", "PLAYWRIGHT", "COMMAND", "MANUAL", "grep", "command", "api", "screenshot", "manual"] as const;
17
-
18
- export const ThresholdSchema = z.object({
19
- op: z.enum(THRESHOLD_OPS),
20
- value: z.union([z.string(), z.number()]),
21
- unit: z.string().optional(),
22
- });
23
-
24
- export const EvidenceMethodSchema = z.object({
25
- type: z.enum(EVIDENCE_METHOD_TYPES),
26
- command: z.string().optional(),
27
- });
28
-
29
- export const EvidenceSchema = z.object({
30
- type: z.enum(["file-citation", "grep-output", "api-response", "screenshot", "test-output", "command-output", "manual-attestation"]),
31
- content: z.string().optional(),
32
- value: z.number().nullable().optional(),
33
- url: z.string().nullable().optional(),
34
- }).nullable().optional();
35
-
36
- export const ContextFileSchema = z.object({
37
- path: z.string(),
38
- lines: z.string().optional(),
39
- reason: z.string().optional(),
40
- });
41
-
42
- export const ACSchema = z.object({
43
- id: z.string(),
44
- type: z.enum(["CODE", "OUTCOME"]).optional(),
45
- statement: z.string(),
46
- specElement: z.string().optional(),
47
- threshold: ThresholdSchema.optional(),
48
- evidenceMethod: EvidenceMethodSchema.optional(),
49
- contextFiles: z.array(ContextFileSchema).optional(),
50
- evidence: EvidenceSchema,
51
- verdict: z.enum(["PENDING", "PASS", "FAIL", "SKIP"]).optional(),
52
- }).superRefine((ac, ctx) => {
53
- if (!ac.threshold) {
54
- ctx.addIssue({ code: z.ZodIssueCode.custom, message: `${ac.id}: missing threshold`, path: ["threshold"] });
55
- }
56
- if (BEHAVIORAL_PATTERN.test(ac.statement)) {
57
- ctx.addIssue({ code: z.ZodIssueCode.custom, message: `${ac.id}: behavioral language "${ac.statement.match(BEHAVIORAL_PATTERN)?.[0]}"`, path: ["statement"] });
58
- }
59
- // Heuristic: minimum statement length (5 words)
60
- const words = ac.statement.split(/\s+/).filter(Boolean);
61
- if (words.length < 5) {
62
- ctx.addIssue({
63
- code: z.ZodIssueCode.custom,
64
- message: `${ac.id}: statement too short (${words.length} words, min 5)`,
65
- path: ["statement"],
66
- });
67
- }
68
- // Heuristic: garbage/tautological statement detection
69
- for (const pattern of GARBAGE_PATTERNS) {
70
- if (pattern.test(ac.statement.trim())) {
71
- ctx.addIssue({
72
- code: z.ZodIssueCode.custom,
73
- message: `${ac.id}: tautological/garbage statement "${ac.statement}"`,
74
- path: ["statement"],
75
- });
76
- break;
77
- }
78
- }
79
- // Heuristic: weak threshold detection
80
- if (ac.threshold) {
81
- const numVal = Number(ac.threshold.value);
82
- if (ac.threshold.op === ">=" && !isNaN(numVal) && numVal <= 1) {
83
- ctx.addIssue({
84
- code: z.ZodIssueCode.custom,
85
- message: `${ac.id}: threshold too weak (${ac.threshold.op} ${ac.threshold.value}) — effectively always passes`,
86
- path: ["threshold"],
87
- });
88
- }
89
- }
90
- });
91
-
92
- export const SourceSpecSchema = z.object({
93
- path: z.string(),
94
- citedInDiscovery: z.boolean(),
95
- specElements: z.array(z.string()).optional(),
96
- });
97
-
98
- export const AgentSchema = z.object({
99
- spawned: z.boolean().optional(),
100
- verdict: z.enum(["PASS", "FAIL", "SKIP"]).nullable().optional(),
101
- branch: z.string().optional(),
102
- iterations: z.number().optional(),
103
- comparedToSpec: z.boolean().optional(),
104
- screenshots: z.array(z.string()).optional(),
105
- findings: z.string().nullable().optional(),
106
- testedSha: z.string().optional(),
107
- testedPaths: z.array(z.string()).optional(),
108
- port: z.number().optional(),
109
- }).optional();
110
-
111
- export const EnvironmentLocalSchema = z.object({
112
- api: z.enum(["PASS", "FAIL", "SKIP"]).nullable().optional(),
113
- apiSkipReason: z.string().optional(),
114
- ui: z.enum(["PASS", "FAIL", "SKIP"]).nullable().optional(),
115
- uiSkipReason: z.string().optional(),
116
- tests: z.enum(["PASS", "FAIL", "SKIP"]).nullable().optional(),
117
- quinn: z.object({
118
- port: z.number().optional(),
119
- }).optional(),
120
- }).optional();
121
-
122
- export const EnvironmentProdSchema = z.object({
123
- rebuild: z.enum(["PASS", "FAIL", "SKIP"]).nullable().optional(),
124
- rebuildSkipReason: z.string().nullable().optional(),
125
- smoke: z.enum(["PASS", "FAIL", "SKIP"]).nullable().optional(),
126
- smokeSkipReason: z.string().nullable().optional(),
127
- quinn: z.enum(["PASS", "FAIL", "SKIP"]).nullable().optional(),
128
- quinnSkipReason: z.string().nullable().optional(),
129
- quinnSpot: z.enum(["PASS", "FAIL", "SKIP"]).nullable().optional(),
130
- quinnSpotSkipReason: z.string().optional(),
131
- }).optional();
132
-
133
- export const GateResultSchema = z.object({
134
- result: z.enum(["PASS", "FAIL"]).nullable().optional(),
135
- attempt: z.number().optional(),
136
- failures: z.array(z.any()).optional(),
137
- ts: z.string().optional(),
138
- commitSha: z.string().optional(),
139
- }).optional();
140
-
141
- export const PhaseTimingEntry = z.object({
142
- enteredTs: z.string(),
143
- exitedTs: z.string().optional(),
144
- iteration: z.number().optional(),
145
- source: z.enum(["gate-runner", "DA"]),
146
- });
147
-
148
- export const ChangelogEntry = z.object({
149
- ts: z.string(),
150
- event: z.string(),
151
- detail: z.string().optional(),
152
- phase: z.string().optional(),
153
- actor: z.enum(["da", "marcus", "quinn", "rook", "gate-runner", "ship-workflow"]).optional(),
154
- });
155
-
156
- export const WorkflowStateSchema = z.object({
157
- schemaVersion: z.literal(2),
158
- issue: z.number(),
159
- repo: z.string().optional(),
160
- issueRepo: z.string().optional(),
161
- projectRoot: z.string().optional(),
162
- slug: z.string(),
163
- phase: z.enum(["GOAL", "DISCOVERY", "SCOPE", "BUILD", "VERIFY", "SHIP", "DONE", "CIRCUIT_BREAK"]),
164
- issueGoal: z.string().min(1, "issueGoal cannot be empty"),
165
-
166
- sourceSpecs: z.array(SourceSpecSchema).optional(),
167
-
168
- sizing: z.object({
169
- predicted: z.enum(["XS", "S", "M", "L"]).optional(),
170
- ceremonyTier: z.enum(["LIGHT", "STANDARD", "THOROUGH"]).optional(),
171
- actualFiles: z.number().optional(),
172
- actualMinutes: z.number().optional(),
173
- }).optional(),
174
-
175
- acs: z.array(ACSchema),
176
-
177
- governingSpec: z.object({
178
- path: z.string(),
179
- detectedFrom: z.string().optional(),
180
- }).optional(),
181
-
182
- agents: z.object({
183
- marcus: AgentSchema,
184
- quinn: AgentSchema,
185
- rook: AgentSchema,
186
- }).optional(),
187
-
188
- environments: z.object({
189
- local: EnvironmentLocalSchema,
190
- prod: EnvironmentProdSchema,
191
- }).optional(),
192
-
193
- gates: z.object({
194
- scope: GateResultSchema,
195
- verify: GateResultSchema,
196
- ship: GateResultSchema,
197
- }).optional(),
198
-
199
- daDirectEdits: z.number().optional(),
200
- iterationCount: z.number().optional(),
201
- startTs: z.string().optional(),
202
- updatedTs: z.string().optional(),
203
-
204
- phaseTimings: z.record(z.string(), z.array(PhaseTimingEntry)).optional(),
205
-
206
- gateContract: z.object({
207
- environments: z.any().optional(),
208
- verdicts: z.any().optional(),
209
- evidence: z.any().optional(),
210
- baselines: z.object({
211
- testBaseline: z.number().optional(),
212
- tscBaseline: z.number().optional(),
213
- }).optional(),
214
- }).optional(),
215
-
216
- changelog: z.array(ChangelogEntry).optional(),
217
-
218
- verifyBlockers: z.array(z.object({
219
- id: z.string(),
220
- description: z.string(),
221
- fixCommit: z.string().optional(),
222
- quinnReverified: z.boolean().default(false),
223
- })).optional(),
224
-
225
- bootstrappedFrom: z.string().optional(),
226
- beforeState: z.object({
227
- type: z.enum(["text", "screenshot", "api", "data", "none"]),
228
- path: z.string().nullable(),
229
- capturedAt: z.string(),
230
- description: z.string().optional(),
231
- }).optional(),
232
-
233
- issueType: z.enum(["feature", "bug-fix", "bug", "refactor", "chore"]).optional(),
234
- rca: z.object({
235
- rootCause: z.string().optional(),
236
- prediction: z.string().optional(),
237
- predictionVerified: z.boolean().optional(),
238
- }).optional(),
239
-
240
- blastRadius: z.object({
241
- filesRead: z.number(),
242
- filesChanged: z.number(),
243
- }).optional(),
244
-
245
- foundIssues: z.array(z.object({
246
- description: z.string(),
247
- disposition: z.enum(["fixed", "filed", "scoped-out"]).optional(),
248
- issueNumber: z.number().optional(),
249
- })).optional(),
250
-
251
- filesChangedOutsideBrief: z.array(z.string()).optional(),
252
-
253
- quinnJourneyPath: z.string().optional(),
254
-
255
- conformityFindings: z.any().optional(),
256
-
257
- preExistingFailures: z.array(z.string()).optional(),
258
-
259
- proofOfFix: z.object({
260
- commitSha: z.string(),
261
- verified: z.boolean(),
262
- }).optional(),
263
- });
264
-
265
- export type WorkflowState = z.infer<typeof WorkflowStateSchema>;
266
-
267
- // ── AFK batch plan schema (#468) ────────────────────────────
268
-
269
- const REJECTED_SKIP_REASONS = [
270
- "needs investigation",
271
- "needs browser testing",
272
- "can't do from here",
273
- ];
274
-
275
- export const AfkBatchPlanSchema = z.object({
276
- approvedAt: z.string(),
277
- planned: z.array(z.number()),
278
- shipped: z.array(z.number()),
279
- skipped: z.array(z.object({
280
- issue: z.number(),
281
- reason: z.string(),
282
- delegationAction: z.string().optional(),
283
- })),
284
- inProgress: z.number().nullable(),
285
- });
286
-
287
- export type AfkBatchPlan = z.infer<typeof AfkBatchPlanSchema>;
288
-
289
- export { REJECTED_SKIP_REASONS };
290
-
291
- // ── Adversary report schema (ADR-009 B1) ──────────────────────
292
-
293
- export const AdversaryReportSchema = z.object({
294
- gameable: z.number(),
295
- approved: z.boolean(),
296
- exploits: z.array(z.object({
297
- acId: z.string(),
298
- exploit: z.string(),
299
- recommendation: z.string(),
300
- })),
301
- });
302
-
303
- // ── Chain artifact schemas ──────────────────────────────────
304
-
305
- export const GoalRecordSchema = z.object({
306
- contractVersion: z.string(),
307
- id: z.string(),
308
- goalStatement: z.string().min(1),
309
- governingSpec: z.object({
310
- path: z.string(),
311
- detectedFrom: z.string().optional(),
312
- }).optional(),
313
- successCriteria: z.array(z.object({
314
- id: z.string(),
315
- assertion: z.string(),
316
- evidenceType: z.string(),
317
- threshold: z.object({ op: z.string(), value: z.string(), unit: z.string().optional() }),
318
- })),
319
- scopeBoundary: z.object({ in: z.array(z.string()), out: z.array(z.string()) }).optional(),
320
- artifactRef: z.object({ type: z.string(), locator: z.string() }).optional(),
321
- });
322
-
323
- export const ShipEvidenceSchema = z.object({
324
- contractVersion: z.string(),
325
- issueNumber: z.number(),
326
- gateOut: z.object({
327
- status: z.enum(["PASS", "FAIL"]),
328
- evidence: z.array(z.object({
329
- criterion: z.string(),
330
- result: z.enum(["PASS", "FAIL", "SKIP"]),
331
- detail: z.any().optional(),
332
- })),
333
- }),
334
- mergeCommitSha: z.string().optional(),
335
- capturedAt: z.string(),
336
- iterationCount: z.number().optional(),
337
- sizing: z.object({ predicted: z.string().optional(), actual: z.string().optional() }).optional(),
338
- });
339
-
340
- export const ProveEvidenceSchema = z.object({
341
- issueNumber: z.number(),
342
- verdict: z.enum(["PROVEN", "UNPROVEN", "INCONCLUSIVE"]),
343
- commitSHA: z.string(),
344
- capturedAt: z.string(),
345
- beforeEvidence: z.object({
346
- type: z.enum(["text", "screenshot", "api", "data", "none"]),
347
- path: z.string().nullable(),
348
- capturedAt: z.string(),
349
- description: z.string(),
350
- }),
351
- afterEvidence: z.object({
352
- type: z.enum(["text", "screenshot", "api", "data", "none"]),
353
- path: z.string().nullable(),
354
- capturedAt: z.string(),
355
- environment: z.enum(["local", "prod"]),
356
- description: z.string(),
357
- }),
358
- comparisonSummary: z.string(),
359
- quinnVerdict: z.enum(["PASS", "FAIL", "SKIP"]).optional(),
360
- reproduced: z.boolean(),
361
- gaps: z.array(z.object({ ac: z.string(), status: z.string(), detail: z.string() })).optional(),
362
- });