@warpgogol/forge 9.7.1 → 10.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/AGENTS.md +50 -27
- package/CHANGELOG.md +27 -0
- package/bin/cli.js +0 -0
- package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts.map +1 -1
- package/dist/os/codebase/handlers/codebase-measure-symbols.js +35 -4
- package/dist/os/codebase/handlers/codebase-measure-symbols.js.map +1 -1
- package/dist/os/core/core.module.d.ts.map +1 -1
- package/dist/os/core/core.module.js +1 -69
- package/dist/os/core/core.module.js.map +1 -1
- package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
- package/dist/os/core/handlers/assets-helpers.js +2 -3
- package/dist/os/core/handlers/assets-helpers.js.map +1 -1
- package/dist/os/core/handlers/determinism-check.d.ts.map +1 -1
- package/dist/os/core/handlers/determinism-check.js +2 -3
- package/dist/os/core/handlers/determinism-check.js.map +1 -1
- package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
- package/dist/os/core/handlers/release-prepare.js +2 -4
- package/dist/os/core/handlers/release-prepare.js.map +1 -1
- package/dist/os/flow/handlers/flow-peers.js +1 -1
- package/dist/os/flow/handlers/flow-peers.js.map +1 -1
- package/dist/os/{mission → flow}/open-missions.d.ts +1 -2
- package/dist/os/flow/open-missions.d.ts.map +1 -0
- package/dist/os/flow/open-missions.js +37 -0
- package/dist/os/flow/open-missions.js.map +1 -0
- package/dist/os/flow/preflight.js +1 -1
- package/dist/os/flow/preflight.js.map +1 -1
- package/dist/src/command-modules.d.ts.map +1 -1
- package/dist/src/command-modules.js +0 -2
- package/dist/src/command-modules.js.map +1 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/onboarding/doctor.d.ts +0 -5
- package/dist/src/onboarding/doctor.d.ts.map +1 -1
- package/dist/src/onboarding/doctor.js +6 -79
- package/dist/src/onboarding/doctor.js.map +1 -1
- package/dist/src/onboarding/npm-token-check.d.ts +1 -1
- package/dist/src/onboarding/npm-token-check.d.ts.map +1 -1
- package/dist/src/onboarding/npm-token-check.js +2 -2
- package/dist/src/onboarding/npm-token-check.js.map +1 -1
- package/dist/src/utils/hash.d.ts +1 -0
- package/dist/src/utils/hash.d.ts.map +1 -1
- package/dist/src/utils/hash.js +4 -0
- package/dist/src/utils/hash.js.map +1 -1
- package/dist/{os/mission → src/utils}/lockfile.d.ts +1 -18
- package/dist/src/utils/lockfile.d.ts.map +1 -0
- package/dist/src/utils/lockfile.js +70 -0
- package/dist/src/utils/lockfile.js.map +1 -0
- package/os/codebase/handlers/codebase-measure-symbols.ts +32 -4
- package/os/core/core.module.ts +3 -76
- package/os/core/handlers/assets-helpers.ts +2 -4
- package/os/core/handlers/determinism-check.ts +2 -3
- package/os/core/handlers/lifecycle-handlers.test.ts +529 -0
- package/os/core/handlers/release-prepare.ts +2 -4
- package/os/correctness/gate/trust-boundary-cx18.test.ts +1 -1
- package/os/flow/handlers/flow-peers.ts +1 -1
- package/os/flow/open-missions.ts +45 -0
- package/os/flow/preflight.ts +1 -1
- package/os/flow/tests/release-lines.test.ts +136 -0
- package/os/flow/tests/state-roots.test.ts +1 -48
- package/os/rfc/handlers/validate-corpus.test.ts +149 -0
- package/os/rfc/probe-batch.test.ts +253 -0
- package/os/rfc/verifier/rfc-1391/ac10-operating-model-policy.acceptance.test.ts +63 -0
- package/package.json +161 -506
- package/src/command-modules.ts +0 -2
- package/src/index.ts +0 -2
- package/src/onboarding/doctor.ts +9 -96
- package/src/onboarding/npm-token-check.ts +3 -3
- package/src/tests/pkg-health-self-scan.test.ts +29 -0
- package/src/tests/rfc-evidence-sync.test.ts +369 -0
- package/src/tests/skill-agents-sync.test.ts +192 -0
- package/src/utils/hash.ts +5 -0
- package/src/utils/lockfile.ts +78 -0
- package/dist/os/core/handlers/forge-autonomy-validate.d.ts +0 -25
- package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +0 -1
- package/dist/os/core/handlers/forge-autonomy-validate.js +0 -208
- package/dist/os/core/handlers/forge-autonomy-validate.js.map +0 -1
- package/dist/os/mission/handlers/archive.d.ts +0 -4
- package/dist/os/mission/handlers/archive.d.ts.map +0 -1
- package/dist/os/mission/handlers/archive.js +0 -583
- package/dist/os/mission/handlers/archive.js.map +0 -1
- package/dist/os/mission/importer-block.d.ts +0 -19
- package/dist/os/mission/importer-block.d.ts.map +0 -1
- package/dist/os/mission/importer-block.js +0 -124
- package/dist/os/mission/importer-block.js.map +0 -1
- package/dist/os/mission/index.d.ts +0 -2
- package/dist/os/mission/index.d.ts.map +0 -1
- package/dist/os/mission/index.js +0 -15
- package/dist/os/mission/index.js.map +0 -1
- package/dist/os/mission/lockfile.d.ts.map +0 -1
- package/dist/os/mission/lockfile.js +0 -138
- package/dist/os/mission/lockfile.js.map +0 -1
- package/dist/os/mission/mission.module.d.ts +0 -3
- package/dist/os/mission/mission.module.d.ts.map +0 -1
- package/dist/os/mission/mission.module.js +0 -63
- package/dist/os/mission/mission.module.js.map +0 -1
- package/dist/os/mission/open-missions.d.ts.map +0 -1
- package/dist/os/mission/open-missions.js +0 -42
- package/dist/os/mission/open-missions.js.map +0 -1
- package/dist/os/mission/types.d.ts +0 -23
- package/dist/os/mission/types.d.ts.map +0 -1
- package/dist/os/mission/types.js +0 -19
- package/dist/os/mission/types.js.map +0 -1
- package/dist/os/werkstatt/handlers/lock.d.ts +0 -10
- package/dist/os/werkstatt/handlers/lock.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/lock.js +0 -153
- package/dist/os/werkstatt/handlers/lock.js.map +0 -1
- package/dist/os/werkstatt/handlers/schema.d.ts +0 -33
- package/dist/os/werkstatt/handlers/schema.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/schema.js +0 -42
- package/dist/os/werkstatt/handlers/schema.js.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts +0 -15
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +0 -171
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts +0 -18
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.js +0 -51
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.js.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts +0 -11
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +0 -86
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +0 -1
- package/dist/os/werkstatt/handlers/workspace-deps.d.ts +0 -12
- package/dist/os/werkstatt/handlers/workspace-deps.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/workspace-deps.js +0 -42
- package/dist/os/werkstatt/handlers/workspace-deps.js.map +0 -1
- package/dist/os/werkstatt/index.d.ts +0 -7
- package/dist/os/werkstatt/index.d.ts.map +0 -1
- package/dist/os/werkstatt/index.js +0 -18
- package/dist/os/werkstatt/index.js.map +0 -1
- package/dist/os/werkstatt/werkstatt.module.d.ts +0 -3
- package/dist/os/werkstatt/werkstatt.module.d.ts.map +0 -1
- package/dist/os/werkstatt/werkstatt.module.js +0 -91
- package/dist/os/werkstatt/werkstatt.module.js.map +0 -1
- package/os/core/handlers/forge-autonomy-validate.ts +0 -276
- package/os/correctness/gate/trust-boundary-cx19.test.ts +0 -514
- package/os/mission/handlers/archive.test.ts +0 -764
- package/os/mission/handlers/archive.ts +0 -711
- package/os/mission/handlers/ship-inflight-degraded.test.ts +0 -105
- package/os/mission/importer-block.ts +0 -119
- package/os/mission/index.ts +0 -15
- package/os/mission/lockfile.ts +0 -152
- package/os/mission/mission.module.ts +0 -68
- package/os/mission/open-missions.ts +0 -50
- package/os/mission/types.ts +0 -42
- package/os/werkstatt/handlers/lock.ts +0 -168
- package/os/werkstatt/handlers/schema.ts +0 -47
- package/os/werkstatt/handlers/werkstatt-lock-recover.ts +0 -206
- package/os/werkstatt/handlers/werkstatt-lock-status.ts +0 -82
- package/os/werkstatt/handlers/werkstatt-operation-validate.ts +0 -112
- package/os/werkstatt/handlers/workspace-deps.ts +0 -56
- package/os/werkstatt/index.ts +0 -39
- package/os/werkstatt/werkstatt.module.ts +0 -95
- package/src/tests/doctor-autonomy.test.ts +0 -246
- package/src/tests/forge-autonomy-validate.test.ts +0 -159
- package/src/tests/werkstatt-lock.test.ts +0 -357
package/src/command-modules.ts
CHANGED
|
@@ -19,14 +19,12 @@ export async function loadForgeCommandModules(): Promise<ForgeModule[]> {
|
|
|
19
19
|
await import("../os/adr/adr.module.ts").then((m) => m.createForgeAdrModule()),
|
|
20
20
|
await import("../os/plan/plan.module.ts").then((m) => m.createForgePlanModule()),
|
|
21
21
|
await import("../os/audit/audit.module.ts").then((m) => m.createForgeAuditModule()),
|
|
22
|
-
await import("../os/mission/mission.module.ts").then((m) => m.createForgeMissionModule()),
|
|
23
22
|
await import("../os/spec/spec.module.ts").then((m) => m.createForgeSpecModule()),
|
|
24
23
|
await import("../os/program/program.module.ts").then((m) => m.createForgeProgramModule()),
|
|
25
24
|
await import("../os/plugin/plugin.module.ts").then((m) => m.forgePluginModule),
|
|
26
25
|
await import("../os/workflow/workflow.module.ts").then((m) => m.createForgeWorkflowModule()),
|
|
27
26
|
await import("../os/naming/naming.module.ts").then((m) => m.createForgeNamingModule()),
|
|
28
27
|
await import("../os/compass/compass.module.ts").then((m) => m.forgeCompassModule),
|
|
29
|
-
await import("../os/werkstatt/werkstatt.module.ts").then((m) => m.forgeWerkstattModule),
|
|
30
28
|
await import("../os/session/session.module.ts").then((m) => m.createForgeSessionModule()),
|
|
31
29
|
await import("../os/exploration/exploration.module.ts").then((m) =>
|
|
32
30
|
m.createForgeExplorationModule(),
|
package/src/index.ts
CHANGED
|
@@ -187,12 +187,10 @@ export { createForgeRfcModule } from "../os/rfc/rfc.module.ts";
|
|
|
187
187
|
export { createForgeWorkflowModule } from "../os/workflow/workflow.module.ts";
|
|
188
188
|
export { createForgeNamingModule } from "../os/naming/naming.module.ts";
|
|
189
189
|
export { forgeCompassModule } from "../os/compass/compass.module.ts";
|
|
190
|
-
export { forgeWerkstattModule } from "../os/werkstatt/werkstatt.module.ts";
|
|
191
190
|
export { createForgeSpecModule } from "../os/spec/spec.module.ts";
|
|
192
191
|
export { createForgeAdrModule } from "../os/adr/adr.module.ts";
|
|
193
192
|
export { createForgePlanModule } from "../os/plan/plan.module.ts";
|
|
194
193
|
export { createForgeAuditModule } from "../os/audit/audit.module.ts";
|
|
195
|
-
export { createForgeMissionModule } from "../os/mission/mission.module.ts";
|
|
196
194
|
export { createForgeExplorationModule } from "../os/exploration/exploration.module.ts";
|
|
197
195
|
export { createForgeNotesModule } from "../os/notes/notes.module.ts";
|
|
198
196
|
export { createForgeProgramModule } from "../os/program/program.module.ts";
|
package/src/onboarding/doctor.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<MODULE_CONTRACT>
|
|
3
3
|
<purpose>forge.doctor — diagnoses forge state in an existing project.
|
|
4
4
|
Checks for forge.yaml, AGENTS.md, PREFERENCES.md, .agents/skills/, docs/rfcs/,
|
|
5
|
-
|
|
5
|
+
bindings contract (RFC-0393).</purpose>
|
|
6
6
|
<non-goals>
|
|
7
7
|
<item>Do not modify files — doctor is read-only diagnostics.</item>
|
|
8
8
|
</non-goals>
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
commentStyleForPath,
|
|
28
28
|
} from "../utils/index.ts";
|
|
29
29
|
import { readFileSync, existsSync } from "../utils/sync-fs.ts";
|
|
30
|
-
import { join, relative, dirname, resolve
|
|
30
|
+
import { join, relative, dirname, resolve } from "node:path";
|
|
31
31
|
import picomatch from "picomatch";
|
|
32
32
|
import { parse as parseYaml } from "yaml";
|
|
33
33
|
import { forgePluginManifestSchema } from "../plugin/forge-plugin-manifest.ts";
|
|
@@ -77,10 +77,6 @@ interface DoctorCheck {
|
|
|
77
77
|
unmappedFiles?: string[];
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
interface ForbiddenImport {
|
|
81
|
-
file: string;
|
|
82
|
-
specifier: string;
|
|
83
|
-
}
|
|
84
80
|
|
|
85
81
|
interface BindingValidation {
|
|
86
82
|
resolved: string[];
|
|
@@ -99,26 +95,6 @@ async function pathExists(target: string, io: WorkspaceIO): Promise<boolean> {
|
|
|
99
95
|
return io.exists(target);
|
|
100
96
|
}
|
|
101
97
|
|
|
102
|
-
// FORGE-AUTONOMY-01 (RFC-0940, ADR-0019): `import type` statements are exempt
|
|
103
|
-
// (erased at compile time); `os/werkstatt/` is the declared werkstatt-adapter
|
|
104
|
-
// boundary and may import @warpgogol/*; other `os/` dirs may not import
|
|
105
|
-
// @warpgogol/werkstatt-engine but may use @warpgogol/werkstatt-shared (exempt
|
|
106
|
-
// shared infrastructure); `src/` and the rest of the tree may not carry any
|
|
107
|
-
// runtime @warpgogol/* import. dist/, tests dirs, and *.test.ts/*.spec.ts/
|
|
108
|
-
// *.d.ts are generated or fixture surfaces, not scanned source.
|
|
109
|
-
const FORBIDDEN_IMPORT_PATTERN =
|
|
110
|
-
/(?:^|\n)\s*(import\s+[^;]+?\s+from\s+|require\s*\(\s*)["'`](@warpgogol\/[^"'`]+)["'`]/g;
|
|
111
|
-
|
|
112
|
-
const AUTONOMY_EXCLUDE_DIRS = new Set([
|
|
113
|
-
"node_modules",
|
|
114
|
-
"dist",
|
|
115
|
-
"tests",
|
|
116
|
-
"tests-handoff",
|
|
117
|
-
"templates",
|
|
118
|
-
]);
|
|
119
|
-
const AUTONOMY_EXCLUDE_SUFFIXES = [".test.ts", ".spec.ts", ".d.ts"];
|
|
120
|
-
const ENGINE_SPECIFIER = "@warpgogol/werkstatt-engine";
|
|
121
|
-
|
|
122
98
|
// Per-check fix hints for the pretty-output failure line — a generic
|
|
123
99
|
// "run 'forge create'" hint is wrong for checks create cannot repair.
|
|
124
100
|
const CHECK_FIX_HINTS: Record<string, string> = {
|
|
@@ -129,59 +105,10 @@ const CHECK_FIX_HINTS: Record<string, string> = {
|
|
|
129
105
|
"npm-token (@warpgogol)": "configure a @warpgogol npm token in .npmrc",
|
|
130
106
|
"git-branch": "rename the default branch to 'main'",
|
|
131
107
|
"domain-invariants": "fix the reported invariant violations",
|
|
132
|
-
"autonomy-guard":
|
|
133
|
-
"remove the flagged @warpgogol/* imports or place them behind the os/werkstatt/ adapter boundary (FORGE-AUTONOMY-01)",
|
|
134
108
|
bindings: "fix the invalid forge.yaml bindings",
|
|
135
109
|
"outcome-config": "declare the outcomeBuild/outcomeServe bindings or drop the outcomeSurfaces entry",
|
|
136
110
|
};
|
|
137
111
|
|
|
138
|
-
function isForbiddenSpecifier(specifier: string, relToForge: string): boolean {
|
|
139
|
-
if (relToForge.startsWith("os/werkstatt/")) return false;
|
|
140
|
-
if (relToForge.startsWith("os/")) {
|
|
141
|
-
return specifier === ENGINE_SPECIFIER || specifier.startsWith(`${ENGINE_SPECIFIER}/`);
|
|
142
|
-
}
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async function scanForForbiddenImports(
|
|
147
|
-
dir: string,
|
|
148
|
-
forgeRoot: string,
|
|
149
|
-
workspaceRoot: string,
|
|
150
|
-
io: WorkspaceIO,
|
|
151
|
-
): Promise<ForbiddenImport[]> {
|
|
152
|
-
const violations: ForbiddenImport[] = [];
|
|
153
|
-
const entries = await io.readdir(dir).catch(() => []);
|
|
154
|
-
|
|
155
|
-
for (const entry of entries) {
|
|
156
|
-
const fullPath = join(dir, entry.name);
|
|
157
|
-
|
|
158
|
-
if (entry.isDirectory) {
|
|
159
|
-
if (AUTONOMY_EXCLUDE_DIRS.has(entry.name)) continue;
|
|
160
|
-
const sub = await scanForForbiddenImports(fullPath, forgeRoot, workspaceRoot, io);
|
|
161
|
-
violations.push(...sub);
|
|
162
|
-
} else if (
|
|
163
|
-
entry.name.endsWith(".ts") &&
|
|
164
|
-
!AUTONOMY_EXCLUDE_SUFFIXES.some((suffix) => entry.name.endsWith(suffix))
|
|
165
|
-
) {
|
|
166
|
-
const relToForge = relative(forgeRoot, fullPath).split(sep).join("/");
|
|
167
|
-
const content = await io.readFile(fullPath).catch(() => "");
|
|
168
|
-
let match: RegExpExecArray | null;
|
|
169
|
-
const pattern = new RegExp(FORBIDDEN_IMPORT_PATTERN.source, "g");
|
|
170
|
-
while ((match = pattern.exec(content)) !== null) {
|
|
171
|
-
if (/\bimport\s+type\b/.test(match[1]!)) continue;
|
|
172
|
-
const specifier = match[2]!;
|
|
173
|
-
if (!isForbiddenSpecifier(specifier, relToForge)) continue;
|
|
174
|
-
violations.push({
|
|
175
|
-
file: relative(workspaceRoot, fullPath),
|
|
176
|
-
specifier,
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return violations;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
112
|
// ---------------------------------------------------------------------------
|
|
186
113
|
// Bindings validation (RFC-0393)
|
|
187
114
|
// ---------------------------------------------------------------------------
|
|
@@ -1481,7 +1408,7 @@ function checkPrerequisites(prerequisites: ProfilePrerequisite[]): DoctorCheck {
|
|
|
1481
1408
|
export async function runDoctor(
|
|
1482
1409
|
input: ForgeCommandInput,
|
|
1483
1410
|
context: ForgeRuntimeContext,
|
|
1484
|
-
): Promise<ForgeCommandResult<{ command: string; checks: DoctorCheck[]; allPass: boolean;
|
|
1411
|
+
): Promise<ForgeCommandResult<{ command: string; checks: DoctorCheck[]; allPass: boolean; bindings: BindingValidation; domain?: DomainReport; fixes?: DoctorFixResult[] }>> {
|
|
1485
1412
|
const { workspaceRoot, logger, outputFormat, dryRun } = context;
|
|
1486
1413
|
const fio = resolveIo(context.io);
|
|
1487
1414
|
const strict = input.flags["strict"] === true;
|
|
@@ -1559,7 +1486,7 @@ export async function runDoctor(
|
|
|
1559
1486
|
name: "npm-token (@warpgogol)",
|
|
1560
1487
|
status: tokenCheck.canFetch ? "pass" : "fail",
|
|
1561
1488
|
message: tokenCheck.canFetch
|
|
1562
|
-
? `
|
|
1489
|
+
? `registry fetches @warpgogol/forge (${tokenCheck.registry ?? "default registry"})`
|
|
1563
1490
|
: tokenCheck.fixHint!,
|
|
1564
1491
|
});
|
|
1565
1492
|
}
|
|
@@ -1567,7 +1494,7 @@ export async function runDoctor(
|
|
|
1567
1494
|
// Check git branch is 'main' (not 'master')
|
|
1568
1495
|
checks.push(checkGitBranch(workspaceRoot));
|
|
1569
1496
|
|
|
1570
|
-
|
|
1497
|
+
|
|
1571
1498
|
let forgeRoot: string;
|
|
1572
1499
|
try {
|
|
1573
1500
|
forgeRoot = resolveForgeRoot(workspaceRoot);
|
|
@@ -1575,6 +1502,9 @@ export async function runDoctor(
|
|
|
1575
1502
|
forgeRoot = join(workspaceRoot, "packages", "forge");
|
|
1576
1503
|
}
|
|
1577
1504
|
|
|
1505
|
+
// Source-scanning checks distinguish development checkouts from immutable npm installs.
|
|
1506
|
+
const forgeSourceCheckout = isForgeSourceCheckout(forgeRoot);
|
|
1507
|
+
|
|
1578
1508
|
// RFC-0640: Resolve domain report for domain-aware checks
|
|
1579
1509
|
const domainReport = resolveDomainReport(workspaceRoot, forgeRoot);
|
|
1580
1510
|
|
|
@@ -1648,23 +1578,6 @@ export async function runDoctor(
|
|
|
1648
1578
|
: `${invalidProfiles.length} profile(s) invalid (advisory): ${invalidProfiles.map((p) => p.id).join(", ")}`,
|
|
1649
1579
|
});
|
|
1650
1580
|
|
|
1651
|
-
// Source-scanning checks only make sense on a forge development checkout —
|
|
1652
|
-
// the published tarball ships src/ and os/, but an installed package's
|
|
1653
|
-
// source is immutable and a finding there is not actionable for consumers.
|
|
1654
|
-
const forgeSourceCheckout = isForgeSourceCheckout(forgeRoot);
|
|
1655
|
-
const forbiddenImports = forgeSourceCheckout
|
|
1656
|
-
? await scanForForbiddenImports(forgeRoot, forgeRoot, workspaceRoot, fio)
|
|
1657
|
-
: [];
|
|
1658
|
-
checks.push({
|
|
1659
|
-
name: "autonomy-guard",
|
|
1660
|
-
status: forbiddenImports.length === 0 ? "pass" : "fail",
|
|
1661
|
-
message:
|
|
1662
|
-
forbiddenImports.length === 0
|
|
1663
|
-
? forgeSourceCheckout
|
|
1664
|
-
? "No @warpgogol/* imports in forge source"
|
|
1665
|
-
: "npm-installed forge — source autonomy check skipped"
|
|
1666
|
-
: `${forbiddenImports.length} @warpgogol/* import(s) found in forge source — remove them`,
|
|
1667
|
-
});
|
|
1668
1581
|
|
|
1669
1582
|
// Check bindings contract (RFC-0393)
|
|
1670
1583
|
const bindingsResult = await validateBindings(workspaceRoot, fio);
|
|
@@ -1798,7 +1711,7 @@ export async function runDoctor(
|
|
|
1798
1711
|
const fixFailed = fixes.some((f) => f.action === "failed");
|
|
1799
1712
|
|
|
1800
1713
|
return {
|
|
1801
|
-
data: { command: "forge.doctor", checks: finalChecks, allPass,
|
|
1714
|
+
data: { command: "forge.doctor", checks: finalChecks, allPass, bindings: bindingsResult, domain: domainReport, ...(fix ? { fixes } : {}) },
|
|
1802
1715
|
exitCode: hasFails || fixFailed ? 1 : 0,
|
|
1803
1716
|
summary: allPass
|
|
1804
1717
|
? "forge.doctor: all checks passed"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
<MODULE_CONTRACT>
|
|
3
|
-
<purpose>Non-interactive npm-token probe for the private @warpgogol registry scope (RFC-1125) — parses .npmrc for the @warpgogol scope registry and auth token presence, probes the registry via `npm view @warpgogol/
|
|
3
|
+
<purpose>Non-interactive npm-token probe for the private @warpgogol registry scope (RFC-1125) — parses .npmrc for the @warpgogol scope registry and auth token presence, probes the registry via `npm view @warpgogol/forge version` (injectable for tests) before pnpm install runs in forge create, re-verifies post-install in forge.doctor, and returns a structured NpmTokenCheck with an actionable fixHint on failure.</purpose>
|
|
4
4
|
<non-goals>
|
|
5
5
|
<item>Do not prompt the operator — the probe is non-interactive (create.ts forbids prompts).</item>
|
|
6
6
|
<item>Do not accept tokens via CLI flags — tokens must not appear in argv/history.</item>
|
|
@@ -22,7 +22,7 @@ export interface NpmTokenCheck {
|
|
|
22
22
|
registry: string | null;
|
|
23
23
|
/** A usable token is configured — NPM_TOKEN env or a real _authToken value. */
|
|
24
24
|
tokenPresent: boolean;
|
|
25
|
-
/** `npm view @warpgogol/
|
|
25
|
+
/** `npm view @warpgogol/forge version` succeeded from workspaceRoot. */
|
|
26
26
|
canFetch: boolean;
|
|
27
27
|
/** Actionable remediation when canFetch is false; null on success. */
|
|
28
28
|
fixHint: string | null;
|
|
@@ -37,7 +37,7 @@ export interface NpmTokenProbeDeps {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const WARPGOGOL_SCOPE = "@warpgogol";
|
|
40
|
-
const PROBE_PACKAGE = "@warpgogol/
|
|
40
|
+
const PROBE_PACKAGE = "@warpgogol/forge";
|
|
41
41
|
const PROBE_TIMEOUT_MS = 15_000;
|
|
42
42
|
const PLACEHOLDER_TOKENS = new Set(["YOUR_NPM_TOKEN", ""]);
|
|
43
43
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC-1517 self-scan regression: the real werkstatt workspace must carry zero
|
|
3
|
+
* PKG-HEALTH-10 violations — any shipped `../` literal resolving outside its
|
|
4
|
+
* package root is either a genuine defect (fix it), a monorepo-bound file
|
|
5
|
+
* (excludePathSegments), or a justified non-path use (same-line suppression /
|
|
6
|
+
* pkgHealth10Suppressions). This file is monorepo-only: it reads the real
|
|
7
|
+
* workspace tree, so it lives in excludePathSegments for the standalone
|
|
8
|
+
* extract.
|
|
9
|
+
*/
|
|
10
|
+
import { test, expect } from "vitest";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import type { ForgeCommandInput, ForgeRuntimeContext } from "../../src/types.ts";
|
|
13
|
+
import { runPackageHealth } from "../../os/core/handlers/package-health.ts";
|
|
14
|
+
|
|
15
|
+
test("PKG-HEALTH-10 reports no violations on the real workspace", async () => {
|
|
16
|
+
const context: ForgeRuntimeContext = {
|
|
17
|
+
workspaceRoot: join(process.cwd(), "..", ".."),
|
|
18
|
+
logger: { section: () => {}, info: () => {}, warn: () => {}, error: () => {}, success: () => {} },
|
|
19
|
+
dryRun: false,
|
|
20
|
+
outputFormat: "json",
|
|
21
|
+
};
|
|
22
|
+
const input: ForgeCommandInput = { argv: [], flags: {} };
|
|
23
|
+
const result = await runPackageHealth(input, context, () => ({ ok: true, detail: "" }));
|
|
24
|
+
const v10 =
|
|
25
|
+
result.data?.violations
|
|
26
|
+
.filter((v) => v.ruleId === "PKG-HEALTH-10")
|
|
27
|
+
.map((v) => `${v.packageName}: ${v.message}`) ?? [];
|
|
28
|
+
expect(v10).toEqual([]);
|
|
29
|
+
}, 120_000);
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>
|
|
4
|
+
Unit tests for rfc evidence sync covering rfc.evidence.sync (RFC-1306); rfc.implement.stamp --sync (RFC-1306).
|
|
5
|
+
</purpose>
|
|
6
|
+
<non-goals>
|
|
7
|
+
<item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
|
|
8
|
+
</non-goals>
|
|
9
|
+
</MODULE_CONTRACT>
|
|
10
|
+
<CHANGE_SUMMARY>
|
|
11
|
+
<item>RFC-1311: Compass header sweep — declares the rfc suite's contract for test-file scaffold coverage.</item>
|
|
12
|
+
<item>RFC-1310: governance-id parity guards on ecosystem.commit and rfc.implement.stamp</item>
|
|
13
|
+
<item>RFC-1320</item>
|
|
14
|
+
<item>RFC-1489: batch test probes through one instrumented Vitest run + frontmatter corpus reads
|
|
15
|
+
|
|
16
|
+
runProbeSet is the single shared execution point: barrier-free segments of test probes sharing one effective bound run in one vitest --reporter=json --outputFile process with per-(file,testName) attribution; missing files/reports yield unverified. run/page/proof and all non-test kinds are barriers. --no-batch escapes to the legacy path on acceptance.run, verification.emit and verification.refresh. rfc.validate reads non-target corpus files frontmatter-only via readRfcFrontmatter (64 KiB bound, full-parse fallback); emit/refresh/acceptance corpus scans use the same accessor. Corpus map slimmed to RfcCorpusEntry {fileName, frontmatter}.</item>
|
|
17
|
+
</CHANGE_SUMMARY>
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
// @vitest-environment node
|
|
21
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
22
|
+
import { fileURLToPath } from "node:url";
|
|
23
|
+
import { describe, expect, test, vi } from "vitest";
|
|
24
|
+
|
|
25
|
+
import {
|
|
26
|
+
EVIDENCE_SYNC_STEPS,
|
|
27
|
+
EVIDENCE_SYNC_EMIT_STEP,
|
|
28
|
+
runRfcEvidenceSync,
|
|
29
|
+
} from "../../os/rfc/handlers/rfc-evidence-sync.ts";
|
|
30
|
+
import type { ForgeCommandInput, ForgeInvokeResult, ForgeRuntimeContext } from "../types.ts";
|
|
31
|
+
|
|
32
|
+
function makeContext(
|
|
33
|
+
invoke?: ForgeRuntimeContext["invoke"],
|
|
34
|
+
workspaceRoot = "/tmp/rfc-evidence-sync-test",
|
|
35
|
+
): ForgeRuntimeContext {
|
|
36
|
+
return {
|
|
37
|
+
workspaceRoot,
|
|
38
|
+
logger: {
|
|
39
|
+
section: () => {},
|
|
40
|
+
info: () => {},
|
|
41
|
+
warn: () => {},
|
|
42
|
+
error: () => {},
|
|
43
|
+
success: () => {},
|
|
44
|
+
},
|
|
45
|
+
dryRun: false,
|
|
46
|
+
outputFormat: "json",
|
|
47
|
+
invoke,
|
|
48
|
+
} as unknown as ForgeRuntimeContext;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const okReport: ForgeInvokeResult = { exitCode: 0, ok: true, filesModified: [] };
|
|
52
|
+
|
|
53
|
+
const run = (input: Partial<ForgeCommandInput>, ctx: ForgeRuntimeContext) =>
|
|
54
|
+
runRfcEvidenceSync({ argv: [], flags: {}, ...input } as ForgeCommandInput, ctx);
|
|
55
|
+
|
|
56
|
+
describe("rfc.evidence.sync (RFC-1306)", () => {
|
|
57
|
+
test("step list is pinned — the canonical regen order is contract", () => {
|
|
58
|
+
expect(EVIDENCE_SYNC_STEPS).toEqual([
|
|
59
|
+
"checks.commands.generate",
|
|
60
|
+
"command.manifest.generate",
|
|
61
|
+
"validator.inventory.generate",
|
|
62
|
+
"docs.commands.generate",
|
|
63
|
+
"ecosystem.manifest.generate",
|
|
64
|
+
]);
|
|
65
|
+
expect(EVIDENCE_SYNC_EMIT_STEP).toBe("rfc.verification.emit");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// The committed command manifest exists only in the monorepo workshop; the
|
|
69
|
+
// standalone forge extraction has no docs/ tree, so the ratchet is skipped there.
|
|
70
|
+
const ratchetManifestPath = fileURLToPath(
|
|
71
|
+
new URL("../../../../docs/command-manifest.generated.yaml", import.meta.url),
|
|
72
|
+
);
|
|
73
|
+
test.skipIf(!existsSync(ratchetManifestPath))(
|
|
74
|
+
"coverage ratchet: every chain step's declared writes stay inside the sync declaration",
|
|
75
|
+
() => {
|
|
76
|
+
// RFC-1306 Risks: the chain is the canonical regen order — a step gaining
|
|
77
|
+
// a generated artifact without the sync declaration covering it must fail
|
|
78
|
+
// here. Source of truth is the committed command manifest (the command's
|
|
79
|
+
// writes are embedded verbatim); the workspace-wide *.generated.*
|
|
80
|
+
// producer set (60+ commands) is deliberately out of scope — the chain is
|
|
81
|
+
// the RFC-evidence subset, not every generator.
|
|
82
|
+
const manifest = readFileSync(ratchetManifestPath, "utf8");
|
|
83
|
+
const entries = manifest.split(/\n(?= - name: )/);
|
|
84
|
+
const writesOf = (name: string): string[] => {
|
|
85
|
+
const entry = entries.find((e) => e.startsWith(` - name: ${name}\n`));
|
|
86
|
+
if (!entry)
|
|
87
|
+
throw new Error(`command "${name}" missing from command manifest — stale fixture?`);
|
|
88
|
+
const block = entry.match(/ writes:\n((?: - .*\n)+)/);
|
|
89
|
+
return block ? [...block[1]!.matchAll(/ - (.*)/g)].map((m) => m[1]!) : [];
|
|
90
|
+
};
|
|
91
|
+
const syncWrites = new Set(writesOf("rfc.evidence.sync"));
|
|
92
|
+
expect(syncWrites.size).toBeGreaterThan(0);
|
|
93
|
+
for (const step of [...EVIDENCE_SYNC_STEPS, EVIDENCE_SYNC_EMIT_STEP]) {
|
|
94
|
+
for (const artifact of writesOf(step)) {
|
|
95
|
+
expect(
|
|
96
|
+
syncWrites.has(artifact),
|
|
97
|
+
`${step} writes ${artifact} — rfc.evidence.sync's writes[] must declare every step output`,
|
|
98
|
+
).toBe(true);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
test("EVIDENCE-SYNC-01: absent invoke port fails closed (standalone forge CLI)", async () => {
|
|
105
|
+
const result = await run({ flags: { id: "RFC-9999" } }, makeContext(undefined));
|
|
106
|
+
expect(result.exitCode).toBe(1);
|
|
107
|
+
const violations = (result.data as { violations: Array<{ rule: string }> }).violations;
|
|
108
|
+
expect(violations.map((v) => v.rule)).toEqual(["EVIDENCE-SYNC-01"]);
|
|
109
|
+
expect(violations[0]!.rule).toBe("EVIDENCE-SYNC-01");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test("dry-run lists all steps and invokes nothing (AC: honors context.dryRun)", async () => {
|
|
113
|
+
const invoke = vi.fn(async () => okReport);
|
|
114
|
+
const ctx = makeContext(invoke);
|
|
115
|
+
ctx.dryRun = true;
|
|
116
|
+
const result = await run({ flags: { id: "RFC-9999" } }, ctx);
|
|
117
|
+
expect(result.exitCode).toBe(0);
|
|
118
|
+
expect(invoke).not.toHaveBeenCalled();
|
|
119
|
+
expect(result.summary).toContain(EVIDENCE_SYNC_EMIT_STEP);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("AC-2: mid-chain step failure exits non-zero with that step's diagnostics verbatim", async () => {
|
|
123
|
+
const failingDiagnostics = [
|
|
124
|
+
{ ruleId: "CMDGEN-04", severity: "error", message: "suspect file x.ts" },
|
|
125
|
+
{ ruleId: "CMDGEN-05", severity: "error", message: "control codepoint" },
|
|
126
|
+
];
|
|
127
|
+
const invoke = vi.fn(async (name: string) =>
|
|
128
|
+
name === "validator.inventory.generate"
|
|
129
|
+
? ({
|
|
130
|
+
exitCode: 1,
|
|
131
|
+
ok: false,
|
|
132
|
+
data: { diagnostics: failingDiagnostics },
|
|
133
|
+
summary: "inventory failed",
|
|
134
|
+
} satisfies ForgeInvokeResult)
|
|
135
|
+
: okReport,
|
|
136
|
+
);
|
|
137
|
+
const result = await run({}, makeContext(invoke));
|
|
138
|
+
expect(result.exitCode).toBe(1);
|
|
139
|
+
|
|
140
|
+
const data = result.data as {
|
|
141
|
+
violations: Array<{ rule: string; step?: string; stepDiagnostics?: unknown }>;
|
|
142
|
+
data: { failedStep: string; steps: Array<{ step: string; status: string }> };
|
|
143
|
+
};
|
|
144
|
+
expect(data.violations).toHaveLength(1);
|
|
145
|
+
expect(data.violations[0]!.rule).toBe("EVIDENCE-SYNC-02");
|
|
146
|
+
expect(data.violations[0]!.step).toBe("validator.inventory.generate");
|
|
147
|
+
expect(data.violations[0]!.stepDiagnostics).toEqual(failingDiagnostics);
|
|
148
|
+
expect(data.data.failedStep).toBe("validator.inventory.generate");
|
|
149
|
+
// Steps after the failure never ran — the chain stops loud.
|
|
150
|
+
expect(data.data.steps).toHaveLength(3);
|
|
151
|
+
expect(invoke).toHaveBeenCalledTimes(3);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test("AC-3: fully-synced tree reports all steps clean with zero changed files", async () => {
|
|
155
|
+
const invoke = vi.fn(async () => okReport);
|
|
156
|
+
const result = await run({ flags: { id: "RFC-9999" } }, makeContext(invoke));
|
|
157
|
+
expect(result.exitCode).toBe(0);
|
|
158
|
+
const data = result.data as {
|
|
159
|
+
data: { steps: Array<{ step: string; status: string; filesModified: string[] }> };
|
|
160
|
+
};
|
|
161
|
+
expect(data.data.steps).toHaveLength(6);
|
|
162
|
+
expect(data.data.steps.every((s) => s.status === "pass")).toBe(true);
|
|
163
|
+
expect(data.data.steps.flatMap((s) => s.filesModified)).toEqual([]);
|
|
164
|
+
expect(result.summary).toContain("0 files changed");
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("AC-4: --id appends rfc.verification.emit as the final step with the id", async () => {
|
|
168
|
+
const invoke = vi.fn(async (_name: string): Promise<ForgeInvokeResult> => okReport);
|
|
169
|
+
await run({ flags: { id: "RFC-1306" } }, makeContext(invoke));
|
|
170
|
+
|
|
171
|
+
const calls = invoke.mock.calls.map(([name]) => name);
|
|
172
|
+
expect(calls).toEqual([...EVIDENCE_SYNC_STEPS, EVIDENCE_SYNC_EMIT_STEP]);
|
|
173
|
+
expect(invoke).toHaveBeenLastCalledWith(EVIDENCE_SYNC_EMIT_STEP, { id: "RFC-1306" });
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test("no --id: only the five manifest steps run (emit skipped)", async () => {
|
|
177
|
+
const invoke = vi.fn(async (_name: string): Promise<ForgeInvokeResult> => okReport);
|
|
178
|
+
const result = await run({}, makeContext(invoke));
|
|
179
|
+
expect(result.exitCode).toBe(0);
|
|
180
|
+
const calls = invoke.mock.calls.map(([name]) => name);
|
|
181
|
+
expect(calls).toEqual([...EVIDENCE_SYNC_STEPS]);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("filesModified per step surfaces in the step report and summary", async () => {
|
|
185
|
+
const invoke = vi.fn(async (name: string) =>
|
|
186
|
+
name === "checks.commands.generate"
|
|
187
|
+
? {
|
|
188
|
+
...okReport,
|
|
189
|
+
filesModified: ["packages/werkstatt-site/src/checks/command-tables/index.generated.ts"],
|
|
190
|
+
}
|
|
191
|
+
: okReport,
|
|
192
|
+
);
|
|
193
|
+
const result = await run({}, makeContext(invoke));
|
|
194
|
+
expect(result.exitCode).toBe(0);
|
|
195
|
+
const data = result.data as { data: { steps: Array<{ filesModified: string[] }> } };
|
|
196
|
+
expect(data.data.steps[0]!.filesModified).toEqual([
|
|
197
|
+
"packages/werkstatt-site/src/checks/command-tables/index.generated.ts",
|
|
198
|
+
]);
|
|
199
|
+
expect(result.summary).toContain("1 file changed");
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// ── rfc.implement.stamp --sync (RFC-1306) ────────────────────────────────────
|
|
204
|
+
|
|
205
|
+
import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
|
|
206
|
+
import { tmpdir } from "node:os";
|
|
207
|
+
import { join } from "node:path";
|
|
208
|
+
import { execFileSync } from "node:child_process";
|
|
209
|
+
|
|
210
|
+
import { runRfcImplementStamp } from "../../os/rfc/handlers/implement-stamp.ts";
|
|
211
|
+
|
|
212
|
+
const { mockRunProbe } = vi.hoisted(() => ({ mockRunProbe: vi.fn() }));
|
|
213
|
+
// Spread the original module — validate-rules.ts also consumes
|
|
214
|
+
// validateAcceptanceShape from acceptance.ts; a bare factory drops it and
|
|
215
|
+
// the frontmatter parse fails closed as IMP-01.
|
|
216
|
+
vi.mock("../../os/rfc/acceptance.ts", async (importOriginal) => ({
|
|
217
|
+
...(await importOriginal<typeof import("../../os/rfc/acceptance.ts")>()),
|
|
218
|
+
runProbe: mockRunProbe,
|
|
219
|
+
// RFC-1489: emit drives runProbeSet — the shim preserves the per-probe
|
|
220
|
+
// mock contract so these tests observe the same probe calls as before.
|
|
221
|
+
runProbeSet: async (probes: unknown[], opts: Record<string, unknown>) => {
|
|
222
|
+
const results = [];
|
|
223
|
+
const durationsMs = [];
|
|
224
|
+
for (const p of probes) {
|
|
225
|
+
results.push(
|
|
226
|
+
await mockRunProbe(
|
|
227
|
+
p,
|
|
228
|
+
opts.workspaceRoot,
|
|
229
|
+
opts.commandRegistry,
|
|
230
|
+
opts.forgeRoot,
|
|
231
|
+
opts.outcomeSession,
|
|
232
|
+
),
|
|
233
|
+
);
|
|
234
|
+
durationsMs.push(0);
|
|
235
|
+
}
|
|
236
|
+
return { results, durationsMs };
|
|
237
|
+
},
|
|
238
|
+
}));
|
|
239
|
+
|
|
240
|
+
const git = (dir: string, args: string[]) =>
|
|
241
|
+
execFileSync("git", args, { cwd: dir, encoding: "utf-8" }).trim();
|
|
242
|
+
|
|
243
|
+
async function stampWorkspace() {
|
|
244
|
+
const dir = await mkdtemp(join(tmpdir(), "stamp-sync-"));
|
|
245
|
+
git(dir, ["init", "-q"]);
|
|
246
|
+
git(dir, ["config", "user.email", "t@t.t"]);
|
|
247
|
+
git(dir, ["config", "user.name", "t"]);
|
|
248
|
+
await mkdir(join(dir, "docs", "rfcs"), { recursive: true });
|
|
249
|
+
return dir;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const RFC_MD = `---
|
|
253
|
+
id: RFC-0100
|
|
254
|
+
title: "Stamp sync fixture"
|
|
255
|
+
status: accepted
|
|
256
|
+
kind: command
|
|
257
|
+
scope: workspace
|
|
258
|
+
owners:
|
|
259
|
+
- architecture
|
|
260
|
+
createdAt: 2026-10-01
|
|
261
|
+
updatedAt: 2026-10-01
|
|
262
|
+
acceptance:
|
|
263
|
+
- probe: file-exists
|
|
264
|
+
path: src/index.ts
|
|
265
|
+
criterion: AC-1
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
# RFC-0100
|
|
269
|
+
|
|
270
|
+
## Context
|
|
271
|
+
Fixture.
|
|
272
|
+
## Acceptance criteria
|
|
273
|
+
|
|
274
|
+
- [x] AC-1: THE thing SHALL work (evidence: test: packages/forge/x.test.ts)
|
|
275
|
+
`;
|
|
276
|
+
|
|
277
|
+
describe("rfc.implement.stamp --sync (RFC-1306)", () => {
|
|
278
|
+
test("--sync invokes rfc.evidence.sync through the host port before stamping", async () => {
|
|
279
|
+
const dir = await stampWorkspace();
|
|
280
|
+
try {
|
|
281
|
+
await writeFile(join(dir, "docs", "rfcs", "rfc-0100-stamp-sync.md"), RFC_MD);
|
|
282
|
+
mockRunProbe.mockResolvedValue({
|
|
283
|
+
probe: { probe: "file-exists", path: "src/index.ts", criterion: "AC-1" },
|
|
284
|
+
ok: true,
|
|
285
|
+
detail: "exists",
|
|
286
|
+
});
|
|
287
|
+
// Emit the evidence envelope, then commit so the stamp gates see a
|
|
288
|
+
// clean RFC file and a passing envelope.
|
|
289
|
+
const emit = await import("../../os/rfc/verification-evidence.ts");
|
|
290
|
+
const emitResult = await emit.runRfcVerificationEmit(
|
|
291
|
+
{ argv: [], flags: { id: "RFC-0100" } } as unknown as ForgeCommandInput,
|
|
292
|
+
makeContext(undefined, dir),
|
|
293
|
+
);
|
|
294
|
+
expect(emitResult.exitCode).toBe(0);
|
|
295
|
+
git(dir, ["add", "-A"]);
|
|
296
|
+
git(dir, ["commit", "-qm", "feat: implement RFC-0100\n\nX-RFC: RFC-0100"]);
|
|
297
|
+
|
|
298
|
+
const invoke = vi.fn(async (_name: string): Promise<ForgeInvokeResult> => okReport);
|
|
299
|
+
const result = await runRfcImplementStamp(
|
|
300
|
+
{
|
|
301
|
+
argv: [],
|
|
302
|
+
flags: { id: "RFC-0100", sync: true },
|
|
303
|
+
} as unknown as ForgeCommandInput,
|
|
304
|
+
makeContext(invoke, dir),
|
|
305
|
+
);
|
|
306
|
+
expect(result.exitCode).toBe(0);
|
|
307
|
+
// RFC-1320: the post-stamp re-emit (RFC-1271) runs the freshness gate
|
|
308
|
+
// through the same invoke port — generated.drift.validate precedes the
|
|
309
|
+
// probe run for the file-exists probe's referenced path.
|
|
310
|
+
expect(invoke).toHaveBeenCalledTimes(2);
|
|
311
|
+
expect(invoke).toHaveBeenNthCalledWith(1, "rfc.evidence.sync", { id: "RFC-0100" });
|
|
312
|
+
expect(invoke).toHaveBeenNthCalledWith(2, "generated.drift.validate", {
|
|
313
|
+
target: "workspace",
|
|
314
|
+
paths: ["src/index.ts"],
|
|
315
|
+
});
|
|
316
|
+
} finally {
|
|
317
|
+
await rm(dir, { recursive: true, force: true });
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
test("--sync fails closed without a kernel host (EVIDENCE-SYNC-01)", async () => {
|
|
322
|
+
const dir = await stampWorkspace();
|
|
323
|
+
try {
|
|
324
|
+
await writeFile(join(dir, "docs", "rfcs", "rfc-0100-stamp-sync.md"), RFC_MD);
|
|
325
|
+
git(dir, ["add", "-A"]);
|
|
326
|
+
git(dir, ["commit", "-qm", "feat: implement RFC-0100"]);
|
|
327
|
+
|
|
328
|
+
const result = await runRfcImplementStamp(
|
|
329
|
+
{
|
|
330
|
+
argv: [],
|
|
331
|
+
flags: { id: "RFC-0100", sync: true },
|
|
332
|
+
} as unknown as ForgeCommandInput,
|
|
333
|
+
makeContext(undefined, dir),
|
|
334
|
+
);
|
|
335
|
+
expect(result.exitCode).toBe(1);
|
|
336
|
+
const violations = (result.data as { violations: Array<{ rule: string }> }).violations;
|
|
337
|
+
expect(violations.map((v) => v.rule)).toContain("EVIDENCE-SYNC-01");
|
|
338
|
+
} finally {
|
|
339
|
+
await rm(dir, { recursive: true, force: true });
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
test("--sync propagates a chain failure as EVIDENCE-SYNC-02 and does not stamp", async () => {
|
|
344
|
+
const dir = await stampWorkspace();
|
|
345
|
+
try {
|
|
346
|
+
await writeFile(join(dir, "docs", "rfcs", "rfc-0100-stamp-sync.md"), RFC_MD);
|
|
347
|
+
git(dir, ["add", "-A"]);
|
|
348
|
+
git(dir, ["commit", "-qm", "feat: implement RFC-0100"]);
|
|
349
|
+
|
|
350
|
+
const invoke = vi.fn(async (): Promise<ForgeInvokeResult> => ({
|
|
351
|
+
exitCode: 1,
|
|
352
|
+
ok: false,
|
|
353
|
+
summary: 'failed at step "command.manifest.generate"',
|
|
354
|
+
}));
|
|
355
|
+
const result = await runRfcImplementStamp(
|
|
356
|
+
{
|
|
357
|
+
argv: [],
|
|
358
|
+
flags: { id: "RFC-0100", sync: true },
|
|
359
|
+
} as unknown as ForgeCommandInput,
|
|
360
|
+
makeContext(invoke, dir),
|
|
361
|
+
);
|
|
362
|
+
expect(result.exitCode).toBe(1);
|
|
363
|
+
const violations = (result.data as { violations: Array<{ rule: string }> }).violations;
|
|
364
|
+
expect(violations.map((v) => v.rule)).toContain("EVIDENCE-SYNC-02");
|
|
365
|
+
} finally {
|
|
366
|
+
await rm(dir, { recursive: true, force: true });
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
});
|