@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,130 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>
|
|
4
|
+
Migration-map coverage proof (Werkstatt RFC-1646 AC-5) — every v9 protection
|
|
5
|
+
family in the protection migration map is accounted for exactly once: either
|
|
6
|
+
mapped to a live node id in the graph or consciously removed with a recorded
|
|
7
|
+
reason. The map is a versioned artifact whose completeness is itself a contract
|
|
8
|
+
node — the map validates itself. Silent loss is impossible.
|
|
9
|
+
</purpose>
|
|
10
|
+
<non-goals>
|
|
11
|
+
<item>No remediation machinery — proof emission only.</item>
|
|
12
|
+
</non-goals>
|
|
13
|
+
<CHANGE_SUMMARY>
|
|
14
|
+
<item>RFC-1646 (WP-3): initial coverage proof.</item>
|
|
15
|
+
</CHANGE_SUMMARY>
|
|
16
|
+
*/
|
|
17
|
+
import { readFileSync } from "node:fs";
|
|
18
|
+
import yaml from "yaml";
|
|
19
|
+
/** Dispositions that constitute a conscious, recorded removal — never silent. */
|
|
20
|
+
const REMOVAL_DISPOSITIONS = new Set(["removed-at-wp8", "superseded", "transitional-host"]);
|
|
21
|
+
export function parseMigrationMapFull(path) {
|
|
22
|
+
const doc = yaml.parse(readFileSync(path, "utf8"));
|
|
23
|
+
return { entries: doc.entries ?? [], families: doc.families ?? [] };
|
|
24
|
+
}
|
|
25
|
+
export function parseMigrationMap(path) {
|
|
26
|
+
const doc = yaml.parse(readFileSync(path, "utf8"));
|
|
27
|
+
return doc.entries ?? [];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Emit the coverage proof: every entry either names a live graph node
|
|
31
|
+
* (`mappedNodeId` resolvable, or disposition `mapped` with the node present)
|
|
32
|
+
* or carries a removal disposition with a non-empty reason. Anything else is
|
|
33
|
+
* a gap — a silent-loss candidate the contract node refuses.
|
|
34
|
+
*/
|
|
35
|
+
export function emitCoverageProof(entries, graph) {
|
|
36
|
+
const gaps = [];
|
|
37
|
+
let mappedCount = 0;
|
|
38
|
+
let removedCount = 0;
|
|
39
|
+
for (const entry of entries) {
|
|
40
|
+
if (!entry.id || !entry.protection) {
|
|
41
|
+
gaps.push({ entryId: entry.id ?? "(missing id)", reason: "entry lacks id or protection description" });
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (entry.disposition === "mapped") {
|
|
45
|
+
const nodeId = entry.mappedNodeId ?? entry.restoredBy ?? "";
|
|
46
|
+
if (nodeId && graph.nodes[nodeId]) {
|
|
47
|
+
mappedCount += 1;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
gaps.push({
|
|
51
|
+
entryId: entry.id,
|
|
52
|
+
reason: `disposition 'mapped' but node '${nodeId || "(none named)"}' is not in the graph`,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (REMOVAL_DISPOSITIONS.has(entry.disposition)) {
|
|
58
|
+
if (!entry.reason || entry.reason.trim().length === 0) {
|
|
59
|
+
gaps.push({ entryId: entry.id, reason: `removal disposition '${entry.disposition}' without a recorded reason` });
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
removedCount += 1;
|
|
63
|
+
}
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
gaps.push({ entryId: entry.id, reason: `unknown disposition '${entry.disposition}'` });
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
complete: gaps.length === 0,
|
|
70
|
+
entries: entries.length,
|
|
71
|
+
mappedCount,
|
|
72
|
+
removedCount,
|
|
73
|
+
gaps,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Family-granularity coverage proof (WP-3 completion instrument). Rules:
|
|
78
|
+
* nothing stays pending; removed/superseded require a recorded reason;
|
|
79
|
+
* mapped requires a named target; nodeStatus 'live' additionally requires the
|
|
80
|
+
* target node present in the graph — a live claim that does not resolve is a
|
|
81
|
+
* silent-loss inversion and fails the proof.
|
|
82
|
+
*/
|
|
83
|
+
export function emitFamiliesCoverageProof(families, graph) {
|
|
84
|
+
const gaps = [];
|
|
85
|
+
let mappedCount = 0;
|
|
86
|
+
let removedCount = 0;
|
|
87
|
+
for (const fam of families) {
|
|
88
|
+
if (!fam.id) {
|
|
89
|
+
gaps.push({ entryId: "(missing id)", reason: "family lacks id" });
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (fam.disposition === "pending" || !fam.disposition) {
|
|
93
|
+
gaps.push({ entryId: fam.id, reason: "disposition pending — nothing stays pending at WP-3 closure" });
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (fam.disposition === "removed" || fam.disposition === "superseded") {
|
|
97
|
+
if (!fam.reason || fam.reason.trim().length === 0) {
|
|
98
|
+
gaps.push({ entryId: fam.id, reason: `${fam.disposition} without a recorded reason` });
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
removedCount += 1;
|
|
102
|
+
}
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (fam.disposition === "mapped") {
|
|
106
|
+
if (!fam.target || fam.target.trim().length === 0) {
|
|
107
|
+
gaps.push({ entryId: fam.id, reason: "mapped without a named target node family" });
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (fam.nodeStatus === "live" && !graph.nodes[fam.target]) {
|
|
111
|
+
gaps.push({
|
|
112
|
+
entryId: fam.id,
|
|
113
|
+
reason: `claims nodeStatus live but target '${fam.target}' is not in the graph`,
|
|
114
|
+
});
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
mappedCount += 1;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
gaps.push({ entryId: fam.id, reason: `unknown disposition '${fam.disposition}'` });
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
complete: gaps.length === 0,
|
|
124
|
+
entries: families.length,
|
|
125
|
+
mappedCount,
|
|
126
|
+
removedCount,
|
|
127
|
+
gaps,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=migration-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-map.js","sourceRoot":"","sources":["../../../src/contract/migration-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AAEF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,MAAM,CAAC;AA4BxB,iFAAiF;AACjF,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAE5F,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAoE,CAAC;IACtH,OAAO,EAAE,OAAO,EAAE,G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W,GAAG,EAAE,CAAC,CAAC;IACrF,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC;QAC3B,OAAO,EAAE,QAAQ,CAAC,MAAM;QACxB,WAAW;QACX,YAAY;QACZ,IAAI;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/** The atom of protection. Nodes form a DAG via declared dependsOn edges. */
|
|
2
|
+
export interface ContractNode {
|
|
3
|
+
/** Stable namespaced id, e.g. "forge.rfc.validate.V-25"; plugin nodes are prefixed by plugin id. */
|
|
4
|
+
id: string;
|
|
5
|
+
kind: "validator" | "oracle" | "auditor" | "invariant";
|
|
6
|
+
/** Plugin id or "core". */
|
|
7
|
+
owner: string;
|
|
8
|
+
inputs: InputDecl[];
|
|
9
|
+
substrate: "static" | "execution" | "review" | "external";
|
|
10
|
+
severity: "blocking" | "advisory";
|
|
11
|
+
/** SDK-registered executor reference. */
|
|
12
|
+
executorRef: string;
|
|
13
|
+
/** Semver — part of the evidence key. */
|
|
14
|
+
executorVersion: string;
|
|
15
|
+
/** Node ids; DAG enforced at load. */
|
|
16
|
+
dependsOn: string[];
|
|
17
|
+
cachePolicy: "content-addressed" | "uncacheable";
|
|
18
|
+
/** Human/agent-facing explanation template. */
|
|
19
|
+
description: string;
|
|
20
|
+
}
|
|
21
|
+
/** Closed input vocabulary — anything outside it cannot be declared. */
|
|
22
|
+
export type InputDecl = {
|
|
23
|
+
kind: "file-glob";
|
|
24
|
+
pattern: string;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "file-content";
|
|
27
|
+
path: string;
|
|
28
|
+
} | {
|
|
29
|
+
kind: "git-ref";
|
|
30
|
+
ref: string;
|
|
31
|
+
} | {
|
|
32
|
+
kind: "node-verdict";
|
|
33
|
+
nodeId: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "command-output";
|
|
36
|
+
command: string;
|
|
37
|
+
args: string[];
|
|
38
|
+
} | {
|
|
39
|
+
kind: "environment";
|
|
40
|
+
keys: string[];
|
|
41
|
+
};
|
|
42
|
+
export declare const INPUT_KINDS: readonly ["file-glob", "file-content", "git-ref", "node-verdict", "command-output", "environment"];
|
|
43
|
+
export interface InputFingerprint {
|
|
44
|
+
nodeId: string;
|
|
45
|
+
/** sha256 over canonical input serialization. */
|
|
46
|
+
digest: string;
|
|
47
|
+
/** Per-input digests — explainability. Keyed by input index. */
|
|
48
|
+
inputs: Record<string, string>;
|
|
49
|
+
/** Evidence metadata, not part of digest. */
|
|
50
|
+
computedAt: string;
|
|
51
|
+
}
|
|
52
|
+
export interface Violation {
|
|
53
|
+
ruleId: string;
|
|
54
|
+
message: string;
|
|
55
|
+
severity: "blocking" | "advisory";
|
|
56
|
+
file?: string;
|
|
57
|
+
line?: number;
|
|
58
|
+
}
|
|
59
|
+
export type Verdict = {
|
|
60
|
+
status: "pass";
|
|
61
|
+
} | {
|
|
62
|
+
status: "fail";
|
|
63
|
+
violations: Violation[];
|
|
64
|
+
} | {
|
|
65
|
+
status: "uncacheable-pass";
|
|
66
|
+
} | {
|
|
67
|
+
status: "error";
|
|
68
|
+
message: string;
|
|
69
|
+
};
|
|
70
|
+
/** Immutable, content-addressed evidence. Written once, never migrated. */
|
|
71
|
+
export interface EvidenceRecord {
|
|
72
|
+
schema: "forge:evidence/v1";
|
|
73
|
+
/** sha256(nodeId + inputDigest + executorVersion) */
|
|
74
|
+
key: string;
|
|
75
|
+
nodeId: string;
|
|
76
|
+
inputFingerprint: InputFingerprint;
|
|
77
|
+
verdict: Verdict;
|
|
78
|
+
executorVersion: string;
|
|
79
|
+
startedAt: string;
|
|
80
|
+
durationMs: number;
|
|
81
|
+
/** The frozen unit under evaluation. */
|
|
82
|
+
changeUnitId: string;
|
|
83
|
+
/** Content-addressed blobs (logs, reports). */
|
|
84
|
+
artifactRefs: string[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The unit of evaluation — frozen at creation, immutable thereafter.
|
|
88
|
+
* `frozenRefs` holds the resolved values of every git-ref input the graph
|
|
89
|
+
* declares, captured at unit creation: nodes never read live mutable git
|
|
90
|
+
* state, so the frozen values are the only legal resolution source.
|
|
91
|
+
*/
|
|
92
|
+
export interface ChangeUnit {
|
|
93
|
+
id: string;
|
|
94
|
+
/** sha256 of the frozen tree object. */
|
|
95
|
+
treeDigest: string;
|
|
96
|
+
/** Integration target ref at creation. */
|
|
97
|
+
baseRef: string;
|
|
98
|
+
createdAt: string;
|
|
99
|
+
frozenRefs: Record<string, string>;
|
|
100
|
+
metadata: Record<string, string>;
|
|
101
|
+
}
|
|
102
|
+
/** Typed configuration error for fail-closed registration refusal. */
|
|
103
|
+
export interface RegistrationError {
|
|
104
|
+
ruleId: "CG-REG-01" | "CG-REG-02" | "CG-REG-03" | "CG-REG-04" | "CG-REG-05" | "CG-REG-06" | "CG-REG-07";
|
|
105
|
+
message: string;
|
|
106
|
+
nodeId?: string;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/contract/types.ts"],"names":[],"mappings":"AAeA,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,oGAAoG;IACpG,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;IACvD,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;IAC1D,QAAQ,EAAE,UAAU,GAAG,UAAU,CAAC;IAClC,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,eAAe,EAAE,MAAM,CAAC;IACxB,sCAAsC;IACtC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAA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AAE,kBAAkB,CAAA;CAAE,GAC9B;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,mBAAmB,CAAC;IAC5B,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,sEAAsE;AACtE,MAAM,WAAW,iBAAiB;IAChC,MAAM,EACF,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>
|
|
4
|
+
Contract-evidence graph schema types (Werkstatt RFC-1646) — the atom of protection,
|
|
5
|
+
the closed input vocabulary, verdicts, immutable evidence records, and the frozen
|
|
6
|
+
change unit. Schema-only: no evaluation or storage logic lives here.
|
|
7
|
+
</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>Not the scheduler, not the executor runtime — those consume these types.</item>
|
|
10
|
+
</non-goals>
|
|
11
|
+
<CHANGE_SUMMARY>
|
|
12
|
+
<item>RFC-1646 (WP-3): initial schema contracts.</item>
|
|
13
|
+
</CHANGE_SUMMARY>
|
|
14
|
+
*/
|
|
15
|
+
export const INPUT_KINDS = [
|
|
16
|
+
"file-glob",
|
|
17
|
+
"file-content",
|
|
18
|
+
"git-ref",
|
|
19
|
+
"node-verdict",
|
|
20
|
+
"command-output",
|
|
21
|
+
"environment",
|
|
22
|
+
];
|
|
23
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/contract/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;EAaE;AAgCF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,WAAW;IACX,cAAc;IACd,SAAS;IACT,cAAc;IACd,gBAAgB;IAChB,aAAa;CACL,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ContractGraph } from "../contract/graph.ts";
|
|
2
|
+
import type { EvidenceStore } from "../contract/evidence-store.ts";
|
|
3
|
+
import type { Executor } from "../contract/evaluator.ts";
|
|
4
|
+
import { type GitExec } from "./gitops.ts";
|
|
5
|
+
import type { QueueStore } from "./store.ts";
|
|
6
|
+
/** Bound on infra-failure requeues before terminal refusal — poison-pill protection. */
|
|
7
|
+
export declare const MAX_INFRA_REQUEUE_ATTEMPTS = 5;
|
|
8
|
+
export interface DrainOptions {
|
|
9
|
+
store: QueueStore;
|
|
10
|
+
repoDir: string;
|
|
11
|
+
governedRef: string;
|
|
12
|
+
graph: ContractGraph;
|
|
13
|
+
evidenceStore: EvidenceStore;
|
|
14
|
+
executors: Record<string, Executor>;
|
|
15
|
+
git?: GitExec;
|
|
16
|
+
/** Test hook — a drain that evaluates without an evidence store round trip. */
|
|
17
|
+
treeMaterializer?: (repoDir: string, treeDigest: string) => string;
|
|
18
|
+
}
|
|
19
|
+
export interface DrainReport {
|
|
20
|
+
status: "drained" | "drain-in-progress" | "empty";
|
|
21
|
+
processed: Array<{
|
|
22
|
+
unitId: string;
|
|
23
|
+
terminal: string;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Drain the queue once, strict FIFO, exiting when empty. A second concurrent
|
|
28
|
+
* drain reports drain-in-progress and exits 0 — it never double-processes.
|
|
29
|
+
*/
|
|
30
|
+
export declare function drainQueue(options: DrainOptions): Promise<DrainReport>;
|
|
31
|
+
//# sourceMappingURL=drain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drain.d.ts","sourceRoot":"","sources":["../../../src/integration/drain.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,EAML,KAAK,OAAO,EAEb,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,wFAAwF;AACxF,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,aAAa,CAAC;IACrB,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACpC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;CACpE;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,SAAS,GAAG,mBAAmB,GAAG,OAAO,CAAC;IAClD,SAAS,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxD;AA2KD;;;GAGG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAgC5E"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>
|
|
4
|
+
On-demand drain worker (Werkstatt RFC-1647) — strict FIFO, single logical writer:
|
|
5
|
+
lease, rebase-materialize the frozen unit onto the current head, evaluate the
|
|
6
|
+
candidate tree through the contract graph, integrate or refuse, loop until the
|
|
7
|
+
queue is empty, exit. Never a daemon. Idempotent recovery: lease expiry plus
|
|
8
|
+
state-machine re-entry; integration verified by commit existence before
|
|
9
|
+
re-creation — no orphan states.
|
|
10
|
+
</purpose>
|
|
11
|
+
<non-goals>
|
|
12
|
+
<item>No parallelism, no speculative pre-evaluation — strict FIFO v1.</item>
|
|
13
|
+
</non-goals>
|
|
14
|
+
<CHANGE_SUMMARY>
|
|
15
|
+
<item>RFC-1647 (WP-4): initial drain worker.</item>
|
|
16
|
+
</CHANGE_SUMMARY>
|
|
17
|
+
*/
|
|
18
|
+
import { evaluateGraph } from "../contract/evaluator.js";
|
|
19
|
+
import { commitExists, commitTreeEquals, integrateCandidate, replayChainOntoHead, resolveRef, defaultGitExec, } from "./gitops.js";
|
|
20
|
+
import { acquireLease } from "./lease.js";
|
|
21
|
+
import { isTerminal } from "./types.js";
|
|
22
|
+
/** Bound on infra-failure requeues before terminal refusal — poison-pill protection. */
|
|
23
|
+
export const MAX_INFRA_REQUEUE_ATTEMPTS = 5;
|
|
24
|
+
function journal(store, entry) {
|
|
25
|
+
store.appendJournal({
|
|
26
|
+
schema: "forge:queue-journal/v1",
|
|
27
|
+
at: new Date().toISOString(),
|
|
28
|
+
...entry,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function transition(store, unit, state, actor) {
|
|
32
|
+
unit.state = state;
|
|
33
|
+
store.writeUnit(unit);
|
|
34
|
+
journal(store, {
|
|
35
|
+
unitId: unit.id,
|
|
36
|
+
transition: state.status === "evaluating" ? "evaluating" : state.status,
|
|
37
|
+
actor,
|
|
38
|
+
detail: state.status === "refused" ? { nodeId: state.reason.nodeId, summary: state.reason.summary } : undefined,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Re-entry normalization: a unit in non-terminal state after lease expiry is
|
|
43
|
+
* either already landed (verify by commit existence — idempotency by
|
|
44
|
+
* verification, not assumption) or safely reprocessable. Returns true when the
|
|
45
|
+
* unit still needs processing.
|
|
46
|
+
*/
|
|
47
|
+
function normalizeForReentry(git, store, repoDir, unit, governedRef, actor) {
|
|
48
|
+
if (isTerminal(unit.state))
|
|
49
|
+
return false;
|
|
50
|
+
if (unit.state.status === "evaluating") {
|
|
51
|
+
// Did the in-flight integration actually land? The governed ref tip equality
|
|
52
|
+
// is the verification — tree digest preimage, never assumption.
|
|
53
|
+
try {
|
|
54
|
+
const tip = resolveRef(git, repoDir, governedRef);
|
|
55
|
+
if (commitExists(git, repoDir, tip) && commitTreeEquals(git, repoDir, tip, unit.treeDigest)) {
|
|
56
|
+
transition(store, unit, { status: "integrated", commitSha: tip, evidenceKey: "recovered-by-verification" }, actor);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// unverifiable — fall through to requeue
|
|
62
|
+
}
|
|
63
|
+
unit.attempts += 1;
|
|
64
|
+
transition(store, unit, { status: "queued" }, actor);
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
async function processUnit(options, lease, unit) {
|
|
69
|
+
const { store, repoDir, governedRef, graph, evidenceStore, executors } = options;
|
|
70
|
+
const git = options.git ?? defaultGitExec;
|
|
71
|
+
const actor = `drain:${lease.lease.leaseId}`;
|
|
72
|
+
transition(store, unit, { status: "evaluating", leaseId: lease.lease.leaseId, since: new Date().toISOString() }, actor);
|
|
73
|
+
// Rebase-materialize against the ACTUAL current head — the single-writer
|
|
74
|
+
// guarantee makes this stable inside the drain.
|
|
75
|
+
const headSha = resolveRef(git, repoDir, governedRef);
|
|
76
|
+
const replay = replayChainOntoHead(git, repoDir, headSha, unit.commitChain);
|
|
77
|
+
if (!replay.ok) {
|
|
78
|
+
// Terminal conflicted — the owning session rebases and re-enqueues a NEW unit.
|
|
79
|
+
transition(store, unit, { status: "conflicted", conflictingPaths: replay.conflictingPaths }, actor);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// The graph evaluates the candidate tree — the exact content that would
|
|
83
|
+
// integrate, never the session's private tree.
|
|
84
|
+
const changeUnit = {
|
|
85
|
+
id: `unit-${unit.id}`,
|
|
86
|
+
treeDigest: replay.candidateTree,
|
|
87
|
+
baseRef: governedRef,
|
|
88
|
+
createdAt: new Date().toISOString(),
|
|
89
|
+
frozenRefs: { [governedRef]: headSha },
|
|
90
|
+
metadata: { integrationUnit: unit.id },
|
|
91
|
+
};
|
|
92
|
+
const treeRoot = options.treeMaterializer
|
|
93
|
+
? options.treeMaterializer(repoDir, replay.candidateTree)
|
|
94
|
+
: repoDir;
|
|
95
|
+
let report;
|
|
96
|
+
try {
|
|
97
|
+
report = await evaluateGraph({
|
|
98
|
+
graph,
|
|
99
|
+
store: evidenceStore,
|
|
100
|
+
changeUnit,
|
|
101
|
+
executors,
|
|
102
|
+
treeRoot,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
// Evaluation infrastructure failure is NOT a verdict — requeue for a later drain.
|
|
107
|
+
// Bounded: a poison-pill unit must not hang the queue forever — after the bound,
|
|
108
|
+
// terminal refusal carries the error as evidence of an unhealthy system.
|
|
109
|
+
unit.attempts += 1;
|
|
110
|
+
if (unit.attempts > MAX_INFRA_REQUEUE_ATTEMPTS) {
|
|
111
|
+
transition(store, unit, {
|
|
112
|
+
status: "refused",
|
|
113
|
+
reason: {
|
|
114
|
+
nodeId: "core.integration.infra",
|
|
115
|
+
summary: `evaluation infrastructure failed ${unit.attempts} times: ${err instanceof Error ? err.message : String(err)}`,
|
|
116
|
+
violations: 0,
|
|
117
|
+
},
|
|
118
|
+
evidenceKey: "",
|
|
119
|
+
}, actor);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
transition(store, unit, { status: "queued" }, actor);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (!report.blockingPassed) {
|
|
126
|
+
const blocking = report.nodes.find((n) => {
|
|
127
|
+
const node = graph.nodes[n.nodeId];
|
|
128
|
+
return node?.severity === "blocking" && n.verdict.status !== "pass" && n.verdict.status !== "uncacheable-pass";
|
|
129
|
+
});
|
|
130
|
+
const violations = blocking?.verdict.status === "fail" ? blocking.verdict.violations.length : 1;
|
|
131
|
+
transition(store, unit, {
|
|
132
|
+
status: "refused",
|
|
133
|
+
reason: {
|
|
134
|
+
nodeId: blocking?.nodeId ?? "core.unknown",
|
|
135
|
+
summary: blocking?.verdict.status === "error"
|
|
136
|
+
? `executor error: ${blocking.verdict.message}`
|
|
137
|
+
: `${violations} blocking violation(s)`,
|
|
138
|
+
violations,
|
|
139
|
+
},
|
|
140
|
+
evidenceKey: blocking?.evidenceKey ?? "",
|
|
141
|
+
}, actor);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
// Green evaluation — integrate the candidate into the governed ref (single write point).
|
|
145
|
+
integrateCandidate(git, repoDir, governedRef, replay.candidateCommit);
|
|
146
|
+
transition(store, unit, {
|
|
147
|
+
status: "integrated",
|
|
148
|
+
commitSha: replay.candidateCommit,
|
|
149
|
+
evidenceKey: report.nodes.find((n) => n.evidenceKey)?.evidenceKey ?? "",
|
|
150
|
+
}, actor);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Drain the queue once, strict FIFO, exiting when empty. A second concurrent
|
|
154
|
+
* drain reports drain-in-progress and exits 0 — it never double-processes.
|
|
155
|
+
*/
|
|
156
|
+
export async function drainQueue(options) {
|
|
157
|
+
const git = options.git ?? defaultGitExec;
|
|
158
|
+
const lease = acquireLease(options.store.queueDir);
|
|
159
|
+
if (!lease) {
|
|
160
|
+
return { status: "drain-in-progress", processed: [] };
|
|
161
|
+
}
|
|
162
|
+
const processed = [];
|
|
163
|
+
try {
|
|
164
|
+
for (;;) {
|
|
165
|
+
lease.heartbeat(); // per-unit boundary — fresh heartbeat each iteration
|
|
166
|
+
const live = options.store
|
|
167
|
+
.units()
|
|
168
|
+
.filter((u) => !isTerminal(u.state))
|
|
169
|
+
.sort((a, b) => a.enqueuedAt.localeCompare(b.enqueuedAt) || a.id.localeCompare(b.id));
|
|
170
|
+
if (live.length === 0) {
|
|
171
|
+
store_checkpoint(options.store);
|
|
172
|
+
return { status: processed.length > 0 ? "drained" : "empty", processed };
|
|
173
|
+
}
|
|
174
|
+
const unit = live[0];
|
|
175
|
+
if (!normalizeForReentry(git, options.store, options.repoDir, unit, options.governedRef, `drain:${lease.lease.leaseId}`)) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
await processUnit(options, lease, unit);
|
|
179
|
+
const final = options.store.readUnit(unit.id);
|
|
180
|
+
processed.push({ unitId: unit.id, terminal: final?.state.status ?? "unknown" });
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
finally {
|
|
184
|
+
lease.release();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function store_checkpoint(store) {
|
|
188
|
+
try {
|
|
189
|
+
store.checkpoint();
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
// checkpoint failure never blocks a drain verdict
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=drain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drain.js","sourceRoot":"","sources":["../../../src/integration/drain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;EAgBE;AAEF,OAAO,EAAE,aAAa,EAAyB,MAAM,0BAA0B,CAAC;AAMhF,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EAEV,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAoB,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAgD,MAAM,YAAY,CAAC;AAEtF,wFAAwF;AACxF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAmB5C,SAAS,OAAO,CAAC,KAAiB,EAAE,KAA+C;IACjF,KAAK,CAAC,aAAa,CAAC;QAClB,MAAM,EAAE,wBAAwB;QAChC,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAC5B,GAAG,KAAK;KACT,CAAC,CAAC;AACL,CAAC;AAED,SAAS,UAAU,CACjB,KAAiB,EACjB,IAAqB,EACrB,KAA+B,EAC/B,KAAa;IAEb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACnB,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,CAAC,KAAK,EAAE;QACb,MAAM,EAAE,IAAI,CAAC,EAAE;QACf,UAAU,EAAE,KAAK,CAAC,MAAM,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAE,KAAK,CAAC,MAA0C;QAC5G,KAAK;QACL,MAAM,EAAE,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE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EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;YAAS,CAAC;QACT,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAiB;IACzC,IAAI,CAAC;QACH,KAAK,CAAC,UAAU,EAAE,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,kDAAkD;IACpD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { QueueStore } from "./store.ts";
|
|
2
|
+
import { type IntegrationUnit, type QueueJournalEntry } from "./types.ts";
|
|
3
|
+
/** uuidv7-style time-ordered id — millisecond prefix keeps FIFO sort stable. */
|
|
4
|
+
export declare function newUnitId(now?: number): string;
|
|
5
|
+
export interface EnqueueInput {
|
|
6
|
+
treeDigest: string;
|
|
7
|
+
baseRef: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
worktreePath: string;
|
|
10
|
+
governanceIds: string[];
|
|
11
|
+
commitChain: string[];
|
|
12
|
+
}
|
|
13
|
+
/** Freeze-and-enqueue: the unit either exists complete in the queue or not at all. */
|
|
14
|
+
export declare function enqueueUnit(store: QueueStore, input: EnqueueInput): IntegrationUnit;
|
|
15
|
+
export interface QueueView {
|
|
16
|
+
units: Array<{
|
|
17
|
+
id: string;
|
|
18
|
+
status: string;
|
|
19
|
+
enqueuedAt: string;
|
|
20
|
+
sessionId: string;
|
|
21
|
+
terminal: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
journalTail: QueueJournalEntry[];
|
|
24
|
+
liveLease: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Read-only queue state — consumes frozen records and the append-only journal only. */
|
|
27
|
+
export declare function inspectQueue(store: QueueStore, journalTailLines?: number): QueueView;
|
|
28
|
+
/** Verbatim recovery path named in every conflicted terminal — the agent contract. */
|
|
29
|
+
export declare const CONFLICTED_RECOVERY_INSTRUCTION = "This unit is terminally conflicted and is never retried in place. The owning session rebases its worktree onto the current head, resolves the named paths, freezes the result as a NEW unit and re-enqueues it \u2014 units are immutable, re-enqueue is a new id.";
|
|
30
|
+
//# sourceMappingURL=enqueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enqueue.d.ts","sourceRoot":"","sources":["../../../src/integration/enqueue.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAc,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEtF,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,GAAG,SAAa,GAAG,MAAM,CAIlD;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,GAAG,eAAe,CAkBnF;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,KAAK,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,OAAO,CAAC;KACnB,CAAC,CAAC;IACH,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wFAAwF;AACxF,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,gBAAgB,SAAK,GAAG,SAAS,CAchF;AAED,sFAAsF;AACtF,eAAO,MAAM,+BAA+B,uQACqN,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>
|
|
4
|
+
Enqueue path + read-only observability surfaces (Werkstatt RFC-1647) — sessions
|
|
5
|
+
freeze their work into immutable units and enqueue atomically; queue state is
|
|
6
|
+
inspectable at all times through read-only surfaces consuming frozen state only.
|
|
7
|
+
The conflicted-recovery contract names itself verbatim: the owning session
|
|
8
|
+
rebases onto the current head and re-enqueues a NEW unit — units are immutable,
|
|
9
|
+
re-enqueue is a new id.
|
|
10
|
+
</purpose>
|
|
11
|
+
<non-goals>
|
|
12
|
+
<item>No drain triggers as daemons — enqueueing commands may trigger an on-demand drain.</item>
|
|
13
|
+
</non-goals>
|
|
14
|
+
<CHANGE_SUMMARY>
|
|
15
|
+
<item>RFC-1647 (WP-4): initial enqueue + observability.</item>
|
|
16
|
+
</CHANGE_SUMMARY>
|
|
17
|
+
*/
|
|
18
|
+
import { randomBytes } from "node:crypto";
|
|
19
|
+
import { isTerminal } from "./types.js";
|
|
20
|
+
/** uuidv7-style time-ordered id — millisecond prefix keeps FIFO sort stable. */
|
|
21
|
+
export function newUnitId(now = Date.now()) {
|
|
22
|
+
const timeHex = now.toString(16).padStart(12, "0");
|
|
23
|
+
const rand = randomBytes(8).toString("hex");
|
|
24
|
+
return `${timeHex}-${rand}`;
|
|
25
|
+
}
|
|
26
|
+
/** Freeze-and-enqueue: the unit either exists complete in the queue or not at all. */
|
|
27
|
+
export function enqueueUnit(store, input) {
|
|
28
|
+
const unit = {
|
|
29
|
+
schema: "forge:integration-unit/v1",
|
|
30
|
+
id: newUnitId(),
|
|
31
|
+
treeDigest: input.treeDigest,
|
|
32
|
+
baseRef: input.baseRef,
|
|
33
|
+
source: {
|
|
34
|
+
sessionId: input.sessionId,
|
|
35
|
+
worktreePath: input.worktreePath,
|
|
36
|
+
governanceIds: input.governanceIds,
|
|
37
|
+
},
|
|
38
|
+
commitChain: input.commitChain,
|
|
39
|
+
enqueuedAt: new Date().toISOString(),
|
|
40
|
+
state: { status: "queued" },
|
|
41
|
+
attempts: 0,
|
|
42
|
+
};
|
|
43
|
+
store.enqueue(unit);
|
|
44
|
+
return unit;
|
|
45
|
+
}
|
|
46
|
+
/** Read-only queue state — consumes frozen records and the append-only journal only. */
|
|
47
|
+
export function inspectQueue(store, journalTailLines = 20) {
|
|
48
|
+
const units = store.units().map((u) => ({
|
|
49
|
+
id: u.id,
|
|
50
|
+
status: u.state.status,
|
|
51
|
+
enqueuedAt: u.enqueuedAt,
|
|
52
|
+
sessionId: u.source.sessionId,
|
|
53
|
+
terminal: isTerminal(u.state),
|
|
54
|
+
}));
|
|
55
|
+
const journal = store.journal();
|
|
56
|
+
return {
|
|
57
|
+
units,
|
|
58
|
+
journalTail: journal.slice(-journalTailLines),
|
|
59
|
+
liveLease: false, // lease state is operational, not evidence — callers may probe separately
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** Verbatim recovery path named in every conflicted terminal — the agent contract. */
|
|
63
|
+
export const CONFLICTED_RECOVERY_INSTRUCTION = "This unit is terminally conflicted and is never retried in place. The owning session rebases its worktree onto the current head, resolves the named paths, freezes the result as a NEW unit and re-enqueues it — units are immutable, re-enqueue is a new id.";
|
|
64
|
+
//# sourceMappingURL=enqueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enqueue.js","sourceRoot":"","sources":["../../../src/integration/enqueue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;EAgBE;AAEF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,UAAU,EAAgD,MAAM,YAAY,CAAC;AAEtF,gFAAgF;AAChF,MAAM,UAAU,SAAS,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IACxC,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EA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