@inventarch/cli 1.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LANGUAGE.md +2 -2
- package/README.md +17 -4
- package/SPEC.md +51 -7
- package/assets/base/0305ca741b1dfec97ff35fbeb36d4a66a0c9c0614b730fe14fcdac0f1565e28a.ia.tgz +0 -0
- package/assets/base.json +3 -3
- package/assets/host/3d2c8530db8d14755410b17be8228a230d88de96f9dc78f953979d3ca7c6ea62.tgz +0 -0
- package/assets/host.json +4 -4
- package/assets/vocabulary.json +436 -4
- package/dist/bundled-base.d.ts +18 -0
- package/dist/bundled-base.d.ts.map +1 -0
- package/dist/bundled-base.js +44 -0
- package/dist/bundled-base.js.map +1 -0
- package/dist/capture.d.ts +108 -0
- package/dist/capture.d.ts.map +1 -0
- package/dist/capture.js +346 -0
- package/dist/capture.js.map +1 -0
- package/dist/claude-cli.js +1 -1
- package/dist/claude-cli.js.map +1 -1
- package/dist/commands.d.ts +23 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +201 -10
- package/dist/commands.js.map +1 -1
- package/dist/compile.d.ts +5 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +40 -51
- package/dist/compile.js.map +1 -1
- package/dist/consumer.d.ts +48 -7
- package/dist/consumer.d.ts.map +1 -1
- package/dist/consumer.js +142 -29
- package/dist/consumer.js.map +1 -1
- package/dist/decline.d.ts.map +1 -1
- package/dist/decline.js +15 -7
- package/dist/decline.js.map +1 -1
- package/dist/distribute.d.ts +68 -16
- package/dist/distribute.d.ts.map +1 -1
- package/dist/distribute.js +243 -110
- package/dist/distribute.js.map +1 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +113 -60
- package/dist/doctor.js.map +1 -1
- package/dist/format.d.ts +2 -2
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +19 -11
- package/dist/format.js.map +1 -1
- package/dist/home-remedy.d.ts +8 -4
- package/dist/home-remedy.d.ts.map +1 -1
- package/dist/home-remedy.js +8 -4
- package/dist/home-remedy.js.map +1 -1
- package/dist/host-projection.d.ts +73 -6
- package/dist/host-projection.d.ts.map +1 -1
- package/dist/host-projection.js +296 -38
- package/dist/host-projection.js.map +1 -1
- package/dist/host.d.ts +106 -30
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +270 -139
- package/dist/host.js.map +1 -1
- package/dist/init.d.ts +285 -37
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +1270 -205
- package/dist/init.js.map +1 -1
- package/dist/inspect.d.ts +26 -2
- package/dist/inspect.d.ts.map +1 -1
- package/dist/inspect.js +117 -52
- package/dist/inspect.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +3 -1
- package/dist/main.js.map +1 -1
- package/dist/migration-journal.d.ts +35 -0
- package/dist/migration-journal.d.ts.map +1 -0
- package/dist/migration-journal.js +205 -0
- package/dist/migration-journal.js.map +1 -0
- package/dist/next.d.ts +21 -0
- package/dist/next.d.ts.map +1 -0
- package/dist/next.js +210 -0
- package/dist/next.js.map +1 -0
- package/dist/operation-help.d.ts.map +1 -1
- package/dist/operation-help.js +14 -3
- package/dist/operation-help.js.map +1 -1
- package/dist/pack.d.ts +3 -1
- package/dist/pack.d.ts.map +1 -1
- package/dist/pack.js +56 -11
- package/dist/pack.js.map +1 -1
- package/dist/position.d.ts +22 -0
- package/dist/position.d.ts.map +1 -0
- package/dist/position.js +242 -0
- package/dist/position.js.map +1 -0
- package/dist/project.d.ts +42 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +232 -0
- package/dist/project.js.map +1 -0
- package/dist/read.d.ts +31 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +152 -0
- package/dist/read.js.map +1 -0
- package/dist/render.d.ts +19 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +44 -1
- package/dist/render.js.map +1 -1
- package/dist/session.d.ts +12 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +68 -6
- package/dist/session.js.map +1 -1
- package/dist/user-host.d.ts.map +1 -1
- package/dist/user-host.js +7 -5
- package/dist/user-host.js.map +1 -1
- package/dist/validate.d.ts +1 -2
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +6 -27
- package/dist/validate.js.map +1 -1
- package/dist/vocabulary.d.ts +4 -0
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +12 -7
- package/dist/vocabulary.js.map +1 -1
- package/package.json +6 -6
- package/assets/base/78bff5eb3188b628c06d2f1cf1477fb1bfcea874ec3863ae112b4972b8e81517.ia.tgz +0 -0
- package/assets/host/b97e367bbf15db09f552d6bd6dd3701210efe77931d34b57ccb85240957aba61.tgz +0 -0
package/dist/host-projection.js
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Host registration spec §6: a workspace's projection for one host, rendered from its own admitted records.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Milestone position-packet task replace-renderers (plan amendments B9, B11 and B12): the projection is the position
|
|
5
|
+
* packet (`renderPacket`, runtime R19) rendered by the host's adapter for the consumer target (`renderHost`, R20), with
|
|
6
|
+
* the command catalog this CLI tags (`packetCatalog`). One render feeds `ia host`, `ia doctor`'s projection rows and the
|
|
7
|
+
* install/update/remove refresh, so no two of them can disagree about what the projection should contain.
|
|
8
|
+
*
|
|
9
|
+
* `applyHostProjection` is the only writer of projection files. Before any of them changes it retires a steward-guard
|
|
10
|
+
* registration an earlier release made (B11): with no per-system steward agent left to satisfy it, the guard would deny
|
|
11
|
+
* every edit under `.ia/src/systems/<name>/`, so it stays retired until milestone generation-binding re-keys it to
|
|
12
|
+
* `@mandate` scope (task generation-hook-governance). It then applies the planned files through
|
|
13
|
+
* `@inventarch/distribution/projection`, which deletes the owned 1.x steward files and leaves foreign ones (B9), and
|
|
14
|
+
* writes the receipt beside the projection state (B12).
|
|
9
15
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
16
|
+
import { accessSync, closeSync, constants, existsSync, fstatSync, lstatSync, openSync, readFileSync, } from 'node:fs';
|
|
17
|
+
import { resolve } from 'node:path';
|
|
18
|
+
import { renderHost, renderPacket, PACKET_MARKER } from '@inventarch/runtime';
|
|
19
|
+
import { applyGuardRegistration, assertRetirableGuard, planGuardRegistration, } from '@inventarch/distribution/guard-registration';
|
|
20
|
+
import { acquireHostRegistrationLock, assertHostRegistrationIdle, HOST_REGISTRATION, } from '@inventarch/distribution/host';
|
|
21
|
+
import { applyProjection, planProjection } from '@inventarch/distribution/projection';
|
|
22
|
+
import { DistributionError, json, readWorkspaceFile, readWorkspaceJson, replace, sha256, } from '@inventarch/distribution/services';
|
|
23
|
+
import { packetCatalog } from './commands.js';
|
|
15
24
|
import { Refusal } from './consumer.js';
|
|
16
|
-
import {
|
|
25
|
+
import { refusedPath, SETTINGS, STATE } from './host.js';
|
|
26
|
+
import { codeOf, openSession } from './session.js';
|
|
27
|
+
/** This CLI's id@version, which the receipt records and only the applying CLI knows (design item 12). */
|
|
28
|
+
const CLI = `@inventarch/cli@${JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version}`;
|
|
17
29
|
/**
|
|
18
30
|
* §4: the target must admit — zero error findings — before anything is rendered or registered. The refusal is the
|
|
19
31
|
* CLI's own classification of the target, so it is IA-CLI-CONFLICT and names the command that shows the findings.
|
|
@@ -33,41 +45,287 @@ export function checkAdmitted(root) {
|
|
|
33
45
|
}
|
|
34
46
|
}
|
|
35
47
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
48
|
+
* §6.1: the packet over the whole workspace, through the session's own scope, rendered by `host`'s adapter for the
|
|
49
|
+
* consumer target: its files, each carrying `PACKET_MARKER`, and the receipt the render fills (B12). No agent file is
|
|
50
|
+
* rendered for any host.
|
|
39
51
|
*/
|
|
40
|
-
function membershipOf(session) {
|
|
41
|
-
const records = session.reader.records(), revision = session.reader.revision;
|
|
42
|
-
return {
|
|
43
|
-
revision,
|
|
44
|
-
members: [...new Set(records.map((record) => record.source.path))].sort().map((path) => {
|
|
45
|
-
const member = systemMember(path);
|
|
46
|
-
return { path, system: member?.name ?? null, root: member?.root ?? null };
|
|
47
|
-
}),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/** §6.1. Artifacts carry the `ia host` marker line; `@inventarch/distribution/projection` refuses any that does not. */
|
|
51
52
|
export function renderProjectionFor(root, host) {
|
|
52
53
|
const session = openSession(root);
|
|
53
54
|
try {
|
|
54
55
|
requireAdmitted(session, root);
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
const rendered = renderWorkspaceProjection(records, revision, membershipOf(session), {
|
|
58
|
-
host,
|
|
59
|
-
modes: HOST_MODES.map((row) => ({ invocation: launcherInvocation(row), meaning: row.meaning })),
|
|
60
|
-
distributions: (lock?.packages ?? []).map((pkg) => ({ id: pkg.id, version: pkg.version })),
|
|
61
|
-
operations: [...LEGACY_OPERATIONS],
|
|
62
|
-
});
|
|
63
|
-
// Contract §4.1 lists IA-COMP-* as finding codes. This is a CLI refusal carrying the renderer's finding code
|
|
64
|
-
// unchanged, because the renderer's assessment is the only thing that knows why the projection cannot exist.
|
|
65
|
-
if (rendered.assessment.outcome !== 'pass')
|
|
66
|
-
throw new Refusal('IA-COMP-PROJECTION-INVALID', rendered.assessment.findings.map((finding) => finding.message).join('; '), 3, { path: root }, 'Run "ia validate" and "ia inspect" to check each system\'s steward declaration.');
|
|
67
|
-
return rendered.artifacts;
|
|
56
|
+
const { packet, digest, hostNote } = renderPacket(session.reader, session.reader.resolveScope().token, packetCatalog());
|
|
57
|
+
return renderHost(host, packet, digest, hostNote, 'consumer');
|
|
68
58
|
}
|
|
69
59
|
finally {
|
|
70
60
|
session.close();
|
|
71
61
|
}
|
|
72
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* B11: whether this workspace holds a steward-guard registration an earlier release made, which the projection apply
|
|
65
|
+
* retires. Only Claude ever registered one; its ownership state is the registration, as `ia host` and `ia doctor`
|
|
66
|
+
* decide it.
|
|
67
|
+
*/
|
|
68
|
+
export const ownsGuard = (root, host) => host === 'claude' && existsSync(resolve(root, STATE.hooks));
|
|
69
|
+
/**
|
|
70
|
+
* B11: the removal of the steward-guard registration this workspace owns, or null when it owns none. A refusal the
|
|
71
|
+
* mechanism does not locate at a file concerns the guard group in the settings file — a group changed by hand, or
|
|
72
|
+
* settings that do not parse — except a pending host journal, which is the journal's.
|
|
73
|
+
*/
|
|
74
|
+
export function planRetirement(root, host) {
|
|
75
|
+
try {
|
|
76
|
+
if (host === 'claude')
|
|
77
|
+
assertRetirableGuard(root);
|
|
78
|
+
if (!ownsGuard(root, host))
|
|
79
|
+
return null;
|
|
80
|
+
return planGuardRegistration(root, { remove: HOST_REGISTRATION });
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
const code = codeOf(error, '');
|
|
84
|
+
if (error instanceof Error &&
|
|
85
|
+
/^IA-/.test(code) &&
|
|
86
|
+
code !== 'IA-DIST-RECOVERY-REQUIRED' &&
|
|
87
|
+
refusedPath(error) === null)
|
|
88
|
+
throw new DistributionError(code, error.message, SETTINGS);
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** The file plan `applyHostProjection` applies for `rendered`, or the removal of the owned set for null. */
|
|
93
|
+
export const planFiles = (root, host, rendered) => {
|
|
94
|
+
preflightReceipt(root, host);
|
|
95
|
+
return planProjection({ root, host, artifacts: rendered?.files ?? [], marker: PACKET_MARKER });
|
|
96
|
+
};
|
|
97
|
+
/** Check every destination ancestor and the opened destination without changing bytes. */
|
|
98
|
+
export function preflightReceipt(root, host) {
|
|
99
|
+
for (const path of [STATE.receipt(host), pendingPath(host)]) {
|
|
100
|
+
const parts = path.split('/'), ancestors = [];
|
|
101
|
+
const unsafe = (relative = path) => new DistributionError('IA-DIST-PATH-UNSAFE', 'Expected an unaliased receipt file and directory ancestors', relative);
|
|
102
|
+
for (let i = 1; i < parts.length; i++) {
|
|
103
|
+
const relative = parts.slice(0, i).join('/'), absolute = resolve(root, relative);
|
|
104
|
+
let stat;
|
|
105
|
+
try {
|
|
106
|
+
stat = lstatSync(absolute, { bigint: true });
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (error.code === 'ENOENT')
|
|
110
|
+
break;
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
if (stat.isSymbolicLink() || !stat.isDirectory())
|
|
114
|
+
throw unsafe(relative);
|
|
115
|
+
ancestors.push({ stat });
|
|
116
|
+
accessSync(absolute, constants.W_OK);
|
|
117
|
+
}
|
|
118
|
+
const checkAncestors = () => {
|
|
119
|
+
for (let i = 1; i < parts.length; i++) {
|
|
120
|
+
const relative = parts.slice(0, i).join('/'), current = lstatSync(resolve(root, relative), { bigint: true, throwIfNoEntry: false }), before = ancestors[i - 1]?.stat;
|
|
121
|
+
if (!current) {
|
|
122
|
+
if (before)
|
|
123
|
+
throw unsafe(relative);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
if (!current.isDirectory() ||
|
|
127
|
+
current.isSymbolicLink() ||
|
|
128
|
+
(before && (current.dev !== before.dev || current.ino !== before.ino)))
|
|
129
|
+
throw unsafe(relative);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const absolute = resolve(root, path);
|
|
133
|
+
let fd;
|
|
134
|
+
try {
|
|
135
|
+
// No pathname precheck: validate the handle actually opened. O_NOFOLLOW protects the leaf where supported;
|
|
136
|
+
// the identity checks below also cover Windows and ancestor replacement. No creation or truncation occurs.
|
|
137
|
+
fd = openSync(absolute, constants.O_RDWR | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
// A bad kind may itself prevent opening (directories on Windows, or a dangling link). Preserve its path remedy.
|
|
141
|
+
const named = lstatSync(absolute, { bigint: true, throwIfNoEntry: false });
|
|
142
|
+
if (named && (!named.isFile() || named.isSymbolicLink() || named.nlink !== 1n))
|
|
143
|
+
throw unsafe();
|
|
144
|
+
if (error.code === 'ENOENT' && !named) {
|
|
145
|
+
checkAncestors();
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
// Windows file IDs can exceed Number.MAX_SAFE_INTEGER; retain every bit when comparing identities.
|
|
152
|
+
const opened = fstatSync(fd, { bigint: true }), named = lstatSync(absolute, { bigint: true });
|
|
153
|
+
if (!opened.isFile() ||
|
|
154
|
+
opened.nlink !== 1n ||
|
|
155
|
+
!named.isFile() ||
|
|
156
|
+
named.isSymbolicLink() ||
|
|
157
|
+
named.nlink !== 1n ||
|
|
158
|
+
opened.dev !== named.dev ||
|
|
159
|
+
opened.ino !== named.ino)
|
|
160
|
+
throw unsafe();
|
|
161
|
+
checkAncestors();
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
closeSync(fd);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
readPending(root, host);
|
|
168
|
+
}
|
|
169
|
+
const pendingPath = (host) => `.ia/distributions/hosts/${host}-receipt-pending.json`;
|
|
170
|
+
function readPending(root, host) {
|
|
171
|
+
const path = pendingPath(host);
|
|
172
|
+
if (!existsSync(resolve(root, path)))
|
|
173
|
+
return null;
|
|
174
|
+
let value;
|
|
175
|
+
try {
|
|
176
|
+
value = readWorkspaceJson({ root, path });
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
throw new DistributionError(codeOf(error, 'IA-CLI-FAILED'), error instanceof Error ? error.message : String(error), path);
|
|
180
|
+
}
|
|
181
|
+
const { digest, ...body } = value ?? {};
|
|
182
|
+
if (value === null ||
|
|
183
|
+
typeof value !== 'object' ||
|
|
184
|
+
Array.isArray(value) ||
|
|
185
|
+
value.format !== 'ia.packet-receipt-pending.v1' ||
|
|
186
|
+
value.host !== host ||
|
|
187
|
+
typeof value.guard !== 'boolean' ||
|
|
188
|
+
!digests(value.removed) ||
|
|
189
|
+
value.removed.some((file) => !/^\.claude\/agents\/[a-z][a-z0-9-]*\.md$/.test(file.path) &&
|
|
190
|
+
![
|
|
191
|
+
'.claude/rules/ia-workspace.md',
|
|
192
|
+
'.claude/skills/ia-authoring/SKILL.md',
|
|
193
|
+
'AGENTS.md',
|
|
194
|
+
'.agents/skills/ia-authoring/SKILL.md',
|
|
195
|
+
].includes(file.path)) ||
|
|
196
|
+
(value.receipt !== undefined && !HEX.test(value.receipt)) ||
|
|
197
|
+
Object.keys(body).sort().join(',') !==
|
|
198
|
+
(value.receipt === undefined ? 'format,guard,host,removed' : 'format,guard,host,receipt,removed') ||
|
|
199
|
+
digest !== sha256(json(body)))
|
|
200
|
+
throw new DistributionError('IA-DIST-INPUT-INVALID', 'Invalid pending projection receipt evidence', path);
|
|
201
|
+
// The receipt committed but a kill left the pending cleanup undone: that was a successful last apply.
|
|
202
|
+
if (value.receipt !== undefined &&
|
|
203
|
+
existsSync(resolve(root, STATE.receipt(host))) &&
|
|
204
|
+
sha256(readWorkspaceFile({ root, path: STATE.receipt(host) })) === value.receipt)
|
|
205
|
+
return null;
|
|
206
|
+
return body;
|
|
207
|
+
}
|
|
208
|
+
/** Verified deletion provenance shared by projection apply and a migration's durable effect plan. */
|
|
209
|
+
export function projectionEvidence(root, host, actions, retirement, previous) {
|
|
210
|
+
if (previous !== undefined &&
|
|
211
|
+
(JSON.stringify(readReceipt(root, host)) !== JSON.stringify(previous) ||
|
|
212
|
+
!previous.files.every((file) => sha256(readWorkspaceFile({ root, path: file.path })) === file.sha256) ||
|
|
213
|
+
!previous.removed.every((file) => !existsSync(resolve(root, file.path)))))
|
|
214
|
+
throw new DistributionError('IA-DIST-LOCAL-MODIFICATION', 'Completed projection differs from its receipt', STATE.receipt(host));
|
|
215
|
+
const removed = actions.flatMap((action) => action.action === 'remove' && existsSync(resolve(root, action.path))
|
|
216
|
+
? [{ path: action.path, sha256: sha256(readWorkspaceFile({ root, path: action.path })) }]
|
|
217
|
+
: []);
|
|
218
|
+
const pending = readPending(root, host);
|
|
219
|
+
const prior = pending ?? (previous === undefined ? null : { guard: previous.guard === 'retired', removed: previous.removed });
|
|
220
|
+
for (const file of removed) {
|
|
221
|
+
const recorded = prior?.removed.find((row) => row.path === file.path);
|
|
222
|
+
if (recorded !== undefined && recorded.sha256 !== file.sha256)
|
|
223
|
+
throw new DistributionError('IA-DIST-LOCAL-MODIFICATION', 'Pending removal evidence differs from the current owned bytes', file.path);
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
format: 'ia.packet-receipt-pending.v1',
|
|
227
|
+
host,
|
|
228
|
+
guard: prior?.guard === true || retirement,
|
|
229
|
+
removed: [...new Map([...(prior?.removed ?? []), ...removed].map((file) => [file.path, file])).values()],
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The one writer of projection files: B11, then the files, then B12. `rendered` is `renderProjectionFor`'s output,
|
|
234
|
+
* or null to remove the owned set. Both the guard retirement and the file plan are planned before anything is written,
|
|
235
|
+
* so a refusal either planner finds changes nothing; then the guard registration is removed (its group in
|
|
236
|
+
* `.claude/settings.local.json` and its ownership state), and only then are the files written and the owned 1.x
|
|
237
|
+
* steward files deleted. A failure past the retirement so leaves the guard retired and never the steward files
|
|
238
|
+
* deleted with the guard still registered; a rerun converges. The receipt (`<host>-receipt.json` beside the
|
|
239
|
+
* projection state) describes the files as an apply left them, so it is deleted, under the host lock, before any of
|
|
240
|
+
* them changes: an interrupted apply leaves none, which `ia doctor` reports as unknown, never as a hand edit. It is
|
|
241
|
+
* written last, under the host lock, with the legacy files deleted (`removed`), the foreign files left in place, the
|
|
242
|
+
* retirement, this CLI's id@version and the time; a removal leaves it deleted. `checkpoint` runs after the retirement
|
|
243
|
+
* (`guard`), at each of `applyProjection`'s own stages and after the receipt (`receipt`), which is where an
|
|
244
|
+
* interruption test cuts. A migration may supply its verified previous receipt to refresh host notes while retaining
|
|
245
|
+
* that operation's retirement and deletion evidence; ordinary applies omit it and keep last-apply semantics.
|
|
246
|
+
*/
|
|
247
|
+
export function applyHostProjection(root, host, rendered, checkpoint = () => { }, previous) {
|
|
248
|
+
// A pending host journal refuses every host write, as it refuses the plan (§8).
|
|
249
|
+
assertHostRegistrationIdle(root);
|
|
250
|
+
const retirement = planRetirement(root, host), plan = planFiles(root, host, rendered);
|
|
251
|
+
const writeEvidence = (path, value) => {
|
|
252
|
+
const unlock = acquireHostRegistrationLock(root);
|
|
253
|
+
try {
|
|
254
|
+
replace(root, path, value === null ? null : Buffer.from(json(value)));
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
unlock();
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const evidence = projectionEvidence(root, host, plan.actions, retirement !== null, previous);
|
|
261
|
+
// Evidence precedes retirement and every deletion; it survives failure and the projection state's collapse.
|
|
262
|
+
writeEvidence(pendingPath(host), { ...evidence, digest: sha256(json(evidence)) });
|
|
263
|
+
checkpoint('evidence');
|
|
264
|
+
if (retirement !== null)
|
|
265
|
+
applyGuardRegistration(retirement);
|
|
266
|
+
checkpoint('guard');
|
|
267
|
+
// The last apply's receipt goes before any projection file changes (B12).
|
|
268
|
+
writeEvidence(STATE.receipt(host), null);
|
|
269
|
+
const result = applyProjection(plan, checkpoint), guard = evidence.guard ? 'retired' : 'none';
|
|
270
|
+
const receipt = rendered === null
|
|
271
|
+
? null
|
|
272
|
+
: {
|
|
273
|
+
...rendered.receipt,
|
|
274
|
+
cli: CLI,
|
|
275
|
+
removed: evidence.removed.filter((file) => !existsSync(resolve(root, file.path))),
|
|
276
|
+
foreign: plan.actions.filter((action) => action.action === 'foreign').map((action) => action.path),
|
|
277
|
+
guard,
|
|
278
|
+
writtenAt: new Date().toISOString(),
|
|
279
|
+
};
|
|
280
|
+
if (receipt !== null) {
|
|
281
|
+
const completed = { ...evidence, receipt: sha256(json(receipt)) };
|
|
282
|
+
writeEvidence(pendingPath(host), { ...completed, digest: sha256(json(completed)) });
|
|
283
|
+
}
|
|
284
|
+
writeEvidence(STATE.receipt(host), receipt);
|
|
285
|
+
writeEvidence(pendingPath(host), null);
|
|
286
|
+
checkpoint('receipt');
|
|
287
|
+
return {
|
|
288
|
+
status: rendered !== null ? 'projected' : result.removed > 0 ? 'projection-removed' : 'absent',
|
|
289
|
+
guard,
|
|
290
|
+
receipt,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
const HEX = /^[a-f0-9]{64}$/;
|
|
294
|
+
const digests = (value) => Array.isArray(value) &&
|
|
295
|
+
value.every((row) => row !== null &&
|
|
296
|
+
typeof row === 'object' &&
|
|
297
|
+
typeof row.path === 'string' &&
|
|
298
|
+
HEX.test(String(row.sha256)));
|
|
299
|
+
/**
|
|
300
|
+
* B12: the receipt `applyHostProjection` wrote for `host`, or null when there is none — a 1.x registration, or one
|
|
301
|
+
* whose receipt was deleted. A receipt that cannot be read, or that lacks the fields `ia doctor` checks, refuses at
|
|
302
|
+
* its own path.
|
|
303
|
+
*/
|
|
304
|
+
export function readReceipt(root, host) {
|
|
305
|
+
const path = STATE.receipt(host);
|
|
306
|
+
if (!existsSync(resolve(root, path)))
|
|
307
|
+
return null;
|
|
308
|
+
let value;
|
|
309
|
+
try {
|
|
310
|
+
value = readWorkspaceJson({ root, path });
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
if (error instanceof Error && 'code' in error && typeof error.code === 'string')
|
|
314
|
+
throw new DistributionError(error.code, error.message, path);
|
|
315
|
+
throw error;
|
|
316
|
+
}
|
|
317
|
+
const row = value;
|
|
318
|
+
if (row === null ||
|
|
319
|
+
typeof row !== 'object' ||
|
|
320
|
+
Array.isArray(row) ||
|
|
321
|
+
row.format !== 'ia.packet-receipt.v1' ||
|
|
322
|
+
row.host !== host ||
|
|
323
|
+
!HEX.test(String(row.packetDigest)) ||
|
|
324
|
+
!digests(row.files) ||
|
|
325
|
+
!digests(row.removed) ||
|
|
326
|
+
!Array.isArray(row.foreign) ||
|
|
327
|
+
!row.foreign.every((item) => typeof item === 'string'))
|
|
328
|
+
throw new DistributionError('IA-DIST-INPUT-INVALID', 'Invalid projection receipt', path);
|
|
329
|
+
return row;
|
|
330
|
+
}
|
|
73
331
|
//# sourceMappingURL=host-projection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-projection.js","sourceRoot":"","sources":["../src/host-projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAQ3C;;;GAGG;AACH,SAAS,eAAe,CAAC,OAAgB,EAAE,IAAY;IACrD,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,MAAM,KAAK,UAAU;QAC3C,MAAM,IAAI,OAAO,CACf,iBAAiB,EACjB,4FAA4F,EAC5F,CAAC,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,EACd,gDAAgD,CACjD,CAAC;AACN,CAAC;AACD,uEAAuE;AACvE,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC;QACH,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;YAAS,CAAC;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AC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;QAC3B,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC;QAEtD,MAAM,IAAI,iBAAiB,CAAC,uBAAuB,EAAE,4BAA4B,EAAE,IAAI,CAAC,CAAC;IAC3F,OAAO,GAAoB,CAAC;AAC9B,CAAC"}
|
package/dist/host.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ProjectionAction } from '@inventarch/distribution/projection';
|
|
2
|
+
import type { HostOutput } from '@inventarch/runtime';
|
|
2
3
|
import type { Context, Result } from './consumer.js';
|
|
3
4
|
import { Refusal } from './consumer.js';
|
|
4
5
|
import type { HostName } from './host-projection.js';
|
|
5
6
|
import type { Capabilities } from './render.js';
|
|
6
|
-
|
|
7
|
+
/** §5.1's elements. `ia host` registers no steward guard since milestone position-packet (B11), so none is `hooks`. */
|
|
8
|
+
export type ElementId = 'mcp' | 'context' | 'projection';
|
|
7
9
|
/**
|
|
8
10
|
* §5.4's four capabilities, plus `absent` for a removal row whose element this workspace does not own: claiming
|
|
9
11
|
* `registered` for something that is not there would be a false report.
|
|
@@ -17,18 +19,20 @@ export interface Conflict {
|
|
|
17
19
|
export interface Element {
|
|
18
20
|
readonly id: ElementId;
|
|
19
21
|
/**
|
|
20
|
-
* §4's plan actions. `none` is an element with nothing to do: the unselected context element,
|
|
21
|
-
*
|
|
22
|
+
* §4's plan actions. `none` is an element with nothing to do: the unselected context element, or a removal of an
|
|
23
|
+
* element this workspace does not own.
|
|
22
24
|
*/
|
|
23
25
|
readonly action: 'create' | 'update' | 'unchanged' | 'remove' | 'refused' | 'none';
|
|
24
26
|
readonly paths: readonly string[];
|
|
25
27
|
readonly capability: Capability;
|
|
26
28
|
readonly conflict: Conflict | null;
|
|
27
29
|
/**
|
|
28
|
-
* The projection's per-file actions. `
|
|
29
|
-
* not
|
|
30
|
+
* The projection's per-file actions (B9). `remove` includes each 1.x steward file the state owns; `foreign` is a
|
|
31
|
+
* `.claude/agents/*.md` file it does not own, marked or not: listed and never touched, so it is not a conflict.
|
|
30
32
|
*/
|
|
31
33
|
readonly files?: readonly ProjectionAction[];
|
|
34
|
+
/** The projection's B11 step: `retire` when the apply first removes a steward-guard registration this workspace owns. */
|
|
35
|
+
readonly guard?: 'retire' | 'none';
|
|
32
36
|
}
|
|
33
37
|
export interface HostView {
|
|
34
38
|
readonly root: string;
|
|
@@ -61,17 +65,25 @@ export declare const USER_PLUGIN_MISSING = "The user-level plugin is not install
|
|
|
61
65
|
export declare const MACHINE_LOCAL: Readonly<Record<HostName, string>>;
|
|
62
66
|
/** §5.4: the MCP element's one fixed addition, from §2.3's host facts. */
|
|
63
67
|
export declare const MCP_APPROVAL = "Claude Code asks for approval before starting a project MCP server.";
|
|
64
|
-
/**
|
|
65
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Operator decision 2026-10-08 (plan amendment B11), said where the guard used to be registered, as operator decision
|
|
70
|
+
* 2026-09-23 ("narrow + disclose") said what it refused: the guard is retired, so nothing it refused is refused now.
|
|
71
|
+
*/
|
|
72
|
+
export declare const GUARD_SCOPE = "ia host registers no steward guard, and applying the projection retires one an earlier release registered: with no per-system steward subagents left, it would deny every edit under .ia/src/systems/<name>/. Until a later release re-keys the guard to @mandate scope, nothing blocks those edits.";
|
|
66
73
|
/** §5.1's files, exported once so `ia doctor` names the same ones. */
|
|
67
74
|
export declare const MCP_PATH: Readonly<Record<HostName, string>>;
|
|
68
75
|
export declare const SETTINGS = ".claude/settings.local.json";
|
|
69
76
|
export declare const HOSTS_AREA = ".ia/distributions/hosts";
|
|
70
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* §5.1's state files. Their presence says whether this workspace owns an element; their content is the mechanisms'.
|
|
79
|
+
* `hooks` is a steward-guard registration an earlier release made, which the projection apply retires (B11), and
|
|
80
|
+
* `receipt` the receipt it writes beside the projection state (B12).
|
|
81
|
+
*/
|
|
71
82
|
export declare const STATE: {
|
|
72
83
|
readonly mcp: (host: HostName) => string;
|
|
73
84
|
readonly hooks: ".ia/distributions/hosts/claude-guard-workspace.json";
|
|
74
85
|
readonly projection: (host: HostName) => string;
|
|
86
|
+
readonly receipt: (host: HostName) => string;
|
|
75
87
|
};
|
|
76
88
|
/**
|
|
77
89
|
* The repair for an ownership state file that cannot be read, or null when `path` is not one. The mechanisms refuse
|
|
@@ -88,8 +100,16 @@ export declare function modifiedRepair(host: HostName, elements: readonly ('mcp'
|
|
|
88
100
|
export declare const JOURNALS: readonly (readonly [string, string])[];
|
|
89
101
|
/** §8: the lock every host sub-transaction holds while it writes (`acquireHostRegistrationLock`). */
|
|
90
102
|
export declare const HOST_LOCK = ".ia/distributions/hosts/lock.json";
|
|
91
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* The close of a remedy whose follow-up is the refused command itself, run again as typed, so the recovery before it
|
|
105
|
+
* is the one command named (design row 27). `ia init --host` cannot simply be run again once it has initialized, so it
|
|
106
|
+
* names `ia host` instead of such a remedy.
|
|
107
|
+
*/
|
|
108
|
+
export declare const THEN_RERUN = ", then rerun.";
|
|
109
|
+
/** An installed CLI recovery, delegating the named distribution mechanism with an explicit root. */
|
|
92
110
|
export declare const recoverCommand: (command: string, root: string) => string;
|
|
111
|
+
/** Recovery needs an existing explicit root, including one whose initialization was interrupted. */
|
|
112
|
+
export declare function runRecovery(context: Context): Result;
|
|
93
113
|
/**
|
|
94
114
|
* §8 "or refuses naming a recovery": a held host lock is another run or a killed one, and nothing here can tell
|
|
95
115
|
* which, so the next action names the recovery that decides it — `recoverHost` takes the lock in recovery mode,
|
|
@@ -115,10 +135,20 @@ export type Pinned = {
|
|
|
115
135
|
*/
|
|
116
136
|
export declare function pinnedRelease(packageRoot: string): Pinned;
|
|
117
137
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
|
|
138
|
+
* §4: the target must be initialized and admit; anything else names ia init or ia validate. `named` is the root as the
|
|
139
|
+
* init it names spells it: `ia host` names the resolved root, and `ia project` the root as its invocation typed it.
|
|
140
|
+
*/
|
|
141
|
+
export declare function requireInitialized(root: string, named?: string): void;
|
|
142
|
+
/** The journal a failed transaction left behind, if any, with the command that recovers it. */
|
|
143
|
+
export declare const pendingJournal: (root: string) => readonly [string, string] | undefined;
|
|
144
|
+
/** Design row 27: the recovery is the one command named; the refused command is simply run again after it. */
|
|
145
|
+
export declare const recoverNext: (root: string, command: string) => string;
|
|
146
|
+
/**
|
|
147
|
+
* A next action of this verb made runnable from any cwd: every quoted `ia host <host>` or `ia project <host>` command
|
|
148
|
+
* it names, and the `ia validate` a workspace that does not admit names (host-projection.ts), gains `--root <root>`.
|
|
149
|
+
* `ia init --host` uses it, because its `<directory>` may not be the cwd a rerun discovers from, and so do `ia project`
|
|
150
|
+
* and `ia doctor`. Every such command opens with `"ia host <host>`, `"ia project <host>` or `"ia validate`, and one
|
|
151
|
+
* that names `--root` itself is left as it is, so the rewrite reaches each one and nothing else.
|
|
122
152
|
*/
|
|
123
153
|
export declare const rootedNext: (next: string, host: HostName, root: string) => string;
|
|
124
154
|
/** A next action as printed: with `--root` given, each `ia host <host>` command in it carries the root. */
|
|
@@ -126,34 +156,80 @@ export declare const hostNext: (text: string, host: HostName, root: string, root
|
|
|
126
156
|
/** The file a mechanism located its refusal at (`locate` in @inventarch/distribution's files.ts), or null. */
|
|
127
157
|
export declare const refusedPath: (error: unknown) => string | null;
|
|
128
158
|
/**
|
|
129
|
-
* §6.3: the repair for a projection refusal located at `path`. The ownership state has its own repair;
|
|
130
|
-
*
|
|
131
|
-
*
|
|
159
|
+
* §6.3: the repair for a projection refusal with `code` located at `path`. The ownership state has its own repair; a
|
|
160
|
+
* guard group the retirement (B11) refuses as changed is deleted by hand, after which the retirement removes the
|
|
161
|
+
* ownership state alone, and settings it cannot read are fixed; any other file is never replaced or adopted, so it is
|
|
162
|
+
* moved or deleted first. `ia host`, `ia doctor` and the install refresh all name it this way.
|
|
163
|
+
*/
|
|
164
|
+
export declare const projectionRepair: (host: HostName, path: string, rerun: string, code?: string) => string;
|
|
165
|
+
/** A journal owns recovery; raw operating-system errors never authorize deleting settings or ownership. */
|
|
166
|
+
export declare function projectionFailure(error: unknown, root: string, host: HostName, rerun: string): Refusal;
|
|
167
|
+
/**
|
|
168
|
+
* Host registration spec §4: the hosts whose projection this workspace owns, by their projection state's presence, as
|
|
169
|
+
* `ia host`, `ia doctor` and the install refresh decide it, a projection `ia project` wrote without a registration
|
|
170
|
+
* included.
|
|
132
171
|
*/
|
|
133
|
-
export declare const
|
|
172
|
+
export declare const projectedHosts: (root: string) => readonly HostName[];
|
|
173
|
+
/**
|
|
174
|
+
* The apply that repairs `host`'s projection, which `ia doctor` and the install refresh both name (task
|
|
175
|
+
* ia-project-verb): `ia host <host> --apply` for a registered host, and `ia project <host> --apply` for a projection
|
|
176
|
+
* `ia project` wrote without a registration, which `ia host` would also register an MCP server for.
|
|
177
|
+
*/
|
|
178
|
+
export declare const projectionRerun: (root: string, host: HostName) => string;
|
|
179
|
+
/** §8: a pending journal refuses the whole verb and names the recovery that clears it. `ia project` shares it. */
|
|
180
|
+
export declare function requireIdle(root: string, supplied: string): void;
|
|
181
|
+
/**
|
|
182
|
+
* §5.1 `projection`, planned by the real planners: B11's retirement of an owned guard registration, then the file plan
|
|
183
|
+
* (B9). Both read only the workspace, so the plan is exactly apply's. A retirement is a change, and so is a missing
|
|
184
|
+
* receipt, which every apply writes (B12), so a projection whose files are unchanged is then an update; a removal that
|
|
185
|
+
* finds only a guard registration or a receipt removes them. `ia project` plans with it, and both verbs' applies
|
|
186
|
+
* re-plan with it (`replanProjection`), so no two of them can plan the projection differently.
|
|
187
|
+
*/
|
|
188
|
+
export declare function projectionElement(root: string, host: HostName, rendered: HostOutput | null): Element;
|
|
134
189
|
/** §4's plan. It reads the workspace and the package's pin and writes nothing, the payload included. */
|
|
135
190
|
export declare function collectHost(context: Context): HostView;
|
|
191
|
+
/** One applied element; the projection's also says whether it retired a steward-guard registration first (B11). */
|
|
192
|
+
export interface AppliedElement {
|
|
193
|
+
readonly id: ElementId;
|
|
194
|
+
readonly status: string;
|
|
195
|
+
readonly guard?: 'retired' | 'none';
|
|
196
|
+
}
|
|
136
197
|
export interface HostApplied {
|
|
137
198
|
readonly status: 'host-registered' | 'host-removed';
|
|
138
|
-
readonly elements: readonly
|
|
139
|
-
readonly id: ElementId;
|
|
140
|
-
readonly status: string;
|
|
141
|
-
}[];
|
|
199
|
+
readonly elements: readonly AppliedElement[];
|
|
142
200
|
readonly observed: false;
|
|
143
201
|
}
|
|
202
|
+
/** What an apply that retired the steward guard (B11) says it did. */
|
|
203
|
+
export declare const GUARD_RETIRED = "Retired the steward guard an earlier release registered: its group in .claude/settings.local.json and its ownership state are removed.";
|
|
204
|
+
/**
|
|
205
|
+
* Apply's re-plan of the projection, shared by `ia host --apply` and `ia project --apply`: the projection element
|
|
206
|
+
* planned against the rendering the apply writes, so a conflict either of its planners finds (the guard retirement or
|
|
207
|
+
* the file plan) is raised, worded by the verb's `refuse`, before anything is written. `applyHostProjection` plans
|
|
208
|
+
* both again before its first write.
|
|
209
|
+
*/
|
|
210
|
+
export declare function replanProjection(root: string, host: HostName, rendered: HostOutput | null, refuse: (conflict: Conflict) => Refusal): void;
|
|
144
211
|
/**
|
|
145
|
-
* §8: mcp,
|
|
146
|
-
* re-planned with the verifying planners before any is applied
|
|
147
|
-
* the workspace changes; each apply then re-plans under
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* is
|
|
212
|
+
* §8: mcp, projection in order; removal in reverse. The payload is materialized, then every sub-transaction is
|
|
213
|
+
* re-planned with the verifying planners before any is applied — the projection's guard retirement (B11) and file plan
|
|
214
|
+
* included — so a refusal any planner can find is raised before the workspace changes; each apply then re-plans under
|
|
215
|
+
* the host lock and refuses a plan that went stale. The projection is applied through `applyHostProjection`, the one
|
|
216
|
+
* writer of projection files, which retires an owned steward guard before any projection file changes and reports it
|
|
217
|
+
* as the element's `guard`. Cancellation is observed between sub-transactions. A failure after an element was written
|
|
218
|
+
* names the rerun that finishes the set, or the recovery a pending journal needs. `checkpoint` runs after each element
|
|
219
|
+
* completes, which is where an interruption test cuts.
|
|
151
220
|
*/
|
|
152
221
|
export declare function applyHostSet(view: HostView, packageRoot: string, signal?: AbortSignal, checkpoint?: (id: ElementId) => void): HostApplied;
|
|
222
|
+
/** A projection plan's B11 step as its plan says it, in `ia host` and `ia project` alike. */
|
|
223
|
+
export declare const GUARD_RETIRE = "first retires the steward guard registered in .claude/settings.local.json";
|
|
224
|
+
/**
|
|
225
|
+
* Each projected file with its action, at `column`; a foreign steward file says why it is left alone. `ia host` nests
|
|
226
|
+
* the rows under its projection element and `ia project` lists them as its file plan, so both word them alike.
|
|
227
|
+
*/
|
|
228
|
+
export declare const projectionFileRows: (files: readonly ProjectionAction[], column: number, caps: Capabilities) => readonly string[];
|
|
153
229
|
/**
|
|
154
|
-
* §5.3's machine-local sentence and, for a Claude registration, §5.4's approval note and the guard's
|
|
155
|
-
*
|
|
156
|
-
*
|
|
230
|
+
* §5.3's machine-local sentence and, for a Claude registration, §5.4's approval note and the guard's retirement (only
|
|
231
|
+
* Claude ever registered the guard, B11). `ia init --host` prints the same blocks after its host step, so the two verbs
|
|
232
|
+
* cannot word them differently.
|
|
157
233
|
*/
|
|
158
234
|
export declare const hostNotes: (host: HostName, caps: Capabilities, remove?: boolean) => readonly (readonly string[])[];
|
|
159
235
|
export declare function renderHostPlan(view: HostView, applied: HostApplied | null, caps: Capabilities): string;
|