@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
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>system.products.status command handler (RFC-1639) — reports each
|
|
4
|
+
registered product's health against disk reality: resolved checkout folder,
|
|
5
|
+
declared profile, syncedVersion vs the hub baseline, dirty state, live
|
|
6
|
+
session worktrees and commits ahead; plus registry-vs-disk diagnostics
|
|
7
|
+
(unregistered forge siblings, missing or broken local checkouts). Read-only
|
|
8
|
+
— a registered product missing on disk is the only error; everything else
|
|
9
|
+
degrades to warnings so the report stays complete.</purpose>
|
|
10
|
+
<non-goals>
|
|
11
|
+
<item>No writes — the report never mutates registry or product files.</item>
|
|
12
|
+
<item>No queue, outbox, scenario or version-set behavior — RFC-1509..1511.</item>
|
|
13
|
+
</non-goals>
|
|
14
|
+
</MODULE_CONTRACT>
|
|
15
|
+
<CHANGE_SUMMARY>
|
|
16
|
+
<item>RFC-1639: system.products.status — member health + registry-vs-disk probe</item>
|
|
17
|
+
<item>RFC-1639: step 1-2 — friction record fields, roster frozen/ignored, system.products.status</item>
|
|
18
|
+
<item>RFC-1639: review — SYSTEM-MAP-01 rules decl, git-probe warnings, sibling kind/path discriminants, friction.add provenance, ingest hardening</item>
|
|
19
|
+
</CHANGE_SUMMARY>
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import path from "node:path";
|
|
23
|
+
import YAML from "yaml";
|
|
24
|
+
|
|
25
|
+
import { resolveIo } from "../../../src/utils/io.ts";
|
|
26
|
+
import type {
|
|
27
|
+
Diagnostic,
|
|
28
|
+
ForgeCommandInput,
|
|
29
|
+
ForgeCommandResult,
|
|
30
|
+
ForgeRuntimeContext,
|
|
31
|
+
WorkspaceIO,
|
|
32
|
+
} from "../../../src/types.ts";
|
|
33
|
+
import { git } from "../../flow/git.ts";
|
|
34
|
+
import {
|
|
35
|
+
assertSystemRepository,
|
|
36
|
+
FORGE_CONFIG_FILE,
|
|
37
|
+
loadSystemMap,
|
|
38
|
+
SYSTEM_PRODUCTS_FILE,
|
|
39
|
+
} from "../repo.ts";
|
|
40
|
+
import type { SystemMap } from "../repo.ts";
|
|
41
|
+
|
|
42
|
+
export interface ProductStatus {
|
|
43
|
+
id: string;
|
|
44
|
+
folder: string | null;
|
|
45
|
+
profile: string | null;
|
|
46
|
+
forgeVersion: string | null;
|
|
47
|
+
versionOk: boolean | null;
|
|
48
|
+
dirty: boolean | null;
|
|
49
|
+
sessionWorktrees: string[];
|
|
50
|
+
aheadOfOrigin: number | null;
|
|
51
|
+
frozen: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface SystemProductsStatusResult {
|
|
55
|
+
command: "system.products.status";
|
|
56
|
+
status: "ok" | "warn" | "fail";
|
|
57
|
+
hub: string;
|
|
58
|
+
baseline: string | null;
|
|
59
|
+
products: ProductStatus[];
|
|
60
|
+
warnings: Diagnostic[];
|
|
61
|
+
errors: Diagnostic[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function diagnostic(
|
|
65
|
+
ruleId: "SYSTEM-PRODUCTS-01" | "SYSTEM-PRODUCTS-02",
|
|
66
|
+
severity: "error" | "warning",
|
|
67
|
+
file: string,
|
|
68
|
+
message: string,
|
|
69
|
+
fixHint: string,
|
|
70
|
+
): Diagnostic {
|
|
71
|
+
return { ruleId, severity, file, message, fixHint };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Read the two fields the report needs — null when the file is absent or
|
|
75
|
+
* unreadable (the caller turns that into the broken-checkout diagnostic). */
|
|
76
|
+
async function readProductForgeYaml(
|
|
77
|
+
io: WorkspaceIO,
|
|
78
|
+
dir: string,
|
|
79
|
+
): Promise<{ profile: string | null; syncedVersion: string | null } | null> {
|
|
80
|
+
const abs = path.join(dir, FORGE_CONFIG_FILE);
|
|
81
|
+
if (!(await io.exists(abs))) return null;
|
|
82
|
+
try {
|
|
83
|
+
const parsed = YAML.parse(await io.readFile(abs)) as Record<string, unknown> | null;
|
|
84
|
+
if (parsed === null || typeof parsed !== "object") return null;
|
|
85
|
+
const rawProfile = parsed["profile"];
|
|
86
|
+
const profile =
|
|
87
|
+
typeof rawProfile === "string"
|
|
88
|
+
? rawProfile
|
|
89
|
+
: rawProfile !== null && typeof rawProfile === "object"
|
|
90
|
+
? (((rawProfile as Record<string, unknown>)["id"] as string | undefined) ?? null)
|
|
91
|
+
: null;
|
|
92
|
+
const rawForge = parsed["forge"];
|
|
93
|
+
const syncedVersion =
|
|
94
|
+
rawForge !== null && typeof rawForge === "object"
|
|
95
|
+
? (((rawForge as Record<string, unknown>)["syncedVersion"] as string | null) ?? null)
|
|
96
|
+
: null;
|
|
97
|
+
return { profile, syncedVersion };
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function dirExists(io: WorkspaceIO, abs: string): Promise<boolean> {
|
|
104
|
+
try {
|
|
105
|
+
return (await io.stat(abs)).isDirectory;
|
|
106
|
+
} catch {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export async function runSystemProductsStatus(
|
|
112
|
+
_input: ForgeCommandInput,
|
|
113
|
+
context: ForgeRuntimeContext,
|
|
114
|
+
): Promise<ForgeCommandResult<SystemProductsStatusResult>> {
|
|
115
|
+
const io = resolveIo(context.io);
|
|
116
|
+
const root = context.workspaceRoot;
|
|
117
|
+
const warnings: Diagnostic[] = [];
|
|
118
|
+
const errors: Diagnostic[] = [];
|
|
119
|
+
const products: ProductStatus[] = [];
|
|
120
|
+
|
|
121
|
+
const refusal = await assertSystemRepository(root, io);
|
|
122
|
+
if (refusal) {
|
|
123
|
+
errors.push(refusal);
|
|
124
|
+
return finish(root, null, products, warnings, errors, context);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const loaded = await loadSystemMap(root, io);
|
|
128
|
+
for (const d of loaded.diagnostics) {
|
|
129
|
+
(d.severity === "error" ? errors : warnings).push(d);
|
|
130
|
+
}
|
|
131
|
+
const map = loaded.map;
|
|
132
|
+
if (map === null) {
|
|
133
|
+
return finish(root, null, products, warnings, errors, context);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Baseline — the hub's own syncedVersion (the toolchain it distributes).
|
|
137
|
+
const hubConfig = await readProductForgeYaml(io, root);
|
|
138
|
+
const baseline = hubConfig?.syncedVersion ?? null;
|
|
139
|
+
if (baseline === null) {
|
|
140
|
+
warnings.push(
|
|
141
|
+
diagnostic(
|
|
142
|
+
"SYSTEM-PRODUCTS-02",
|
|
143
|
+
"warning",
|
|
144
|
+
FORGE_CONFIG_FILE,
|
|
145
|
+
"the hub's forge.yaml carries no forge.syncedVersion — versionOk cannot be evaluated",
|
|
146
|
+
"Run `forge upgrade` in the hub to stamp syncedVersion.",
|
|
147
|
+
),
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (map.local === null) {
|
|
152
|
+
warnings.push(
|
|
153
|
+
diagnostic(
|
|
154
|
+
"SYSTEM-PRODUCTS-02",
|
|
155
|
+
"warning",
|
|
156
|
+
"system/products.local.yaml",
|
|
157
|
+
"products.local.yaml is absent — local checkouts are unknown; every product reports folder: null",
|
|
158
|
+
"Create system/products.local.yaml (gitignored) mapping product ids to folders.",
|
|
159
|
+
),
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const resolvedFolders = new Set<string>();
|
|
164
|
+
for (const product of map.products.products) {
|
|
165
|
+
products.push(await probeProduct(product, map, root, baseline, io, warnings, errors));
|
|
166
|
+
const entry = products[products.length - 1]!;
|
|
167
|
+
if (entry.folder !== null) resolvedFolders.add(entry.folder);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Registry-vs-disk: a sibling of the hub carrying forge.yaml that is not a
|
|
171
|
+
// registered product — an adoption gap, unless deliberately `ignored`.
|
|
172
|
+
const ignored = new Set((map.products.ignored ?? []).map((i) => i.id));
|
|
173
|
+
const superfolder = path.dirname(root);
|
|
174
|
+
try {
|
|
175
|
+
for (const child of await io.readdir(superfolder)) {
|
|
176
|
+
if (!child.isDirectory || child.name.includes("@") || child.name.startsWith(".")) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const childAbs = path.join(superfolder, child.name);
|
|
180
|
+
if (childAbs === root || resolvedFolders.has(childAbs) || ignored.has(child.name)) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (await io.exists(path.join(childAbs, FORGE_CONFIG_FILE))) {
|
|
184
|
+
warnings.push({
|
|
185
|
+
...diagnostic(
|
|
186
|
+
"SYSTEM-PRODUCTS-02",
|
|
187
|
+
"warning",
|
|
188
|
+
child.name,
|
|
189
|
+
`sibling "${child.name}" carries forge.yaml but is not a registered product`,
|
|
190
|
+
`Declare it in ${SYSTEM_PRODUCTS_FILE} or name it in ignored[].`,
|
|
191
|
+
),
|
|
192
|
+
data: { kind: "unregistered-forge-sibling", path: childAbs },
|
|
193
|
+
});
|
|
194
|
+
} else if (await io.exists(path.join(childAbs, ".git"))) {
|
|
195
|
+
warnings.push({
|
|
196
|
+
...diagnostic(
|
|
197
|
+
"SYSTEM-PRODUCTS-02",
|
|
198
|
+
"warning",
|
|
199
|
+
child.name,
|
|
200
|
+
`sibling "${child.name}" is a git checkout without forge.yaml — a pre-adoption signal`,
|
|
201
|
+
`Run forge.init in ${child.name} or name it in ignored[].`,
|
|
202
|
+
),
|
|
203
|
+
data: { kind: "git-sibling-without-forge", path: childAbs },
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
} catch {
|
|
208
|
+
warnings.push(
|
|
209
|
+
diagnostic(
|
|
210
|
+
"SYSTEM-PRODUCTS-02",
|
|
211
|
+
"warning",
|
|
212
|
+
superfolder,
|
|
213
|
+
"could not enumerate the hub's sibling directories — registry-vs-disk check skipped",
|
|
214
|
+
"Check read permissions on the parent directory.",
|
|
215
|
+
),
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return finish(root, baseline, products, warnings, errors, context);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function probeProduct(
|
|
223
|
+
product: SystemMap["products"]["products"][number],
|
|
224
|
+
map: SystemMap,
|
|
225
|
+
root: string,
|
|
226
|
+
baseline: string | null,
|
|
227
|
+
io: WorkspaceIO,
|
|
228
|
+
warnings: Diagnostic[],
|
|
229
|
+
errors: Diagnostic[],
|
|
230
|
+
): Promise<ProductStatus> {
|
|
231
|
+
const status: ProductStatus = {
|
|
232
|
+
id: product.id,
|
|
233
|
+
folder: null,
|
|
234
|
+
profile: null,
|
|
235
|
+
forgeVersion: null,
|
|
236
|
+
versionOk: null,
|
|
237
|
+
dirty: null,
|
|
238
|
+
sessionWorktrees: [],
|
|
239
|
+
aheadOfOrigin: null,
|
|
240
|
+
frozen: product.frozen === true,
|
|
241
|
+
};
|
|
242
|
+
const flag = (message: string, fixHint: string, file = product.id): void => {
|
|
243
|
+
// frozen products are reported but exempt from error diagnostics.
|
|
244
|
+
(status.frozen ? warnings : errors).push(
|
|
245
|
+
diagnostic(
|
|
246
|
+
status.frozen ? "SYSTEM-PRODUCTS-02" : "SYSTEM-PRODUCTS-01",
|
|
247
|
+
status.frozen ? "warning" : "error",
|
|
248
|
+
file,
|
|
249
|
+
status.frozen ? `${message} (frozen — informational only)` : message,
|
|
250
|
+
fixHint,
|
|
251
|
+
),
|
|
252
|
+
);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const local = map.local?.folders[product.id];
|
|
256
|
+
if (map.local !== null && local === undefined) {
|
|
257
|
+
flag(
|
|
258
|
+
`product "${product.id}" has no folder in system/products.local.yaml`,
|
|
259
|
+
`Add "${product.id}: <folder>" to system/products.local.yaml when its repository is checked out.`,
|
|
260
|
+
"system/products.local.yaml",
|
|
261
|
+
);
|
|
262
|
+
return status;
|
|
263
|
+
}
|
|
264
|
+
const folder =
|
|
265
|
+
local !== undefined ? (path.isAbsolute(local) ? local : path.join(root, local)) : null;
|
|
266
|
+
status.folder = folder;
|
|
267
|
+
if (folder === null) return status;
|
|
268
|
+
|
|
269
|
+
if (!(await dirExists(io, folder))) {
|
|
270
|
+
flag(
|
|
271
|
+
`product "${product.id}" names a local folder that does not exist: ${local}`,
|
|
272
|
+
`Check out the ${product.id} repository at ${local} or fix the mapping.`,
|
|
273
|
+
"system/products.local.yaml",
|
|
274
|
+
);
|
|
275
|
+
return status;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const shape = await readProductForgeYaml(io, folder);
|
|
279
|
+
if (shape === null) {
|
|
280
|
+
flag(
|
|
281
|
+
`product "${product.id}" has no readable forge.yaml at ${folder}`,
|
|
282
|
+
`Restore ${FORGE_CONFIG_FILE} in ${folder} or fix the products.local.yaml mapping.`,
|
|
283
|
+
);
|
|
284
|
+
return status;
|
|
285
|
+
}
|
|
286
|
+
status.profile = shape.profile;
|
|
287
|
+
status.forgeVersion = shape.syncedVersion;
|
|
288
|
+
// A missing member version is provably unequal, not "unknown" — only a
|
|
289
|
+
// missing hub baseline makes versionOk un-evaluable (null).
|
|
290
|
+
status.versionOk = baseline !== null ? status.forgeVersion === baseline : null;
|
|
291
|
+
|
|
292
|
+
// Live session worktrees: siblings of the product folder named `<id>@*`.
|
|
293
|
+
try {
|
|
294
|
+
for (const sib of await io.readdir(path.dirname(folder))) {
|
|
295
|
+
if (sib.isDirectory && sib.name.startsWith(`${product.id}@`)) {
|
|
296
|
+
status.sessionWorktrees.push(sib.name);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
} catch {
|
|
300
|
+
// the parent listing is best-effort — absence of worktrees is the common case
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Git probes degrade to null + warning — a product with no readable git
|
|
304
|
+
// state reports its other fields rather than failing. A missing io
|
|
305
|
+
// capability is never a concrete verdict (AGENTS.md capability rule).
|
|
306
|
+
if (!(await io.exists(path.join(folder, ".git")))) {
|
|
307
|
+
warnings.push(
|
|
308
|
+
diagnostic(
|
|
309
|
+
"SYSTEM-PRODUCTS-02",
|
|
310
|
+
"warning",
|
|
311
|
+
product.id,
|
|
312
|
+
`product "${product.id}" has no .git at ${folder} — git probes skipped`,
|
|
313
|
+
"",
|
|
314
|
+
),
|
|
315
|
+
);
|
|
316
|
+
} else if (typeof io.exec !== "function") {
|
|
317
|
+
warnings.push(
|
|
318
|
+
diagnostic(
|
|
319
|
+
"SYSTEM-PRODUCTS-02",
|
|
320
|
+
"warning",
|
|
321
|
+
product.id,
|
|
322
|
+
`product "${product.id}" git probes unavailable — io.exec missing`,
|
|
323
|
+
"",
|
|
324
|
+
),
|
|
325
|
+
);
|
|
326
|
+
} else {
|
|
327
|
+
const dirty = await git(folder, io, ["status", "--porcelain", "--untracked-files=no"]);
|
|
328
|
+
if (dirty.exitCode === 0) {
|
|
329
|
+
status.dirty = dirty.stdout.trim().length > 0;
|
|
330
|
+
} else {
|
|
331
|
+
warnings.push(
|
|
332
|
+
diagnostic(
|
|
333
|
+
"SYSTEM-PRODUCTS-02",
|
|
334
|
+
"warning",
|
|
335
|
+
product.id,
|
|
336
|
+
`git status failed for "${product.id}" (${dirty.stderr.trim() || `exit ${dirty.exitCode}`})`,
|
|
337
|
+
"",
|
|
338
|
+
),
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
const ahead = await git(folder, io, ["rev-list", "--count", "@{upstream}..HEAD"]);
|
|
342
|
+
if (ahead.exitCode === 0) {
|
|
343
|
+
status.aheadOfOrigin = parseInt(ahead.stdout.trim(), 10);
|
|
344
|
+
} else {
|
|
345
|
+
warnings.push(
|
|
346
|
+
diagnostic(
|
|
347
|
+
"SYSTEM-PRODUCTS-02",
|
|
348
|
+
"warning",
|
|
349
|
+
product.id,
|
|
350
|
+
`git rev-list failed for "${product.id}" (${ahead.stderr.trim() || `exit ${ahead.exitCode}`}) — no upstream or detached HEAD`,
|
|
351
|
+
"",
|
|
352
|
+
),
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return status;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function finish(
|
|
361
|
+
root: string,
|
|
362
|
+
baseline: string | null,
|
|
363
|
+
products: ProductStatus[],
|
|
364
|
+
warnings: Diagnostic[],
|
|
365
|
+
errors: Diagnostic[],
|
|
366
|
+
context: ForgeRuntimeContext,
|
|
367
|
+
): ForgeCommandResult<SystemProductsStatusResult> {
|
|
368
|
+
const status = errors.length > 0 ? "fail" : warnings.length > 0 ? "warn" : "ok";
|
|
369
|
+
if (context.outputFormat === "pretty") {
|
|
370
|
+
for (const p of products) {
|
|
371
|
+
context.logger.info(
|
|
372
|
+
` ${p.id}: ${p.forgeVersion ?? "—"} ${p.versionOk === true ? "=" : p.versionOk === false ? "≠" : ""}${baseline ?? "—"} ${p.dirty === true ? "dirty" : p.dirty === false ? "clean" : ""}${p.frozen ? " frozen" : ""}`.trimEnd(),
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
for (const d of errors) context.logger.error(`${d.ruleId} · ${d.message}`);
|
|
376
|
+
for (const d of warnings) context.logger.warn(`${d.ruleId} · ${d.message}`);
|
|
377
|
+
}
|
|
378
|
+
return {
|
|
379
|
+
data: {
|
|
380
|
+
command: "system.products.status",
|
|
381
|
+
status,
|
|
382
|
+
hub: root,
|
|
383
|
+
baseline,
|
|
384
|
+
products,
|
|
385
|
+
warnings,
|
|
386
|
+
errors,
|
|
387
|
+
},
|
|
388
|
+
exitCode: errors.length > 0 ? 1 : 0,
|
|
389
|
+
summary: `system.products.status: ${status} — ${products.length} product(s), ${errors.length} error(s), ${warnings.length} warning(s)`,
|
|
390
|
+
nextSteps:
|
|
391
|
+
errors.length > 0
|
|
392
|
+
? [{ action: "Fix the error-severity product diagnostics above", kind: "required" }]
|
|
393
|
+
: [],
|
|
394
|
+
};
|
|
395
|
+
}
|
package/os/system/schemas.ts
CHANGED
|
@@ -11,6 +11,8 @@ All objects are strict — unknown keys are schema violations (SYSTEM-MAP-01).</
|
|
|
11
11
|
<CHANGE_SUMMARY>
|
|
12
12
|
<item>RFC-1508: step 2 — system map schemas (system, products, edges, products-local)</item>
|
|
13
13
|
<item>RFC-1508: review r1 — contract-exact schemas: strict objects, remote/offers, folders+launcher local map, edge note + required forbidden reason</item>
|
|
14
|
+
<item>RFC-1639: additive roster fields — product.frozen + top-level ignored[]</item>
|
|
15
|
+
<item>RFC-1639: review — SYSTEM-MAP-01 rules decl, git-probe warnings, sibling kind/path discriminants, friction.add provenance, ingest hardening</item>
|
|
14
16
|
</CHANGE_SUMMARY>
|
|
15
17
|
*/
|
|
16
18
|
|
|
@@ -43,14 +45,29 @@ export const systemProductSchema = z
|
|
|
43
45
|
remote: z.string().min(1),
|
|
44
46
|
/** Contract ids this product offers to consumers (package or spec ids). */
|
|
45
47
|
offers: z.array(z.string().min(1)).default([]),
|
|
48
|
+
/** RFC-1639: pinned by contract — health reports stay visible but never flag it. */
|
|
49
|
+
frozen: z.boolean().optional(),
|
|
46
50
|
})
|
|
47
51
|
.strict();
|
|
48
52
|
export type SystemProduct = z.infer<typeof systemProductSchema>;
|
|
49
53
|
|
|
54
|
+
/** RFC-1639: a sibling directory deliberately outside the member model —
|
|
55
|
+
* matched against literal directory names, so any non-empty name is legal. */
|
|
56
|
+
export const systemIgnoredSiblingSchema = z
|
|
57
|
+
.object({
|
|
58
|
+
id: z.string().min(1),
|
|
59
|
+
note: z.string().optional(),
|
|
60
|
+
})
|
|
61
|
+
.strict();
|
|
62
|
+
export type SystemIgnoredSibling = z.infer<typeof systemIgnoredSiblingSchema>;
|
|
63
|
+
|
|
50
64
|
export const systemProductsSchema = z
|
|
51
65
|
.object({
|
|
52
66
|
schema: z.literal("forge/system-products@1"),
|
|
53
67
|
products: z.array(systemProductSchema),
|
|
68
|
+
/** RFC-1639: sibling dirs that are not products — silences the
|
|
69
|
+
* unregistered-forge-sibling diagnostic by name. */
|
|
70
|
+
ignored: z.array(systemIgnoredSiblingSchema).optional(),
|
|
54
71
|
})
|
|
55
72
|
.strict();
|
|
56
73
|
export type SystemProducts = z.infer<typeof systemProductsSchema>;
|
|
@@ -13,12 +13,13 @@ dispatch's product side is limited to opening the task branch and writing
|
|
|
13
13
|
</non-goals>
|
|
14
14
|
</MODULE_CONTRACT>
|
|
15
15
|
<CHANGE_SUMMARY>
|
|
16
|
-
<item>RFC-1511: accept recorded products map in verified gate, guard folders lookup and exec edges (RFC-1511 review r1)</item>
|
|
17
|
-
<item>RFC-1533: surface pending flow branches in flow.open and the pre-user-prompt nudge</item>
|
|
18
16
|
<item>RFC-1541: version-set@2 contracts with validator and pin-drift scenario checks</item>
|
|
19
17
|
<item>RFC-1616: close RFC-1616 r13 trust-boundary counterexamples</item>
|
|
20
18
|
<item>RFC-1616: declare subprocess env inputs and drop pull_request trigger</item>
|
|
21
|
-
<
|
|
19
|
+
<item>RFC-1639: system.products.status — member health + registry-vs-disk probe</item>
|
|
20
|
+
<item>RFC-1641: system.product.register — roster write surface with --discover sibling scan</item>
|
|
21
|
+
<item>RFC-1639: review — SYSTEM-MAP-01 rules decl, git-probe warnings, sibling kind/path discriminants, friction.add provenance, ingest hardening</item>
|
|
22
|
+
<history>RFC-1508, RFC-1509, RFC-1510, RFC-1511, RFC-1533</history>
|
|
22
23
|
</CHANGE_SUMMARY>
|
|
23
24
|
*/
|
|
24
25
|
|
|
@@ -26,6 +27,8 @@ import type { ForgeModule } from "../../src/forge-module.ts";
|
|
|
26
27
|
|
|
27
28
|
export async function createForgeSystemModule(): Promise<ForgeModule> {
|
|
28
29
|
const { runSystemMapValidate } = await import("./handlers/system-map-validate.ts");
|
|
30
|
+
const { runSystemProductsStatus } = await import("./handlers/system-products-status.ts");
|
|
31
|
+
const { runSystemProductRegister } = await import("./handlers/system-product-register.ts");
|
|
29
32
|
const { runSystemTaskCreate } = await import("./handlers/system-task-create.ts");
|
|
30
33
|
const { runSystemTaskMove } = await import("./handlers/system-task-move.ts");
|
|
31
34
|
const { runSystemTaskDispatch } = await import("./handlers/system-task-dispatch.ts");
|
|
@@ -82,6 +85,117 @@ export async function createForgeSystemModule(): Promise<ForgeModule> {
|
|
|
82
85
|
flags: {},
|
|
83
86
|
execute: runSystemMapValidate,
|
|
84
87
|
},
|
|
88
|
+
{
|
|
89
|
+
name: "system.products.status",
|
|
90
|
+
description:
|
|
91
|
+
"Read-only member health report (RFC-1639). Refuses outside the " +
|
|
92
|
+
"system profile (SYSTEM-01). For every products.yaml entry resolved " +
|
|
93
|
+
"through products.local.yaml folders it reports the checkout path, " +
|
|
94
|
+
"declared profile, syncedVersion vs the hub's own syncedVersion " +
|
|
95
|
+
"baseline, dirty state, live <id>@* session worktrees, and commits " +
|
|
96
|
+
"ahead of upstream — git probes degrade to null + warning. " +
|
|
97
|
+
"Registry-vs-disk: a sibling dir carrying forge.yaml that is not a " +
|
|
98
|
+
"registered product warns (SYSTEM-PRODUCTS-02) unless named in " +
|
|
99
|
+
"ignored[]; a registered product missing or broken on disk errors " +
|
|
100
|
+
"(SYSTEM-PRODUCTS-01) unless frozen. Exit 1 iff an error exists.",
|
|
101
|
+
scope: "workspace",
|
|
102
|
+
contract: "system",
|
|
103
|
+
rules: [
|
|
104
|
+
{ id: "SYSTEM-01", severity: "error" },
|
|
105
|
+
{ id: "SYSTEM-MAP-01", severity: "error" },
|
|
106
|
+
{ id: "SYSTEM-PRODUCTS-01", severity: "error" },
|
|
107
|
+
{ id: "SYSTEM-PRODUCTS-02", severity: "warning" },
|
|
108
|
+
],
|
|
109
|
+
mutatesState: false,
|
|
110
|
+
execOnReadOnly: true,
|
|
111
|
+
writes: [],
|
|
112
|
+
coverage: "operator",
|
|
113
|
+
coverageNote:
|
|
114
|
+
"maintenance sweeps — the operator's per-repo version/dirty/worktree audit (RFC-1639)",
|
|
115
|
+
reads: [
|
|
116
|
+
"forge.yaml",
|
|
117
|
+
"system/system.yaml",
|
|
118
|
+
"system/products.yaml",
|
|
119
|
+
"system/edges.yaml",
|
|
120
|
+
"system/products.local.yaml",
|
|
121
|
+
],
|
|
122
|
+
cacheable: false,
|
|
123
|
+
flags: {},
|
|
124
|
+
execute: runSystemProductsStatus,
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "system.product.register",
|
|
128
|
+
description:
|
|
129
|
+
"Register a product in the system hub roster (RFC-1641) — the " +
|
|
130
|
+
"member-registry write surface. Explicit form --id <kebab> " +
|
|
131
|
+
"--remote <url> [--folder <path>] [--offers <contract>]* [--frozen] " +
|
|
132
|
+
"appends products.yaml and maps the folder in the gitignored " +
|
|
133
|
+
"products.local.yaml; --update modifies an existing id. --discover " +
|
|
134
|
+
"scans the hub's parent directory and registers every sibling " +
|
|
135
|
+
"carrying forge.yaml that is not already registered — id from the " +
|
|
136
|
+
"directory name, remote from git origin — skipping ignored[] names, " +
|
|
137
|
+
"@-worktrees, hidden dirs, the hub itself, non-kebab names and " +
|
|
138
|
+
"siblings with no readable origin (each reported as skipped). " +
|
|
139
|
+
"Invalid input — non-kebab id, duplicate without --update, missing " +
|
|
140
|
+
"--remote, a folder already mapped to another product — is " +
|
|
141
|
+
"SYSTEM-PRODUCTS-03 and writes nothing; SYSTEM-PRODUCTS-04 warns " +
|
|
142
|
+
"when a named folder is absent on disk. Writes files only — the " +
|
|
143
|
+
"session commits.",
|
|
144
|
+
scope: "workspace",
|
|
145
|
+
contract: "system",
|
|
146
|
+
rules: [
|
|
147
|
+
{ id: "SYSTEM-01", severity: "error" },
|
|
148
|
+
{ id: "SYSTEM-MAP-01", severity: "error" },
|
|
149
|
+
{ id: "SYSTEM-PRODUCTS-03", severity: "error" },
|
|
150
|
+
{ id: "SYSTEM-PRODUCTS-04", severity: "warning" },
|
|
151
|
+
],
|
|
152
|
+
mutatesState: true,
|
|
153
|
+
idempotency: "rerun-safe",
|
|
154
|
+
writes: ["system/products.yaml", "system/products.local.yaml"],
|
|
155
|
+
generates: [],
|
|
156
|
+
coverage: "operator",
|
|
157
|
+
coverageNote:
|
|
158
|
+
"member onboarding — the operator or a hub session registers products and discovers forge siblings (RFC-1641)",
|
|
159
|
+
reads: [
|
|
160
|
+
"forge.yaml",
|
|
161
|
+
"system/system.yaml",
|
|
162
|
+
"system/products.yaml",
|
|
163
|
+
"system/edges.yaml",
|
|
164
|
+
"system/products.local.yaml",
|
|
165
|
+
"<sibling>/forge.yaml",
|
|
166
|
+
"<sibling>/.git/**",
|
|
167
|
+
],
|
|
168
|
+
cacheable: false,
|
|
169
|
+
flags: {
|
|
170
|
+
id: {
|
|
171
|
+
kind: "string",
|
|
172
|
+
description: "Product id (kebab-case) — required unless --discover",
|
|
173
|
+
},
|
|
174
|
+
remote: {
|
|
175
|
+
kind: "string",
|
|
176
|
+
description: "Git remote url — required on first registration",
|
|
177
|
+
},
|
|
178
|
+
folder: {
|
|
179
|
+
kind: "string",
|
|
180
|
+
description: "Local checkout folder, absolute or repo-relative (e.g. ../billing)",
|
|
181
|
+
},
|
|
182
|
+
offers: {
|
|
183
|
+
kind: "string[]",
|
|
184
|
+
description: "Contract ids this product offers (repeatable)",
|
|
185
|
+
},
|
|
186
|
+
frozen: {
|
|
187
|
+
kind: "boolean",
|
|
188
|
+
description: "Pin the product by contract — health reports stay informational",
|
|
189
|
+
},
|
|
190
|
+
update: { kind: "boolean", description: "Modify an already-registered product id" },
|
|
191
|
+
discover: {
|
|
192
|
+
kind: "boolean",
|
|
193
|
+
description: "Scan sibling dirs for unregistered forge repositories and register them",
|
|
194
|
+
},
|
|
195
|
+
"dry-run": { kind: "boolean", description: "Plan only — write nothing" },
|
|
196
|
+
},
|
|
197
|
+
execute: runSystemProductRegister,
|
|
198
|
+
},
|
|
85
199
|
{
|
|
86
200
|
name: "system.task.create",
|
|
87
201
|
description:
|