@inventarch/cli 1.2.0 → 3.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.
Files changed (125) hide show
  1. package/README.md +20 -5
  2. package/SPEC.md +86 -11
  3. package/assets/base/08eaab3e1a6215d78283b82a94a0228367ac7bd78d0a746c56db79c8d7546c3a.ia.tgz +0 -0
  4. package/assets/base.json +3 -3
  5. package/assets/host/d7722e32fd0511df2a6dfdf2353e621fdff1cf559d5c8b7ac256c7eceac0452f.tgz +0 -0
  6. package/assets/host.json +4 -4
  7. package/assets/vocabulary.json +11 -3
  8. package/dist/adopt.d.ts +8 -0
  9. package/dist/adopt.d.ts.map +1 -0
  10. package/dist/adopt.js +60 -0
  11. package/dist/adopt.js.map +1 -0
  12. package/dist/author.d.ts +32 -0
  13. package/dist/author.d.ts.map +1 -0
  14. package/dist/author.js +226 -0
  15. package/dist/author.js.map +1 -0
  16. package/dist/briefing.d.ts +2 -0
  17. package/dist/briefing.d.ts.map +1 -1
  18. package/dist/briefing.js +15 -3
  19. package/dist/briefing.js.map +1 -1
  20. package/dist/bundled-base.d.ts +18 -0
  21. package/dist/bundled-base.d.ts.map +1 -0
  22. package/dist/bundled-base.js +44 -0
  23. package/dist/bundled-base.js.map +1 -0
  24. package/dist/capture.d.ts +41 -6
  25. package/dist/capture.d.ts.map +1 -1
  26. package/dist/capture.js +132 -43
  27. package/dist/capture.js.map +1 -1
  28. package/dist/commands.d.ts +30 -8
  29. package/dist/commands.d.ts.map +1 -1
  30. package/dist/commands.js +287 -35
  31. package/dist/commands.js.map +1 -1
  32. package/dist/compile.d.ts +3 -4
  33. package/dist/compile.d.ts.map +1 -1
  34. package/dist/compile.js +28 -72
  35. package/dist/compile.js.map +1 -1
  36. package/dist/consumer.d.ts +11 -2
  37. package/dist/consumer.d.ts.map +1 -1
  38. package/dist/consumer.js +103 -20
  39. package/dist/consumer.js.map +1 -1
  40. package/dist/distribute.d.ts +30 -8
  41. package/dist/distribute.d.ts.map +1 -1
  42. package/dist/distribute.js +112 -60
  43. package/dist/distribute.js.map +1 -1
  44. package/dist/doctor-authority.d.ts +3 -0
  45. package/dist/doctor-authority.d.ts.map +1 -0
  46. package/dist/doctor-authority.js +65 -0
  47. package/dist/doctor-authority.js.map +1 -0
  48. package/dist/doctor-mounts.d.ts +4 -0
  49. package/dist/doctor-mounts.d.ts.map +1 -0
  50. package/dist/doctor-mounts.js +32 -0
  51. package/dist/doctor-mounts.js.map +1 -0
  52. package/dist/doctor.d.ts.map +1 -1
  53. package/dist/doctor.js +327 -79
  54. package/dist/doctor.js.map +1 -1
  55. package/dist/format.d.ts.map +1 -1
  56. package/dist/format.js +2 -1
  57. package/dist/format.js.map +1 -1
  58. package/dist/host-projection.d.ts +131 -6
  59. package/dist/host-projection.d.ts.map +1 -1
  60. package/dist/host-projection.js +663 -42
  61. package/dist/host-projection.js.map +1 -1
  62. package/dist/host.d.ts +154 -32
  63. package/dist/host.d.ts.map +1 -1
  64. package/dist/host.js +393 -142
  65. package/dist/host.js.map +1 -1
  66. package/dist/init.d.ts +296 -38
  67. package/dist/init.d.ts.map +1 -1
  68. package/dist/init.js +1303 -203
  69. package/dist/init.js.map +1 -1
  70. package/dist/main.d.ts +1 -6
  71. package/dist/main.d.ts.map +1 -1
  72. package/dist/main.js +4 -7
  73. package/dist/main.js.map +1 -1
  74. package/dist/migration-journal.d.ts +35 -0
  75. package/dist/migration-journal.d.ts.map +1 -0
  76. package/dist/migration-journal.js +205 -0
  77. package/dist/migration-journal.js.map +1 -0
  78. package/dist/next.d.ts +21 -0
  79. package/dist/next.d.ts.map +1 -0
  80. package/dist/next.js +216 -0
  81. package/dist/next.js.map +1 -0
  82. package/dist/operation-help.d.ts.map +1 -1
  83. package/dist/operation-help.js +15 -4
  84. package/dist/operation-help.js.map +1 -1
  85. package/dist/pack.d.ts.map +1 -1
  86. package/dist/pack.js +24 -2
  87. package/dist/pack.js.map +1 -1
  88. package/dist/position.d.ts +22 -0
  89. package/dist/position.d.ts.map +1 -0
  90. package/dist/position.js +244 -0
  91. package/dist/position.js.map +1 -0
  92. package/dist/preview.d.ts +145 -0
  93. package/dist/preview.d.ts.map +1 -0
  94. package/dist/preview.js +962 -0
  95. package/dist/preview.js.map +1 -0
  96. package/dist/profile.d.ts +118 -0
  97. package/dist/profile.d.ts.map +1 -0
  98. package/dist/profile.js +362 -0
  99. package/dist/profile.js.map +1 -0
  100. package/dist/project.d.ts +45 -0
  101. package/dist/project.d.ts.map +1 -0
  102. package/dist/project.js +263 -0
  103. package/dist/project.js.map +1 -0
  104. package/dist/read.d.ts +12 -2
  105. package/dist/read.d.ts.map +1 -1
  106. package/dist/read.js +32 -18
  107. package/dist/read.js.map +1 -1
  108. package/dist/render.d.ts +24 -2
  109. package/dist/render.d.ts.map +1 -1
  110. package/dist/render.js +171 -4
  111. package/dist/render.js.map +1 -1
  112. package/dist/session.d.ts +39 -12
  113. package/dist/session.d.ts.map +1 -1
  114. package/dist/session.js +55 -11
  115. package/dist/session.js.map +1 -1
  116. package/dist/user-host.d.ts +3 -3
  117. package/dist/user-host.js +10 -10
  118. package/dist/user-host.js.map +1 -1
  119. package/dist/validate.d.ts +28 -16
  120. package/dist/validate.d.ts.map +1 -1
  121. package/dist/validate.js +245 -23
  122. package/dist/validate.js.map +1 -1
  123. package/package.json +6 -6
  124. package/assets/base/0305ca741b1dfec97ff35fbeb36d4a66a0c9c0614b730fe14fcdac0f1565e28a.ia.tgz +0 -0
  125. package/assets/host/c5fb2bfbba619cbd558ecc1e94dd2c16e37aa8599b4e423f1f59ed01f2074e03.tgz +0 -0
