@warpgogol/forge 10.0.0 → 10.1.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 +12 -0
- package/dist/os/rfc/probe-batch.d.ts.map +1 -1
- package/dist/os/rfc/probe-batch.js +13 -6
- package/dist/os/rfc/probe-batch.js.map +1 -1
- package/dist/src/contract/core-nodes.d.ts +8 -0
- package/dist/src/contract/core-nodes.d.ts.map +1 -0
- package/dist/src/contract/core-nodes.js +101 -0
- package/dist/src/contract/core-nodes.js.map +1 -0
- package/dist/src/contract/evaluator.d.ts +48 -0
- package/dist/src/contract/evaluator.d.ts.map +1 -0
- package/dist/src/contract/evaluator.js +158 -0
- package/dist/src/contract/evaluator.js.map +1 -0
- package/dist/src/contract/evidence-store.d.ts +17 -0
- package/dist/src/contract/evidence-store.d.ts.map +1 -0
- package/dist/src/contract/evidence-store.js +113 -0
- package/dist/src/contract/evidence-store.js.map +1 -0
- package/dist/src/contract/executors/zero-deps.d.ts +3 -0
- package/dist/src/contract/executors/zero-deps.d.ts.map +1 -0
- package/dist/src/contract/executors/zero-deps.js +88 -0
- package/dist/src/contract/executors/zero-deps.js.map +1 -0
- package/dist/src/contract/fingerprint.d.ts +34 -0
- package/dist/src/contract/fingerprint.d.ts.map +1 -0
- package/dist/src/contract/fingerprint.js +153 -0
- package/dist/src/contract/fingerprint.js.map +1 -0
- package/dist/src/contract/graph.d.ts +23 -0
- package/dist/src/contract/graph.d.ts.map +1 -0
- package/dist/src/contract/graph.js +158 -0
- package/dist/src/contract/graph.js.map +1 -0
- package/dist/src/contract/migration-map.d.ts +51 -0
- package/dist/src/contract/migration-map.d.ts.map +1 -0
- package/dist/src/contract/migration-map.js +130 -0
- package/dist/src/contract/migration-map.js.map +1 -0
- package/dist/src/contract/types.d.ts +108 -0
- package/dist/src/contract/types.d.ts.map +1 -0
- package/dist/src/contract/types.js +23 -0
- package/dist/src/contract/types.js.map +1 -0
- package/dist/src/integration/drain.d.ts +31 -0
- package/dist/src/integration/drain.d.ts.map +1 -0
- package/dist/src/integration/drain.js +195 -0
- package/dist/src/integration/drain.js.map +1 -0
- package/dist/src/integration/enqueue.d.ts +30 -0
- package/dist/src/integration/enqueue.d.ts.map +1 -0
- package/dist/src/integration/enqueue.js +64 -0
- package/dist/src/integration/enqueue.js.map +1 -0
- package/dist/src/integration/gitops.d.ts +33 -0
- package/dist/src/integration/gitops.d.ts.map +1 -0
- package/dist/src/integration/gitops.js +128 -0
- package/dist/src/integration/gitops.js.map +1 -0
- package/dist/src/integration/lease.d.ts +16 -0
- package/dist/src/integration/lease.d.ts.map +1 -0
- package/dist/src/integration/lease.js +140 -0
- package/dist/src/integration/lease.js.map +1 -0
- package/dist/src/integration/materialize.d.ts +7 -0
- package/dist/src/integration/materialize.d.ts.map +1 -0
- package/dist/src/integration/materialize.js +34 -0
- package/dist/src/integration/materialize.js.map +1 -0
- package/dist/src/integration/store.d.ts +21 -0
- package/dist/src/integration/store.d.ts.map +1 -0
- package/dist/src/integration/store.js +131 -0
- package/dist/src/integration/store.js.map +1 -0
- package/dist/src/integration/types.d.ts +71 -0
- package/dist/src/integration/types.d.ts.map +1 -0
- package/dist/src/integration/types.js +18 -0
- package/dist/src/integration/types.js.map +1 -0
- package/dist/src/sdk/context.d.ts +13 -0
- package/dist/src/sdk/context.d.ts.map +1 -0
- package/dist/src/sdk/context.js +128 -0
- package/dist/src/sdk/context.js.map +1 -0
- package/dist/src/sdk/loader.d.ts +25 -0
- package/dist/src/sdk/loader.d.ts.map +1 -0
- package/dist/src/sdk/loader.js +155 -0
- package/dist/src/sdk/loader.js.map +1 -0
- package/dist/src/sdk/scan.d.ts +16 -0
- package/dist/src/sdk/scan.d.ts.map +1 -0
- package/dist/src/sdk/scan.js +126 -0
- package/dist/src/sdk/scan.js.map +1 -0
- package/dist/src/sdk/skills-gen.d.ts +27 -0
- package/dist/src/sdk/skills-gen.d.ts.map +1 -0
- package/dist/src/sdk/skills-gen.js +87 -0
- package/dist/src/sdk/skills-gen.js.map +1 -0
- package/dist/src/sdk/types.d.ts +124 -0
- package/dist/src/sdk/types.d.ts.map +1 -0
- package/dist/src/sdk/types.js +34 -0
- package/dist/src/sdk/types.js.map +1 -0
- package/os/rfc/probe-batch.ts +13 -6
- package/package.json +17 -1
- package/src/contract/core-nodes.ts +111 -0
- package/src/contract/evaluator.ts +207 -0
- package/src/contract/evidence-store.ts +119 -0
- package/src/contract/executors/zero-deps.ts +92 -0
- package/src/contract/fingerprint.ts +176 -0
- package/src/contract/graph.ts +181 -0
- package/src/contract/migration-map.ts +174 -0
- package/src/contract/types.ts +125 -0
- package/src/integration/drain.ts +271 -0
- package/src/integration/enqueue.ts +92 -0
- package/src/integration/gitops.ts +174 -0
- package/src/integration/lease.ts +144 -0
- package/src/integration/materialize.ts +40 -0
- package/src/integration/store.ts +153 -0
- package/src/integration/types.ts +79 -0
- package/src/sdk/context.ts +135 -0
- package/src/sdk/loader.ts +170 -0
- package/src/sdk/scan.ts +132 -0
- package/src/sdk/skills-gen.ts +104 -0
- package/src/sdk/types.ts +135 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>
|
|
4
|
+
Skills generation (Werkstatt RFC-1648) — .agents/skills is generated by resolving
|
|
5
|
+
core skills plus all active plugins' skills into one UNTRACKED tree, content-hashed
|
|
6
|
+
inputs, incremental regeneration. Tracked twins are gone by construction: single
|
|
7
|
+
source, generated view — nothing to drift.
|
|
8
|
+
</purpose>
|
|
9
|
+
<CHANGE_SUMMARY><item>RFC-1648 (WP-5): initial skills generation.</item></CHANGE_SUMMARY>
|
|
10
|
+
*/
|
|
11
|
+
import { createHash } from "node:crypto";
|
|
12
|
+
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
function hashTree(dir) {
|
|
15
|
+
const hash = createHash("sha256");
|
|
16
|
+
const walk = (d, prefix) => {
|
|
17
|
+
if (!existsSync(d))
|
|
18
|
+
return;
|
|
19
|
+
for (const entry of readdirSync(d).sort()) {
|
|
20
|
+
const p = join(d, entry);
|
|
21
|
+
const rel = prefix ? `${prefix}/${entry}` : entry;
|
|
22
|
+
if (statSync(p).isDirectory())
|
|
23
|
+
walk(p, rel);
|
|
24
|
+
else {
|
|
25
|
+
hash.update(rel);
|
|
26
|
+
hash.update(readFileSync(p));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
walk(dir, "");
|
|
31
|
+
return hash.digest("hex");
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Generate .agents/skills from core + active plugin skill dirs. The target is
|
|
35
|
+
* wiped and rewritten — it is a generated VIEW, untracked by construction;
|
|
36
|
+
* callers must ensure the path is gitignored.
|
|
37
|
+
*/
|
|
38
|
+
export function generateSkillsTree(targetDir, sources) {
|
|
39
|
+
const inputHash = createHash("sha256");
|
|
40
|
+
for (const s of sources)
|
|
41
|
+
inputHash.update(s.pluginId).update(hashTree(s.skillsDir));
|
|
42
|
+
rmSync(targetDir, { recursive: true, force: true });
|
|
43
|
+
mkdirSync(targetDir, { recursive: true });
|
|
44
|
+
let written = 0;
|
|
45
|
+
for (const source of sources) {
|
|
46
|
+
const { skillsDir } = source;
|
|
47
|
+
if (!existsSync(skillsDir))
|
|
48
|
+
continue;
|
|
49
|
+
// flatten: contents merge at the generated root; otherwise the directory
|
|
50
|
+
// itself becomes a top-level entry (the _shared support contract).
|
|
51
|
+
const rootPrefix = source.flatten === false ? source.skillsDir.split("/").pop() : "";
|
|
52
|
+
const walk = (d, rel) => {
|
|
53
|
+
for (const entry of readdirSync(d)) {
|
|
54
|
+
const p = join(d, entry);
|
|
55
|
+
const r = rel ? join(rel, entry) : entry;
|
|
56
|
+
if (statSync(p).isDirectory())
|
|
57
|
+
walk(p, r);
|
|
58
|
+
else {
|
|
59
|
+
const target = join(targetDir, rootPrefix, r);
|
|
60
|
+
mkdirSync(join(target, ".."), { recursive: true });
|
|
61
|
+
copyFileSync(p, target);
|
|
62
|
+
written += 1;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
walk(skillsDir, "");
|
|
67
|
+
}
|
|
68
|
+
const digest = inputHash.digest("hex");
|
|
69
|
+
writeFileSync(join(targetDir, ".generated.json"), JSON.stringify({ inputHash: digest, at: new Date().toISOString() }));
|
|
70
|
+
return { written, inputHash: digest, targetDir };
|
|
71
|
+
}
|
|
72
|
+
export function resolveCanonicalSkillSources(coreSkillsDir) {
|
|
73
|
+
const sources = [];
|
|
74
|
+
for (const category of ["fo", "meta", "shared"]) {
|
|
75
|
+
const dir = join(coreSkillsDir, category);
|
|
76
|
+
if (existsSync(dir)) {
|
|
77
|
+
// Each category subtree flattens: skills/<cat>/<skill>/ -> <skill>/
|
|
78
|
+
sources.push({ pluginId: `core-${category}`, skillsDir: dir, flatten: true });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const sharedSupport = join(coreSkillsDir, "_shared");
|
|
82
|
+
if (existsSync(sharedSupport)) {
|
|
83
|
+
sources.push({ pluginId: "core-_shared", skillsDir: sharedSupport, flatten: false });
|
|
84
|
+
}
|
|
85
|
+
return sources;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=skills-gen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills-gen.js","sourceRoot":"","sources":["../../../src/sdk/skills-gen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;EASE;AAEF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1H,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA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|
4
|
+
id: string;
|
|
5
|
+
version: string;
|
|
6
|
+
/** Required semver range — violation refuses load, fail-closed. */
|
|
7
|
+
forgeRange: string;
|
|
8
|
+
capabilities: {
|
|
9
|
+
filesystem?: "none" | "read" | "readwrite";
|
|
10
|
+
network?: boolean;
|
|
11
|
+
processSpawn?: boolean;
|
|
12
|
+
gitMutation?: boolean;
|
|
13
|
+
envKeys?: string[];
|
|
14
|
+
};
|
|
15
|
+
registers: {
|
|
16
|
+
commands?: string[];
|
|
17
|
+
skills?: string;
|
|
18
|
+
contractNodes?: string[];
|
|
19
|
+
hooks?: string[];
|
|
20
|
+
};
|
|
21
|
+
pluginDependencies?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export interface CommandResult {
|
|
24
|
+
status: "pass" | "fail" | "error";
|
|
25
|
+
violations?: Array<{
|
|
26
|
+
ruleId: string;
|
|
27
|
+
message: string;
|
|
28
|
+
severity: string;
|
|
29
|
+
file?: string;
|
|
30
|
+
}>;
|
|
31
|
+
message?: string;
|
|
32
|
+
data?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
export interface CommandModule {
|
|
35
|
+
/** Namespaced, e.g. "typescript.validate". */
|
|
36
|
+
id: string;
|
|
37
|
+
scope: "repo" | "workspace" | "system";
|
|
38
|
+
description: string;
|
|
39
|
+
/** zod schema — closed flag vocabulary. */
|
|
40
|
+
flagsSchema?: unknown;
|
|
41
|
+
run(ctx: PluginContext, args: Record<string, unknown>): Promise<CommandResult>;
|
|
42
|
+
}
|
|
43
|
+
/** Lifecycle hooks — closed list in v1; new hook points require core minor versions. */
|
|
44
|
+
export type LifecycleHook = "onActivate" | "onDeactivate" | "beforeIntegrate" | "afterIntegrate";
|
|
45
|
+
export declare const LIFECYCLE_HOOKS: readonly LifecycleHook[];
|
|
46
|
+
export interface WorkspaceIOPort {
|
|
47
|
+
readFile(path: string): Promise<string>;
|
|
48
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
49
|
+
exists(path: string): Promise<boolean>;
|
|
50
|
+
list(dir: string, pattern?: string): Promise<string[]>;
|
|
51
|
+
}
|
|
52
|
+
export interface EvidenceAccessPort {
|
|
53
|
+
consult(nodeId: string, inputDigest: string): Promise<{
|
|
54
|
+
hit: boolean;
|
|
55
|
+
verdict?: unknown;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
export interface ContractRegistryPort {
|
|
59
|
+
registerNode(node: unknown): {
|
|
60
|
+
ok: true;
|
|
61
|
+
} | {
|
|
62
|
+
ok: false;
|
|
63
|
+
errors: string[];
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export interface BindingsResolverPort {
|
|
67
|
+
get<T = unknown>(key: string): T | undefined;
|
|
68
|
+
require<T = unknown>(key: string): T;
|
|
69
|
+
}
|
|
70
|
+
export interface GitPort {
|
|
71
|
+
exec(args: string[]): Promise<string>;
|
|
72
|
+
}
|
|
73
|
+
export interface ProcessPort {
|
|
74
|
+
spawn(cmd: string, args: string[], opts?: {
|
|
75
|
+
cwd?: string;
|
|
76
|
+
timeoutMs?: number;
|
|
77
|
+
}): Promise<{
|
|
78
|
+
stdout: string;
|
|
79
|
+
stderr: string;
|
|
80
|
+
exitCode: number;
|
|
81
|
+
}>;
|
|
82
|
+
}
|
|
83
|
+
export interface NetworkPort {
|
|
84
|
+
fetch(url: string, init?: {
|
|
85
|
+
method?: string;
|
|
86
|
+
headers?: Record<string, string>;
|
|
87
|
+
body?: string;
|
|
88
|
+
}): Promise<{
|
|
89
|
+
status: number;
|
|
90
|
+
body: string;
|
|
91
|
+
}>;
|
|
92
|
+
}
|
|
93
|
+
export interface LoggerPort {
|
|
94
|
+
info(msg: string): void;
|
|
95
|
+
warn(msg: string): void;
|
|
96
|
+
error(msg: string): void;
|
|
97
|
+
}
|
|
98
|
+
export interface PathResolverPort {
|
|
99
|
+
resolve(...parts: string[]): string;
|
|
100
|
+
root(): string;
|
|
101
|
+
}
|
|
102
|
+
export interface PluginContext {
|
|
103
|
+
workspace: WorkspaceIOPort;
|
|
104
|
+
evidence: EvidenceAccessPort;
|
|
105
|
+
contracts: ContractRegistryPort;
|
|
106
|
+
bindings: BindingsResolverPort;
|
|
107
|
+
git: GitPort;
|
|
108
|
+
process: ProcessPort;
|
|
109
|
+
network: NetworkPort;
|
|
110
|
+
log: LoggerPort;
|
|
111
|
+
paths: PathResolverPort;
|
|
112
|
+
}
|
|
113
|
+
/** Typed incompatibility error — fail-closed, no degraded modes. */
|
|
114
|
+
export declare class PluginLoadError extends Error {
|
|
115
|
+
readonly kind: "forgerange-violation" | "manifest-invalid" | "capability-unknown" | "dependency-conflict" | "registration-refused";
|
|
116
|
+
readonly pluginId?: string | undefined;
|
|
117
|
+
constructor(kind: "forgerange-violation" | "manifest-invalid" | "capability-unknown" | "dependency-conflict" | "registration-refused", message: string, pluginId?: string | undefined);
|
|
118
|
+
}
|
|
119
|
+
export declare class CapabilityViolation extends Error {
|
|
120
|
+
readonly capability: string;
|
|
121
|
+
readonly pluginId: string;
|
|
122
|
+
constructor(capability: string, pluginId: string, detail: string);
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/sdk/types.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,0BAA0B,CAAC;IACnC,sDAAsD;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE;QACZ,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;QAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,SA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AkB,GAAG,oBAAoB,GAAG,qBAAqB,GAAG,sBAAsB,EACzI,OAAO,EAAE,MAAM,EACC,QAAQ,CAAC,EAAE,MAAM,YAAA;CAKpC;AAED,qBAAa,mBAAoB,SAAQ,KAAK;aAE1B,UAAU,EAAE,MAAM;aAClB,QAAQ,EAAE,MAAM;gBADhB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChC,MAAM,EAAE,MAAM;CAKjB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>
|
|
4
|
+
Plugin SDK types (Werkstatt RFC-1648) — the platform boundary for in-process
|
|
5
|
+
executable plugins: manifest contract, command module contract, and the typed
|
|
6
|
+
PluginContext ports through which ALL platform interaction flows. Plugins never
|
|
7
|
+
touch raw node capabilities.
|
|
8
|
+
</purpose>
|
|
9
|
+
<non-goals><item>No loader or enforcement logic — contracts only.</item></non-goals>
|
|
10
|
+
<CHANGE_SUMMARY><item>RFC-1648 (WP-5): initial SDK contracts.</item></CHANGE_SUMMARY>
|
|
11
|
+
*/
|
|
12
|
+
export const LIFECYCLE_HOOKS = ["onActivate", "onDeactivate", "beforeIntegrate", "afterIntegrate"];
|
|
13
|
+
/** Typed incompatibility error — fail-closed, no degraded modes. */
|
|
14
|
+
export class PluginLoadError extends Error {
|
|
15
|
+
kind;
|
|
16
|
+
pluginId;
|
|
17
|
+
constructor(kind, message, pluginId) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.kind = kind;
|
|
20
|
+
this.pluginId = pluginId;
|
|
21
|
+
this.name = "PluginLoadError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class CapabilityViolation extends Error {
|
|
25
|
+
capability;
|
|
26
|
+
pluginId;
|
|
27
|
+
constructor(capability, pluginId, detail) {
|
|
28
|
+
super(`capability violation: plugin "${pluginId}" has no ${capability} grant — ${detail}`);
|
|
29
|
+
this.capability = capability;
|
|
30
|
+
this.pluginId = pluginId;
|
|
31
|
+
this.name = "CapabilityViolation";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/sdk/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AA4CF,MAAM,CAAC,MAAM,eAAe,GAA6B,CAAC,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;AA2D7H,oEAAoE;AACpE,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAEtB;IAEA;IAHlB,YACkB,IAAyH,EACzI,OAAe,EACC,QAAiB;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,SAAI,GAAJ,IAAI,CAAqH;QAEzH,aAAQ,GAAR,QAAQ,CAAS;QAGjC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAE1B;IACA;IAFlB,YACkB,UAAkB,EAClB,QAAgB,EAChC,MAAc;QAEd,KAAK,CAAC,iCAAiC,QAAQ,YAAY,UAAU,YAAY,MAAM,EAAE,CAAC,CAAC;QAJ3E,eAAU,GAAV,UAAU,CAAQ;QAClB,aAAQ,GAAR,QAAQ,CAAQ;QAIhC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF"}
|
package/os/rfc/probe-batch.ts
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
import { spawn } from "../../src/utils/sync-fs.ts";
|
|
15
15
|
import { resolveSpawnPlan } from "../../src/utils/spawn.ts";
|
|
16
|
-
import { mkdtempSync, rmSync } from "node:fs";
|
|
16
|
+
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
17
|
+
import { createRequire } from "node:module";
|
|
17
18
|
import { tmpdir } from "node:os";
|
|
18
19
|
import path from "node:path";
|
|
19
20
|
|
|
@@ -115,9 +116,17 @@ export async function spawnBatchedVitest(
|
|
|
115
116
|
boundMs: number,
|
|
116
117
|
outputFile: string,
|
|
117
118
|
): Promise<BatchSpawnOutcome> {
|
|
119
|
+
// v10 monorepo topology: vitest is a per-package dependency, never a workspace-root
|
|
120
|
+
// one — `pnpm exec vitest` from the root resolves nothing. Resolve the vitest
|
|
121
|
+
// entrypoint through THIS module's own package resolution (probe-batch ships inside
|
|
122
|
+
// the forge package, so its resolution always reaches the package-local vitest)
|
|
123
|
+
// and spawn node directly with cwd=workspaceRoot so probe paths stay root-relative.
|
|
124
|
+
const vitestPkgJson = createRequire(import.meta.url).resolve("vitest/package.json");
|
|
125
|
+
const vitestBin = JSON.parse(readFileSync(vitestPkgJson, "utf8")) as { bin?: Record<string, string> };
|
|
126
|
+
const binRel = vitestBin.bin?.vitest ?? "./vitest.mjs";
|
|
127
|
+
const vitestEntry = path.join(path.dirname(vitestPkgJson), binRel);
|
|
118
128
|
const args = [
|
|
119
|
-
|
|
120
|
-
"vitest",
|
|
129
|
+
vitestEntry,
|
|
121
130
|
"run",
|
|
122
131
|
...files,
|
|
123
132
|
"--reporter=json",
|
|
@@ -130,9 +139,7 @@ export async function spawnBatchedVitest(
|
|
|
130
139
|
|
|
131
140
|
let stderrTail = "";
|
|
132
141
|
const exit = await new Promise<{ exitCode: number | null; timedOut: boolean }>((resolve) => {
|
|
133
|
-
|
|
134
|
-
// cmd.exe; a missing pnpm keeps spawn ENOENT for the caller to classify.
|
|
135
|
-
const plan = resolveSpawnPlan("pnpm", args);
|
|
142
|
+
const plan = resolveSpawnPlan(process.execPath, args);
|
|
136
143
|
const child = spawn(plan.command, plan.args, {
|
|
137
144
|
cwd: workspaceRoot,
|
|
138
145
|
stdio: ["ignore", "ignore", "pipe"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warpgogol/forge",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -307,6 +307,22 @@
|
|
|
307
307
|
"./os/adversarial-module": {
|
|
308
308
|
"types": "./dist/os/adversarial/adversarial.module.d.ts",
|
|
309
309
|
"default": "./dist/os/adversarial/adversarial.module.js"
|
|
310
|
+
},
|
|
311
|
+
"./sdk": {
|
|
312
|
+
"types": "./dist/sdk/types.d.ts",
|
|
313
|
+
"default": "./dist/sdk/types.js"
|
|
314
|
+
},
|
|
315
|
+
"./sdk/context": {
|
|
316
|
+
"types": "./dist/sdk/context.d.ts",
|
|
317
|
+
"default": "./dist/sdk/context.js"
|
|
318
|
+
},
|
|
319
|
+
"./sdk/loader": {
|
|
320
|
+
"types": "./dist/sdk/loader.d.ts",
|
|
321
|
+
"default": "./dist/sdk/loader.js"
|
|
322
|
+
},
|
|
323
|
+
"./integration": {
|
|
324
|
+
"types": "./dist/integration/enqueue.d.ts",
|
|
325
|
+
"default": "./dist/integration/enqueue.js"
|
|
310
326
|
}
|
|
311
327
|
},
|
|
312
328
|
"files": [
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>
|
|
4
|
+
The first real v9-lineage contract nodes (Werkstatt RFC-1646 WP-3c) — thin
|
|
5
|
+
executors over existing validator logic, demonstrating incremental scheduling
|
|
6
|
+
on real protections. `core.contract.zero-werkstatt-deps` is the live form of
|
|
7
|
+
PMM-0004's supersession target; `core.contract.migration-map-completeness` is
|
|
8
|
+
the map validating itself — silent loss impossible by construction.
|
|
9
|
+
</purpose>
|
|
10
|
+
<non-goals>
|
|
11
|
+
<item>Not the full v9 protection decomposition — families node-ify gradually
|
|
12
|
+
as the migration map completes; this is the demonstrated-live seed set.</item>
|
|
13
|
+
</non-goals>
|
|
14
|
+
<CHANGE_SUMMARY>
|
|
15
|
+
<item>RFC-1646 (WP-3c): first real node registrations.</item>
|
|
16
|
+
</CHANGE_SUMMARY>
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { readFileSync } from "node:fs";
|
|
20
|
+
import { join } from "node:path";
|
|
21
|
+
|
|
22
|
+
import type { Executor } from "./evaluator.ts";
|
|
23
|
+
import yaml from "yaml";
|
|
24
|
+
import { emitCoverageProof, emitFamiliesCoverageProof, type MigrationMapEntry, type MigrationFamily } from "./migration-map.ts";
|
|
25
|
+
import { scanWerkstattDeps } from "./executors/zero-deps.ts";
|
|
26
|
+
import type { ContractNode } from "./types.ts";
|
|
27
|
+
import type { ContractGraph } from "./graph.ts";
|
|
28
|
+
|
|
29
|
+
export const CORE_EXECUTOR_ZERO_DEPS = "core.executor.zero-deps";
|
|
30
|
+
export const CORE_EXECUTOR_MAP_COMPLETENESS = "core.executor.map-completeness";
|
|
31
|
+
|
|
32
|
+
export function coreContractNodes(): ContractNode[] {
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
id: "core.contract.zero-werkstatt-deps",
|
|
36
|
+
kind: "validator",
|
|
37
|
+
owner: "core",
|
|
38
|
+
inputs: [
|
|
39
|
+
{ kind: "file-glob", pattern: "packages/*/src/**/*.ts" },
|
|
40
|
+
{ kind: "file-glob", pattern: "packages/*/os/**/*.ts" },
|
|
41
|
+
{ kind: "file-glob", pattern: "packages/*/package.json" },
|
|
42
|
+
],
|
|
43
|
+
substrate: "static",
|
|
44
|
+
severity: "blocking",
|
|
45
|
+
executorRef: CORE_EXECUTOR_ZERO_DEPS,
|
|
46
|
+
executorVersion: "1.0.0",
|
|
47
|
+
dependsOn: [],
|
|
48
|
+
cachePolicy: "content-addressed",
|
|
49
|
+
description:
|
|
50
|
+
"Zero-dependency contract (RFC-1649 AC-3): no package source or manifest may reference werkstatt-engine/werkstatt-shared. The structural guarantee that superseded FORGE-AUTONOMY-01.",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: "core.contract.migration-map-completeness",
|
|
54
|
+
kind: "invariant",
|
|
55
|
+
owner: "core",
|
|
56
|
+
inputs: [{ kind: "file-content", path: "docs/migration/protection-migration-map.yaml" }],
|
|
57
|
+
substrate: "static",
|
|
58
|
+
severity: "blocking",
|
|
59
|
+
executorRef: CORE_EXECUTOR_MAP_COMPLETENESS,
|
|
60
|
+
executorVersion: "1.0.0",
|
|
61
|
+
dependsOn: [],
|
|
62
|
+
cachePolicy: "content-addressed",
|
|
63
|
+
description:
|
|
64
|
+
"The migration map validates itself (RFC-1646): every entry is mapped to a live node or consciously removed with a recorded reason — silent loss impossible.",
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function coreExecutors(graphRef: () => ContractGraph): Record<string, Executor> {
|
|
70
|
+
return {
|
|
71
|
+
[CORE_EXECUTOR_ZERO_DEPS]: async ({ treeRoot }) => {
|
|
72
|
+
const violations = scanWerkstattDeps(treeRoot);
|
|
73
|
+
return violations.length > 0 ? { status: "fail", violations } : { status: "pass" };
|
|
74
|
+
},
|
|
75
|
+
[CORE_EXECUTOR_MAP_COMPLETENESS]: async ({ treeRoot }) => {
|
|
76
|
+
let full: { entries?: MigrationMapEntry[]; families?: MigrationFamily[] };
|
|
77
|
+
try {
|
|
78
|
+
full = yaml.parse(
|
|
79
|
+
readFileSync(join(treeRoot, "docs/migration/protection-migration-map.yaml"), "utf8"),
|
|
80
|
+
) as { entries?: MigrationMapEntry[]; families?: MigrationFamily[] };
|
|
81
|
+
} catch {
|
|
82
|
+
return {
|
|
83
|
+
status: "fail",
|
|
84
|
+
violations: [
|
|
85
|
+
{
|
|
86
|
+
ruleId: "PMM-MAP-01",
|
|
87
|
+
message: "migration map unreadable",
|
|
88
|
+
severity: "blocking",
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const entryProof = emitCoverageProof(full.entries ?? [], graphRef());
|
|
94
|
+
const familyProof = emitFamiliesCoverageProof(full.families ?? [], graphRef());
|
|
95
|
+
const proof = {
|
|
96
|
+
complete: entryProof.complete && familyProof.complete,
|
|
97
|
+
gaps: [...entryProof.gaps, ...familyProof.gaps],
|
|
98
|
+
};
|
|
99
|
+
return proof.complete
|
|
100
|
+
? { status: "pass" }
|
|
101
|
+
: {
|
|
102
|
+
status: "fail",
|
|
103
|
+
violations: proof.gaps.map((g) => ({
|
|
104
|
+
ruleId: "PMM-MAP-02",
|
|
105
|
+
message: `${g.entryId}: ${g.reason}`,
|
|
106
|
+
severity: "blocking" as const,
|
|
107
|
+
})),
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>
|
|
4
|
+
Minimal contract-graph evaluator (Werkstatt RFC-1646) — executes the affected
|
|
5
|
+
nodes of a change unit in topological order with content-addressed evidence reuse.
|
|
6
|
+
Verdict vocabulary is exact: uncacheable-pass is never reused across change units;
|
|
7
|
+
error never counts as pass for blocking nodes and is never cached (transient
|
|
8
|
+
executor failures must not poison the evidence store); pass and fail verdicts are
|
|
9
|
+
both cacheable — evidence of failure is still evidence.
|
|
10
|
+
</purpose>
|
|
11
|
+
<non-goals>
|
|
12
|
+
<item>No parallelism, no cone computation against a base unit, no sampling
|
|
13
|
+
verification of command-output determinism — scheduler maturity lands with the
|
|
14
|
+
transactional queue integration (WP-4). This evaluator proves the schema semantics.</item>
|
|
15
|
+
</non-goals>
|
|
16
|
+
<CHANGE_SUMMARY>
|
|
17
|
+
<item>RFC-1646 (WP-3): initial evaluator.</item>
|
|
18
|
+
</CHANGE_SUMMARY>
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { computeInputFingerprint, evidenceKey, verdictDigest, type FingerprintContext } from "./fingerprint.ts";
|
|
22
|
+
import type { ContractGraph } from "./graph.ts";
|
|
23
|
+
import type { EvidenceStore } from "./evidence-store.ts";
|
|
24
|
+
import type { ChangeUnit, ContractNode, Verdict, Violation } from "./types.ts";
|
|
25
|
+
|
|
26
|
+
export type ExecutorResult = { status: "pass" } | { status: "fail"; violations: Violation[] };
|
|
27
|
+
|
|
28
|
+
export type Executor = (input: {
|
|
29
|
+
node: ContractNode;
|
|
30
|
+
treeRoot: string;
|
|
31
|
+
changeUnit: ChangeUnit;
|
|
32
|
+
}) => Promise<ExecutorResult>;
|
|
33
|
+
|
|
34
|
+
export interface EvaluationOptions {
|
|
35
|
+
graph: ContractGraph;
|
|
36
|
+
store: EvidenceStore;
|
|
37
|
+
changeUnit: ChangeUnit;
|
|
38
|
+
executors: Record<string, Executor>;
|
|
39
|
+
treeRoot: string;
|
|
40
|
+
env?: Record<string, string | undefined>;
|
|
41
|
+
execCommand?: FingerprintContext["execCommand"];
|
|
42
|
+
/** Per-executor timeout in ms — an over-running executor is an error verdict, never a pass. */
|
|
43
|
+
executorTimeoutMs?: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface NodeEvaluation {
|
|
47
|
+
nodeId: string;
|
|
48
|
+
verdict: Verdict;
|
|
49
|
+
evidenceKey: string | null;
|
|
50
|
+
reused: boolean;
|
|
51
|
+
durationMs: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface EvaluationReport {
|
|
55
|
+
changeUnitId: string;
|
|
56
|
+
nodes: NodeEvaluation[];
|
|
57
|
+
/** Count of nodes whose evidence was reused at identical input digests — the skip metric substrate. */
|
|
58
|
+
reusedCount: number;
|
|
59
|
+
executedCount: number;
|
|
60
|
+
/** True when every blocking node passed (pass or reused pass). error never counts. */
|
|
61
|
+
blockingPassed: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function isUncacheable(node: ContractNode): boolean {
|
|
65
|
+
// A node with no fingerprintable input is uncacheable by construction — never a stale pass.
|
|
66
|
+
return node.cachePolicy === "uncacheable" || node.inputs.length === 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function runExecutor(
|
|
70
|
+
executor: Executor,
|
|
71
|
+
input: { node: ContractNode; treeRoot: string; changeUnit: ChangeUnit },
|
|
72
|
+
timeoutMs: number,
|
|
73
|
+
): Promise<Verdict> {
|
|
74
|
+
let timer: NodeJS.Timeout | undefined;
|
|
75
|
+
try {
|
|
76
|
+
const result = await Promise.race([
|
|
77
|
+
executor(input),
|
|
78
|
+
new Promise<never>((_, reject) => {
|
|
79
|
+
timer = setTimeout(() => reject(new Error(`executor timeout after ${timeoutMs}ms`)), timeoutMs);
|
|
80
|
+
}),
|
|
81
|
+
]);
|
|
82
|
+
return result;
|
|
83
|
+
} catch (err) {
|
|
84
|
+
// Executor crash/timeout — error is never evidence of compliance.
|
|
85
|
+
return { status: "error", message: err instanceof Error ? err.message : String(err) };
|
|
86
|
+
} finally {
|
|
87
|
+
if (timer) clearTimeout(timer);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Evaluate the graph against a frozen change unit. Fingerprint computation
|
|
93
|
+
* failure is a blocking scheduling-time error — it throws before any execution.
|
|
94
|
+
*/
|
|
95
|
+
export async function evaluateGraph(options: EvaluationOptions): Promise<EvaluationReport> {
|
|
96
|
+
const { graph, store, changeUnit, executors, treeRoot } = options;
|
|
97
|
+
const timeoutMs = options.executorTimeoutMs ?? 60_000;
|
|
98
|
+
const verdictDigests: Record<string, string> = {};
|
|
99
|
+
const ctxBase: Omit<FingerprintContext, "verdictDigests"> = {
|
|
100
|
+
treeRoot,
|
|
101
|
+
changeUnit,
|
|
102
|
+
env: options.env ?? process.env,
|
|
103
|
+
execCommand: options.execCommand ?? (() => ""),
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// Scheduling phase: fingerprint everything before any execution — an unreadable
|
|
107
|
+
// input is a blocking error at scheduling time, never discovered mid-run.
|
|
108
|
+
const fingerprints = new Map<string, ReturnType<typeof computeInputFingerprint>>();
|
|
109
|
+
for (const nodeId of graph.topologicalOrder) {
|
|
110
|
+
const node = graph.nodes[nodeId];
|
|
111
|
+
if (!node) continue;
|
|
112
|
+
if (isUncacheable(node)) continue;
|
|
113
|
+
// node-verdict inputs resolve during execution in topological order; at
|
|
114
|
+
// scheduling time their digest contribution is the dependency's declared
|
|
115
|
+
// presence. The per-input digest for node-verdict is computed lazily at
|
|
116
|
+
// execution — but the scheduling guarantee (all file/command/env inputs
|
|
117
|
+
// computable) is enforced here.
|
|
118
|
+
const nonVerdictInputs = node.inputs.filter((i) => i.kind !== "node-verdict");
|
|
119
|
+
if (nonVerdictInputs.length > 0) {
|
|
120
|
+
// Throws on unreadable input — scheduling-time blocking error, before any execution.
|
|
121
|
+
computeInputFingerprint(nodeId, nonVerdictInputs, { ...ctxBase, verdictDigests: {} });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const nodes: NodeEvaluation[] = [];
|
|
126
|
+
for (const nodeId of graph.topologicalOrder) {
|
|
127
|
+
const node = graph.nodes[nodeId];
|
|
128
|
+
if (!node) continue;
|
|
129
|
+
const startedAt = new Date();
|
|
130
|
+
const uncacheable = isUncacheable(node);
|
|
131
|
+
|
|
132
|
+
if (!uncacheable) {
|
|
133
|
+
const fp = computeInputFingerprint(nodeId, node.inputs, { ...ctxBase, verdictDigests });
|
|
134
|
+
fingerprints.set(nodeId, fp);
|
|
135
|
+
const key = evidenceKey(nodeId, fp.digest, node.executorVersion);
|
|
136
|
+
const existing = store.read(key);
|
|
137
|
+
if (existing) {
|
|
138
|
+
verdictDigests[nodeId] = verdictDigest(existing.verdict);
|
|
139
|
+
nodes.push({
|
|
140
|
+
nodeId,
|
|
141
|
+
verdict: existing.verdict,
|
|
142
|
+
evidenceKey: key,
|
|
143
|
+
reused: true,
|
|
144
|
+
durationMs: 0,
|
|
145
|
+
});
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const executor = executors[node.executorRef];
|
|
151
|
+
let verdict: Verdict;
|
|
152
|
+
if (!executor) {
|
|
153
|
+
verdict = { status: "error", message: `executor '${node.executorRef}' not provided at evaluation` };
|
|
154
|
+
} else {
|
|
155
|
+
verdict = await runExecutor(executor, { node, treeRoot, changeUnit }, timeoutMs);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Uncacheable nodes: a pass is marked uncacheable-pass and the verdict is
|
|
159
|
+
// never written to the reusable evidence store.
|
|
160
|
+
let finalVerdict = verdict;
|
|
161
|
+
if (uncacheable && verdict.status === "pass") {
|
|
162
|
+
finalVerdict = { status: "uncacheable-pass" };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Evidence policy: pass and fail are cacheable; error and uncacheable-pass never are.
|
|
166
|
+
let key: string | null = null;
|
|
167
|
+
if (!uncacheable && (finalVerdict.status === "pass" || finalVerdict.status === "fail")) {
|
|
168
|
+
const fp = fingerprints.get(nodeId) ?? computeInputFingerprint(nodeId, node.inputs, { ...ctxBase, verdictDigests });
|
|
169
|
+
key = evidenceKey(nodeId, fp.digest, node.executorVersion);
|
|
170
|
+
store.write({
|
|
171
|
+
schema: "forge:evidence/v1",
|
|
172
|
+
key,
|
|
173
|
+
nodeId,
|
|
174
|
+
inputFingerprint: fp,
|
|
175
|
+
verdict: finalVerdict,
|
|
176
|
+
executorVersion: node.executorVersion,
|
|
177
|
+
startedAt: startedAt.toISOString(),
|
|
178
|
+
durationMs: Date.now() - startedAt.getTime(),
|
|
179
|
+
changeUnitId: changeUnit.id,
|
|
180
|
+
artifactRefs: [],
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
verdictDigests[nodeId] = verdictDigest(finalVerdict);
|
|
185
|
+
nodes.push({
|
|
186
|
+
nodeId,
|
|
187
|
+
verdict: finalVerdict,
|
|
188
|
+
evidenceKey: key,
|
|
189
|
+
reused: false,
|
|
190
|
+
durationMs: Date.now() - startedAt.getTime(),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const blockingPassed = nodes.every((n) => {
|
|
195
|
+
const node = graph.nodes[n.nodeId];
|
|
196
|
+
if (!node || node.severity !== "blocking") return true;
|
|
197
|
+
return n.verdict.status === "pass" || n.verdict.status === "uncacheable-pass";
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
changeUnitId: changeUnit.id,
|
|
202
|
+
nodes,
|
|
203
|
+
reusedCount: nodes.filter((n) => n.reused).length,
|
|
204
|
+
executedCount: nodes.filter((n) => !n.reused).length,
|
|
205
|
+
blockingPassed,
|
|
206
|
+
};
|
|
207
|
+
}
|