/*
Register the werkstatt.autonomy.validate command with the kernel registry and module loader (RFC-0772).
- Do not implement validation logic — delegate to plugin/autonomy-validate.ts.
- RFC-1097: step 6 — compass.migrate codemod run
Mechanical v1 to v2 header migration across the workspace: 942 files rewritten — CHANGE_SUMMARY windows collapsed into history, forbidden v1 blocks stripped, KEY_DECISIONS seeded from @ai-invariant comments (5 files) or TODO placeholders (103 files), blocks reordered to canonical order.
- RFC-1097: sweep — werkstatt-engine clean
Sweep batch 4: 73 Compass headers on headerless engine files (certification, component-runtime, isolation, evolution, testing), real KEY_DECISIONS on 75 files (kernel, cache, dht, swim, gitmesh, runtime), ~80 purpose expansions (CONTRACT-02/PURPOSE-02), non-goals on 13 CONTRACT-03 files, CS-07 history literal fix repo-wide (253 files). Policy: .template.ts/.template.astro excludedPaths. werkstatt-engine now 0 diagnostics.
- RFC-1173: declare mutatesState on all kernel commands — collectDeclarationDiagnostics emits error-severity MUTATES-STATE-DECLARED, command.manifest.validate is the blocking consumer in packages.check, sweep declares the flag on every command definition (factories hardcode false for read-only check specs)
- RFC-1231: step 1 — rename supportsAllSites to acceptsAllFlag
Mechanical sweep: the field only ever gated --all argv acceptance; fan-out
follows the parsed selector. Guard renamed assertAllSitesAllowed ->
assertAllFlagAccepted, message updated. 417 declaration sites + type
surfaces (KernelCommandMetadata, ForgeCommandMetadata) in one atomic pass.
- RFC-1248: VITE-CLIENT-DEP-02 lazy-import gate + SCAN-02 validator reads-root existence check (RFC-1248)
RFC-0772
*/
import type {
KernelCommandInput,
KernelCommandResult,
KernelRuntimeContext,
} from "../src/kernel/types.ts";
import type { ModuleExport } from "../src/runtime/desired-state.ts";
import {
runAutonomyValidate,
type AutonomyValidateResult,
} from "../src/plugin/autonomy-validate.ts";
export const werkstattAutonomyModule: ModuleExport = {
name: "werkstatt-autonomy",
version: "0.1.0",
declarations: [],
commands: [
{
name: "werkstatt.autonomy.validate",
mutatesState: false,
contract: "werkstatt",
rules: [],
modulePath: "packages/werkstatt-engine/os/werkstatt-autonomy.module.ts",
description:
"Scan packages/werkstatt/src/** for forbidden @warpgogol/* imports (excluding self-imports and shared schema packages). Enforces DNA-64 engine/plugin boundary (RFC-0772).",
scope: "workspace",
acceptsAllFlag: false,
flags: {},
reads: ["packages/werkstatt-engine/src/**"],
cacheable: false,
async execute(
_input: KernelCommandInput,
context: KernelRuntimeContext,
): Promise> {
const result = await runAutonomyValidate(context.workspaceRoot);
return {
exitCode: result.status === "pass" ? 0 : 1,
data: result,
summary:
result.status === "pass"
? `Autonomy guard passed — ${result.scannedFiles} files scanned, zero violations`
: `Autonomy guard failed — ${result.violations.length} violation${result.violations.length === 1 ? "" : "s"} in ${result.scannedFiles} files`,
};
},
},
],
pipelines: [],
};