@warpgogol/forge 9.7.0 → 9.7.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 +25 -0
- package/dist/os/adr/handlers/archive.d.ts.map +1 -1
- package/dist/os/adr/handlers/archive.js +3 -7
- package/dist/os/adr/handlers/archive.js.map +1 -1
- package/dist/os/adr/handlers/list-create.d.ts.map +1 -1
- package/dist/os/adr/handlers/list-create.js +8 -6
- package/dist/os/adr/handlers/list-create.js.map +1 -1
- package/dist/os/audit/handlers/archive.d.ts.map +1 -1
- package/dist/os/audit/handlers/archive.js +3 -7
- package/dist/os/audit/handlers/archive.js.map +1 -1
- package/dist/os/core/archive-regen.d.ts +1 -0
- package/dist/os/core/archive-regen.d.ts.map +1 -1
- package/dist/os/core/archive-regen.js +31 -6
- package/dist/os/core/archive-regen.js.map +1 -1
- package/dist/os/core/core.module.d.ts.map +1 -1
- package/dist/os/core/core.module.js +5 -0
- package/dist/os/core/core.module.js.map +1 -1
- package/dist/os/core/handlers/pinned-check.d.ts +13 -0
- package/dist/os/core/handlers/pinned-check.d.ts.map +1 -1
- package/dist/os/core/handlers/pinned-check.js +25 -0
- package/dist/os/core/handlers/pinned-check.js.map +1 -1
- package/dist/os/core/handlers/pinned-types.d.ts +7 -0
- package/dist/os/core/handlers/pinned-types.d.ts.map +1 -1
- package/dist/os/core/handlers/pinned-validate.d.ts.map +1 -1
- package/dist/os/core/handlers/pinned-validate.js +24 -1
- package/dist/os/core/handlers/pinned-validate.js.map +1 -1
- package/dist/os/flow/digest.d.ts +73 -1
- package/dist/os/flow/digest.d.ts.map +1 -1
- package/dist/os/flow/digest.js +344 -92
- package/dist/os/flow/digest.js.map +1 -1
- package/dist/os/flow/evidence-lock.d.ts +36 -0
- package/dist/os/flow/evidence-lock.d.ts.map +1 -0
- package/dist/os/flow/evidence-lock.js +156 -0
- package/dist/os/flow/evidence-lock.js.map +1 -0
- package/dist/os/flow/flow.module.d.ts.map +1 -1
- package/dist/os/flow/flow.module.js +36 -14
- package/dist/os/flow/flow.module.js.map +1 -1
- package/dist/os/flow/git.d.ts +50 -3
- package/dist/os/flow/git.d.ts.map +1 -1
- package/dist/os/flow/git.js +144 -12
- package/dist/os/flow/git.js.map +1 -1
- package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-digest.js +3 -5
- package/dist/os/flow/handlers/flow-digest.js.map +1 -1
- package/dist/os/flow/handlers/flow-push.d.ts +81 -0
- package/dist/os/flow/handlers/flow-push.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-push.js +642 -138
- package/dist/os/flow/handlers/flow-push.js.map +1 -1
- package/dist/os/flow/locks.d.ts +8 -0
- package/dist/os/flow/locks.d.ts.map +1 -1
- package/dist/os/flow/locks.js +6 -3
- package/dist/os/flow/locks.js.map +1 -1
- package/dist/os/flow/preflight.d.ts.map +1 -1
- package/dist/os/flow/preflight.js +4 -2
- package/dist/os/flow/preflight.js.map +1 -1
- package/dist/os/flow/registry.d.ts +9 -5
- package/dist/os/flow/registry.d.ts.map +1 -1
- package/dist/os/flow/registry.js +2 -2
- package/dist/os/flow/registry.js.map +1 -1
- package/dist/os/friction/friction.module.d.ts.map +1 -1
- package/dist/os/friction/friction.module.js +30 -5
- package/dist/os/friction/friction.module.js.map +1 -1
- package/dist/os/friction/handlers/friction-add.d.ts.map +1 -1
- package/dist/os/friction/handlers/friction-add.js +10 -17
- package/dist/os/friction/handlers/friction-add.js.map +1 -1
- package/dist/os/friction/handlers/friction-migrate.d.ts.map +1 -1
- package/dist/os/friction/handlers/friction-migrate.js +188 -2
- package/dist/os/friction/handlers/friction-migrate.js.map +1 -1
- package/dist/os/friction/store.d.ts +4 -0
- package/dist/os/friction/store.d.ts.map +1 -1
- package/dist/os/friction/store.js +20 -0
- package/dist/os/friction/store.js.map +1 -1
- package/dist/os/friction/types.d.ts +12 -0
- package/dist/os/friction/types.d.ts.map +1 -1
- package/dist/os/friction/types.js +8 -0
- package/dist/os/friction/types.js.map +1 -1
- package/dist/os/gate/handlers/gate-probe-catalog.d.ts.map +1 -1
- package/dist/os/gate/handlers/gate-probe-catalog.js +38 -5
- package/dist/os/gate/handlers/gate-probe-catalog.js.map +1 -1
- package/dist/os/mission/handlers/archive.d.ts.map +1 -1
- package/dist/os/mission/handlers/archive.js +3 -7
- package/dist/os/mission/handlers/archive.js.map +1 -1
- package/dist/os/plan/handlers/archive.d.ts.map +1 -1
- package/dist/os/plan/handlers/archive.js +3 -7
- package/dist/os/plan/handlers/archive.js.map +1 -1
- package/dist/os/rfc/handlers/archive.d.ts.map +1 -1
- package/dist/os/rfc/handlers/archive.js +3 -7
- package/dist/os/rfc/handlers/archive.js.map +1 -1
- package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
- package/dist/os/rfc/handlers/list-create.js +15 -7
- package/dist/os/rfc/handlers/list-create.js.map +1 -1
- package/dist/os/session/handlers/archive.d.ts.map +1 -1
- package/dist/os/session/handlers/archive.js +3 -7
- package/dist/os/session/handlers/archive.js.map +1 -1
- package/dist/os/system/handlers/system-product-register.d.ts +24 -0
- package/dist/os/system/handlers/system-product-register.d.ts.map +1 -0
- package/dist/os/system/handlers/system-product-register.js +322 -0
- package/dist/os/system/handlers/system-product-register.js.map +1 -0
- package/dist/os/system/handlers/system-products-status.d.ts +23 -0
- package/dist/os/system/handlers/system-products-status.d.ts.map +1 -0
- package/dist/os/system/handlers/system-products-status.js +235 -0
- package/dist/os/system/handlers/system-products-status.js.map +1 -0
- package/dist/os/system/schemas.d.ts +13 -0
- package/dist/os/system/schemas.d.ts.map +1 -1
- package/dist/os/system/schemas.js +15 -0
- package/dist/os/system/schemas.js.map +1 -1
- package/dist/os/system/system.module.d.ts.map +1 -1
- package/dist/os/system/system.module.js +113 -3
- package/dist/os/system/system.module.js.map +1 -1
- package/dist/src/config/forge-config.d.ts +2 -0
- package/dist/src/config/forge-config.d.ts.map +1 -1
- package/dist/src/config/forge-config.js +11 -10
- package/dist/src/config/forge-config.js.map +1 -1
- package/dist/src/onboarding/create.d.ts.map +1 -1
- package/dist/src/onboarding/create.js +27 -2
- package/dist/src/onboarding/create.js.map +1 -1
- package/dist/src/profiles/stack-profile.js +2 -2
- package/dist/src/types.js +2 -2
- package/dist/src/utils/verifier-git.d.ts +27 -1
- package/dist/src/utils/verifier-git.d.ts.map +1 -1
- package/dist/src/utils/verifier-git.js +36 -6
- package/dist/src/utils/verifier-git.js.map +1 -1
- package/docs/reference/system-hub.md +104 -0
- package/os/adr/handlers/archive.ts +3 -11
- package/os/adr/handlers/list-create.test.ts +174 -0
- package/os/adr/handlers/list-create.ts +16 -8
- package/os/audit/handlers/archive.ts +3 -11
- package/os/core/archive-regen.ts +33 -7
- package/os/core/core.module.ts +7 -0
- package/os/core/docs-archive.test.ts +25 -0
- package/os/core/handlers/pinned-check.ts +30 -0
- package/os/core/handlers/pinned-types.ts +7 -0
- package/os/core/handlers/pinned-validate.ts +28 -3
- package/os/flow/digest.ts +436 -95
- package/os/flow/evidence-lock.ts +184 -0
- package/os/flow/flow.module.ts +37 -14
- package/os/flow/git.ts +206 -11
- package/os/flow/handlers/flow-digest.ts +12 -8
- package/os/flow/handlers/flow-push.ts +725 -137
- package/os/flow/locks.ts +24 -7
- package/os/flow/preflight.ts +4 -2
- package/os/flow/registry.ts +7 -3
- package/os/flow/tests/digest-id-inputs.test.ts +106 -0
- package/os/flow/tests/digest-persist.test.ts +243 -0
- package/os/flow/tests/evidence-preflight-surface-skip.test.ts +218 -0
- package/os/flow/tests/flow-push-attest.test.ts +137 -0
- package/os/flow/tests/flow-push-review-baseline.test.ts +339 -0
- package/os/flow/tests/flow-push-verifier-batch.test.ts +134 -0
- package/os/friction/friction-add.test.ts +42 -0
- package/os/friction/friction-migrate.test.ts +67 -2
- package/os/friction/friction.module.ts +33 -5
- package/os/friction/handlers/friction-add.ts +10 -15
- package/os/friction/handlers/friction-migrate.ts +220 -1
- package/os/friction/store.ts +19 -0
- package/os/friction/types.ts +8 -0
- package/os/gate/handlers/gate-probe-catalog.ts +39 -7
- package/os/gate/handlers/gate-probe-ratchet.test.ts +57 -22
- package/os/mission/handlers/archive.ts +3 -11
- package/os/plan/handlers/archive.ts +3 -11
- package/os/rfc/handlers/archive.ts +3 -11
- package/os/rfc/handlers/list-create.ts +22 -17
- package/os/session/handlers/archive.ts +3 -11
- package/os/system/handlers/system-product-register.ts +492 -0
- package/os/system/handlers/system-products-status.ts +395 -0
- package/os/system/schemas.ts +17 -0
- package/os/system/system.module.ts +117 -3
- package/os/system/tests/system-product-register.test.ts +304 -0
- package/os/system/tests/system-products-status.test.ts +154 -0
- package/package.json +1 -1
- package/profiles/root-agents-system.md +82 -0
- package/profiles/system.yaml +1 -0
- package/src/config/forge-config.ts +16 -11
- package/src/onboarding/create-superfolder-guard.test.ts +73 -0
- package/src/onboarding/create.ts +28 -2
- package/src/profiles/stack-profile.ts +2 -2
- package/src/tests/evidence-consult-serialization.test.ts +202 -0
- package/src/tests/pinned-validate.test.ts +194 -0
- package/src/tests/profile-flow-hooks.test.ts +1 -0
- package/src/tests/profile-schema.test.ts +1 -0
- package/src/tests/stack-profile.test.ts +1 -0
- package/src/types.ts +2 -2
- package/src/utils/verifier-git.ts +53 -5
package/os/flow/locks.ts
CHANGED
|
@@ -15,12 +15,12 @@ locks broken, always released in finally. Used for the short registry lock
|
|
|
15
15
|
<item>Refused attempts render the holder via describeHeldLock — `stale` serves callers classifying a lock they never waited on.</item>
|
|
16
16
|
</KEY_DECISIONS>
|
|
17
17
|
<CHANGE_SUMMARY>
|
|
18
|
-
<item>RFC-1504: review fixes — single io.readFile parse per iteration, real ageMs on dead-holder onStale, atomic break claim</item>
|
|
19
|
-
<item>RFC-1515: harden forge flow worktree lifecycle against vanished paths, forge-local state, dead-holder locks and generated drift</item>
|
|
20
18
|
<item>RFC-1515: close rfc-1515 review findings — delete tolerated paths before worktree remove, prune vanished registrations, verified branch -D, shared held-lock render, gated e2e throw, journal toleratedState, edge tests</item>
|
|
21
19
|
<item>RFC-1515: record rfc-1515 review r1 fixes, key decisions and corrected probe path</item>
|
|
22
20
|
<item>RFC-1597: atomic cut preflight + covers-resume + worktree-bound owner regen (RFC-1597)</item>
|
|
23
|
-
<
|
|
21
|
+
<item>RFC-1633: serialize evidence consults + bestEffort reader mode (RFC-1633)</item>
|
|
22
|
+
<item>RFC-1633: review round 1 — digest envInputs, package-wide bestEffort scan, holder command, serialized standalone preflight</item>
|
|
23
|
+
<history>RFC-1487, RFC-1504, RFC-1515</history>
|
|
24
24
|
</CHANGE_SUMMARY>
|
|
25
25
|
*/
|
|
26
26
|
|
|
@@ -52,6 +52,9 @@ export interface FlowLockOptions {
|
|
|
52
52
|
now?: () => number;
|
|
53
53
|
/** Injectable sleep for tests. */
|
|
54
54
|
sleep?: (ms: number) => Promise<void>;
|
|
55
|
+
/** RFC-1633: extra fields merged into the written lock payload (e.g.
|
|
56
|
+
* `command` on evidence-consult.lock) — readers ignore unknown keys. */
|
|
57
|
+
extraContent?: Record<string, unknown>;
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
/** Thrown when the wait budget elapses while a live lock is held. */
|
|
@@ -59,11 +62,17 @@ export class LockTimeoutError extends Error {
|
|
|
59
62
|
readonly lockPath: string;
|
|
60
63
|
/** RFC-1515: last observed holder payload — absent when the lock file was
|
|
61
64
|
* unreadable or vanished between polls ("holder unknown"). */
|
|
62
|
-
readonly holder?: {
|
|
65
|
+
readonly holder?: {
|
|
66
|
+
pid: number;
|
|
67
|
+
host?: string;
|
|
68
|
+
at: string;
|
|
69
|
+
bootId?: string;
|
|
70
|
+
command?: string;
|
|
71
|
+
};
|
|
63
72
|
constructor(
|
|
64
73
|
lockPath: string,
|
|
65
74
|
waitedMs: number,
|
|
66
|
-
holder?: { pid: number; host?: string; at: string; bootId?: string },
|
|
75
|
+
holder?: { pid: number; host?: string; at: string; bootId?: string; command?: string },
|
|
67
76
|
) {
|
|
68
77
|
super(`lock ${lockPath} still held after ${waitedMs} ms`);
|
|
69
78
|
this.name = "LockTimeoutError";
|
|
@@ -85,6 +94,8 @@ export interface HeldLockDiagnostic {
|
|
|
85
94
|
pid: number;
|
|
86
95
|
host?: string;
|
|
87
96
|
at: string;
|
|
97
|
+
/** RFC-1633: caller-supplied holder label when the lock file carries one. */
|
|
98
|
+
command?: string;
|
|
88
99
|
/** ms since the holder's `at` — null when the timestamp never parsed. */
|
|
89
100
|
heldMs: number | null;
|
|
90
101
|
disposition: "live" | "dead-holder" | "stale";
|
|
@@ -99,7 +110,7 @@ export interface HeldLockDiagnostic {
|
|
|
99
110
|
* they never waited on.
|
|
100
111
|
*/
|
|
101
112
|
export function describeHeldLock(
|
|
102
|
-
holder: { pid: number; host?: string; at: string; bootId?: string },
|
|
113
|
+
holder: { pid: number; host?: string; at: string; bootId?: string; command?: string },
|
|
103
114
|
staleMs: number,
|
|
104
115
|
): HeldLockDiagnostic {
|
|
105
116
|
const heldAtMs = Date.parse(holder.at);
|
|
@@ -108,6 +119,7 @@ export function describeHeldLock(
|
|
|
108
119
|
pid: holder.pid,
|
|
109
120
|
host: holder.host,
|
|
110
121
|
at: holder.at,
|
|
122
|
+
command: holder.command,
|
|
111
123
|
heldMs,
|
|
112
124
|
disposition: holderIsDead(holder, currentBootId())
|
|
113
125
|
? "dead-holder"
|
|
@@ -157,6 +169,9 @@ interface HeldLock {
|
|
|
157
169
|
host?: string;
|
|
158
170
|
at: string;
|
|
159
171
|
bootId?: string;
|
|
172
|
+
/** RFC-1633: caller-supplied label (e.g. the consult kind) written via
|
|
173
|
+
* extraContent — surfaced in timeout diagnostics. */
|
|
174
|
+
command?: string;
|
|
160
175
|
}
|
|
161
176
|
|
|
162
177
|
/**
|
|
@@ -176,6 +191,7 @@ async function readHolder(
|
|
|
176
191
|
host: typeof parsed["host"] === "string" ? parsed["host"] : undefined,
|
|
177
192
|
at: typeof parsed["at"] === "string" ? parsed["at"] : "",
|
|
178
193
|
bootId: typeof parsed["bootId"] === "string" ? parsed["bootId"] : undefined,
|
|
194
|
+
command: typeof parsed["command"] === "string" ? parsed["command"] : undefined,
|
|
179
195
|
};
|
|
180
196
|
} catch {
|
|
181
197
|
return null;
|
|
@@ -203,10 +219,11 @@ export async function withFlowLock<T>(
|
|
|
203
219
|
let heldPayload: { pid: number; at: string } | null = null;
|
|
204
220
|
for (;;) {
|
|
205
221
|
const at = new Date(now()).toISOString();
|
|
206
|
-
const content: LockFileContent = {
|
|
222
|
+
const content: LockFileContent & Record<string, unknown> = {
|
|
207
223
|
pid: process.pid,
|
|
208
224
|
host: hostname(),
|
|
209
225
|
at,
|
|
226
|
+
...(opts.extraContent ?? {}),
|
|
210
227
|
};
|
|
211
228
|
if (ownBootId !== undefined) content.bootId = ownBootId;
|
|
212
229
|
const acquired = await tryAcquire(lockPath, content);
|
package/os/flow/preflight.ts
CHANGED
|
@@ -14,12 +14,12 @@ closed by the RFC: adding a check requires an amendment.</purpose>
|
|
|
14
14
|
</non-goals>
|
|
15
15
|
</MODULE_CONTRACT>
|
|
16
16
|
<CHANGE_SUMMARY>
|
|
17
|
-
<item>RFC-1599: sweep primary dirt into opened worktrees + bind session writes to the owning checkout (RFC-1599)</item>
|
|
18
17
|
<item>RFC-1616: close r25 trust-boundary counterexamples — pseudo-ref fingerprinting, resolved-path mutation ownership, origin/scratch spawn watches, transient-refusal retry</item>
|
|
19
18
|
<item>RFC-1622: bind RFC-1622 manifest regeneration to rendered bytes</item>
|
|
20
19
|
<item>RFC-1616: keep foreign-dirt attribution and lockfile/remote anchors honest under the judged evidence channel (RFC-1616)</item>
|
|
21
20
|
<item>RFC-1616: surface evidence refusals through claims and consult paths honestly (RFC-1616 follow-up)</item>
|
|
22
|
-
<
|
|
21
|
+
<item>RFC-1640: classify decision-log generated files as owned generated rebase conflicts</item>
|
|
22
|
+
<history>ADR-0129, ADR-0130, RFC-0000, RFC-1528, RFC-1531, RFC-1537, RFC-1538, RFC-1543, RFC-1544, RFC-1545, RFC-1546, RFC-1574, RFC-1590, RFC-1591, RFC-1599</history>
|
|
23
23
|
</CHANGE_SUMMARY>
|
|
24
24
|
*/
|
|
25
25
|
|
|
@@ -1338,6 +1338,8 @@ export const GENERATED_BASENAME_OWNERS: Record<string, string> = {
|
|
|
1338
1338
|
"ecosystem.generated.yaml": "ecosystem.manifest.generate",
|
|
1339
1339
|
"command-manifest.generated.yaml": "command.manifest.generate",
|
|
1340
1340
|
"agent-tools.generated.json": "command.tools.generate",
|
|
1341
|
+
"decision-log.generated.md": "rfc.decision-log.generate",
|
|
1342
|
+
"decision-log.generated.yaml": "rfc.decision-log.generate",
|
|
1341
1343
|
};
|
|
1342
1344
|
|
|
1343
1345
|
/**
|
package/os/flow/registry.ts
CHANGED
|
@@ -17,12 +17,12 @@ forge/journal.jsonl.</purpose>
|
|
|
17
17
|
<item>`held` is typed null now — the wave-2 outbound RFC widens it to { heldAt, riskCategory, reason }.</item>
|
|
18
18
|
</KEY_DECISIONS>
|
|
19
19
|
<CHANGE_SUMMARY>
|
|
20
|
-
<item>RFC-1532: FlowJournalEvent.gateReport — the repo-relative path links integrate/backmerge and integrate-refusal events to the attempt's persisted gate report</item>
|
|
21
20
|
<item>RFC-1538: revalidate integration preconditions post-lock and reuse the session engine</item>
|
|
22
21
|
<item>RFC-1531: add flow.integrate remediation flags on the shared dirty classifier</item>
|
|
23
22
|
<item>RFC-1589: run the integration gate outside the integration lock</item>
|
|
24
23
|
<item>RFC-1616: close RFC-1616 r3 trust-boundary counterexamples</item>
|
|
25
|
-
<
|
|
24
|
+
<item>RFC-1633: serialize evidence consults + bestEffort reader mode (RFC-1633)</item>
|
|
25
|
+
<history>RFC-1487, RFC-1490, RFC-1491, RFC-1503, RFC-1515, RFC-1532, RFC-1537</history>
|
|
26
26
|
</CHANGE_SUMMARY>
|
|
27
27
|
*/
|
|
28
28
|
|
|
@@ -136,7 +136,11 @@ export interface FlowJournalEvent {
|
|
|
136
136
|
| "publish"
|
|
137
137
|
| "publish-superseded"
|
|
138
138
|
| "publish-retired"
|
|
139
|
-
| "integrate-refusal"
|
|
139
|
+
| "integrate-refusal"
|
|
140
|
+
/** RFC-1633: evidence-consult lock break/wait-refusal bookkeeping —
|
|
141
|
+
* appended by evidence-lock.ts only on lock breaks and EVIDENCE-LOCKED
|
|
142
|
+
* refusals (bounded cardinality; acquire/release never journals). */
|
|
143
|
+
| "consult-lock";
|
|
140
144
|
branch: string;
|
|
141
145
|
sha: string;
|
|
142
146
|
detail: string;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1638 AC-4 evidence: digestId is computed over the reduced
|
|
4
|
+
judged-input set — refs/remotes/origin/*, derived ahead counts, and the
|
|
5
|
+
pushedTags journal suppression are OUTSIDE the hash, so post-push drift
|
|
6
|
+
of those surfaces cannot invalidate a reviewed digestId; while any local
|
|
7
|
+
mutation (tip move, journal tail, status) still does.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>No inputHash-vs-attestation coverage — flow-push-attest.test.ts owns the push-side assertions.</item>
|
|
10
|
+
</non-goals>
|
|
11
|
+
</MODULE_CONTRACT>
|
|
12
|
+
<KEY_DECISIONS>
|
|
13
|
+
<item>Remote drift is staged by plumbing (commit-tree + update-ref) — no checkout, so the local worktree/status input stays byte-identical across the two collects.</item>
|
|
14
|
+
</KEY_DECISIONS>
|
|
15
|
+
<CHANGE_SUMMARY>
|
|
16
|
+
<item>RFC-1638: digestId reduced-input-set stability tests</item>
|
|
17
|
+
<item>RFC-1638: persist reviewed digests + attest pushed state by input hash</item>
|
|
18
|
+
</CHANGE_SUMMARY>
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { rm, writeFile } from "node:fs/promises";
|
|
22
|
+
import { join } from "node:path";
|
|
23
|
+
|
|
24
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
25
|
+
|
|
26
|
+
import { ambientIo } from "../../../src/utils/io.ts";
|
|
27
|
+
import { collectDigest } from "../digest.ts";
|
|
28
|
+
import { appendJournal } from "../registry.ts";
|
|
29
|
+
import { releaseTagAnnotation, writeReleaseTag } from "../release-tags.ts";
|
|
30
|
+
import { gitExec, initRepoWithOrigin } from "./helpers.ts";
|
|
31
|
+
|
|
32
|
+
const dirs: string[] = [];
|
|
33
|
+
afterEach(async () => {
|
|
34
|
+
for (const dir of dirs.splice(0)) await rm(dir, { recursive: true, force: true });
|
|
35
|
+
}, 20_000);
|
|
36
|
+
|
|
37
|
+
async function unpushedCommit(repo: string, file: string, content: string): Promise<void> {
|
|
38
|
+
await writeFile(join(repo, file), content);
|
|
39
|
+
await gitExec(repo, ["add", file]);
|
|
40
|
+
await gitExec(repo, ["commit", "-m", `add ${file}`]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Plant a diverged child on refs/remotes/origin/<branch> via plumbing —
|
|
44
|
+
* the local checkout never moves, so only the remote-tracking input drifts. */
|
|
45
|
+
async function divergeRemoteRef(repo: string, branch: string): Promise<void> {
|
|
46
|
+
const base = (await gitExec(repo, ["rev-parse", `refs/remotes/origin/${branch}`])).stdout.trim();
|
|
47
|
+
const tree = (await gitExec(repo, ["rev-parse", `${base}^{tree}`])).stdout.trim();
|
|
48
|
+
const foreign = (
|
|
49
|
+
await gitExec(repo, ["commit-tree", tree, "-p", base, "-m", `foreign ${branch}`])
|
|
50
|
+
).stdout.trim();
|
|
51
|
+
await gitExec(repo, ["update-ref", `refs/remotes/origin/${branch}`, foreign]);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe("digestId reduced input set (RFC-1638, AC-4)", () => {
|
|
55
|
+
it("a remote-tracking ref move does not invalidate the quoted digestId", async () => {
|
|
56
|
+
const { repo } = await initRepoWithOrigin(dirs, { prefix: "digest-id-" });
|
|
57
|
+
await unpushedCommit(repo, "work.txt", "w\n");
|
|
58
|
+
const before = await collectDigest(repo, ambientIo, { fetch: false });
|
|
59
|
+
|
|
60
|
+
await divergeRemoteRef(repo, "develop");
|
|
61
|
+
const after = await collectDigest(repo, ambientIo, { fetch: false });
|
|
62
|
+
|
|
63
|
+
expect(after.digestId).toBe(before.digestId);
|
|
64
|
+
}, 120_000);
|
|
65
|
+
|
|
66
|
+
it("a journal 'push' record suppressing a tag does not change digestId", async () => {
|
|
67
|
+
const { repo } = await initRepoWithOrigin(dirs, { prefix: "digest-tag-" });
|
|
68
|
+
const tip = (await gitExec(repo, ["rev-parse", "develop"])).stdout.trim();
|
|
69
|
+
await writeReleaseTag(repo, ambientIo, {
|
|
70
|
+
name: "v1.0.1",
|
|
71
|
+
target: tip,
|
|
72
|
+
annotation: releaseTagAnnotation({
|
|
73
|
+
tag: "v1.0.1",
|
|
74
|
+
line: "repo",
|
|
75
|
+
version: "1.0.1",
|
|
76
|
+
level: "baseline",
|
|
77
|
+
previous: null,
|
|
78
|
+
rfcs: [],
|
|
79
|
+
fingerprints: {},
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
82
|
+
const before = await collectDigest(repo, ambientIo, { fetch: false });
|
|
83
|
+
expect(before.tags).toContain("v1.0.1");
|
|
84
|
+
|
|
85
|
+
await appendJournal(ambientIo, join(repo, ".git"), {
|
|
86
|
+
event: "push",
|
|
87
|
+
branch: "develop",
|
|
88
|
+
sha: tip,
|
|
89
|
+
detail: "v1.0.1",
|
|
90
|
+
at: new Date().toISOString(),
|
|
91
|
+
});
|
|
92
|
+
const after = await collectDigest(repo, ambientIo, { fetch: false });
|
|
93
|
+
|
|
94
|
+
expect(after.digestId).toBe(before.digestId);
|
|
95
|
+
expect(after.tags).not.toContain("v1.0.1"); // display list suppressed, hash stable
|
|
96
|
+
}, 120_000);
|
|
97
|
+
|
|
98
|
+
it("a local tip move DOES change digestId — the reduced set still covers local state", async () => {
|
|
99
|
+
const { repo } = await initRepoWithOrigin(dirs, { prefix: "digest-local-" });
|
|
100
|
+
await unpushedCommit(repo, "work.txt", "w\n");
|
|
101
|
+
const before = await collectDigest(repo, ambientIo, { fetch: false });
|
|
102
|
+
await unpushedCommit(repo, "more.txt", "m\n");
|
|
103
|
+
const after = await collectDigest(repo, ambientIo, { fetch: false });
|
|
104
|
+
expect(after.digestId).not.toBe(before.digestId);
|
|
105
|
+
}, 120_000);
|
|
106
|
+
});
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1638 AC-1 evidence: flow.digest persists the reviewed digest plus
|
|
4
|
+
its input hash under .git/forge/digests/<digestId>.json
|
|
5
|
+
(forge/persisted-digest@1), and every collector read maps to a declared
|
|
6
|
+
DigestInputs field — the exhaustiveness contract that keeps attestation from
|
|
7
|
+
attesting a stale digest clean.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>No push-path coverage — flow-push-attest.test.ts owns the consumer side.</item>
|
|
10
|
+
</non-goals>
|
|
11
|
+
</MODULE_CONTRACT>
|
|
12
|
+
<KEY_DECISIONS>
|
|
13
|
+
<item>The coverage assertion records real consult argv via the git.ts consultProbe seam, every io read through a wrapped ambientIo, AND ambient-io reads by monkeypatching ambientIo's methods for the collect window — a read escaping all three channels maps to nothing and FAILS (fail-closed classifiers, no catch-all).</item>
|
|
14
|
+
<item>An unclassified read FAILS the test — that is the false-negative tripwire: extending the collector without extending DigestInputs cannot slip silently.</item>
|
|
15
|
+
</KEY_DECISIONS>
|
|
16
|
+
<CHANGE_SUMMARY>
|
|
17
|
+
<item>RFC-1638: persist reviewed digests + DigestInputs coverage assertion</item>
|
|
18
|
+
<item>RFC-1638: review round 1 — fail-closed classifiers, ambient-io interception</item>
|
|
19
|
+
<item>RFC-1643: committed verifier-review baseline for flow.push</item>
|
|
20
|
+
</CHANGE_SUMMARY>
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { readFile, rm, writeFile } from "node:fs/promises";
|
|
24
|
+
import { tmpdir } from "node:os";
|
|
25
|
+
import { join } from "node:path";
|
|
26
|
+
|
|
27
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
28
|
+
|
|
29
|
+
import { ambientIo } from "../../../src/utils/io.ts";
|
|
30
|
+
import type { WorkspaceIO } from "../../../src/types.ts";
|
|
31
|
+
import {
|
|
32
|
+
collectDigest,
|
|
33
|
+
digestInputHash,
|
|
34
|
+
observeDigestInputs,
|
|
35
|
+
PERSISTED_DIGEST_SCHEMA,
|
|
36
|
+
PERSISTED_DIGESTS_DIR,
|
|
37
|
+
type DigestInputs,
|
|
38
|
+
type PersistedDigest,
|
|
39
|
+
} from "../digest.ts";
|
|
40
|
+
import { consultProbe } from "../git.ts";
|
|
41
|
+
import { gitExec, initRepoWithOrigin } from "./helpers.ts";
|
|
42
|
+
|
|
43
|
+
const dirs: string[] = [];
|
|
44
|
+
afterEach(async () => {
|
|
45
|
+
consultProbe.current = null;
|
|
46
|
+
for (const dir of dirs.splice(0)) {
|
|
47
|
+
await rm(dir, { recursive: true, force: true });
|
|
48
|
+
}
|
|
49
|
+
}, 20_000);
|
|
50
|
+
|
|
51
|
+
async function unpushedCommit(repo: string, file: string, content: string): Promise<void> {
|
|
52
|
+
await writeFile(join(repo, file), content);
|
|
53
|
+
await gitExec(repo, ["add", file]);
|
|
54
|
+
await gitExec(repo, ["commit", "-m", `add ${file}`]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type InputField = keyof DigestInputs | "own-artifact" | "machinery";
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The reads → inputs mapping from the RFC's exhaustiveness contract —
|
|
61
|
+
* FAIL-CLOSED: a consult argv this function cannot place maps to
|
|
62
|
+
* `undefined` and fails the coverage assertion.
|
|
63
|
+
*/
|
|
64
|
+
function classifyConsult(argv: readonly string[]): InputField | undefined {
|
|
65
|
+
const [op] = argv;
|
|
66
|
+
const head = argv.join(" ");
|
|
67
|
+
// Evidence-channel self-capture (RFC-1616 preflight): gitdir/shape
|
|
68
|
+
// resolves, the branch-name probe and the full config dump gate whether a
|
|
69
|
+
// consult is TRUSTED — they never feed digest content, and a drifted
|
|
70
|
+
// surface makes the channel's own re-preflight refuse the consult
|
|
71
|
+
// (observeDigestInputs → null → recount), so the safe direction holds
|
|
72
|
+
// without a DigestInputs field.
|
|
73
|
+
if (
|
|
74
|
+
op === "symbolic-ref" ||
|
|
75
|
+
head.includes("--git-path") ||
|
|
76
|
+
head.includes("--absolute-git-dir") ||
|
|
77
|
+
head.includes("--git-common-dir") ||
|
|
78
|
+
head.includes("--no-includes --list")
|
|
79
|
+
) {
|
|
80
|
+
return "machinery";
|
|
81
|
+
}
|
|
82
|
+
if (op === "status") return "statusPorcelainSha256";
|
|
83
|
+
if (op === "remote" || op === "ls-remote" || op === "fetch") return "remoteConfigSha256";
|
|
84
|
+
if (op === "config") {
|
|
85
|
+
// Only the remote-identity consults are hashed — anything else read
|
|
86
|
+
// through config escapes remoteConfigSha256.
|
|
87
|
+
return /remote\.|url\.|insteadof|credential|protocol|core\.ssh|http/i.test(head)
|
|
88
|
+
? "remoteConfigSha256"
|
|
89
|
+
: undefined;
|
|
90
|
+
}
|
|
91
|
+
if (op === "rev-parse") {
|
|
92
|
+
if (head.includes("refs/remotes/")) return "developRemote";
|
|
93
|
+
// RFC-1643: tips resolve fully qualified (`refs/heads/*`).
|
|
94
|
+
if (argv.includes("develop") || argv.includes("refs/heads/develop")) return "developLocal";
|
|
95
|
+
if (argv.includes("main") || argv.includes("refs/heads/main")) return "mainLocal";
|
|
96
|
+
if (argv.includes("HEAD")) return "head";
|
|
97
|
+
return undefined; // any other rev-parse resolves a surface no input pins
|
|
98
|
+
}
|
|
99
|
+
if (op === "worktree") return "sessions";
|
|
100
|
+
if (op === "check-ignore" || op === "ls-files") return "statusPorcelainSha256";
|
|
101
|
+
// Object/graph reads pinned by the recorded branch tips + HEAD.
|
|
102
|
+
if (
|
|
103
|
+
[
|
|
104
|
+
"rev-list",
|
|
105
|
+
"log",
|
|
106
|
+
"show",
|
|
107
|
+
"diff",
|
|
108
|
+
"cat-file",
|
|
109
|
+
"for-each-ref",
|
|
110
|
+
"merge-base",
|
|
111
|
+
"describe",
|
|
112
|
+
"ls-tree",
|
|
113
|
+
"tag",
|
|
114
|
+
"grep",
|
|
115
|
+
].includes(op)
|
|
116
|
+
) {
|
|
117
|
+
return "head";
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* io-read path → input field — FAIL-CLOSED. Own-artifact = the persisted
|
|
124
|
+
* digests dir itself; machinery = tmpdir scratch outside the judged
|
|
125
|
+
* surface. Direct node:fs imports the io adapter cannot see (e.g. the
|
|
126
|
+
* ambient `frontmatter-io` alias is intercepted via the monkeypatch below;
|
|
127
|
+
* truly invisible reads would surface only via statusPorcelain changes —
|
|
128
|
+
* the comment documents that residual carve-out).
|
|
129
|
+
*/
|
|
130
|
+
function classifyIoPath(path: string): InputField | undefined {
|
|
131
|
+
const p = path.replaceAll("\\", "/");
|
|
132
|
+
if (p.includes(`/${PERSISTED_DIGESTS_DIR}/`)) return "own-artifact";
|
|
133
|
+
if (p.includes("/forge/digests/")) return "own-artifact";
|
|
134
|
+
if (p.endsWith("/forge/journal.jsonl")) return "journalTailSha256";
|
|
135
|
+
if (p.includes("/forge/registry")) return "sessions";
|
|
136
|
+
if (p.includes("/.github/workflows")) return "tagTriggerFilesSha256";
|
|
137
|
+
if (p.endsWith("/.git/HEAD")) return "head";
|
|
138
|
+
if (p.includes("/.git/refs/") || p.endsWith("/.git/packed-refs")) return "head";
|
|
139
|
+
if (p.endsWith("/.git/config")) return "remoteConfigSha256";
|
|
140
|
+
if (p.includes("/.git/objects/") || p.includes("/.git/worktrees/")) return "head";
|
|
141
|
+
if (p.includes(tmpdir().replaceAll("\\", "/"))) return "machinery";
|
|
142
|
+
if (p.includes("/node_modules/")) return "machinery";
|
|
143
|
+
// Worktree file reads (forge.yaml, package.json, pnpm-workspace.yaml,
|
|
144
|
+
// docs/**, hooks/**, *.md, .gitignore) — the porcelain belt pins them.
|
|
145
|
+
if (!p.includes("/.git/")) return "statusPorcelainSha256";
|
|
146
|
+
// Any other .git-internal read — index, COMMIT_EDITMSG, hooks state —
|
|
147
|
+
// maps to no input: fail the test so DigestInputs must grow.
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
describe("flow.digest persisted digest (RFC-1638, AC-1)", () => {
|
|
152
|
+
it("collectDigest writes forge/persisted-digest@1 with a matching inputHash", async () => {
|
|
153
|
+
const { repo } = await initRepoWithOrigin(dirs, { prefix: "digest-persist-" });
|
|
154
|
+
await unpushedCommit(repo, "work.txt", "w\n");
|
|
155
|
+
const data = await collectDigest(repo, ambientIo, { fetch: false });
|
|
156
|
+
|
|
157
|
+
const dir = join(repo, ".git", PERSISTED_DIGESTS_DIR);
|
|
158
|
+
const file = join(dir, `${data.digestId}.json`);
|
|
159
|
+
const persisted = JSON.parse(await readFile(file, "utf8")) as PersistedDigest;
|
|
160
|
+
|
|
161
|
+
expect(persisted.schema).toBe(PERSISTED_DIGEST_SCHEMA);
|
|
162
|
+
expect(persisted.digestId).toBe(data.digestId);
|
|
163
|
+
expect(persisted.computedAt).toMatch(/^\d{4}-\d{2}-\d{2}T/);
|
|
164
|
+
expect(persisted.digest).toEqual(data);
|
|
165
|
+
// The preimage member the suppressed tag view cannot reconstruct —
|
|
166
|
+
// the field push-side recompute binds the payload through.
|
|
167
|
+
expect(persisted.releaseTags).toEqual(expect.arrayContaining(data.tags));
|
|
168
|
+
|
|
169
|
+
// The persisted input hash re-observes equal on unchanged state — that
|
|
170
|
+
// is the equality attestation relies on.
|
|
171
|
+
const inputs = await observeDigestInputs(repo, ambientIo);
|
|
172
|
+
expect(inputs).not.toBeNull();
|
|
173
|
+
expect(digestInputHash(inputs!)).toBe(persisted.inputHash);
|
|
174
|
+
}, 90_000);
|
|
175
|
+
|
|
176
|
+
it("every collector read maps to a declared DigestInputs field", async () => {
|
|
177
|
+
const { repo } = await initRepoWithOrigin(dirs, { prefix: "digest-cover-" });
|
|
178
|
+
await unpushedCommit(repo, "work.txt", "w\n");
|
|
179
|
+
|
|
180
|
+
const consults: Array<{ argv: readonly string[]; channel: string }> = [];
|
|
181
|
+
const ioReads: string[] = [];
|
|
182
|
+
consultProbe.current = (argv, channel) => consults.push({ argv, channel });
|
|
183
|
+
const io: WorkspaceIO = {
|
|
184
|
+
...ambientIo,
|
|
185
|
+
readFile: async (p: string) => {
|
|
186
|
+
ioReads.push(p);
|
|
187
|
+
return ambientIo.readFile(p);
|
|
188
|
+
},
|
|
189
|
+
readFileBytes: async (p: string) => {
|
|
190
|
+
ioReads.push(p);
|
|
191
|
+
return ambientIo.readFileBytes(p);
|
|
192
|
+
},
|
|
193
|
+
exists: async (p: string) => {
|
|
194
|
+
ioReads.push(p);
|
|
195
|
+
return ambientIo.exists(p);
|
|
196
|
+
},
|
|
197
|
+
readdir: async (p: string) => {
|
|
198
|
+
ioReads.push(p);
|
|
199
|
+
return ambientIo.readdir(p);
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
// Ambient-io reads (helpers importing `ambientIo` directly — e.g.
|
|
203
|
+
// frontmatter-io's `fs` alias) escape the wrapped adapter; patch the
|
|
204
|
+
// object's methods for the collect window so they record too.
|
|
205
|
+
const ambientReads: string[] = [];
|
|
206
|
+
const originals = {
|
|
207
|
+
readFile: ambientIo.readFile,
|
|
208
|
+
exists: ambientIo.exists,
|
|
209
|
+
readdir: ambientIo.readdir,
|
|
210
|
+
};
|
|
211
|
+
ambientIo.readFile = async (p: string) => {
|
|
212
|
+
ambientReads.push(p);
|
|
213
|
+
return originals.readFile(p);
|
|
214
|
+
};
|
|
215
|
+
ambientIo.exists = async (p: string) => {
|
|
216
|
+
ambientReads.push(p);
|
|
217
|
+
return originals.exists(p);
|
|
218
|
+
};
|
|
219
|
+
ambientIo.readdir = async (p: string) => {
|
|
220
|
+
ambientReads.push(p);
|
|
221
|
+
return originals.readdir(p);
|
|
222
|
+
};
|
|
223
|
+
try {
|
|
224
|
+
await collectDigest(repo, io, { fetch: false });
|
|
225
|
+
} finally {
|
|
226
|
+
consultProbe.current = null;
|
|
227
|
+
ambientIo.readFile = originals.readFile;
|
|
228
|
+
ambientIo.exists = originals.exists;
|
|
229
|
+
ambientIo.readdir = originals.readdir;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
expect(consults.length).toBeGreaterThan(0);
|
|
233
|
+
const unmappedConsults = consults.filter((c) => classifyConsult(c.argv) === undefined);
|
|
234
|
+
const unmappedReads = [...ioReads, ...ambientReads].filter(
|
|
235
|
+
(p) => classifyIoPath(p) === undefined,
|
|
236
|
+
);
|
|
237
|
+
expect(
|
|
238
|
+
unmappedConsults.map((c) => `${c.channel}: ${c.argv.join(" ")}`),
|
|
239
|
+
"collector consults that map to no DigestInputs field — extend DigestInputs or the attestation goes stale-blind",
|
|
240
|
+
).toEqual([]);
|
|
241
|
+
expect(unmappedReads, "collector io reads that map to no DigestInputs field").toEqual([]);
|
|
242
|
+
}, 90_000);
|
|
243
|
+
});
|