@@ -3,7 +3,7 @@ import type { InstallationPlan } from '@inventarch/distribution/install';
3
3
  import type { RegistryChoice, RegistryLevel } from '@inventarch/distribution/registry';
4
4
  import type { Context, Host, Result } from './consumer.js';
5
5
  import type { HostName } from './host-projection.js';
6
- import type { Capabilities } from './render.js';
6
+ import type { AdviceContext, Capabilities } from './render.js';
7
7
  export type Operation = 'install' | 'update' | 'remove' | 'restore';
8
8
  /** §2.8: the id grammar is `provider/name`, and a positional may pin it with `@<range>`. */
9
9
  export declare const REQUEST: RegExp;
@@ -46,6 +46,20 @@ export interface PlanView {
46
46
  readonly planOut: string | null;
47
47
  /** Hosts whose projection this workspace owns; `applyPlan` refreshes each after the install commits. */
48
48
  readonly refresh: readonly HostName[];
49
+ readonly projectionFiles: readonly {
50
+ readonly host: HostName;
51
+ readonly files: readonly {
52
+ readonly path: string;
53
+ readonly action: string;
54
+ }[];
55
+ }[];
56
+ /**
57
+ * The refreshed hosts that own a steward-guard registration an earlier release made, which their refresh retires
58
+ * before any projection file changes (B11); a plan lists the retirement.
59
+ */
60
+ readonly retire: readonly HostName[];
61
+ /** After an apply, the refreshed hosts whose refresh retired that registration; empty before an apply. */
62
+ readonly retired: readonly HostName[];
49
63
  /** Whether `--root` was given, so every `ia host` command printed carries it (`rootedNext`). */
50
64
  readonly rooted: boolean;
51
65
  }
