-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecks.test.ts
More file actions
628 lines (574 loc) · 27.1 KB
/
Copy pathchecks.test.ts
File metadata and controls
628 lines (574 loc) · 27.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
import { expect, test } from "bun:test";
import { spawnSync } from "node:child_process";
import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { validateDocumentation } from "./docs";
import { REQUIRED_FILES, validateRepository } from "./sdlc";
const BUNDLE_ID = "2026-08-30-example";
const BUNDLE_DIR = `docs/sdlc/changes/${BUNDLE_ID}`;
test("one PR CI check retains validation while nightly packages main and releases remain manual", () => {
const directory = join(import.meta.dir, "../../.github/workflows");
const workflows = Object.fromEntries(readdirSync(directory).filter(name => name.endsWith(".yml")).map(name => [
name,
Bun.YAML.parse(readFileSync(join(directory, name), "utf8")) as {
on: Record<string, unknown>;
jobs: Record<string, { steps: { run?: string }[] }>;
},
]));
expect(Object.keys(workflows).filter(name => "pull_request" in workflows[name]!.on)).toEqual(["ci.yml"]);
const ci = workflows["ci.yml"]!;
expect(Object.keys(ci.jobs)).toEqual(["test"]);
const commands = ci.jobs.test!.steps.map(step => step.run ?? "").join("\n");
for (const command of [
"script/verify/checks.test.ts", "script/verify/four-stage.test.ts", "script/devflow.test.ts",
"bun script/verify/docs.ts", "bun script/devflow.ts check-pr", "bun script/verify/sdlc.ts",
"bun run check", "bunx tsc --noEmit", "bun run test:ci", "bun run mutation:taskboard", "bunx vite build",
]) expect(commands).toContain(command);
expect(commands).not.toContain("build:release");
for (const name of ["nightly-macos.yml", "windows-desktop.yml", "release-macos.yml"]) {
if (name !== "nightly-macos.yml") expect(workflows[name]!.on).not.toHaveProperty("push");
expect(workflows[name]!.on).not.toHaveProperty("pull_request");
expect(workflows[name]!.on).toHaveProperty("workflow_dispatch");
}
expect(workflows["nightly-macos.yml"]!.on).toHaveProperty("schedule");
expect(workflows["nightly-macos.yml"]!.on.push).toEqual({ branches: ["main"] });
});
function write(root: string, path: string, body: string): void {
const absolute = join(root, path);
mkdirSync(dirname(absolute), { recursive: true });
writeFileSync(absolute, body);
}
function temporaryRoot(prefix: string): string {
return mkdtempSync(join(tmpdir(), prefix));
}
function git(root: string, ...args: string[]): string {
const result = spawnSync("git", args, { cwd: root, encoding: "utf8" });
if (result.status !== 0) {
throw new Error(result.stderr.trim() || result.stdout.trim() || `git ${args.join(" ")} failed`);
}
return result.stdout.trim();
}
function stageSections(name: string): string {
const common = (heading: string, body: string) => `## ${heading}\n\n${body}\n\n`;
if (name === "intent") {
return [
common("Problem", "Real problem and desired outcome."),
common("Proposed outcome", "Observable improvement."),
common("Affected users and systems", "Repository maintainers."),
common("Constraints", "Keep scope narrow."),
common("Out of scope", "Product runtime."),
common("Success signals", "Checks pass."),
common("Open questions", "None."),
common("Decision", "Accepted for fixture."),
].join("");
}
if (name === "spec") {
return [
common("Requirements", "Observable behavior."),
common("User experience", "No user-facing change."),
common("Technical design", "Fixture only."),
common("Security and privacy", "Not applicable."),
common("Alternatives and non-goals", "None."),
common("Areas of concern", "None."),
common("Acceptance criteria", "- [x] AC-1: The observable result is checked by `example-check`."),
common("Decision", "Accepted for fixture."),
].join("");
}
if (name === "plan") {
return [
common("Files and ownership", "README.md"),
common("Order of work", "Implement and verify."),
common("Test-first proof", "`example-check`"),
common("Visual or integration proof", "Not applicable."),
common("Risks and mitigations", "Low risk."),
common("Rollback", "Revert diff."),
common("Deviations", "None."),
common("Decision", "Accepted for fixture."),
].join("");
}
return [
common("Automated checks", "- AC-1: PASS — `example-check` passed in the fixed fixture."),
common("Behavioral evidence", "The acceptance mapping is recorded under Automated checks."),
common("Visual evidence", "Not applicable."),
common("Security and privacy evidence", "Not applicable."),
common("Deviations and residual risk", "Residual risk: the check covers only the fixture."),
common("Verdict", "Verdict: verified."),
common(
"Review and release",
"Approval: product owner approved on 2026-08-30.\nRelease target: none.\nRelease identity: not applicable until released.\nSmoke evidence: not applicable until released.\nRollback: revert diff.\nNo release: fixture only.",
),
common("Feedback", "No feedback recorded yet."),
].join("");
}
function writeStageBundle(
root: string,
{
planAccepted = true,
verificationStatus = "passed",
scope = "README.md",
risk = "medium",
approver = "reviewer",
owner = "repository maintainers",
acPass = true,
releaseTarget = "none",
releaseApproval = "pending",
}: {
planAccepted?: boolean;
verificationStatus?: string;
scope?: string;
risk?: string;
approver?: string;
owner?: string;
acPass?: boolean;
releaseTarget?: string;
releaseApproval?: string;
} = {},
): void {
const accepted = planAccepted ? "accepted" : "draft";
const verificationBody = stageSections("verification")
.replaceAll(
"- AC-1: PASS — `example-check` passed in the fixed fixture.",
acPass
? "- AC-1: PASS — `example-check` passed in the fixed fixture."
: "- AC-1: BLOCKED — missing proof.",
)
.replace("Verdict: verified.", verificationStatus === "passed" ? "Verdict: verified." : "Verdict: pending.");
write(
root,
`${BUNDLE_DIR}/intent.md`,
`---\nid: "${BUNDLE_ID}"\nstage: intent\nschema: 3\nstatus: accepted\nowner: ${owner}\ncreated: 2026-08-30\nsource: user\nrisk: ${risk}\napproved_by: "${approver}"\napproved_at: "2026-08-30"\n---\n\n# Intent: Example\n\n${stageSections("intent")}`,
);
write(
root,
`${BUNDLE_DIR}/spec.md`,
`---\nid: "${BUNDLE_ID}"\nstage: spec\nschema: 3\nstatus: accepted\nowner: ${owner}\ncreated: 2026-08-30\nbased_on: intent.md\nrisk: ${risk}\napproved_by: "${approver}"\napproved_at: "2026-08-30"\n---\n\n# Spec: Example\n\n${stageSections("spec")}`,
);
write(
root,
`${BUNDLE_DIR}/plan.md`,
`---\nid: "${BUNDLE_ID}"\nstage: plan\nschema: 3\nstatus: ${accepted}\nowner: ${owner}\ncreated: 2026-08-30\nbased_on: spec.md\nrisk: ${risk}\nscope: ${scope}\napproved_by: "${planAccepted ? approver : ""}"\napproved_at: "${planAccepted ? "2026-08-30" : ""}"\n---\n\n# Plan: Example\n\n${stageSections("plan")}`,
);
write(
root,
`${BUNDLE_DIR}/verification.md`,
`---\nid: "${BUNDLE_ID}"\nstage: verification\nschema: 3\nstatus: ${verificationStatus}\nowner: ${owner}\ncreated: 2026-08-30\nbased_on: plan.md\ncommit: ""\nverification_mode: owner\nverified_by: "${verificationStatus === "passed" ? approver : ""}"\nverified_at: "${verificationStatus === "passed" ? "2026-08-30" : ""}"\nrelease_target: ${releaseTarget}\nrelease_identity: ""\n---\n\n# Verification: Example\n\n${verificationBody.replace("Approval: product owner approved on 2026-08-30.", `Approval: ${releaseApproval}.`)}`,
);
}
function sdlcRoot(): string {
const root = temporaryRoot("codetwo-sdlc-");
for (const path of REQUIRED_FILES) write(root, path, "# Contract\n");
writeStageBundle(root);
return root;
}
const EVAL = `---
id: eval-example-gate
kind: eval
status: active
owner: repository maintainers
approvers: repository maintainers
created: 2026-08-30
updated: 2026-08-30
source: real change fixture
inputs: fixed temporary repository
outputs: deterministic assertion result
next_trigger: lifecycle contract changes
---
# Example gate
## Provenance
Derived from the [example change](../changes/2026-08-30-example/intent.md).
## Fixed input and environment
Temporary Git repository at a fixed baseline.
## Allowed actions
Read the fixture and write only inside its temporary directory.
## Observable acceptance
The invalid fixture fails and the valid fixture passes.
## Scoring and failure classes
Exact process exit and error assertions.
## Last result
Result: pass.
Revision: fixture-v1.
Evidence: \`bun test script/verify/checks.test.ts\`.
`;
const INCIDENT = `---
id: incident-2026-08-30-example
kind: incident
status: resolved
owner: repository maintainers
approvers: repository maintainers
created: 2026-08-30
updated: 2026-08-30
source: deterministic alert fixture
inputs: alert and diagnostic evidence
outputs: recovery, follow-up change, and regression eval
next_trigger: follow-up change executes
---
# Example incident
## Detection and impact
A deterministic fixture alert detected the failure.
## Timeline
The fixture records detection and recovery order.
## Diagnosis
The fixture establishes the cause.
## Mitigation and recovery
Recovery verdict: recovered.
The recovery assertion passed.
## Follow-ups
Track the [follow-up change](../changes/2026-08-30-example/intent.md).
## Regression eval
Run the [gate Eval](../evals/example-gate.md).
`;
test("documentation Gate accepts the catalog and rejects unsafe drift", () => {
const root = temporaryRoot("codetwo-docs-");
try {
write(
root,
"docs/catalog.json",
`{"schema":1,"rules":[
{"classification":"catalog","authority":"current","paths":["docs/catalog.json"]},
{"classification":"contract","authority":"current","paths":["docs/reference/current.md"]},
{"classification":"change-record","authority":"historical-state","pattern":"^docs/sdlc/changes/.+/intent\\\\.md$"},
{"classification":"change-evidence","authority":"historical-evidence","pattern":"^docs/sdlc/changes/.+/evidence/"},
{"classification":"archive","authority":"historical-non-normative","pattern":"^docs/archive/"}
]}`,
);
write(root, "docs/reference/current.md", "# Current\n\n[Archive](../archive/README.md)\n");
write(root, "docs/archive/README.md", "# Archive\n");
write(
root,
"docs/sdlc/changes/2026-08-30-example/intent.md",
"---\nschema: 3\nstage: intent\n---\n\n\n",
);
write(root, "docs/sdlc/changes/2026-08-30-example/evidence/window.png", "fixture");
expect(validateDocumentation(root)).toEqual([]);
const skillPath = ".agents/skills/fixture/SKILL.md";
write(root, skillPath, "# Fixture\n\n[Current](../../../docs/reference/current.md)\n");
expect(validateDocumentation(root)).toEqual([]);
write(root, skillPath, "# Fixture\n\n[Missing reference](references/missing.md)\n");
expect(validateDocumentation(root).some(error => error.includes(".agents/skills/fixture/SKILL.md: broken local link"))).toBe(true);
write(root, "docs/reference/current.md", "# Current\n\n[Missing](missing.md)\n");
write(root, "docs/loose.md", "# Loose\n");
write(root, "docs/archive/orphan.png", "fixture");
write(root, "docs/sdlc/changes/2026-08-30-example/intent.md", "---\nstatus: accepted\n---\n");
const errors = validateDocumentation(root);
for (const fragment of ["unclassified", "broken local link", "unreferenced documentation image", "must use schema 3"]) {
expect(errors.some((error) => error.includes(fragment))).toBe(true);
}
} finally {
rmSync(root, { recursive: true, force: true });
}
});
test("SDLC Gate accepts complete stage bundles and rejects missing approval", () => {
const root = sdlcRoot();
try {
expect(validateRepository(root)).toEqual([]);
writeStageBundle(root, { acPass: false, verificationStatus: "passed" });
expect(validateRepository(root).some((error) => error.includes("requires PASS for AC-1"))).toBe(true);
writeStageBundle(root, { risk: "high", approver: "repository maintainers", owner: "repository maintainers" });
expect(validateRepository(root).some((error) => error.includes("approver other than"))).toBe(true);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
test("release, Incident, and Eval Gates fail closed on missing evidence", () => {
const root = sdlcRoot();
try {
writeStageBundle(root, { releaseTarget: "versioned macOS release", releaseApproval: "pending" });
expect(
validateRepository(root, undefined, BUNDLE_ID).some((error) => error.includes("release Approval")),
).toBe(true);
write(root, "docs/sdlc/incidents/2026-08-30-example.md", INCIDENT);
write(root, "docs/sdlc/evals/example-gate.md", EVAL);
writeStageBundle(root);
expect(validateRepository(root)).toEqual([]);
write(
root,
"docs/sdlc/incidents/2026-08-30-example.md",
INCIDENT.replace("../changes/2026-08-30-example/intent.md", "Follow-up pending."),
);
write(
root,
"docs/sdlc/evals/example-gate.md",
EVAL.replace("Result: pass.", "Result: pending."),
);
const evidenceErrors = validateRepository(root);
expect(evidenceErrors.some((error) => error.includes("linked follow-up change"))).toBe(true);
expect(evidenceErrors.some((error) => error.includes("requires Result pass"))).toBe(true);
write(
root,
"docs/sdlc/evals/example-gate.md",
EVAL.replace(
"Derived from the [example change](../changes/2026-08-30-example/intent.md).",
"Provenance pending.",
),
);
expect(
validateRepository(root).some((error) => error.includes("linked provenance")),
).toBe(true);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
test("committed branch Gate requires accepted plan scope", () => {
const root = sdlcRoot();
try {
git(root, "init", "-q");
git(root, "config", "user.name", "SDLC Test");
git(root, "config", "user.email", "sdlc-test@example.invalid");
git(root, "add", ".");
git(root, "commit", "-qm", "baseline");
const base = git(root, "rev-parse", "HEAD");
writeStageBundle(root, { scope: "README.md, fixture.txt" });
write(root, "notes.txt", "uncovered change\n");
git(root, "add", ".");
git(root, "commit", "-qm", "uncovered implementation");
expect(validateRepository(root, base).some((error) => error.includes("notes.txt: changed path is not covered"))).toBe(true);
writeStageBundle(root, { scope: "README.md, notes.txt" });
git(root, "add", `${BUNDLE_DIR}/plan.md`);
git(root, "commit", "-qm", "cover implementation");
expect(validateRepository(root, base)).toEqual([]);
write(
root,
`${BUNDLE_DIR}/intent.md`,
readFileSync(join(root, `${BUNDLE_DIR}/intent.md`), "utf8").replace("schema: 3", "schema: 2"),
);
git(root, "add", `${BUNDLE_DIR}/intent.md`);
git(root, "commit", "-qm", "remove schema");
expect(validateRepository(root, base).some((error) => error.includes("schema 3 is required"))).toBe(true);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
test("worktree Gate includes staged and untracked paths", () => {
const root = sdlcRoot();
try {
git(root, "init", "-q");
git(root, "config", "user.name", "SDLC Test");
git(root, "config", "user.email", "sdlc-test@example.invalid");
git(root, "add", ".");
git(root, "commit", "-qm", "baseline");
writeStageBundle(root, { scope: "README.md, fixture.txt" });
write(root, "README.md", "staged change\n");
git(root, "add", "README.md");
write(root, "notes.txt", "untracked change\n");
expect(
validateRepository(root, undefined, undefined, true).some((error) =>
error.includes("notes.txt: changed path is not covered"),
),
).toBe(true);
writeStageBundle(root, { scope: "README.md, notes.txt" });
expect(validateRepository(root, undefined, undefined, true)).toEqual([]);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
test("new changes cannot reuse an unchanged historical plan", () => {
for (const operation of ["edit", "delete", "rename"]) {
const root = sdlcRoot();
try {
writeStageBundle(root, { scope: "README.md, moved.md" });
write(root, "README.md", "baseline\n");
git(root, "init", "-q");
git(root, "config", "user.name", "SDLC Test");
git(root, "config", "user.email", "sdlc-test@example.invalid");
git(root, "add", ".");
git(root, "commit", "-qm", "baseline");
const base = git(root, "rev-parse", "HEAD");
if (operation === "edit") write(root, "README.md", "new implementation\n");
if (operation === "delete") rmSync(join(root, "README.md"));
if (operation === "rename") git(root, "mv", "README.md", "moved.md");
expect(validateRepository(root, undefined, undefined, true).some(e => e.includes("changed bundle"))).toBe(true);
git(root, "add", ".");
git(root, "commit", "-qm", operation);
expect(validateRepository(root, base).some(e => e.includes("changed bundle"))).toBe(true);
write(root, `${BUNDLE_DIR}/plan.md`, readFileSync(join(root, BUNDLE_DIR, "plan.md"), "utf8") + "\nReviewed this change.\n");
git(root, "add", ".");
git(root, "commit", "-qm", "update governing plan");
expect(validateRepository(root, base)).toEqual([]);
} finally {
rmSync(root, { recursive: true, force: true });
}
}
});
test("acceptance evidence cannot hide a conflicting or different duplicate", () => {
const root = sdlcRoot();
try {
const path = join(root, BUNDLE_DIR, "verification.md");
const original = readFileSync(path, "utf8");
for (const duplicate of [
"- AC-1: FAIL — `example-check` failed.",
"- AC-1: PASS — `different-check` passed.",
]) {
writeFileSync(path, original.replace("The acceptance mapping is recorded under Automated checks.", duplicate));
expect(validateRepository(root).some(e => e.includes("duplicate verification evidence AC-1"))).toBe(true);
}
writeFileSync(path, original.replace("The acceptance mapping is recorded under Automated checks.", "- AC-1: PASS — `example-check` passed in the fixed fixture."));
expect(validateRepository(root)).toEqual([]);
writeFileSync(path, original.replace("status: passed", "status: failed"));
expect(validateRepository(root).some(e => e.includes("FAIL mapping"))).toBe(true);
writeFileSync(path, original.replace("status: passed", "status: failed")
.replace("AC-1: PASS", "AC-1: FAIL").replace("Verdict: verified.", "Verdict: failed."));
expect(validateRepository(root)).toEqual([]);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
test("approved stages reject unfinished markers without rejecting ordinary words", () => {
const root = sdlcRoot();
try {
const path = join(root, BUNDLE_DIR, "intent.md");
const original = readFileSync(path, "utf8");
for (const marker of ["TODO", "TBD", "[fill]", "Finish later: TODO."]) {
writeFileSync(path, original.replace("Real problem and desired outcome.", marker));
expect(validateRepository(root).some(e => e.includes("cannot contain placeholders"))).toBe(true);
}
writeFileSync(path, original.replace("Real problem and desired outcome.", "Document Todoist and TODO_LIST behavior."));
expect(validateRepository(root)).toEqual([]);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
test("sequential draft stages validate without granting implementation or release", () => {
const root = sdlcRoot();
try {
const dir = join(root, BUNDLE_DIR);
const stages = ["intent", "spec", "plan", "verification"];
const original = stages.map(name => readFileSync(join(dir, `${name}.md`), "utf8"));
for (let last = 0; last < stages.length; last += 1) {
for (let i = 0; i < stages.length; i += 1) {
const path = join(dir, `${stages[i]}.md`);
if (i > last) rmSync(path, { force: true });
else writeFileSync(path, i === last
? original[i].replace(/status: (accepted|passed)/, `status: ${i === 3 ? "in-progress" : "in-review"}`)
: original[i]);
}
expect(validateRepository(root)).toEqual([]);
expect(validateRepository(root, undefined, BUNDLE_ID).some(e => e.includes("verification passed"))).toBe(true);
}
// A valid proposal can be reviewed, but cannot authorize a code edit.
writeFileSync(join(dir, "verification.md"), original[3].replace("status: passed", "status: pending"));
git(root, "init", "-q");
git(root, "config", "user.name", "SDLC Test");
git(root, "config", "user.email", "sdlc-test@example.invalid");
git(root, "add", ".");
git(root, "commit", "-qm", "baseline");
writeFileSync(join(dir, "plan.md"), original[2].replace("status: accepted", "status: in-review"));
rmSync(join(dir, "verification.md"));
expect(validateRepository(root, undefined, undefined, true)).toEqual([]);
write(root, "README.md", "implementation before plan acceptance");
expect(validateRepository(root, undefined, undefined, true).some(e => e.includes("changed bundle"))).toBe(true);
writeFileSync(join(dir, "plan.md"), original[2]);
rmSync(join(dir, "spec.md"));
expect(validateRepository(root).some(e => e.includes("requires preceding spec.md"))).toBe(true);
writeFileSync(join(dir, "spec.md"), original[1].replace("status: accepted", "status: draft"));
expect(validateRepository(root).some(e => e.includes("spec must be accepted"))).toBe(true);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
function compactRecord(status = "passed", risk = "medium"): string {
return `---
id: ${BUNDLE_ID}
schema: 4
status: ${status}
owner: implementer
created: 2026-09-08
source: current user task
risk: ${risk}
scope: README.md, moved.md
approved_by: requester
approved_at: 2026-09-08
approval_source: Requester asked to fix this bounded fixture.
next_trigger: Human review of verified local work.
revision: disposable worktree baseline
verification_mode: owner
verified_by: implementer
verified_at: 2026-09-08
release_target: none
---
# Compact fixture
## Intent
Fix the local fixture; preserve external-action authorization.
## Acceptance criteria
- [x] AC-1: Observable fixture result.
## Plan
Change README.md, check it, and revert the diff if needed.
## Verification
- AC-1: PASS — \`fixture-check\` passed in isolated temp directory.
Verdict: verified.
Residual risk: fixture proof only; no production effects.
## Review and release
Approval: pending.
Rollback: revert the fixture commit.
`;
}
function withCompact(check: (root: string, path: string) => void): void {
const root = sdlcRoot();
try {
rmSync(join(root, BUNDLE_DIR), { recursive: true });
write(root, `${BUNDLE_DIR}/change.md`, compactRecord());
check(root, join(root, BUNDLE_DIR, "change.md"));
} finally {
rmSync(root, { recursive: true, force: true });
}
}
test("single record preserves acceptance, authorization, independent design and release Gates", () => {
withCompact((root, path) => {
expect(validateRepository(root)).toEqual([]);
for (const [from, to, error] of [
["schema: 4", "schema: 2", "requires schema 4"],
["approved_by: requester", "approved_by: pending", "requires approved_by"],
["approval_source: Requester asked to fix this bounded fixture.", "approval_source: pending", "requires approval_source"],
["[x] AC-1", "[ ] AC-1", "checked AC-1"],
["AC-1: PASS", "AC-1: BLOCKED", "requires PASS"],
["revision: disposable worktree baseline", "revision:", "requires verified revision"],
["scope: README.md, moved.md", "scope: ../outside", "unsafe or broad"],
["scope: README.md, moved.md", "scope: pending", "explicit scope"],
["Verdict: verified.", "- AC-1: PASS — `fixture-check` passed in isolated temp directory.\nVerdict: verified.", "duplicate verification evidence"],
["Fix the local fixture;", "TODO", "cannot contain placeholders"],
]) {
writeFileSync(path, compactRecord().replace(from, to));
expect(validateRepository(root).some(e => e.includes(error))).toBe(true);
}
writeFileSync(path, compactRecord("passed", "high"));
expect(validateRepository(root).some(e => e.includes("independent design approval"))).toBe(true);
const high = compactRecord("passed", "high").replace("scope: README", "design_approved_by: human reviewer\ndesign_approved_at: 2026-09-08\ndesign_approval_source: Reviewer accepted this fixture design.\nscope: README");
writeFileSync(path, high);
expect(validateRepository(root).some(e => e.includes("independent verifier"))).toBe(true);
writeFileSync(path, high.replace("verified_by: implementer", "verified_by: independent reviewer"));
expect(validateRepository(root)).toEqual([]);
expect(validateRepository(root, undefined, BUNDLE_ID).some(e => e.includes("release_target"))).toBe(true);
const release = compactRecord().replace("release_target: none", "release_target: versioned macOS release");
writeFileSync(path, release);
expect(validateRepository(root, undefined, BUNDLE_ID).some(e => e.includes("release Approval"))).toBe(true);
writeFileSync(path, release.replace("Approval: pending.", "Approval: requester approved the fixture revision on 2026-09-08."));
expect(validateRepository(root, undefined, BUNDLE_ID)).toEqual([]);
write(root, `${BUNDLE_DIR}/intent.md`, "# Do not create a second authority\n");
expect(validateRepository(root).some(e => e.includes("do not mix"))).toBe(true);
});
});
test("single record branch and worktree Gates cover edits, deletions, renames, and Ready status", () => {
for (const operation of ["edit", "delete", "rename"]) withCompact((root, path) => {
write(root, "README.md", "baseline\n");
git(root, "init", "-q");
git(root, "config", "user.name", "Fixture");
git(root, "config", "user.email", "fixture@example.invalid");
git(root, "add", "."); git(root, "commit", "-qm", "baseline");
const base = git(root, "rev-parse", "HEAD");
if (operation === "edit") write(root, "README.md", "change\n");
if (operation === "delete") rmSync(join(root, "README.md"));
if (operation === "rename") git(root, "mv", "README.md", "moved.md");
expect(validateRepository(root, undefined, undefined, true).some(e => e.includes("changed bundle"))).toBe(true);
writeFileSync(path, compactRecord("in-progress") + "\nCurrent local change.\n");
expect(validateRepository(root, undefined, undefined, true)).toEqual([]);
git(root, "add", "."); git(root, "commit", "-qm", "implementation");
expect(validateRepository(root, base, undefined, false, true).some(e => e.includes("Ready PR"))).toBe(true);
writeFileSync(path, compactRecord().replace("scope: README.md, moved.md", "scope: unrelated.md"));
expect(validateRepository(root, undefined, undefined, true)).toEqual([]); // record-only local change
git(root, "add", "."); git(root, "commit", "-qm", "wrong scope");
expect(validateRepository(root, base).some(e => e.includes("not covered"))).toBe(true);
writeFileSync(path, compactRecord() + "\nCurrent local verification.\n");
git(root, "add", "."); git(root, "commit", "-qm", "verified scope");
expect(validateRepository(root, base, undefined, false, true)).toEqual([]);
});
});