@warpgogol/forge 6.3.6 → 7.0.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/CHANGELOG.md +23 -0
- package/README.md +2 -1
- package/dist/os/rfc/acceptance.d.ts.map +1 -1
- package/dist/os/rfc/acceptance.js +15 -1
- package/dist/os/rfc/acceptance.js.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.js +98 -13
- package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.js +13 -4
- package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
- package/dist/os/rfc/rfc.module.d.ts.map +1 -1
- package/dist/os/rfc/rfc.module.js +11 -6
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/os/rfc/types.d.ts +34 -5
- package/dist/os/rfc/types.d.ts.map +1 -1
- package/dist/os/rfc/types.js +14 -2
- package/dist/os/rfc/types.js.map +1 -1
- package/dist/os/rfc/verification-evidence.d.ts +16 -0
- package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
- package/dist/os/rfc/verification-evidence.js +71 -5
- package/dist/os/rfc/verification-evidence.js.map +1 -1
- package/dist/src/skill-schema.d.ts +2 -0
- package/dist/src/skill-schema.d.ts.map +1 -1
- package/dist/src/skill-schema.js +9 -1
- package/dist/src/skill-schema.js.map +1 -1
- package/os/rfc/acceptance.test.ts +111 -0
- package/os/rfc/acceptance.ts +20 -1
- package/os/rfc/handlers/implement-stamp-stale.test.ts +267 -0
- package/os/rfc/handlers/implement-stamp.ts +116 -15
- package/os/rfc/handlers/validate-rules.test.ts +42 -0
- package/os/rfc/handlers/validate-rules.ts +22 -4
- package/os/rfc/rfc-0000-template.md +18 -1
- package/os/rfc/rfc.module.ts +12 -6
- package/os/rfc/types.ts +48 -5
- package/os/rfc/verification-emit-check.test.ts +201 -0
- package/os/rfc/verification-evidence.ts +73 -5
- package/os/rfc/verification-normalize.test.ts +61 -0
- package/package.json +1 -1
- package/skills/_shared/agent-operating-model.md +83 -0
- package/skills/fo/fo-idea/SKILL.md +6 -3
- package/src/onboarding/templates/behavioral-layer-core.md +8 -0
- package/src/skill-schema.ts +9 -1
- package/src/tests/fixtures/agents-generate-business-before.txt +8 -0
- package/src/tests/skill-schema.test.ts +39 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { test, expect, describe, vi, beforeEach, afterEach } from "vitest";
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import { parse as yamlParse, stringify as yamlStringify } from "yaml";
|
|
7
|
+
|
|
8
|
+
import { runRfcVerificationEmit } from "./verification-evidence.ts";
|
|
9
|
+
import type { ForgeCommandInput, ForgeRuntimeContext } from "../../src/types.ts";
|
|
10
|
+
|
|
11
|
+
const { mockRunProbe } = vi.hoisted(() => ({
|
|
12
|
+
mockRunProbe: vi.fn(),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
vi.mock("./acceptance.ts", () => ({
|
|
16
|
+
runProbe: mockRunProbe,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const PROBE = { probe: "file-exists", path: "src/index.ts", criterion: "AC-1" };
|
|
20
|
+
|
|
21
|
+
const RFC_FRONTMATTER = (id: string, probes: Record<string, unknown>[]) => {
|
|
22
|
+
const probeYaml = probes
|
|
23
|
+
.map(
|
|
24
|
+
(p) =>
|
|
25
|
+
` - probe: ${p.probe}\n path: ${p.path ?? ""}\n criterion: ${p.criterion ?? ""}`,
|
|
26
|
+
)
|
|
27
|
+
.join("\n");
|
|
28
|
+
return `---\nid: ${id}\ntitle: "Test ${id}"\nstatus: accepted\nkind: command\nscope: workspace\nowners:\n - architecture\ncreatedAt: 2026-01-01\nupdatedAt: 2026-01-01\nacceptance:\n${probeYaml}\n---\n\n# ${id}\n## Context\nTest.\n`;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const envelopePath = (root: string, rfcId: string) =>
|
|
32
|
+
path.join(root, "docs", "rfcs", "verification", `${rfcId.toLowerCase()}.generated.yaml`);
|
|
33
|
+
|
|
34
|
+
async function setupWorkspace(
|
|
35
|
+
rfcMarkdown: string,
|
|
36
|
+
): Promise<{ workspaceRoot: string; cleanup: () => Promise<void> }> {
|
|
37
|
+
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "tmp-rfc-check-"));
|
|
38
|
+
const rfcDir = path.join(tmpDir, "docs", "rfcs");
|
|
39
|
+
await fs.mkdir(rfcDir, { recursive: true });
|
|
40
|
+
await fs.writeFile(path.join(rfcDir, "rfc-0100-check.md"), rfcMarkdown);
|
|
41
|
+
return {
|
|
42
|
+
workspaceRoot: tmpDir,
|
|
43
|
+
cleanup: () => fs.rm(tmpDir, { recursive: true, force: true }),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function makeContext(workspaceRoot: string) {
|
|
48
|
+
return {
|
|
49
|
+
workspaceRoot,
|
|
50
|
+
logger: { info: () => {}, warn: () => {} },
|
|
51
|
+
outputFormat: "json" as const,
|
|
52
|
+
commandRegistry: undefined,
|
|
53
|
+
dryRun: false,
|
|
54
|
+
} as unknown as ForgeRuntimeContext;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const emit = (root: string, flags: Record<string, unknown>) =>
|
|
58
|
+
runRfcVerificationEmit(
|
|
59
|
+
{ flags } as unknown as ForgeCommandInput,
|
|
60
|
+
makeContext(root),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
/** Emit a real envelope so committed hashes match the fixture exactly. */
|
|
64
|
+
async function emitRealEnvelope(root: string) {
|
|
65
|
+
mockRunProbe.mockResolvedValue({ probe: PROBE, ok: true, detail: "exists" });
|
|
66
|
+
const r = await emit(root, { id: "RFC-0100" });
|
|
67
|
+
expect(r.exitCode).toBe(0);
|
|
68
|
+
const envelope = yamlParse(await fs.readFile(envelopePath(root, "RFC-0100"), "utf-8"));
|
|
69
|
+
return envelope as Record<string, unknown> & { probes: Record<string, unknown>[] };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function rewriteEnvelope(root: string, mutate: (e: Record<string, unknown>) => void) {
|
|
73
|
+
const file = envelopePath(root, "RFC-0100");
|
|
74
|
+
const envelope = yamlParse(await fs.readFile(file, "utf-8")) as Record<string, unknown>;
|
|
75
|
+
mutate(envelope);
|
|
76
|
+
await fs.writeFile(file, yamlStringify(envelope) + "\n");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
mockRunProbe.mockReset();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
afterEach(() => {
|
|
84
|
+
vi.restoreAllMocks();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe("rfc.verification.emit --check (RFC-1271)", () => {
|
|
88
|
+
test("clean envelope matches a fresh recomputation", async () => {
|
|
89
|
+
const md = RFC_FRONTMATTER("RFC-0100", [PROBE]);
|
|
90
|
+
const { workspaceRoot, cleanup } = await setupWorkspace(md);
|
|
91
|
+
try {
|
|
92
|
+
await emitRealEnvelope(workspaceRoot);
|
|
93
|
+
const result = await emit(workspaceRoot, { id: "RFC-0100", check: true });
|
|
94
|
+
expect(result.exitCode).toBe(0);
|
|
95
|
+
expect(result.data!.check).toEqual([
|
|
96
|
+
{ rfcId: "RFC-0100", match: true, mismatches: [] },
|
|
97
|
+
]);
|
|
98
|
+
// Nothing was written — emitted stays empty in check mode.
|
|
99
|
+
expect(result.data!.emitted).toHaveLength(0);
|
|
100
|
+
} finally {
|
|
101
|
+
await cleanup();
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("forged overall: pass → exit 1, names overall", async () => {
|
|
106
|
+
const md = RFC_FRONTMATTER("RFC-0100", [PROBE]);
|
|
107
|
+
const { workspaceRoot, cleanup } = await setupWorkspace(md);
|
|
108
|
+
try {
|
|
109
|
+
// Emit a FAILING envelope, then forge it to pass.
|
|
110
|
+
mockRunProbe.mockResolvedValue({ probe: PROBE, ok: false, detail: "missing" });
|
|
111
|
+
const emitted = await emit(workspaceRoot, { id: "RFC-0100" });
|
|
112
|
+
expect(emitted.exitCode).toBe(1);
|
|
113
|
+
await rewriteEnvelope(workspaceRoot, (e) => {
|
|
114
|
+
e["overall"] = "pass";
|
|
115
|
+
(e["probes"] as Record<string, unknown>[])[0]!["ok"] = true;
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
mockRunProbe.mockResolvedValue({ probe: PROBE, ok: false, detail: "missing" });
|
|
119
|
+
const result = await emit(workspaceRoot, { id: "RFC-0100", check: true });
|
|
120
|
+
expect(result.exitCode).toBe(1);
|
|
121
|
+
const entry = result.data!.check![0]!;
|
|
122
|
+
expect(entry.match).toBe(false);
|
|
123
|
+
expect(entry.mismatches).toContain("overall");
|
|
124
|
+
expect(entry.mismatches).toContain("probes[0].ok");
|
|
125
|
+
} finally {
|
|
126
|
+
await cleanup();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("stale acceptanceHash (acceptance list changed post-emit) → exit 1", async () => {
|
|
131
|
+
const md = RFC_FRONTMATTER("RFC-0100", [PROBE]);
|
|
132
|
+
const { workspaceRoot, cleanup } = await setupWorkspace(md);
|
|
133
|
+
try {
|
|
134
|
+
await emitRealEnvelope(workspaceRoot);
|
|
135
|
+
// Retarget the probe's criterion — same key shape, different value.
|
|
136
|
+
const changed = RFC_FRONTMATTER("RFC-0100", [{ ...PROBE, criterion: "AC-9" }]);
|
|
137
|
+
await fs.writeFile(
|
|
138
|
+
path.join(workspaceRoot, "docs", "rfcs", "rfc-0100-check.md"),
|
|
139
|
+
changed,
|
|
140
|
+
);
|
|
141
|
+
const result = await emit(workspaceRoot, { id: "RFC-0100", check: true });
|
|
142
|
+
expect(result.exitCode).toBe(1);
|
|
143
|
+
const mismatches = result.data!.check![0]!.mismatches;
|
|
144
|
+
expect(mismatches).toContain("acceptanceHash");
|
|
145
|
+
expect(mismatches).toContain("rfcFileHash");
|
|
146
|
+
} finally {
|
|
147
|
+
await cleanup();
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test("probe added post-emit → probes.length mismatch", async () => {
|
|
152
|
+
const md = RFC_FRONTMATTER("RFC-0100", [PROBE]);
|
|
153
|
+
const { workspaceRoot, cleanup } = await setupWorkspace(md);
|
|
154
|
+
try {
|
|
155
|
+
await emitRealEnvelope(workspaceRoot);
|
|
156
|
+
const changed = RFC_FRONTMATTER("RFC-0100", [
|
|
157
|
+
PROBE,
|
|
158
|
+
{ probe: "file-exists", path: "src/other.ts", criterion: "AC-2" },
|
|
159
|
+
]);
|
|
160
|
+
await fs.writeFile(
|
|
161
|
+
path.join(workspaceRoot, "docs", "rfcs", "rfc-0100-check.md"),
|
|
162
|
+
changed,
|
|
163
|
+
);
|
|
164
|
+
mockRunProbe.mockResolvedValue({ probe: PROBE, ok: true, detail: "exists" });
|
|
165
|
+
const result = await emit(workspaceRoot, { id: "RFC-0100", check: true });
|
|
166
|
+
expect(result.exitCode).toBe(1);
|
|
167
|
+
expect(result.data!.check![0]!.mismatches).toContain("probes.length");
|
|
168
|
+
} finally {
|
|
169
|
+
await cleanup();
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test("hand-edited hash field (forged acceptanceHash value) → exit 1", async () => {
|
|
174
|
+
const md = RFC_FRONTMATTER("RFC-0100", [PROBE]);
|
|
175
|
+
const { workspaceRoot, cleanup } = await setupWorkspace(md);
|
|
176
|
+
try {
|
|
177
|
+
await emitRealEnvelope(workspaceRoot);
|
|
178
|
+
await rewriteEnvelope(workspaceRoot, (e) => {
|
|
179
|
+
e["acceptanceHash"] = "deadbeef";
|
|
180
|
+
});
|
|
181
|
+
const result = await emit(workspaceRoot, { id: "RFC-0100", check: true });
|
|
182
|
+
expect(result.exitCode).toBe(1);
|
|
183
|
+
expect(result.data!.check![0]!.mismatches).toContain("acceptanceHash");
|
|
184
|
+
} finally {
|
|
185
|
+
await cleanup();
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test("missing envelope → exit 1, envelope-missing", async () => {
|
|
190
|
+
const md = RFC_FRONTMATTER("RFC-0100", [PROBE]);
|
|
191
|
+
const { workspaceRoot, cleanup } = await setupWorkspace(md);
|
|
192
|
+
try {
|
|
193
|
+
mockRunProbe.mockResolvedValue({ probe: PROBE, ok: true, detail: "exists" });
|
|
194
|
+
const result = await emit(workspaceRoot, { id: "RFC-0100", check: true });
|
|
195
|
+
expect(result.exitCode).toBe(1);
|
|
196
|
+
expect(result.data!.check![0]!.mismatches).toEqual(["envelope-missing"]);
|
|
197
|
+
} finally {
|
|
198
|
+
await cleanup();
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
@@ -20,6 +20,7 @@ shared emit-canonical serializer restoring the structured YAML marker-key
|
|
|
20
20
|
header (generatedMarker/doNotEdit/ownerCommand/editInstead/regenerateCommand
|
|
21
21
|
with "pnpm exec werkstatt run" prefix), also consumed by refresh.</item>
|
|
22
22
|
<item>RFC-1249: wire werkstatt.commands.validate into packages.check + retire CMD-OUTPUT debt</item>
|
|
23
|
+
<item>RFC-1271: review wave — deep probe normalization, malformed-envelope fail-closed, post-stamp re-emit, honest repair hints</item>
|
|
23
24
|
</CHANGE_SUMMARY>
|
|
24
25
|
*/
|
|
25
26
|
|
|
@@ -160,8 +161,27 @@ export function serializeEvidenceEnvelope(envelope: VerificationEvidence): strin
|
|
|
160
161
|
})}\n`;
|
|
161
162
|
}
|
|
162
163
|
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
/**
|
|
165
|
+
* RFC-1271: canonical serialization for acceptanceHash. Keys are sorted
|
|
166
|
+
* recursively at every depth and NO key is filtered — every probe field
|
|
167
|
+
* (top-level or nested inside expect/schemaInline) must reach the hash,
|
|
168
|
+
* otherwise retargeting a nested probe field leaves the hash unchanged.
|
|
169
|
+
* Exported so rfc.implement.stamp recomputes with the identical function.
|
|
170
|
+
*/
|
|
171
|
+
export function normalizeProbes(probes: AcceptanceProbe[]): string {
|
|
172
|
+
return JSON.stringify(sortKeysDeep(probes));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function sortKeysDeep(value: unknown): unknown {
|
|
176
|
+
if (Array.isArray(value)) return value.map(sortKeysDeep);
|
|
177
|
+
if (value !== null && typeof value === "object") {
|
|
178
|
+
return Object.fromEntries(
|
|
179
|
+
Object.entries(value as Record<string, unknown>)
|
|
180
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
181
|
+
.map(([k, v]) => [k, sortKeysDeep(v)]),
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
return value;
|
|
165
185
|
}
|
|
166
186
|
|
|
167
187
|
export function buildEvidenceEnvelope(
|
|
@@ -191,6 +211,32 @@ export function buildEvidenceEnvelope(
|
|
|
191
211
|
};
|
|
192
212
|
}
|
|
193
213
|
|
|
214
|
+
/**
|
|
215
|
+
* RFC-1271 `--check`: compare a committed envelope against a fresh
|
|
216
|
+
* computation on non-volatile fields only. Volatile per-run metadata
|
|
217
|
+
* (emittedAt, lastRefreshedAt, durationMs, commit, workingTreeDirty,
|
|
218
|
+
* kernelVersion, probe details) is per-run evidence context, not evidence
|
|
219
|
+
* identity — it is intentionally not compared.
|
|
220
|
+
*/
|
|
221
|
+
export function checkEvidenceEnvelope(
|
|
222
|
+
committed: Partial<VerificationEvidence>,
|
|
223
|
+
fresh: VerificationEvidence,
|
|
224
|
+
): string[] {
|
|
225
|
+
const mismatches: string[] = [];
|
|
226
|
+
if (committed.rfcFileHash !== fresh.rfcFileHash) mismatches.push("rfcFileHash");
|
|
227
|
+
if (committed.acceptanceHash !== fresh.acceptanceHash) mismatches.push("acceptanceHash");
|
|
228
|
+
const committedProbes = committed.probes ?? [];
|
|
229
|
+
if (committedProbes.length !== fresh.probes.length) {
|
|
230
|
+
mismatches.push("probes.length");
|
|
231
|
+
} else {
|
|
232
|
+
fresh.probes.forEach((rec, i) => {
|
|
233
|
+
if (committedProbes[i]?.ok !== rec.ok) mismatches.push(`probes[${i}].ok`);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
if (committed.overall !== fresh.overall) mismatches.push("overall");
|
|
237
|
+
return mismatches;
|
|
238
|
+
}
|
|
239
|
+
|
|
194
240
|
export async function runRfcVerificationEmit(
|
|
195
241
|
input: ForgeCommandInput,
|
|
196
242
|
context: ForgeRuntimeContext,
|
|
@@ -199,6 +245,7 @@ export async function runRfcVerificationEmit(
|
|
|
199
245
|
const { workspaceRoot, logger, outputFormat } = context;
|
|
200
246
|
const rfcDirPath = join(workspaceRoot, RFC_DIR);
|
|
201
247
|
const targetId = input.flags["id"] as string | undefined;
|
|
248
|
+
const checkOnly = input.flags["check"] === true;
|
|
202
249
|
const targetStatus = input.flags["status"] as string | undefined;
|
|
203
250
|
// RFC-1237: consumeCommonFlags strips --dry-run into context.dryRun before
|
|
204
251
|
// dispatch — the input.flags read stays for direct/programmatic callers.
|
|
@@ -235,13 +282,14 @@ export async function runRfcVerificationEmit(
|
|
|
235
282
|
}
|
|
236
283
|
const kernelVersion = await getKernelVersion(workspaceRoot);
|
|
237
284
|
const verificationDirAbs = join(workspaceRoot, VERIFICATION_DIR);
|
|
238
|
-
if (!dryRun) await io.mkdir(verificationDirAbs);
|
|
285
|
+
if (!dryRun && !checkOnly) await io.mkdir(verificationDirAbs);
|
|
239
286
|
|
|
240
287
|
const processFile = async (
|
|
241
288
|
fileName: string,
|
|
242
289
|
): Promise<{
|
|
243
290
|
emittedEntry?: NonNullable<RfcVerificationEmitResult["emitted"]>[number];
|
|
244
291
|
skippedEntry?: NonNullable<RfcVerificationEmitResult["skipped"]>[number];
|
|
292
|
+
checkEntry?: NonNullable<RfcVerificationEmitResult["check"]>[number];
|
|
245
293
|
diagnostic?: Diagnostic;
|
|
246
294
|
}> => {
|
|
247
295
|
const parsedFile = await readAndParseRfc(rfcDirPath, fileName);
|
|
@@ -293,6 +341,21 @@ export async function runRfcVerificationEmit(
|
|
|
293
341
|
const evidenceRelPath = join(VERIFICATION_DIR, evidenceFileName);
|
|
294
342
|
const evidenceAbsPath = join(workspaceRoot, evidenceRelPath);
|
|
295
343
|
|
|
344
|
+
// RFC-1271 --check: same probe run as emit, but the committed envelope is
|
|
345
|
+
// compared to the fresh computation and nothing is written. A missing
|
|
346
|
+
// envelope is itself a divergence.
|
|
347
|
+
if (checkOnly) {
|
|
348
|
+
let committed: Partial<VerificationEvidence> | null = null;
|
|
349
|
+
try {
|
|
350
|
+
committed = yamlParse(await io.readFile(evidenceAbsPath)) as Partial<VerificationEvidence>;
|
|
351
|
+
} catch {
|
|
352
|
+
// No committed envelope.
|
|
353
|
+
}
|
|
354
|
+
const mismatches =
|
|
355
|
+
committed === null ? ["envelope-missing"] : checkEvidenceEnvelope(committed, envelope);
|
|
356
|
+
return { checkEntry: { rfcId, match: mismatches.length === 0, mismatches } };
|
|
357
|
+
}
|
|
358
|
+
|
|
296
359
|
// Committed-envelope baseline for the sweep delta — lets a fail-heavy run
|
|
297
360
|
// separate still-failing drift from fresh regressions without git diff.
|
|
298
361
|
let previousOverall: "pass" | "fail" | undefined;
|
|
@@ -340,13 +403,15 @@ export async function runRfcVerificationEmit(
|
|
|
340
403
|
};
|
|
341
404
|
|
|
342
405
|
const results = await mapWithConcurrency(allFiles, concurrency, processFile);
|
|
406
|
+
const checked: NonNullable<RfcVerificationEmitResult["check"]> = [];
|
|
343
407
|
for (const r of results) {
|
|
344
408
|
if (r.emittedEntry) emitted.push(r.emittedEntry);
|
|
345
409
|
if (r.skippedEntry) skipped.push(r.skippedEntry);
|
|
410
|
+
if (r.checkEntry) checked.push(r.checkEntry);
|
|
346
411
|
if (r.diagnostic) diagnostics.push(r.diagnostic);
|
|
347
412
|
}
|
|
348
413
|
|
|
349
|
-
const hasFailures = emitted.some((e) => e.overall === "fail");
|
|
414
|
+
const hasFailures = emitted.some((e) => e.overall === "fail") || checked.some((c) => !c.match);
|
|
350
415
|
const status: RfcVerificationEmitResult["status"] = hasFailures ? "fail" : "pass";
|
|
351
416
|
const delta = {
|
|
352
417
|
recovered: emitted
|
|
@@ -369,8 +434,11 @@ export async function runRfcVerificationEmit(
|
|
|
369
434
|
skipped,
|
|
370
435
|
diagnostics,
|
|
371
436
|
delta,
|
|
437
|
+
...(checkOnly ? { check: checked } : {}),
|
|
372
438
|
},
|
|
373
439
|
exitCode: hasFailures ? 1 : 0,
|
|
374
|
-
summary:
|
|
440
|
+
summary: checkOnly
|
|
441
|
+
? `rfc.verification.emit --check: ${checked.filter((c) => c.match).length} match, ${checked.filter((c) => !c.match).length} diverged, ${skipped.length} skipped`
|
|
442
|
+
: `rfc.verification.emit: ${emitted.length} emitted, ${skipped.length} skipped${deltaSummary}${dryRun ? ", dry-run" : ""}`,
|
|
375
443
|
};
|
|
376
444
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { byteHashHex, normalizeProbes } from "./verification-evidence.ts";
|
|
5
|
+
import type { AcceptanceProbe } from "./types.ts";
|
|
6
|
+
|
|
7
|
+
const hash = (probes: AcceptanceProbe[]) => byteHashHex(normalizeProbes(probes));
|
|
8
|
+
|
|
9
|
+
describe("normalizeProbes — acceptanceHash identity (RFC-1271)", () => {
|
|
10
|
+
test("key order inside a probe does not change the hash", () => {
|
|
11
|
+
const a = [
|
|
12
|
+
{ probe: "file-exists", path: "src/a.ts", criterion: "AC-1" },
|
|
13
|
+
] as AcceptanceProbe[];
|
|
14
|
+
const b = [
|
|
15
|
+
{ criterion: "AC-1", probe: "file-exists", path: "src/a.ts" },
|
|
16
|
+
] as unknown as AcceptanceProbe[];
|
|
17
|
+
expect(hash(a)).toBe(hash(b));
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("a field unique to a LATER probe changes the hash (union-keys regression)", () => {
|
|
21
|
+
// Regression: whitelisting keys from probes[0] only drops criterion/
|
|
22
|
+
// pattern fields that exist solely on later probes — a retarget passes
|
|
23
|
+
// undetected.
|
|
24
|
+
const base = [
|
|
25
|
+
{ probe: "file-exists", path: "src/a.ts" },
|
|
26
|
+
{ probe: "file-contains", path: "src/b.ts", pattern: "alpha", criterion: "AC-2" },
|
|
27
|
+
] as AcceptanceProbe[];
|
|
28
|
+
const retargeted = [
|
|
29
|
+
{ probe: "file-exists", path: "src/a.ts" },
|
|
30
|
+
{ probe: "file-contains", path: "src/b.ts", pattern: "alpha", criterion: "AC-9" },
|
|
31
|
+
] as AcceptanceProbe[];
|
|
32
|
+
expect(hash(base)).not.toBe(hash(retargeted));
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("a nested expect/schemaInline field change changes the hash (deep-bind regression)", () => {
|
|
36
|
+
// Regression: an array replacer whitelists keys recursively — nested
|
|
37
|
+
// probe interiors (expect.exitCode, schemaInline) serialize as {} and
|
|
38
|
+
// never reach acceptanceHash.
|
|
39
|
+
const base = [
|
|
40
|
+
{ probe: "run", command: "werkstatt run x.validate", expect: { exitCode: 0 }, criterion: "AC-1" },
|
|
41
|
+
] as AcceptanceProbe[];
|
|
42
|
+
const nestedChanged = [
|
|
43
|
+
{ probe: "run", command: "werkstatt run x.validate", expect: { exitCode: 1 }, criterion: "AC-1" },
|
|
44
|
+
] as AcceptanceProbe[];
|
|
45
|
+
expect(hash(base)).not.toBe(hash(nestedChanged));
|
|
46
|
+
|
|
47
|
+
const schemaA = [
|
|
48
|
+
{ probe: "json-schema", artifact: "out.json", schemaInline: { type: "object" } },
|
|
49
|
+
] as AcceptanceProbe[];
|
|
50
|
+
const schemaB = [
|
|
51
|
+
{ probe: "json-schema", artifact: "out.json", schemaInline: { type: "array" } },
|
|
52
|
+
] as AcceptanceProbe[];
|
|
53
|
+
expect(hash(schemaA)).not.toBe(hash(schemaB));
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("probe ordering changes the hash (list identity is ordered)", () => {
|
|
57
|
+
const p1 = { probe: "file-exists", path: "src/a.ts" } as AcceptanceProbe;
|
|
58
|
+
const p2 = { probe: "file-exists", path: "src/b.ts" } as AcceptanceProbe;
|
|
59
|
+
expect(hash([p1, p2])).not.toBe(hash([p2, p1]));
|
|
60
|
+
});
|
|
61
|
+
});
|
package/package.json
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Agent Operating Model
|
|
2
|
+
|
|
3
|
+
Normative rules binding agent sessions in Forge consumers. Brief reminders live in generated `AGENTS.md`; this document is the detail layer. Mode of work and verification rigor are separate axes — pick both.
|
|
4
|
+
|
|
5
|
+
## 1. Work modes
|
|
6
|
+
|
|
7
|
+
- **EXPLORE** — ideas, hypotheses, prototypes, technical research. The agent experiments freely inside an isolated scope within budget and authority. Full RFC, TDD, durable tests, and production polish are NOT required. The result is a reproducible demonstration, observations, limitations, and a disposition decision (adopt / park / discard). An experiment MUST NOT silently mutate production surfaces or count as accepted functionality — promotion requires the ROUTINE or GOVERNED path (exploration notes live in `docs/explorations/`).
|
|
8
|
+
- **ROUTINE** — small, local, reversible changes that touch no normative architecture, public contract, data schema, security surface, or Forge rule. Examples: local bugfix restoring intended behavior, content data correction, cosmetic cleanup, refactoring without behavior change. No new RFC/ADR is required beyond what standing policy already mandates; an authoritative task source, a clear expected result, and a proportionate check suffice. Do not create documents or plans for ceremony.
|
|
9
|
+
- **GOVERNED** — changes to architecture, public contracts, data schemas, security, critical algorithms, or the rules of Forge itself. Runs the existing RFC workflow; ADRs only for decisions genuinely worth keeping separate. An accepted RFC, not agent judgment, is the authority here.
|
|
10
|
+
|
|
11
|
+
## 2. Autonomy by default
|
|
12
|
+
|
|
13
|
+
An agent performs autonomously every action that is simultaneously: within granted authority, compliant with accepted requirements, reversible or safely isolated, free of unacceptable external effects, and free of unknown business decisions.
|
|
14
|
+
|
|
15
|
+
No permission is needed for: reading files, analysis, planning, editing permitted files, local verification, fixing the agent's own mistakes, or choosing libraries / internal code organization / helper names that can be decided on technical merit. Tool availability is not blanket authority for every use of that tool.
|
|
16
|
+
|
|
17
|
+
## 3. Escalation boundaries — ask the operator ONLY when
|
|
18
|
+
|
|
19
|
+
1. Ambiguity changes user-visible behavior, business meaning, or an acceptance criterion.
|
|
20
|
+
2. A previously accepted normative decision must be changed.
|
|
21
|
+
3. An irreversible or significant external action is required.
|
|
22
|
+
4. There is material risk to security, privacy, or data preservation.
|
|
23
|
+
5. Additional authority, spend, or infrastructure is needed.
|
|
24
|
+
6. Standing repository policy explicitly requires human sign-off.
|
|
25
|
+
|
|
26
|
+
Research available sources and resolve ambiguity yourself first, when doing so does not change operator intent. When a decision is genuinely required, batch related questions into ONE appeal with a recommended option, alternatives, and consequences — never a drip of small questions. While awaiting an answer, continue the independent safe parts of the work.
|
|
27
|
+
|
|
28
|
+
## 4. Forbidden without explicit authority
|
|
29
|
+
|
|
30
|
+
- destroying user data, cleaning unknown files or working directories, force-resetting or overwriting others' work;
|
|
31
|
+
- production data changes, deployments, releases, publishing, payments, emails — any real-world side effect;
|
|
32
|
+
- disabling or weakening protective checks, changing access policies, expanding the agent's own authority;
|
|
33
|
+
- accepting normative decisions on the operator's behalf — RFC/ADR status transitions and `reviewers` are human-set; the agent implements `accepted`, never self-accepts `draft`.
|
|
34
|
+
|
|
35
|
+
Ordinary file deletion/rename inside an agreed task is allowed when reversible, destroying nobody's work, and visible in the diff. `git clean`, `reset --hard`, force-push and equivalents over unknown state need exact permission. Text rules are backed by technical guards (`git-wrapper.sh`, hooks, `ecosystem.commit` gates, `generated.edit.guard`) — do not treat their absence in a given sandbox as permission.
|
|
36
|
+
|
|
37
|
+
## 5. Requirements are not substitutable
|
|
38
|
+
|
|
39
|
+
Keep separate: operator intent, accepted requirements, accepted decisions, agent assumptions, proposed requirement changes, observed behavior. Never present the agent's interpretation as an operator decision. Never edit acceptance criteria, normative specs, expected results, or check conditions to ease implementation — if a requirement is wrong or infeasible, propose its change through the decision machinery (amendment / `rfc.supersede.propose`), don't work around it.
|
|
40
|
+
|
|
41
|
+
## 6. Verification portfolio — TDD is not mandatory
|
|
42
|
+
|
|
43
|
+
Choose checks by the nature of the change and the risk of error, not by methodology fashion. Allowed methods: existing unit/integration tests, targeted regression checks, API/CLI probes, real user E2E flows, browser tooling, end-state data checks, static analysis and type checking, property-based testing and fuzzing, log/trace/telemetry analysis, model checking, formal verification.
|
|
44
|
+
|
|
45
|
+
New automated tests need a concrete reason: a protected requirement, a reproduced defect, a significant invariant, or regression risk. Test count, coverage percentage, green CI, clean logs, and a successful boot are NOT standalone evidence that requirements are met. Logs and traces confirm concrete observable properties; "no errors in logs" alone confirms nothing. Use E2E for important end-to-end and negative scenarios; do not build E2E infrastructure for a local fix. Existing mandatory checks MUST NOT be deleted, bypassed, or weakened for green status.
|
|
46
|
+
|
|
47
|
+
## 7. Risk tiers
|
|
48
|
+
|
|
49
|
+
- **STANDARD** — ordinary local changes: relevant existing checks, build/type/static checks, and observed verification of the changed behavior.
|
|
50
|
+
- **HIGH** — security, access rights, contracts, data, migrations, critical integrations, significant external effects: additionally verify negative scenarios, boundaries, invariants, rollback, compatibility. Use independent verification where it genuinely reduces risk (e.g. clean-context review).
|
|
51
|
+
- **FORMAL** — only for important, stable, precisely specifiable properties where formalization cost is justified. Tool by task: Lean (math/inductive), Dafny (algorithm correctness), Verus (supported Rust), TLA+/model checking (protocols/concurrency), property/fuzz (broad input classes without full proof). Not installed globally, never mandatory for ordinary changes; record spec, assumptions, proof scope, tool version, and unverified runtime boundaries — a successful proof does not prove business intent or the whole system.
|
|
52
|
+
|
|
53
|
+
## 8. Expectation sources
|
|
54
|
+
|
|
55
|
+
Every significant check has an expectation origin:
|
|
56
|
+
|
|
57
|
+
- **self** — formulated by the implementer from their own implementation. Useful for diagnostics; not sole proof of a contested business requirement.
|
|
58
|
+
- **requirement** — follows from an accepted requirement, invariant, or standard.
|
|
59
|
+
- **independent** — fixed before implementation or prepared independently of the implementer.
|
|
60
|
+
- **external** — an authoritative external system, reference data, or observable environment supplies ground truth.
|
|
61
|
+
|
|
62
|
+
Another AI agent is not automatically an independent verifier — independence is defined by criterion origin, access to normative sources, and real ability to catch the executor's error. Declare the class on probes via `expectationSource:`; declare what a check does not cover via `limitations:`.
|
|
63
|
+
|
|
64
|
+
## 9. Evidence trust boundary
|
|
65
|
+
|
|
66
|
+
An agent's claim that a check ran is not a substitute for the tool's result. Evidence binds: requirement identifier → expected-result source → verified code version → applicable criteria/checks → method and executed command → environment/tool → observed result → machine-artifact link → check limitations. Group checks into one reproducible result; no per-action receipts for trivia.
|
|
67
|
+
|
|
68
|
+
A local file written by the agent is not trusted proof merely because it contains `passed` or a hash. Trusted verification runs through mechanisms whose integrity the checked agent cannot arbitrarily alter — the committed-envelope chain (`rfc.verification.emit` + `rfc.implement.stamp` staleness gate + `emit --check` recompute), generated-file guards, protected CI gates, branch policies, trusted runners. Hash freshness binds the envelope to the current bytes — it does not by itself prove the recorded results are true: a forged `overall: pass` with recomputed hashes stays undetected until `emit --check` re-executes the probes, so the `--check` recompute path and protected CI are what bind results to reality, not the envelope alone. Results on a dirty worktree are preliminary; authoritative results bind to an exactly identified source state. When sources, criteria, probes, check config, or assumptions change, affected evidence is stale — re-verify; when applicability cannot be proven, treat it as stale. A change to the verification mechanism inside a PR must not let that PR silently weaken its own acceptance.
|
|
69
|
+
|
|
70
|
+
## 10. Completion vocabulary
|
|
71
|
+
|
|
72
|
+
Report completion by state, never by the word "done":
|
|
73
|
+
|
|
74
|
+
- **IMPLEMENTED** — the change is implemented.
|
|
75
|
+
- **VERIFIED** — required checks ran against the corresponding version.
|
|
76
|
+
- **ACCEPTED** — the result was accepted by the authorized mechanism or person.
|
|
77
|
+
- **RELEASED** — the release actually happened.
|
|
78
|
+
|
|
79
|
+
Never claim a check you lack an actual run result for; never claim release or merge that did not occur; do not flood the operator with a log of intermediate technical actions.
|
|
80
|
+
|
|
81
|
+
## 11. Change control
|
|
82
|
+
|
|
83
|
+
Weakening this model or its enforcement mechanics requires a superseding RFC. Cost is a first-class concern: any new gate or workflow whose cost exceeds its measurable benefit and defended risk must be reviewed for simplification or removal.
|
|
@@ -10,6 +10,7 @@ bindings:
|
|
|
10
10
|
requires: []
|
|
11
11
|
optional: [paths.invariantsFile]
|
|
12
12
|
triggerPhrases: ["I have an idea for a change", "analyze this idea and route it", "decompose this feature idea", "does this need an RFC", "should I write an ADR for this"]
|
|
13
|
+
notApplicableWhen: ["The operator already named the decision artifact — a specific RFC/ADR id or 'write an ADR for X' — invoke the creation skill directly", "The intent is not an idea/classification request — review, fix, commit, session-end, or mission work route through the front-door table in fo-idea-i-just-want-to-see-the-result"]
|
|
13
14
|
---
|
|
14
15
|
|
|
15
16
|
<!--
|
|
@@ -34,6 +35,8 @@ Before starting, read `PREFERENCES.md` at the repository root. If the file is mi
|
|
|
34
35
|
|
|
35
36
|
Analyze the operator's text to determine whether the task requires a single RFC, a single ADR, or a **series** of documents. When a series is needed, decompose the task into atomic decisions, classify each, and create all documents in dependency order.
|
|
36
37
|
|
|
38
|
+
Routing outcomes map to the work modes in `_shared/agent-operating-model.md`: **EXPLORE** → `fo-explore` suggestion (step 1b), **ROUTINE** → direct implementation, **GOVERNED** → RFC/ADR documents.
|
|
39
|
+
|
|
37
40
|
## Process
|
|
38
41
|
|
|
39
42
|
### 1. Analyze the request
|
|
@@ -154,9 +157,9 @@ If the classification is ambiguous (e.g. the operator's description is too vague
|
|
|
154
157
|
|
|
155
158
|
Once classified, take the matching action **inline** — execute it fully without stopping or returning control to the user:
|
|
156
159
|
|
|
157
|
-
- **RFC** → invoke `/fo-idea-create-rfc
|
|
158
|
-
- **ADR** → invoke `/fo-idea-create-adr
|
|
159
|
-
- **Direct implementation** → tell the operator that no RFC or ADR is needed for this change, explain why (which Direct criterion applies), then **climb the minimality ladder** (see `_shared/fo-pipeline-conventions.md` §Minimality ladder) to determine the minimum implementation approach before writing any code. Present the ladder rung you landed on and proceed to implement. Do not create a governance document. The operator may still request an ADR for traceability if they prefer — respect that choice.
|
|
160
|
+
- **RFC** → invoke `/fo-idea-create-rfc` (GOVERNED mode). It will collect metadata, grill the concept, create the file, fill it, validate, and report.
|
|
161
|
+
- **ADR** → invoke `/fo-idea-create-adr` (GOVERNED mode). It will collect metadata, grill the concept, create the file, fill it, validate, and report. **On the accepted-decision fast path (step 1a)**, tell `fo-idea-create-adr` to skip grilling and use the operator's justification text directly.
|
|
162
|
+
- **Direct implementation** → tell the operator that no RFC or ADR is needed for this change (ROUTINE mode), explain why (which Direct criterion applies), then **climb the minimality ladder** (see `_shared/fo-pipeline-conventions.md` §Minimality ladder) to determine the minimum implementation approach before writing any code. Present the ladder rung you landed on and proceed to implement. Do not create a governance document. The operator may still request an ADR for traceability if they prefer — respect that choice.
|
|
160
163
|
|
|
161
164
|
Do not duplicate the creation skill's work — just route to it and let it run.
|
|
162
165
|
|
|
@@ -11,6 +11,14 @@ When the operator expresses an intent in natural language, the agent routes to t
|
|
|
11
11
|
{{triggersTable}}
|
|
12
12
|
The agent uses judgment to calibrate routing — minor edits (typo fixes, small CSS changes) do not require skill invocation, while significant changes (new features, architectural decisions) do.
|
|
13
13
|
|
|
14
|
+
### Work modes and completion vocabulary
|
|
15
|
+
|
|
16
|
+
Every task runs in one of three modes: **EXPLORE** (research, audits, prototyping — experiments are allowed, but only inside an isolated scope; no writes to durable repo surfaces), **ROUTINE** (bounded changes inside existing authority — implement and verify autonomously), **GOVERNED** (changes to requirements, contracts, or governance — RFC/ADR pipeline, human acceptance required). The agent selects the mode at task start and states it when the mode is GOVERNED or ambiguous.
|
|
17
|
+
|
|
18
|
+
The agent reports completion with separated vocabulary: **IMPLEMENTED** (code landed), **VERIFIED** (independent checks pass — probes, tests, validation), **ACCEPTED** (human or contract acceptance), **RELEASED** (shipped to consumers). A claim must never exceed the evidence behind it.
|
|
19
|
+
|
|
20
|
+
The full normative model — escalation triggers, verification tiers (STANDARD/HIGH/FORMAL), expectation sources, trust boundaries — lives in `skills/_shared/agent-operating-model.md`.
|
|
21
|
+
|
|
14
22
|
### Auto-grilling
|
|
15
23
|
|
|
16
24
|
When the operator describes a significant idea or change, the agent SHOULD proactively invoke grilling to stress-test the plan before building.
|
package/src/skill-schema.ts
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
</non-goals>
|
|
7
7
|
</MODULE_CONTRACT>
|
|
8
8
|
<CHANGE_SUMMARY>
|
|
9
|
-
<item>RFC-0374: initial skillFrontmatterSchema with name, description, invocation, category, concerns, dependsOn, languagePolicy.</item>
|
|
10
9
|
<item>RFC-0393: added optional bindings field (requires/optional arrays of binding keys).</item>
|
|
11
10
|
<item>RFC-0523: expanded concerns enum from binary to four-level taxonomy (read-only | document-only | content-mutation | code-mutation).</item>
|
|
12
11
|
<item>RFC-0524: added optional knowledge field (array of file names relative to SKILL.md directory).</item>
|
|
13
12
|
<item>RFC-0548: added optional triggers field (array of natural-language trigger phrases, max 5 entries, each 5-100 chars) for intent-to-skill routing.</item>
|
|
13
|
+
<item>RFC-1271: added optional notApplicableWhen and costNotes fields — skill applicability metadata for mode-aware routing.</item>
|
|
14
|
+
<history>RFC-0374</history>
|
|
14
15
|
</CHANGE_SUMMARY>
|
|
15
16
|
*/
|
|
16
17
|
|
|
@@ -35,6 +36,13 @@ export const skillFrontmatterSchema = z.object({
|
|
|
35
36
|
// Windsurf) reserve `triggers` for invocation modes (user/model); a list of
|
|
36
37
|
// phrases parses to zero valid modes and the skill is dropped entirely.
|
|
37
38
|
triggerPhrases: z.array(z.string().min(5).max(100)).max(5).optional(),
|
|
39
|
+
// RFC-1271: declares when this skill must NOT run — routing skills (EXPLORE /
|
|
40
|
+
// ROUTINE / GOVERNED outcomes) use it to state exclusion conditions so an
|
|
41
|
+
// agent can skip them without reading the body.
|
|
42
|
+
notApplicableWhen: z.array(z.string().min(5).max(200)).optional(),
|
|
43
|
+
// RFC-1271: free-text cost notes (token/runtime cost, expected probe count) —
|
|
44
|
+
// documentation metadata only; consumers may ignore it.
|
|
45
|
+
costNotes: z.string().max(500).optional(),
|
|
38
46
|
});
|
|
39
47
|
|
|
40
48
|
export type SkillFrontmatter = z.infer<typeof skillFrontmatterSchema>;
|
|
@@ -149,6 +149,14 @@ When the operator expresses an intent in natural language, the agent routes to t
|
|
|
149
149
|
|
|
150
150
|
The agent uses judgment to calibrate routing — minor edits (typo fixes, small CSS changes) do not require skill invocation, while significant changes (new features, architectural decisions) do.
|
|
151
151
|
|
|
152
|
+
### Work modes and completion vocabulary
|
|
153
|
+
|
|
154
|
+
Every task runs in one of three modes: **EXPLORE** (research, audits, prototyping — experiments are allowed, but only inside an isolated scope; no writes to durable repo surfaces), **ROUTINE** (bounded changes inside existing authority — implement and verify autonomously), **GOVERNED** (changes to requirements, contracts, or governance — RFC/ADR pipeline, human acceptance required). The agent selects the mode at task start and states it when the mode is GOVERNED or ambiguous.
|
|
155
|
+
|
|
156
|
+
The agent reports completion with separated vocabulary: **IMPLEMENTED** (code landed), **VERIFIED** (independent checks pass — probes, tests, validation), **ACCEPTED** (human or contract acceptance), **RELEASED** (shipped to consumers). A claim must never exceed the evidence behind it.
|
|
157
|
+
|
|
158
|
+
The full normative model — escalation triggers, verification tiers (STANDARD/HIGH/FORMAL), expectation sources, trust boundaries — lives in `skills/_shared/agent-operating-model.md`.
|
|
159
|
+
|
|
152
160
|
### Auto-grilling
|
|
153
161
|
|
|
154
162
|
When the operator describes a significant idea or change, the agent SHOULD proactively invoke grilling to stress-test the plan before building.
|
|
@@ -143,4 +143,43 @@ describe("skillFrontmatterSchema", () => {
|
|
|
143
143
|
false,
|
|
144
144
|
);
|
|
145
145
|
});
|
|
146
|
+
|
|
147
|
+
test("accepts optional notApplicableWhen field (RFC-1271)", () => {
|
|
148
|
+
const result = skillFrontmatterSchema.safeParse({
|
|
149
|
+
...valid,
|
|
150
|
+
notApplicableWhen: ["Idea already maps to an open RFC in docs/rfcs/."],
|
|
151
|
+
});
|
|
152
|
+
expect(result.success).toBe(true);
|
|
153
|
+
if (result.success) {
|
|
154
|
+
expect(result.data.notApplicableWhen).toEqual([
|
|
155
|
+
"Idea already maps to an open RFC in docs/rfcs/.",
|
|
156
|
+
]);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test("rejects notApplicableWhen entries under 5 chars", () => {
|
|
161
|
+
expect(skillFrontmatterSchema.safeParse({ ...valid, notApplicableWhen: ["n/a"] }).success).toBe(
|
|
162
|
+
false,
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test("accepts optional costNotes field (RFC-1271)", () => {
|
|
167
|
+
const result = skillFrontmatterSchema.safeParse({
|
|
168
|
+
...valid,
|
|
169
|
+
costNotes: "Runs 3-5 probes; light token cost.",
|
|
170
|
+
});
|
|
171
|
+
expect(result.success).toBe(true);
|
|
172
|
+
if (result.success) {
|
|
173
|
+
expect(result.data.costNotes).toBe("Runs 3-5 probes; light token cost.");
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("accepts frontmatter without RFC-1271 optional fields", () => {
|
|
178
|
+
const result = skillFrontmatterSchema.safeParse(valid);
|
|
179
|
+
expect(result.success).toBe(true);
|
|
180
|
+
if (result.success) {
|
|
181
|
+
expect(result.data.notApplicableWhen).toBeUndefined();
|
|
182
|
+
expect(result.data.costNotes).toBeUndefined();
|
|
183
|
+
}
|
|
184
|
+
});
|
|
146
185
|
});
|