@@ -103,6 +117,7 @@ export interface Reruns {
103
117
  */
104
118
  export declare const UNMAPPED = "Every requested and locked package's provider needs a registry. Map the provider to an HTTPS URL or a workspace directory in .ia/registries.json, or pass --registry <url|dir>.";
105
119
  export interface PlanRequest {
120
+ readonly packageRoot?: string;
106
121
  readonly signal?: AbortSignal | undefined;
107
122
  readonly root: string;
108
123
  readonly operation: Operation;
@@ -133,17 +148,23 @@ export interface PlanRequest {
133
148
  /** §2.8: a positional adds or repins one direct request; `--requests` supplies the whole set the native path reads. */
134
149
  export declare function mergeRequests(previous: DistributionLock | undefined, ids: readonly string[]): readonly Dependency[];
135
150
  /**
136
- * Host registration spec §4: the hosts whose projection this workspace owns. Ownership is the state file's presence,
137
- * as `ia host` and `ia doctor` decide it. `restore` changes no admitted system, so it has none to refresh.
151
+ * Host registration spec §4: the hosts whose projection this workspace owns (`projectedHosts`), a projection `ia
152
+ * project` wrote without a registration included. `restore` changes no admitted system, so it has none to refresh.
138
153
  */
139
154
  export declare const registeredProjections: (root: string, operation: Operation) => readonly HostName[];
140
155
  /**
141
156
  * Host registration spec §4: `--apply` refuses before any install write when a registered projection would refuse.
142
157
  * A hand edit to an owned file is the refusal the refresh would raise (§6.3), so it is found here, before
143
- * acquisition, the saved plan or the lock is touched; the remedy is the one `ia host` and `ia doctor` name for it.
158
+ * acquisition, the saved plan or the lock is touched; the remedy is the one `ia doctor` names for it, its rerun
159
+ * `projectionRerun`'s: `ia host <host> --apply` for a registered host, `ia project <host> --apply` for a projection
160
+ * `ia project` wrote without a registration (task ia-project-verb).
144
161
  * Missing, outdated and unowned files do not block: the refresh rewrites the first two and never touches the third.
145
162
  * A file the mechanism cannot read — an unreadable ownership state, an aliased or oversized managed file — would
146
- * refuse the refresh too, so it is refused here, located at that file, with the repair `ia host` names for it.
163
+ * refuse the refresh too, so it is refused here, located at that file, with the repair `ia host` names for it. So is
164
+ * a steward-guard registration the refresh's retirement (B11) would refuse: an unreadable guard state, or a guard
165
+ * group changed by hand; a pending host journal that refuses the retirement's plan names its own recovery. So is the
166
+ * hook step the refresh runs (`preflightHooks`, review finding H-R3): an owned hook group deleted, changed or
167
+ * duplicated by hand, or a recorded payload a change of hooks would need, with the repair `ia host` names.
147
168
  */
148
169
  export declare function requireProjectionsClean(root: string, hosts: readonly HostName[], rooted: boolean): void;
149
170
  export declare function collectPlan(request: PlanRequest): Promise<PlanView>;
@@ -156,7 +177,8 @@ export declare function collectPlan(request: PlanRequest): Promise<PlanView>;
156
177
  */
157
178
  export declare function applyPlan(view: PlanView): PlanView;
158
179
  /**
159
- * The `--json` envelope (§2.8): `{version: 1, command, plan, applied?, refresh?, registries?, withdrawn?, planOut?}`.
180
+ * The `--json` envelope (§2.8): `{version: 1, command, plan, applied?, refresh?, retire?, retired?, registries?,
181
+ * withdrawn?, planOut?}`.
160
182
  *
161
183
  * - `plan` is the planner's own value, unchanged.
162
184
  * - `registries` (registry spec §6.1) is present only when registries were the source: one `{provider, base, level}`
@@ -167,7 +189,7 @@ export declare function applyPlan(view: PlanView): PlanView;
167
189
  * restore names bare package ids, as it always has; a registry restore names `id@version` pins (§6.3).
168
190
  */
169
191
  export declare function planEnvelope(view: PlanView): unknown;
170
- export declare function renderPlan(view: PlanView, caps: Capabilities): string;
192
+ export declare function renderPlan(view: PlanView, caps: Capabilities, supplied?: string, advice?: AdviceContext): string;
171
193
  /** §2.8 rule 3's one question, asked once and only where an answer can arrive. */
172
194
  export declare const CONFIRMATION = "Apply these changes? [y/N] ";
173
195
  /**
@@ -181,7 +203,7 @@ export declare const renderSummary: (view: PlanView, caps: Capabilities) => stri
181
203
  * that and exits 0. The summary was on stderr, so what stdout carries is the outcome and the way to get the other
182
204
  * one. `--plan-out` was already written, because a declined apply is exactly the plan-only run rule 1 describes.
183
205
  */
184
- export declare const renderDeclined: (view: PlanView, caps: Capabilities) => string;
206
+ export declare const renderDeclined: (view: PlanView, caps: Capabilities, supplied?: string, advice?: AdviceContext) => string;
185
207
  /**
186
208
  * Registry spec §4: the one chooser a command builds, from the host rather than the process, so every verb that
187
209
  * reports or uses registry routing (`install`, `update`, `restore`, `doctor`) picks the same base for an id. A
@@ -1 +1 @@
1
- {"version":3,"file":"distribute.d.ts","sourceRoot":"","sources":["../src/distribute.ts"],"names":[],"mappings":"AA+CA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEhF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAUzE,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAgBvF,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIrD,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,aAAa,CAAC;AAc5D,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC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,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,CA6CzF"}
@@ -26,30 +26,31 @@
26
26
  * the lock and never chooses a registry.
27
27
  *
28
28
  * Registered host projections (docs/specs/host-registration/README.md §4, "install, update, remove"):
29
- * a workspace that owns a projection for a host — its `<host>-projection.json` state exists — lists installed
30
- * distributions in it, so a change to the installed set changes the projection. `--apply` refuses before anything is
31
- * acquired or written when an owned projection file was edited by hand, because the refresh would refuse it, and
32
- * re-renders each registered projection after the install commits. MCP and hook entries do not depend on the
33
- * installed set and are not touched. `restore` reinstalls the locked generation, whose admitted systems are
29
+ * a workspace that owns a projection for a host — its `<host>-projection.json` state exists — renders the position
30
+ * packet of its admitted records, so a change to the installed set changes the projection. `--apply` refuses before
31
+ * anything is acquired or written when an owned projection file was edited by hand, or when the steward guard the
32
+ * refresh would retire (B11) cannot be removed, because the refresh would refuse either, and re-renders each
33
+ * registered projection after the install commits through `applyHostProjection`, the one writer of projection files,
34
+ * which retires such a guard before any projection file changes and writes the receipt; the plan, and so the question
35
+ * an apply asks, names each refresh that retires one (`retire`). MCP entries do not depend on the installed set and are
36
+ * not touched. `restore` reinstalls the locked generation, whose admitted systems are
34
37
  * unchanged, so it neither checks nor refreshes. A refresh that fails after the install committed cannot undo the
35
38
  * install, and it is not hidden either: like `ia init --host` after initialization, the command refuses at class 3
36
39
  * with the service's code, message and file, and its next action opens "The installation is applied." before the
37
40
  * repair, so a script sees the failure and a reader sees what did happen. `ia doctor` reports the drift until then.
38
41
  */
39
- import { existsSync } from 'node:fs';
40
- import { resolve } from 'node:path';
41
- import { WORKSPACE_PROJECTION_MARKER } from '@inventarch/compliance';
42
+ import { readBase } from './bundled-base.js';
42
43
  import { canonicalDistributionJson, decodeDistributionRequests, DISTRIBUTION_ENGINE_VERSION, INSTALL_PATHS, } from '@inventarch/db/distribution';
43
- import { ARCHIVE_CACHE, applyInstallation, planInstallation } from '@inventarch/distribution/install';
44
- import { applyProjection, observeProjection, planProjection } from '@inventarch/distribution/projection';
44
+ import { ARCHIVE_CACHE, applyInstallation, cacheArchive, planInstallation } from '@inventarch/distribution/install';
45
+ import { legacyProjectionActions, observeProjection } from '@inventarch/distribution/projection';
46
+ import { PACKET_MARKER } from '@inventarch/runtime';
45
47
  import { registryChooser, registryLocation, registryWithdrawals, resolveFromRegistries, unpublishedPins, } from '@inventarch/distribution/registry';
46
48
  import { resolveReleases } from '@inventarch/distribution/resolve';
47
- import { WORKSPACE_HOSTS } from '@inventarch/distribution/hosts';
48
49
  import { acquireArtifact, cachedCandidates, planRestore, pruneLockRequest, readInstalledState, readWorkspaceJson, readWorkspaceLock, resolveCatalog, writeWorkOutput, } from '@inventarch/distribution/services';
49
50
  import { UsageError } from './args.js';
50
51
  import { confirm, Refusal, refusalOf, requireRoot, serviceNext } from './consumer.js';
51
- import { renderProjectionFor } from './host-projection.js';
52
- import { hostNext, lockRefusal, projectionRepair, refusedPath, STATE } from './host.js';
52
+ import { applyHostProjection, ownsGuard, planRetirement, preflightProjection, preflightReceipt, renderProjectionFor, } from './host-projection.js';
53
+ import { GUARD_SCOPE, hostNext, projectedHosts, projectionFailure, projectionRepair, projectionRerun, refusedPath, SETTINGS, } from './host.js';
53
54
  import { codeOf } from './session.js';
54
55
  import { atom, commandFacts, document, entry, fieldRows, headerLine, quote, sectionLabel, truncateDigest, words, } from './render.js';
55
56
  /** §2.8: the id grammar is `provider/name`, and a positional may pin it with `@<range>`. */
@@ -138,7 +139,9 @@ async function acquiring(run, where, route, reruns) {
138
139
  // A refusal located at a cached archive (a corrupt cached lock pin, registry spec §5.1) is repaired by deleting it.
139
140
  const cachedFile = own !== null && own.startsWith(`${ARCHIVE_CACHE}/`) ? own : null;
140
141
  if (code === 'IA-DIST-ARTIFACT-UNAVAILABLE' || (code === 'IA-DIST-LIMIT-EXCEEDED' && REMOTE_LIMIT.test(message)))
141
- throw new Refusal(code, message, 4, at, cachedFile !== null ? deleteCached(cachedFile, reruns) : unavailable(message, route, reruns));
142
+ throw new Refusal(code, message, 4, at, cachedFile !== null ? deleteCached(cachedFile, reruns) : unavailable(message, route, reruns), null, cachedFile === null && message.startsWith('Registry document ') && reruns.chosen === 'variable'
143
+ ? 'reselect'
144
+ : undefined);
142
145
  if (code === '')
143
146
  throw new Refusal('IA-CLI-FAILED', `Artifact transport failed: ${message}`, 4, at, route === 'registry' ? REGISTRY_RETRY(reruns) : RETRY(reruns));
144
147
  if (code === 'IA-DIST-REGISTRY-UNMAPPED')
@@ -236,59 +239,76 @@ function repin(previous, id, to, reruns) {
236
239
  : previous.requests.map((request) => (request.id === id ? { id, range: to } : request));
237
240
  }
238
241
  /**
239
- * Host registration spec §4: the hosts whose projection this workspace owns. Ownership is the state file's presence,
240
- * as `ia host` and `ia doctor` decide it. `restore` changes no admitted system, so it has none to refresh.
242
+ * Host registration spec §4: the hosts whose projection this workspace owns (`projectedHosts`), a projection `ia
243
+ * project` wrote without a registration included. `restore` changes no admitted system, so it has none to refresh.
241
244
  */
242
- export const registeredProjections = (root, operation) => operation === 'restore' ? [] : WORKSPACE_HOSTS.filter((host) => existsSync(resolve(root, STATE.projection(host))));
245
+ export const registeredProjections = (root, operation) => operation === 'restore' ? [] : projectedHosts(root);
243
246
  /**
244
247
  * Host registration spec §4: `--apply` refuses before any install write when a registered projection would refuse.
245
248
  * A hand edit to an owned file is the refusal the refresh would raise (§6.3), so it is found here, before
246
- * acquisition, the saved plan or the lock is touched; the remedy is the one `ia host` and `ia doctor` name for it.
249
+ * acquisition, the saved plan or the lock is touched; the remedy is the one `ia doctor` names for it, its rerun
250
+ * `projectionRerun`'s: `ia host <host> --apply` for a registered host, `ia project <host> --apply` for a projection
251
+ * `ia project` wrote without a registration (task ia-project-verb).
247
252
  * Missing, outdated and unowned files do not block: the refresh rewrites the first two and never touches the third.
248
253
  * A file the mechanism cannot read — an unreadable ownership state, an aliased or oversized managed file — would
249
- * refuse the refresh too, so it is refused here, located at that file, with the repair `ia host` names for it.
254
+ * refuse the refresh too, so it is refused here, located at that file, with the repair `ia host` names for it. So is
255
+ * a steward-guard registration the refresh's retirement (B11) would refuse: an unreadable guard state, or a guard
256
+ * group changed by hand; a pending host journal that refuses the retirement's plan names its own recovery. So is the
257
+ * hook step the refresh runs (`preflightHooks`, review finding H-R3): an owned hook group deleted, changed or
258
+ * duplicated by hand, or a recorded payload a change of hooks would need, with the repair `ia host` names.
250
259
  */
251
260
  export function requireProjectionsClean(root, hosts, rooted) {
252
261
  for (const host of hosts) {
253
- const rerun = `ia host ${host} --apply`;
262
+ const rerun = projectionRerun(root, host);
254
263
  let drifts;
255
264
  try {
256
- drifts = observeProjection({ root, host, artifacts: null, marker: WORKSPACE_PROJECTION_MARKER });
265
+ planRetirement(root, host);
266
+ preflightReceipt(root, host);
267
+ drifts = observeProjection({ root, host, artifacts: null, marker: PACKET_MARKER });
257
268
  }
258
269
  catch (error) {
259
- const refusal = refusalOf(error), path = refusedPath(error) ?? STATE.projection(host);
260
- throw new Refusal(refusal.code, refusal.message, 3, { path }, hostNext(projectionRepair(host, path, rerun), host, root, rooted));
270
+ throw projectionFailure(error, root, host, rerun);
261
271
  }
262
272
  const changed = drifts.find((drift) => drift.drift === 'changed');
263
273
  if (changed !== undefined)
264
274
  throw new Refusal('IA-DIST-LOCAL-MODIFICATION', `Managed file was edited by hand: ${changed.path}`, 3, { path: changed.path }, hostNext(projectionRepair(host, changed.path, rerun), host, root, rooted));
275
+ // The refresh's file plan and hook step on the current render: a generated skill refused at a populated folder of the
276
+ // user's (F4), a hook group changed by hand or a payload a change needs (H-R3) refuse here, before any install write.
277
+ try {
278
+ preflightProjection(root, host);
279
+ }
280
+ catch (error) {
281
+ throw projectionFailure(error, root, host, rerun);
282
+ }
265
283
  }
266
284
  }
267
285
  /**
268
- * Host registration spec §4: after the install committed, a registered projection is re-rendered from the records and
269
- * the new lock and applied through the projection mechanism, which re-checks every file itself. A refusal comes back
270
- * rather than being thrown, so every registered host is attempted before the command refuses. A file the mechanism
286
+ * The files the refresh would render for `host`, by the current records: a generated agent among them is written, never
287
+ * previewed as a 1.x file to remove (review finding H-N7). None when the records do not render; the refresh then refuses.
288
+ */
289
+ function renderedPaths(root, host) {
290
+ try {
291
+ return renderProjectionFor(root, host).files.map((file) => file.path);
292
+ }
293
+ catch {
294
+ return [];
295
+ }
296
+ }
297
+ /**
298
+ * Host registration spec §4: after the install committed, a registered projection is re-rendered from the records of
299
+ * the new generation and applied through `applyHostProjection`, which retires an owned steward guard first (B11),
300
+ * re-checks every file itself and writes the receipt (B12); the retirement comes back as `retired`. A refusal comes
301
+ * back rather than being thrown, so every registered host is attempted before the command refuses. A file the mechanism
271
302
  * located gets `ia host`'s repair for it; a held host lock names the recovery that clears a dead holder's; a CLI
272
- * refusal (the workspace no longer admits, the renderer refused) keeps its own next action; anything else names the
273
- * rerun.
303
+ * refusal (the workspace no longer admits) keeps its own next action; anything else names the rerun, which is
304
+ * `projectionRerun`'s, as `ia doctor` names it.
274
305
  */
275
306
  function refreshed(view, host) {
276
307
  try {
277
- const artifacts = renderProjectionFor(view.root, host);
278
- applyProjection(planProjection({ root: view.root, host, artifacts, marker: WORKSPACE_PROJECTION_MARKER }));
279
- return null;
308
+ return applyHostProjection(view.root, host, renderProjectionFor(view.root, host)).guard;
280
309
  }
281
310
  catch (error) {
282
- const busy = lockRefusal(error, view.root);
283
- if (busy !== null)
284
- return busy;
285
- const refusal = refusalOf(error), path = refusedPath(error), rerun = `ia host ${host} --apply`;
286
- const next = path !== null
287
- ? projectionRepair(host, path, rerun)
288
- : error instanceof Refusal && refusal.next !== null
289
- ? refusal.next
290
- : `Run "${rerun}" to finish.`;
291
- return new Refusal(refusal.code, refusal.message, 3, path === null ? refusal.where : { path }, hostNext(next, host, view.root, view.rooted));
311
+ return projectionFailure(error, view.root, host, projectionRerun(view.root, host));
292
312
  }
293
313
  }
294
314
  /**
@@ -375,6 +395,15 @@ export async function collectPlan(request) {
375
395
  if (operation === 'restore') {
376
396
  // One lock is read, and the withdrawal check and the plan both use that same object (registry spec §6.3).
377
397
  const lock = readWorkspaceLock({ root });
398
+ if (request.packageRoot !== undefined) {
399
+ const base = readBase(request.packageRoot);
400
+ const locked = lock.packages.find((row) => row.id === base.pin.id);
401
+ if (locked?.archive === base.pin.archive) {
402
+ if (locked.manifest !== base.pin.manifest || locked.version !== base.pin.version)
403
+ throw new Refusal('IA-DIST-INPUT-INVALID', 'The locked bundled base manifest or version differs from its verified archive', 3, { path: INSTALL_PATHS.lock }, `Restore the exact portable lock from source control, then run "${reruns.again}".`);
404
+ cacheArchive(root, base.bytes, base.pin.archive);
405
+ }
406
+ }
378
407
  if (request.catalog === undefined && !request.offline) {
379
408
  const choose = chooserOf(request);
380
409
  const restored = await acquiring(async () => {
@@ -416,7 +445,7 @@ export async function collectPlan(request) {
416
445
  }
417
446
  else {
418
447
  const updated = operation === 'update' ? request.ids[0] : undefined;
419
- const requests = updated !== undefined
448
+ let requests = updated !== undefined
420
449
  ? repin(previous, updated, request.to, reruns)
421
450
  : request.requestsFile === undefined
422
451
  ? mergeRequests(previous, request.ids)
@@ -444,6 +473,7 @@ export async function collectPlan(request) {
444
473
  .map((dependency) => dependency.id);
445
474
  const choose = chooserOf(request);
446
475
  const resolution = await acquiring(() => resolveFromRegistries({
476
+ allowKits: operation === 'install',
447
477
  root,
448
478
  requests,
449
479
  engine: DISTRIBUTION_ENGINE_VERSION,
@@ -453,6 +483,7 @@ export async function collectPlan(request) {
453
483
  choose,
454
484
  signal: request.signal,
455
485
  }), null, 'registry', reruns);
486
+ requests = resolution.expandedRequests ?? requests;
456
487
  choices = resolution.candidates;
457
488
  registries = registrySources(resolution.sources.values());
458
489
  }
@@ -473,6 +504,7 @@ export async function collectPlan(request) {
473
504
  content: () => Buffer.from(canonicalDistributionJson(plan)),
474
505
  refusal: 'A saved plan is written to a new file under .ia/work/',
475
506
  });
507
+ const refresh = request.refresh ?? registeredProjections(root, operation);
476
508
  return {
477
509
  operation,
478
510
  root,
@@ -483,7 +515,13 @@ export async function collectPlan(request) {
483
515
  registries,
484
516
  invocation: request.invocation,
485
517
  planOut,
486
- refresh: request.refresh ?? registeredProjections(root, operation),
518
+ refresh,
519
+ projectionFiles: refresh.map((host) => ({
520
+ host,
521
+ files: legacyProjectionActions(root, host, PACKET_MARKER, renderedPaths(root, host)),
522
+ })),
523
+ retire: refresh.filter((host) => ownsGuard(root, host)),
524
+ retired: [],
487
525
  rooted: request.rooted ?? false,
488
526
  };
489
527
  }
@@ -495,19 +533,18 @@ export async function collectPlan(request) {
495
533
  * refused refresh is class 3 naming the first refusal, and the count when more than one host refused (file comment).
496
534
  */
497
535
  export function applyPlan(view) {
498
- const applied = { ...view, applied: applyInstallation(view.plan) };
499
- const refused = view.refresh
500
- .map((host) => refreshed(applied, host))
501
- .filter((refusal) => refusal !== null);
536
+ const installed = { ...view, applied: applyInstallation(view.plan) };
537
+ const results = view.refresh.map((host) => [host, refreshed(installed, host)]), refused = results.flatMap(([, result]) => (result instanceof Refusal ? [result] : []));
502
538
  const [first] = refused;
503
539
  if (first !== undefined) {
504
540
  const count = refused.length > 1 ? ` ${refused.length} registered host projections were not refreshed; this is the first.` : '';
505
541
  throw new Refusal(first.code, first.message, 3, first.where, `The installation is applied.${count} ${first.next}`);
506
542
  }
507
- return applied;
543
+ return { ...installed, retired: results.flatMap(([host, result]) => (result === 'retired' ? [host] : [])) };
508
544
  }
509
545
  /**
510
- * The `--json` envelope (§2.8): `{version: 1, command, plan, applied?, refresh?, registries?, withdrawn?, planOut?}`.
546
+ * The `--json` envelope (§2.8): `{version: 1, command, plan, applied?, refresh?, retire?, retired?, registries?,
547
+ * withdrawn?, planOut?}`.
511
548
  *
512
549
  * - `plan` is the planner's own value, unchanged.
513
550
  * - `registries` (registry spec §6.1) is present only when registries were the source: one `{provider, base, level}`
@@ -524,8 +561,11 @@ export function planEnvelope(view) {
524
561
  plan: view.plan,
525
562
  // `applied` is applyInstallation's return, its `host: 'pending'` literal included (§2.8).
526
563
  ...(view.applied === null ? {} : { applied: view.applied }),
527
- // Host registration spec §4: the registered projections an apply refreshes.
528
- ...(view.refresh.length === 0 ? {} : { refresh: view.refresh }),
564
+ // Host registration spec §4: the registered projections an apply refreshes, those whose refresh retires the
565
+ // steward guard first (B11), and after an apply those whose refresh retired it.
566
+ ...(view.refresh.length === 0 ? {} : { refresh: view.refresh, projectionFiles: view.projectionFiles }),
567
+ ...(view.retire.length === 0 ? {} : { retire: view.retire }),
568
+ ...(view.retired.length === 0 ? {} : { retired: view.retired }),
529
569
  ...(view.registries.length === 0 ? {} : { registries: view.registries }),
530
570
  ...(view.withdrawn.length === 0 ? {} : { withdrawn: view.withdrawn }),
531
571
  ...(view.planOut === null ? {} : { planOut: view.planOut }),
@@ -597,11 +637,20 @@ const wouldWriteBlocks = (view, caps) => {
597
637
  ...projectionsBlocks(view, caps),
598
638
  ];
599
639
  };
600
- /** Host registration spec §4: the plan says which registered projections the apply re-renders. */
640
+ /**
641
+ * Host registration spec §4: the plan says which registered projections the apply re-renders, and which of those
642
+ * refreshes first retire the steward guard an earlier release registered (B11), with what that leaves unguarded.
643
+ */
601
644
  const projectionsBlocks = (view, caps) => view.refresh.length === 0
602
645
  ? []
603
646
  : [
604
- entry([words(`Registered host projections (${view.refresh.join(', ')}) are refreshed after apply.`)], { depth: 1, symbol: 'info' }, caps),
647
+ entry([
648
+ words(`Registered host projections (${view.refresh.join(', ')}) are refreshed after apply${view.retire.length === 0
649
+ ? ''
650
+ : `; the refresh first retires the steward guard registered in ${SETTINGS} (${view.retire.join(', ')})`}.`),
651
+ ], { depth: 1, symbol: 'info' }, caps),
652
+ ...view.projectionFiles.flatMap(({ host, files }) => files.map(({ path, action }) => entry([words(`${host}: ${path} ${action}${action === 'foreign' ? ' (left in place)' : ''}`)], { depth: 1, symbol: action === 'remove' ? 'removed' : 'info' }, caps))),
653
+ ...(view.retire.length === 0 ? [] : [entry([words(GUARD_SCOPE)], { depth: 1, symbol: 'info' }, caps)]),
605
654
  ];
606
655
  /**
607
656
  * What an applied plan says about hosts. `applied.host` is applyInstallation's literal and is never presented as
@@ -610,8 +659,10 @@ const projectionsBlocks = (view, caps) => view.refresh.length === 0
610
659
  */
611
660
  const hostLine = (view) => view.refresh.length === 0
612
661
  ? 'Host state is not reported by the installer; run "ia doctor" for it.'
613
- : `Registered host projections (${view.refresh.join(', ')}) were refreshed; run "ia doctor" for host state.`;
614
- export function renderPlan(view, caps) {
662
+ : `Registered host projections (${view.refresh.join(', ')}) were refreshed${view.retired.length === 0
663
+ ? ''
664
+ : `, and the steward guard an earlier release registered was retired first (${view.retired.join(', ')})`}; run "ia doctor" for host state.`;
665
+ export function renderPlan(view, caps, supplied, advice) {
615
666
  const blocks = [
616
667
  headerBlock(view, caps),
617
668
  view.applied === null
@@ -630,7 +681,7 @@ export function renderPlan(view, caps) {
630
681
  ]),
631
682
  entry(view.applied === null
632
683
  ? [
633
- ...commandFacts('Apply with "', `${view.invocation} --apply --yes`, '".', 3, caps),
684
+ ...commandFacts('Apply with "', `${view.invocation} --apply --yes`, '".', 3, caps, [view.root, supplied], advice),
634
685
  words(`Save the plan for review with --plan-out .ia/work/${view.operation}-plan.json.`),
635
686
  ]
636
687
  : [words('Run "ia validate" to check the installed workspace, or "ia doctor" for the installed state.')], { depth: 0, symbol: 'step' }, caps),
@@ -657,9 +708,9 @@ export const renderSummary = (view, caps) => document([
657
708
  * that and exits 0. The summary was on stderr, so what stdout carries is the outcome and the way to get the other
658
709
  * one. `--plan-out` was already written, because a declined apply is exactly the plan-only run rule 1 describes.
659
710
  */
660
- export const renderDeclined = (view, caps) => document([
711
+ export const renderDeclined = (view, caps, supplied, advice) => document([
661
712
  entry([words('Nothing was applied.')], { depth: 0, symbol: 'info' }, caps),
662
- entry(commandFacts('Apply with "', `${view.invocation} --apply --yes`, '".', 3, caps), { depth: 0, symbol: 'step' }, caps),
713
+ entry(commandFacts('Apply with "', `${view.invocation} --apply --yes`, '".', 3, caps, [view.root, supplied], advice), { depth: 0, symbol: 'step' }, caps),
663
714
  ], { leadingBlank: true });
664
715
  /**
665
716
  * The invocation is rebuilt from the parsed arguments, so the printed command is the one that was understood. A
@@ -740,6 +791,7 @@ export function runDistribute(operation) {
740
791
  if (args.flag('apply'))
741
792
  requireProjectionsClean(root, refresh, rooted);
742
793
  const planned = await collectPlan({
794
+ packageRoot: host.packageRoot,
743
795
  signal: host.signal,
744
796
  root,
745
797
  operation,
@@ -758,7 +810,7 @@ export function runDistribute(operation) {
758
810
  });
759
811
  const rendered = (view) => json
760
812
  ? { exitCode: 0, stdout: JSON.stringify(planEnvelope(view)) + '\n', stderr: '' }
761
- : { exitCode: 0, stdout: renderPlan(view, caps), stderr: '' };
813
+ : { exitCode: 0, stdout: renderPlan(view, caps, args.value('root'), host), stderr: '' };
762
814
  host.signal?.throwIfAborted();
763
815
  if (!args.flag('apply'))
764
816
  return rendered(planned);
@@ -766,7 +818,7 @@ export function runDistribute(operation) {
766
818
  // no terminal, or `--json` — so the only two states left here are "answer it" and "`--yes` says skip it".
767
819
  // A declined answer therefore cannot occur under `--json`, which is why there is no JSON shape for one.
768
820
  if (!args.flag('yes') && !(await confirm(host.interaction, renderSummary(planned, caps), CONFIRMATION)))
769
- return { exitCode: 0, stdout: renderDeclined(planned, caps), stderr: '' };
821
+ return { exitCode: 0, stdout: renderDeclined(planned, caps, args.value('root'), host), stderr: '' };
770
822
  host.signal?.throwIfAborted();
771
823
  return rendered(applyPlan(planned));
772
824
  };