@warpgogol/forge 10.0.0 → 10.1.1
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 +27 -0
- package/bin/cli.ts +17 -0
- package/dist/bin/cli.js +17 -0
- package/dist/bin/cli.js.map +1 -1
- 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 +37 -0
- package/dist/src/integration/drain.d.ts.map +1 -0
- package/dist/src/integration/drain.js +235 -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/onboarding/init.d.ts.map +1 -1
- package/dist/src/onboarding/init.js +4 -0
- package/dist/src/onboarding/init.js.map +1 -1
- package/dist/src/onboarding/upgrade.d.ts.map +1 -1
- package/dist/src/onboarding/upgrade.js +77 -2
- package/dist/src/onboarding/upgrade.js.map +1 -1
- package/dist/src/sdk/cli-bridge.d.ts +26 -0
- package/dist/src/sdk/cli-bridge.d.ts.map +1 -0
- package/dist/src/sdk/cli-bridge.js +89 -0
- package/dist/src/sdk/cli-bridge.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/hooks.d.ts +14 -0
- package/dist/src/sdk/hooks.d.ts.map +1 -0
- package/dist/src/sdk/hooks.js +35 -0
- package/dist/src/sdk/hooks.js.map +1 -0
- package/dist/src/sdk/loader.d.ts +26 -0
- package/dist/src/sdk/loader.d.ts.map +1 -0
- package/dist/src/sdk/loader.js +170 -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 +141 -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/dist/src/utils/gitignore-entry.d.ts +3 -0
- package/dist/src/utils/gitignore-entry.d.ts.map +1 -0
- package/dist/src/utils/gitignore-entry.js +24 -0
- package/dist/src/utils/gitignore-entry.js.map +1 -0
- package/dist/src/utils/verifier-git.d.ts.map +1 -1
- package/dist/src/utils/verifier-git.js +18 -2
- package/dist/src/utils/verifier-git.js.map +1 -1
- 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 +323 -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/onboarding/init.ts +4 -0
- package/src/onboarding/upgrade.ts +84 -1
- package/src/sdk/cli-bridge.ts +94 -0
- package/src/sdk/context.ts +135 -0
- package/src/sdk/hooks.ts +51 -0
- package/src/sdk/loader.ts +187 -0
- package/src/sdk/scan.ts +132 -0
- package/src/sdk/skills-gen.ts +104 -0
- package/src/sdk/types.ts +158 -0
- package/src/utils/gitignore-entry.ts +24 -0
- package/src/utils/verifier-git.ts +17 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ContractGraph } from "./graph.ts";
|
|
2
|
+
export interface MigrationMapEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
protection: string;
|
|
5
|
+
v9Home?: string;
|
|
6
|
+
disposition: string;
|
|
7
|
+
reason?: string;
|
|
8
|
+
restoredBy?: string;
|
|
9
|
+
/** Set when the protection is live as a v10 contract node. */
|
|
10
|
+
mappedNodeId?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CoverageGap {
|
|
13
|
+
entryId: string;
|
|
14
|
+
reason: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CoverageProof {
|
|
17
|
+
complete: boolean;
|
|
18
|
+
entries: number;
|
|
19
|
+
mappedCount: number;
|
|
20
|
+
removedCount: number;
|
|
21
|
+
gaps: CoverageGap[];
|
|
22
|
+
}
|
|
23
|
+
export declare function parseMigrationMapFull(path: string): {
|
|
24
|
+
entries: MigrationMapEntry[];
|
|
25
|
+
families: MigrationFamily[];
|
|
26
|
+
};
|
|
27
|
+
export declare function parseMigrationMap(path: string): MigrationMapEntry[];
|
|
28
|
+
/**
|
|
29
|
+
* Emit the coverage proof: every entry either names a live graph node
|
|
30
|
+
* (`mappedNodeId` resolvable, or disposition `mapped` with the node present)
|
|
31
|
+
* or carries a removal disposition with a non-empty reason. Anything else is
|
|
32
|
+
* a gap — a silent-loss candidate the contract node refuses.
|
|
33
|
+
*/
|
|
34
|
+
export declare function emitCoverageProof(entries: MigrationMapEntry[], graph: ContractGraph): CoverageProof;
|
|
35
|
+
export interface MigrationFamily {
|
|
36
|
+
id: string;
|
|
37
|
+
disposition: string;
|
|
38
|
+
nodeStatus?: string;
|
|
39
|
+
target?: string;
|
|
40
|
+
reason?: string;
|
|
41
|
+
note?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Family-granularity coverage proof (WP-3 completion instrument). Rules:
|
|
45
|
+
* nothing stays pending; removed/superseded require a recorded reason;
|
|
46
|
+
* mapped requires a named target; nodeStatus 'live' additionally requires the
|
|
47
|
+
* target node present in the graph — a live claim that does not resolve is a
|
|
48
|
+
* silent-loss inversion and fails the proof.
|
|
49
|
+
*/
|
|
50
|
+
export declare function emitFamiliesCoverageProof(families: MigrationFamily[], graph: ContractGraph): CoverageProof;
|
|
51
|
+
//# sourceMappingURL=migration-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-map.d.ts","sourceRoot":"","sources":["../../../src/contract/migration-map.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,WAAW,EAAE,CAAC;CACrB;AAKD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAAC,QAAQ,EAAE,eAAe,EAAE,CAAA;CAAE,CAGjH;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAGnE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,KAAK,EAAE,aAAa,GAAG,aAAa,CAwCnG;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,eAAe,EAAE,EAC3B,KAAK,EAAE,aAAa,GACnB,aAAa,CA+Cf"}
|
|
@@ -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,C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,OAAO,EAAE,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,wBAAwB,GAAG,CAAC,WAAW,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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t 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,37 @@
|
|
|
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 HookInvocationError } from "../sdk/hooks.ts";
|
|
6
|
+
import type { LoadedPlugin } from "../sdk/loader.ts";
|
|
7
|
+
import type { QueueStore } from "./store.ts";
|
|
8
|
+
/** Bound on infra-failure requeues before terminal refusal — poison-pill protection. */
|
|
9
|
+
export declare const MAX_INFRA_REQUEUE_ATTEMPTS = 5;
|
|
10
|
+
export interface DrainOptions {
|
|
11
|
+
store: QueueStore;
|
|
12
|
+
repoDir: string;
|
|
13
|
+
governedRef: string;
|
|
14
|
+
graph: ContractGraph;
|
|
15
|
+
evidenceStore: EvidenceStore;
|
|
16
|
+
executors: Record<string, Executor>;
|
|
17
|
+
git?: GitExec;
|
|
18
|
+
/** Test hook — a drain that evaluates without an evidence store round trip. */
|
|
19
|
+
treeMaterializer?: (repoDir: string, treeDigest: string) => string;
|
|
20
|
+
/** Active plugins — lifecycle hooks fire around integration when present. */
|
|
21
|
+
plugins?: LoadedPlugin[];
|
|
22
|
+
/** Collector — afterIntegrate errors surface here (post-hoc, cannot veto). */
|
|
23
|
+
hookErrors?: HookInvocationError[];
|
|
24
|
+
}
|
|
25
|
+
export interface DrainReport {
|
|
26
|
+
status: "drained" | "drain-in-progress" | "empty";
|
|
27
|
+
processed: Array<{
|
|
28
|
+
unitId: string;
|
|
29
|
+
terminal: string;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Drain the queue once, strict FIFO, exiting when empty. A second concurrent
|
|
34
|
+
* drain reports drain-in-progress and exits 0 — it never double-processes.
|
|
35
|
+
*/
|
|
36
|
+
export declare function drainQueue(options: DrainOptions): Promise<DrainReport>;
|
|
37
|
+
//# 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;AACrB,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,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;IACnE,6EAA6E;IAC7E,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACpC;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;AAyND;;;GAGG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAgC5E"}
|
|
@@ -0,0 +1,235 @@
|
|
|
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 { invokeLifecycleHook } from "../sdk/hooks.js";
|
|
21
|
+
import { acquireLease } from "./lease.js";
|
|
22
|
+
import { isTerminal } from "./types.js";
|
|
23
|
+
/** Bound on infra-failure requeues before terminal refusal — poison-pill protection. */
|
|
24
|
+
export const MAX_INFRA_REQUEUE_ATTEMPTS = 5;
|
|
25
|
+
function journal(store, entry) {
|
|
26
|
+
store.appendJournal({
|
|
27
|
+
schema: "forge:queue-journal/v1",
|
|
28
|
+
at: new Date().toISOString(),
|
|
29
|
+
...entry,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function transition(store, unit, state, actor) {
|
|
33
|
+
unit.state = state;
|
|
34
|
+
store.writeUnit(unit);
|
|
35
|
+
journal(store, {
|
|
36
|
+
unitId: unit.id,
|
|
37
|
+
transition: state.status === "evaluating" ? "evaluating" : state.status,
|
|
38
|
+
actor,
|
|
39
|
+
detail: state.status === "refused" ? { nodeId: state.reason.nodeId, summary: state.reason.summary } : undefined,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Re-entry normalization: a unit in non-terminal state after lease expiry is
|
|
44
|
+
* either already landed (verify by commit existence — idempotency by
|
|
45
|
+
* verification, not assumption) or safely reprocessable. Returns true when the
|
|
46
|
+
* unit still needs processing.
|
|
47
|
+
*/
|
|
48
|
+
function normalizeForReentry(git, store, repoDir, unit, governedRef, actor) {
|
|
49
|
+
if (isTerminal(unit.state))
|
|
50
|
+
return false;
|
|
51
|
+
if (unit.state.status === "evaluating") {
|
|
52
|
+
// Did the in-flight integration actually land? The governed ref tip equality
|
|
53
|
+
// is the verification — tree digest preimage, never assumption.
|
|
54
|
+
try {
|
|
55
|
+
const tip = resolveRef(git, repoDir, governedRef);
|
|
56
|
+
if (commitExists(git, repoDir, tip) && commitTreeEquals(git, repoDir, tip, unit.treeDigest)) {
|
|
57
|
+
transition(store, unit, { status: "integrated", commitSha: tip, evidenceKey: "recovered-by-verification" }, actor);
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// unverifiable — fall through to requeue
|
|
63
|
+
}
|
|
64
|
+
unit.attempts += 1;
|
|
65
|
+
transition(store, unit, { status: "queued" }, actor);
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
async function processUnit(options, lease, unit) {
|
|
70
|
+
const { store, repoDir, governedRef, graph, evidenceStore, executors } = options;
|
|
71
|
+
const git = options.git ?? defaultGitExec;
|
|
72
|
+
const actor = `drain:${lease.lease.leaseId}`;
|
|
73
|
+
transition(store, unit, { status: "evaluating", leaseId: lease.lease.leaseId, since: new Date().toISOString() }, actor);
|
|
74
|
+
// Rebase-materialize against the ACTUAL current head — the single-writer
|
|
75
|
+
// guarantee makes this stable inside the drain.
|
|
76
|
+
const headSha = resolveRef(git, repoDir, governedRef);
|
|
77
|
+
const replay = replayChainOntoHead(git, repoDir, headSha, unit.commitChain);
|
|
78
|
+
if (!replay.ok) {
|
|
79
|
+
// Terminal conflicted — the owning session rebases and re-enqueues a NEW unit.
|
|
80
|
+
transition(store, unit, { status: "conflicted", conflictingPaths: replay.conflictingPaths }, actor);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// The graph evaluates the candidate tree — the exact content that would
|
|
84
|
+
// integrate, never the session's private tree.
|
|
85
|
+
const changeUnit = {
|
|
86
|
+
id: `unit-${unit.id}`,
|
|
87
|
+
treeDigest: replay.candidateTree,
|
|
88
|
+
baseRef: governedRef,
|
|
89
|
+
createdAt: new Date().toISOString(),
|
|
90
|
+
frozenRefs: { [governedRef]: headSha },
|
|
91
|
+
metadata: { integrationUnit: unit.id },
|
|
92
|
+
};
|
|
93
|
+
const treeRoot = options.treeMaterializer
|
|
94
|
+
? options.treeMaterializer(repoDir, replay.candidateTree)
|
|
95
|
+
: repoDir;
|
|
96
|
+
let report;
|
|
97
|
+
try {
|
|
98
|
+
report = await evaluateGraph({
|
|
99
|
+
graph,
|
|
100
|
+
store: evidenceStore,
|
|
101
|
+
changeUnit,
|
|
102
|
+
executors,
|
|
103
|
+
treeRoot,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
// Evaluation infrastructure failure is NOT a verdict — requeue for a later drain.
|
|
108
|
+
// Bounded: a poison-pill unit must not hang the queue forever — after the bound,
|
|
109
|
+
// terminal refusal carries the error as evidence of an unhealthy system.
|
|
110
|
+
unit.attempts += 1;
|
|
111
|
+
if (unit.attempts > MAX_INFRA_REQUEUE_ATTEMPTS) {
|
|
112
|
+
transition(store, unit, {
|
|
113
|
+
status: "refused",
|
|
114
|
+
reason: {
|
|
115
|
+
nodeId: "core.integration.infra",
|
|
116
|
+
summary: `evaluation infrastructure failed ${unit.attempts} times: ${err instanceof Error ? err.message : String(err)}`,
|
|
117
|
+
violations: 0,
|
|
118
|
+
},
|
|
119
|
+
evidenceKey: "",
|
|
120
|
+
}, actor);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
transition(store, unit, { status: "queued" }, actor);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (!report.blockingPassed) {
|
|
127
|
+
const blocking = report.nodes.find((n) => {
|
|
128
|
+
const node = graph.nodes[n.nodeId];
|
|
129
|
+
return node?.severity === "blocking" && n.verdict.status !== "pass" && n.verdict.status !== "uncacheable-pass";
|
|
130
|
+
});
|
|
131
|
+
const violations = blocking?.verdict.status === "fail" ? blocking.verdict.violations.length : 1;
|
|
132
|
+
transition(store, unit, {
|
|
133
|
+
status: "refused",
|
|
134
|
+
reason: {
|
|
135
|
+
nodeId: blocking?.nodeId ?? "core.unknown",
|
|
136
|
+
summary: blocking?.verdict.status === "error"
|
|
137
|
+
? `executor error: ${blocking.verdict.message}`
|
|
138
|
+
: `${violations} blocking violation(s)`,
|
|
139
|
+
violations,
|
|
140
|
+
},
|
|
141
|
+
evidenceKey: blocking?.evidenceKey ?? "",
|
|
142
|
+
}, actor);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// Lifecycle veto — beforeIntegrate hooks execute against the green candidate.
|
|
146
|
+
// A throwing hook means the integration environment cannot vouch: the unit
|
|
147
|
+
// requeues under the same bounded infra semantics as evaluation failures —
|
|
148
|
+
// never a silent skip, never an unbounded hang.
|
|
149
|
+
if (options.plugins && options.plugins.length > 0) {
|
|
150
|
+
const before = await invokeLifecycleHook(options.plugins, "beforeIntegrate", {
|
|
151
|
+
unitId: unit.id,
|
|
152
|
+
data: { candidateCommit: replay.candidateCommit, governedRef },
|
|
153
|
+
});
|
|
154
|
+
if (before.errors.length > 0) {
|
|
155
|
+
unit.attempts += 1;
|
|
156
|
+
if (unit.attempts > MAX_INFRA_REQUEUE_ATTEMPTS) {
|
|
157
|
+
transition(store, unit, {
|
|
158
|
+
status: "refused",
|
|
159
|
+
reason: {
|
|
160
|
+
nodeId: "core.integration.hooks",
|
|
161
|
+
summary: `beforeIntegrate hook failed ${unit.attempts} times: ${before.errors.map((e) => `${e.pluginId}: ${e.error}`).join("; ")}`,
|
|
162
|
+
violations: 0,
|
|
163
|
+
},
|
|
164
|
+
evidenceKey: "",
|
|
165
|
+
}, actor);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
transition(store, unit, { status: "queued" }, actor);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Green evaluation — integrate the candidate into the governed ref (single write point).
|
|
173
|
+
integrateCandidate(git, repoDir, governedRef, replay.candidateCommit);
|
|
174
|
+
transition(store, unit, {
|
|
175
|
+
status: "integrated",
|
|
176
|
+
commitSha: replay.candidateCommit,
|
|
177
|
+
evidenceKey: report.nodes.find((n) => n.evidenceKey)?.evidenceKey ?? "",
|
|
178
|
+
}, actor);
|
|
179
|
+
// afterIntegrate is post-hoc notification — errors cannot veto a landed unit,
|
|
180
|
+
// so they surface loudly in the drain report instead.
|
|
181
|
+
if (options.plugins && options.plugins.length > 0) {
|
|
182
|
+
const after = await invokeLifecycleHook(options.plugins, "afterIntegrate", {
|
|
183
|
+
unitId: unit.id,
|
|
184
|
+
outcome: "integrated",
|
|
185
|
+
data: { commitSha: replay.candidateCommit, governedRef },
|
|
186
|
+
});
|
|
187
|
+
if (after.errors.length > 0) {
|
|
188
|
+
options.hookErrors = [...(options.hookErrors ?? []), ...after.errors];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Drain the queue once, strict FIFO, exiting when empty. A second concurrent
|
|
194
|
+
* drain reports drain-in-progress and exits 0 — it never double-processes.
|
|
195
|
+
*/
|
|
196
|
+
export async function drainQueue(options) {
|
|
197
|
+
const git = options.git ?? defaultGitExec;
|
|
198
|
+
const lease = acquireLease(options.store.queueDir);
|
|
199
|
+
if (!lease) {
|
|
200
|
+
return { status: "drain-in-progress", processed: [] };
|
|
201
|
+
}
|
|
202
|
+
const processed = [];
|
|
203
|
+
try {
|
|
204
|
+
for (;;) {
|
|
205
|
+
lease.heartbeat(); // per-unit boundary — fresh heartbeat each iteration
|
|
206
|
+
const live = options.store
|
|
207
|
+
.units()
|
|
208
|
+
.filter((u) => !isTerminal(u.state))
|
|
209
|
+
.sort((a, b) => a.enqueuedAt.localeCompare(b.enqueuedAt) || a.id.localeCompare(b.id));
|
|
210
|
+
if (live.length === 0) {
|
|
211
|
+
store_checkpoint(options.store);
|
|
212
|
+
return { status: processed.length > 0 ? "drained" : "empty", processed };
|
|
213
|
+
}
|
|
214
|
+
const unit = live[0];
|
|
215
|
+
if (!normalizeForReentry(git, options.store, options.repoDir, unit, options.governedRef, `drain:${lease.lease.leaseId}`)) {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
await processUnit(options, lease, unit);
|
|
219
|
+
const final = options.store.readUnit(unit.id);
|
|
220
|
+
processed.push({ unitId: unit.id, terminal: final?.state.status ?? "unknown" });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
finally {
|
|
224
|
+
lease.release();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function store_checkpoint(store) {
|
|
228
|
+
try {
|
|
229
|
+
store.checkpoint();
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
// checkpoint failure never blocks a drain verdict
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
//# 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,mBAAmB,EAA4B,MAAM,iBAAiB,CAAC;AAEhF,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;AAuB5C,SAAS,OAAO,CAAC,KAAiB,EAAE,KAA+C;IACjF,KAAK,CAAC,aAAa,CAAC;QAClB,MAAM,EAAE,w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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
|