@inventarch/distribution 2.0.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 (78) hide show
  1. package/README.md +10 -0
  2. package/SPEC.md +19 -1
  3. package/dist/adoption.d.ts +21 -0
  4. package/dist/adoption.d.ts.map +1 -0
  5. package/dist/adoption.js +187 -0
  6. package/dist/adoption.js.map +1 -0
  7. package/dist/archive.d.ts.map +1 -1
  8. package/dist/archive.js +4 -1
  9. package/dist/archive.js.map +1 -1
  10. package/dist/command.d.ts.map +1 -1
  11. package/dist/command.js +22 -6
  12. package/dist/command.js.map +1 -1
  13. package/dist/files.d.ts.map +1 -1
  14. package/dist/files.js +30 -23
  15. package/dist/files.js.map +1 -1
  16. package/dist/guard-registration.d.ts +120 -5
  17. package/dist/guard-registration.d.ts.map +1 -1
  18. package/dist/guard-registration.js +419 -57
  19. package/dist/guard-registration.js.map +1 -1
  20. package/dist/host-modes.d.ts.map +1 -1
  21. package/dist/host-modes.js +2 -2
  22. package/dist/host-modes.js.map +1 -1
  23. package/dist/host-observe.d.ts +20 -1
  24. package/dist/host-observe.d.ts.map +1 -1
  25. package/dist/host-observe.js +18 -5
  26. package/dist/host-observe.js.map +1 -1
  27. package/dist/host.d.ts +7 -0
  28. package/dist/host.d.ts.map +1 -1
  29. package/dist/host.js +3 -0
  30. package/dist/host.js.map +1 -1
  31. package/dist/implementations.d.ts +181 -0
  32. package/dist/implementations.d.ts.map +1 -0
  33. package/dist/implementations.js +371 -0
  34. package/dist/implementations.js.map +1 -0
  35. package/dist/installation-core.d.ts.map +1 -1
  36. package/dist/installation-core.js +3 -3
  37. package/dist/installation-core.js.map +1 -1
  38. package/dist/lifecycle-registration.d.ts +6 -2
  39. package/dist/lifecycle-registration.d.ts.map +1 -1
  40. package/dist/lifecycle-registration.js +5 -1
  41. package/dist/lifecycle-registration.js.map +1 -1
  42. package/dist/minting.d.ts.map +1 -1
  43. package/dist/minting.js +2 -2
  44. package/dist/minting.js.map +1 -1
  45. package/dist/projection.d.ts +11 -2
  46. package/dist/projection.d.ts.map +1 -1
  47. package/dist/projection.js +78 -13
  48. package/dist/projection.js.map +1 -1
  49. package/dist/registry-build.d.ts +3 -0
  50. package/dist/registry-build.d.ts.map +1 -1
  51. package/dist/registry-build.js +20 -0
  52. package/dist/registry-build.js.map +1 -1
  53. package/dist/registry-collections.d.ts +32 -0
  54. package/dist/registry-collections.d.ts.map +1 -0
  55. package/dist/registry-collections.js +105 -0
  56. package/dist/registry-collections.js.map +1 -0
  57. package/dist/registry-resolve.d.ts +2 -0
  58. package/dist/registry-resolve.d.ts.map +1 -1
  59. package/dist/registry-resolve.js +23 -2
  60. package/dist/registry-resolve.js.map +1 -1
  61. package/dist/registry-source.d.ts +3 -0
  62. package/dist/registry-source.d.ts.map +1 -1
  63. package/dist/registry-source.js +15 -6
  64. package/dist/registry-source.js.map +1 -1
  65. package/dist/registry.d.ts +4 -0
  66. package/dist/registry.d.ts.map +1 -1
  67. package/dist/registry.js +2 -0
  68. package/dist/registry.js.map +1 -1
  69. package/dist/services.d.ts +89 -6
  70. package/dist/services.d.ts.map +1 -1
  71. package/dist/services.js +94 -4
  72. package/dist/services.js.map +1 -1
  73. package/dist/snapshot.d.ts +1 -1
  74. package/dist/snapshot.d.ts.map +1 -1
  75. package/dist/snapshot.js +30 -6
  76. package/dist/snapshot.js.map +1 -1
  77. package/package.json +16 -7
  78. package/references/registry-collections.md +15 -0
@@ -0,0 +1,181 @@
1
+ import type { InstalledImplementationsValue } from '@inventarch/db/distribution';
2
+ import type { HostVerifier } from './host-observe.js';
3
+ import type { WorkspaceHost } from './hosts.js';
4
+ /**
5
+ * Plan amendments C16 and C24 (milestone generation-binding; design item 9): the installed-implementation catalog a v2
6
+ * host payload carries at its root. The payload builder (tools/distribution/host-payload.mjs) generates it and lists it
7
+ * in the payload inventory, because `verifyHostCache` refuses any file the inventory does not list. It describes
8
+ * implementations no host app may import, so this module reads data only: it never imports, loads or runs a handler.
9
+ * Its value's shape, operation rows included, is `@inventarch/db/distribution`'s (`checkInstalledImplementations`),
10
+ * which binders read too (review finding B-N9).
11
+ *
12
+ * Nothing is read from a payload that fails `verifyHostCache`: every file under the payload directory must be one the
13
+ * inventory lists, with its bytes, and no entry may be a link or junction, so a module planted inside the payload
14
+ * directory, beside or above the handler's packages, refuses the whole catalog. Only the payload directory is verified,
15
+ * and the closure check follows literal import specifiers only (review finding B2-N10). An unlisted empty directory is
16
+ * not refused (B-RC1): it holds no module, though one where Node's resolution expects a file can keep a handler from
17
+ * loading, which denies service but never substitutes code. An operation is then `available` only when
18
+ * the payload ships its handler: the handler module and the manifest of every package its closure names are in the
19
+ * verified inventory, and the catalog's handler digest is the SHA-256 the inventory pins for the module. What binds is
20
+ * that module digest together with the verified inventory, which pins every other byte of the closure (review finding
21
+ * B-N5). A declaration whose bytes are not shipped is `unavailable`, never available; a payload that fails verification,
22
+ * or a handler digest that disagrees with its inventory, is a refusal.
23
+ */
24
+ export declare const INSTALLED_IMPLEMENTATIONS = "implementations.json";
25
+ export { INSTALLED_IMPLEMENTATIONS_FORMAT } from '@inventarch/db/distribution';
26
+ export type { AvailableOperation, InstalledImplementationsValue, InstalledOperation, RevokedOperation, UnavailableOperation, } from '@inventarch/db/distribution';
27
+ /** The implementation id a consumer's join names for the catalog itself. */
28
+ export declare const INSTALLED_IMPLEMENTATIONS_ID = "installed-implementations";
29
+ /** Design item 9: the join receipts each consumer records under its own name, beside the host state files. */
30
+ export declare const JOINS = ".ia/distributions/hosts/joins.json";
31
+ export declare const JOINS_FORMAT = "ia.host-joins.v1";
32
+ /** The catalog as `readInstalledImplementations` verified it in one materialized payload. */
33
+ export interface InstalledImplementations extends InstalledImplementationsValue {
34
+ readonly status: 'present';
35
+ /** The payload release whose inventory lists the catalog. */
36
+ readonly release: string;
37
+ /** The payload's version (its inventory's `version`). */
38
+ readonly version: string;
39
+ /** The SHA-256 of the catalog's bytes, as the inventory lists it. */
40
+ readonly digest: string;
41
+ }
42
+ /** A payload that carries no catalog, such as one built before the catalog existed: unavailable, not damaged. */
43
+ export interface InstalledImplementationsUnavailable {
44
+ readonly status: 'unavailable';
45
+ readonly release: string;
46
+ readonly reason: string;
47
+ }
48
+ export type InstalledCatalog = InstalledImplementations | InstalledImplementationsUnavailable;
49
+ /**
50
+ * One consumer's join: the catalog it joined (implementation id, payload version, catalog digest and payload release)
51
+ * at its own revision. A workspace host's consumer revision is the workspace's authored revision when it joined.
52
+ */
53
+ export interface ImplementationJoin {
54
+ readonly consumer: WorkspaceHost;
55
+ readonly implementation: string;
56
+ readonly version: string;
57
+ readonly digest: string;
58
+ readonly release: string;
59
+ readonly consumerRevision: string;
60
+ }
61
+ export type JoinResult = {
62
+ readonly status: 'joined';
63
+ readonly join: ImplementationJoin;
64
+ } | {
65
+ readonly status: 'unavailable';
66
+ readonly reason: string;
67
+ } | {
68
+ readonly status: 'unregistered';
69
+ };
70
+ /**
71
+ * The value of a catalog, as `@inventarch/db/distribution`'s `checkInstalledImplementations` admits one; any other is
72
+ * IA-DIST-INPUT-INVALID with its reason. The payload builder checks what it writes with it too.
73
+ */
74
+ export declare function installedImplementationsValue(value: unknown): InstalledImplementationsValue;
75
+ /**
76
+ * The catalog of the materialized host payload at `directory`. The whole payload is verified first, as `verifyHostCache`
77
+ * verifies it before a registration may launch it, and must verify as `release`: a file anywhere in the payload directory
78
+ * that the inventory does not list, a link or junction, a missing file or changed bytes refuse, with that verification's
79
+ * code (release.json hashing to `release`, inventory.json to the digest release.json names, every listed file to its
80
+ * pin). A release.json that does not hash to `release` refuses as IA-DIST-INTEGRITY-MISMATCH before it is parsed. `given`
81
+ * shares the verification of one report when `hostVerifier` made it; any other value is ignored and the payload is
82
+ * verified afresh (review finding B2-N6). The catalog is the file that verified inventory lists, read again and compared with its pin. Each
83
+ * available operation is checked against the verified inventory (`shipped`). A v1 payload, or a v2 payload whose
84
+ * inventory lists no catalog (one built before the catalog existed), is `unavailable`, not an integrity failure. A
85
+ * missing payload file or release.json is IA-DIST-ARTIFACT-UNAVAILABLE; unexpected or changed bytes are
86
+ * IA-DIST-INTEGRITY-MISMATCH; a link is IA-DIST-PATH-UNSAFE; malformed metadata is IA-DIST-INPUT-INVALID. Nothing is
87
+ * written, imported or executed.
88
+ */
89
+ export declare function readInstalledImplementations(directory: string, release: string, given?: HostVerifier): InstalledCatalog;
90
+ /** The joins recorded at `root`, one per consumer, or null when none was ever recorded. Refusals locate at `JOINS`. */
91
+ export declare function readJoins(rootInput: string): readonly ImplementationJoin[] | null;
92
+ /**
93
+ * Record `host`'s join (design item 9) from its committed registration, under the host lock: the catalog of the payload
94
+ * that `<host>-workspace.json` names, read and checked by `readInstalledImplementations` at that state's own cache and
95
+ * release, at `consumerRevision`. The row is derived from the registration as written, never from what a caller
96
+ * expected to register, so it cannot name a catalog the registration does not use. With no registration, or a payload
97
+ * that carries no catalog, the host's row is dropped instead, so a stale join never outlives what it described; every
98
+ * other consumer's row is kept. Receipts that cannot be read refuse, located at `JOINS`, rather than be replaced.
99
+ */
100
+ export declare function joinHost(rootInput: string, hostInput: string, consumerRevision: string): JoinResult;
101
+ /** Drop `host`'s join under the host lock, keeping every other consumer's; true when a row was removed. */
102
+ export declare function leaveHost(rootInput: string, hostInput: string): boolean;
103
+ /**
104
+ * Where a workspace's execution bindings find their catalog (task execution-binding-host-entry, plan amendment C24): the
105
+ * catalog one of its hosts joined, or why there is none.
106
+ */
107
+ export type JoinedCatalog = {
108
+ readonly status: 'joined';
109
+ readonly consumer: WorkspaceHost;
110
+ readonly release: string;
111
+ readonly version: string;
112
+ readonly digest: string;
113
+ readonly catalog: InstalledImplementations;
114
+ } | {
115
+ readonly status: 'unavailable';
116
+ readonly reason: string;
117
+ } | {
118
+ readonly status: 'damaged';
119
+ readonly consumer: WorkspaceHost;
120
+ readonly release: string;
121
+ /** The payload directory that failed verification, `<home>/hosts/<release>`: deleting it is the repair. */
122
+ readonly payload: string;
123
+ readonly reason: string;
124
+ };
125
+ /**
126
+ * Review finding B2-R2: what a validating installation trusts, the IA home it materializes payloads in and the payload
127
+ * release it pins. A join binds only through a registration of exactly that payload, `<home>/hosts/<release>`; nothing a
128
+ * workspace names outside it is ever opened. Null when the running installation pins no payload, and then nothing binds.
129
+ */
130
+ export interface HostTrust {
131
+ readonly home: string;
132
+ readonly release: string;
133
+ }
134
+ /**
135
+ * The trust of this distribution module's own installation: when it runs from inside a materialized host payload, as the
136
+ * payload's launcher runs `ia-distribution` (and `ia` itself, whose payload copy carries no bundled pin), the release
137
+ * that payload's directory is named for and the IA home holding it. Run from a package install or a checkout, it pins no
138
+ * payload: null. Nothing is verified here; `joinedCatalog` verifies the payload, release.json against this name first,
139
+ * before it reads a catalog from it.
140
+ */
141
+ export declare function installationTrust(): HostTrust | null;
142
+ /**
143
+ * The catalog the workspace at `root` joined, as `trust` (the validating installation's IA home and pinned release)
144
+ * allows it. Only one payload is ever opened: `<home>/hosts/<release>`, the one this installation materializes; a join
145
+ * counts only when its consumer's registration (`<host>-workspace.json`) and the join itself name that release and the
146
+ * registration names that payload directory. A registration of another release, or of a payload anywhere else (another
147
+ * IA home, a directory inside the workspace, a network path), is not trusted and never opened: re-applying
148
+ * `ia host <host>` registers the installation's own payload. The payload is then read once, verified as
149
+ * `readInstalledImplementations` verifies it, and the first trusted join, in consumer order, whose catalog digest it
150
+ * carries is the source. A payload that fails verification with changed or unlisted files, a link or exceeded limits is
151
+ * `damaged`, which binders report as revoked, whichever trusted join names it (review finding B2-N1: every trusted join
152
+ * names the same payload, so the order of joins cannot decide it). With no trust, no receipt, or no trusted join that
153
+ * holds (an `ia project`-only workspace, a host registered by another release, a drifted join, a payload without a
154
+ * catalog or not materialized), the catalog is `unavailable`, with the reasons, so nothing binds. Reads only: nothing is
155
+ * written, imported or executed.
156
+ */
157
+ /** The one payload a trust opens, `<home>/hosts/<release>`, whether it is materialized, and its spellings (B2-R2). */
158
+ export interface TrustedPayload {
159
+ readonly release: string;
160
+ readonly home: string;
161
+ readonly payload: string;
162
+ readonly materialized: boolean;
163
+ readonly spellings: ReadonlySet<string>;
164
+ }
165
+ /**
166
+ * The payload `trust` opens. `ia host` records a payload as verification resolved it, so its real path is one more
167
+ * spelling of the same entry; nothing a workspace names is ever opened to find out.
168
+ */
169
+ export declare function trustedPayload(trust: HostTrust): TrustedPayload;
170
+ /**
171
+ * Why host `host`'s registration (`state`) and its join (at `joined`, or null for no join) do not bind through
172
+ * `trusted`, or null when they do: registered or joined for another release, the payload not materialized, or a
173
+ * registration naming another directory or another spelling of it (review finding B2-RC1). Compares spellings only:
174
+ * the registration's own path is never opened.
175
+ */
176
+ export declare function registrationUntrusted(trusted: TrustedPayload, host: string, state: {
177
+ readonly cache: string;
178
+ readonly release: string;
179
+ }, joined: string | null): string | null;
180
+ export declare function joinedCatalog(rootInput: string, trust: HostTrust | null): JoinedCatalog;
181
+ //# sourceMappingURL=implementations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implementations.d.ts","sourceRoot":"","sources":["../src/implementations.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,6BAA6B,EAG9B,MAAM,6BAA6B,CAAC;AAIrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,yBAAyB,yBAAyB,CAAC;AAChE,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAC/E,YAAY,EACV,kBAAkB,EAClB,6BAA6B,EAC7B,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,4EAA4E;AAC5E,eAAO,MAAM,4BAA4B,8BAA8B,CAAC;AACxE,8GAA8G;AAC9G,eAAO,MAAM,KAAK,uCAAuC,CAAC;AAC1D,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAE/C,6FAA6F;AAC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AC1B;AACD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,SAAS,GAAG,IAAI,CAOpD;AAOD;;;;;;;;;;;;;;GAcG;AACH,sHAAsH;AACtH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACzC;AACD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,cAAc,CAW/D;AACD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAC3D,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,MAAM,GAAG,IAAI,CAQf;AACD,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,aAAa,CAsFvF"}
@@ -0,0 +1,371 @@
1
+ import { existsSync, realpathSync } from 'node:fs';
2
+ import { basename, dirname, isAbsolute, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { pathKey } from '@inventarch/db';
5
+ import { checkInstalledImplementations, decodeDistributionJson } from '@inventarch/db/distribution';
6
+ import { acquireHostRegistrationLock, assertHostRegistrationIdle, HOST_REGISTRATION, saved } from './host.js';
7
+ import { hostPayloadPath } from './host-home.js';
8
+ import { verifierOf } from './host-observe.js';
9
+ import { asWorkspaceHost } from './hosts.js';
10
+ import { bytes, contained, fail, json, locate, object, replace, sha256, utf8, workspace } from './files.js';
11
+ /**
12
+ * Plan amendments C16 and C24 (milestone generation-binding; design item 9): the installed-implementation catalog a v2
13
+ * host payload carries at its root. The payload builder (tools/distribution/host-payload.mjs) generates it and lists it
14
+ * in the payload inventory, because `verifyHostCache` refuses any file the inventory does not list. It describes
15
+ * implementations no host app may import, so this module reads data only: it never imports, loads or runs a handler.
16
+ * Its value's shape, operation rows included, is `@inventarch/db/distribution`'s (`checkInstalledImplementations`),
17
+ * which binders read too (review finding B-N9).
18
+ *
19
+ * Nothing is read from a payload that fails `verifyHostCache`: every file under the payload directory must be one the
20
+ * inventory lists, with its bytes, and no entry may be a link or junction, so a module planted inside the payload
21
+ * directory, beside or above the handler's packages, refuses the whole catalog. Only the payload directory is verified,
22
+ * and the closure check follows literal import specifiers only (review finding B2-N10). An unlisted empty directory is
23
+ * not refused (B-RC1): it holds no module, though one where Node's resolution expects a file can keep a handler from
24
+ * loading, which denies service but never substitutes code. An operation is then `available` only when
25
+ * the payload ships its handler: the handler module and the manifest of every package its closure names are in the
26
+ * verified inventory, and the catalog's handler digest is the SHA-256 the inventory pins for the module. What binds is
27
+ * that module digest together with the verified inventory, which pins every other byte of the closure (review finding
28
+ * B-N5). A declaration whose bytes are not shipped is `unavailable`, never available; a payload that fails verification,
29
+ * or a handler digest that disagrees with its inventory, is a refusal.
30
+ */
31
+ export const INSTALLED_IMPLEMENTATIONS = 'implementations.json';
32
+ export { INSTALLED_IMPLEMENTATIONS_FORMAT } from '@inventarch/db/distribution';
33
+ /** The implementation id a consumer's join names for the catalog itself. */
34
+ export const INSTALLED_IMPLEMENTATIONS_ID = 'installed-implementations';
35
+ /** Design item 9: the join receipts each consumer records under its own name, beside the host state files. */
36
+ export const JOINS = '.ia/distributions/hosts/joins.json';
37
+ export const JOINS_FORMAT = 'ia.host-joins.v1';
38
+ const ROWS = 1024;
39
+ const TOKEN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/, HEX = /^[a-f0-9]{64}$/;
40
+ const JOIN_KEYS = ['consumer', 'implementation', 'version', 'digest', 'release', 'consumerRevision'];
41
+ const prose = (value, limit) => typeof value === 'string' && value.length > 0 && value.length <= limit && !/[\u0000-\u001f]/.test(value);
42
+ const text = (value) => (value === null ? null : utf8(value));
43
+ /** The payload directory of an installed package, with its trailing slash. */
44
+ const packageDirectory = (name) => `runtime/node_modules/${name}/`;
45
+ const byText = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
46
+ /**
47
+ * The value of a catalog, as `@inventarch/db/distribution`'s `checkInstalledImplementations` admits one; any other is
48
+ * IA-DIST-INPUT-INVALID with its reason. The payload builder checks what it writes with it too.
49
+ */
50
+ export function installedImplementationsValue(value) {
51
+ const checked = checkInstalledImplementations(value);
52
+ if (!checked.ok)
53
+ fail('INPUT-INVALID', checked.reason);
54
+ return checked.value;
55
+ }
56
+ /**
57
+ * C24: `operation` as this payload ships it, against the inventory of a payload `verifyHostCache` has verified, so
58
+ * every listed file is present with the bytes the inventory pins and nothing else is there. A handler module or closure
59
+ * package the inventory does not list makes the operation unavailable; a handler digest that disagrees with the
60
+ * inventory is IA-DIST-INTEGRITY-MISMATCH.
61
+ */
62
+ function shipped(operation, inventory) {
63
+ const unavailable = (reason) => ({ id: operation.id, status: 'unavailable', reason });
64
+ const module = inventory.get(operation.module);
65
+ if (module === undefined)
66
+ return unavailable(`its handler module ${operation.module} is not in this payload's inventory`);
67
+ if (module.sha256 !== operation.digest)
68
+ fail('INTEGRITY-MISMATCH', `The catalog's handler digest for ${operation.id} differs from the payload inventory`);
69
+ const missing = operation.packages.find((name) => !inventory.has(packageDirectory(name) + 'package.json'));
70
+ if (missing !== undefined)
71
+ return unavailable(`its closure package ${missing} is not in this payload`);
72
+ return operation;
73
+ }
74
+ /**
75
+ * The catalog of the materialized host payload at `directory`. The whole payload is verified first, as `verifyHostCache`
76
+ * verifies it before a registration may launch it, and must verify as `release`: a file anywhere in the payload directory
77
+ * that the inventory does not list, a link or junction, a missing file or changed bytes refuse, with that verification's
78
+ * code (release.json hashing to `release`, inventory.json to the digest release.json names, every listed file to its
79
+ * pin). A release.json that does not hash to `release` refuses as IA-DIST-INTEGRITY-MISMATCH before it is parsed. `given`
80
+ * shares the verification of one report when `hostVerifier` made it; any other value is ignored and the payload is
81
+ * verified afresh (review finding B2-N6). The catalog is the file that verified inventory lists, read again and compared with its pin. Each
82
+ * available operation is checked against the verified inventory (`shipped`). A v1 payload, or a v2 payload whose
83
+ * inventory lists no catalog (one built before the catalog existed), is `unavailable`, not an integrity failure. A
84
+ * missing payload file or release.json is IA-DIST-ARTIFACT-UNAVAILABLE; unexpected or changed bytes are
85
+ * IA-DIST-INTEGRITY-MISMATCH; a link is IA-DIST-PATH-UNSAFE; malformed metadata is IA-DIST-INPUT-INVALID. Nothing is
86
+ * written, imported or executed.
87
+ */
88
+ export function readInstalledImplementations(directory, release, given) {
89
+ // Review finding B2-N6: only a verifier `hostVerifier` made is shared; anything else is replaced by a fresh one.
90
+ const verify = verifierOf(given);
91
+ if (!HEX.test(release))
92
+ fail('INPUT-INVALID', 'Invalid host release pin');
93
+ // Review finding B2-N2: a release.json that does not hash to the pin is changed bytes, whether or not it still parses.
94
+ const root = workspace(directory), pinned = bytes(root, 'release.json');
95
+ if (pinned !== null && sha256(pinned) !== release)
96
+ fail('INTEGRITY-MISMATCH', 'Host release differs from its pin');
97
+ // B-R1: never read a catalog from a payload that fails verification; an uninventoried module could be loaded in place
98
+ // of a shipped one, inside a closure package or outside every one.
99
+ const verified = verify(root);
100
+ if (verified.release !== release)
101
+ fail('INTEGRITY-MISMATCH', 'Host release differs from its pin');
102
+ if (verified.format === 1)
103
+ return { status: 'unavailable', release, reason: 'a v1 host payload carries no installed-implementation catalog' };
104
+ const catalog = verified.files.get(INSTALLED_IMPLEMENTATIONS);
105
+ if (catalog === undefined)
106
+ return {
107
+ status: 'unavailable',
108
+ release,
109
+ reason: 'this host payload carries no installed-implementation catalog; payloads built before the catalog existed carry none',
110
+ };
111
+ // Read again through the inventory's pin, so the bytes parsed are the bytes verification hashed.
112
+ const content = bytes(verified.directory, INSTALLED_IMPLEMENTATIONS);
113
+ if (content === null || content.length !== catalog.bytes || sha256(content) !== catalog.sha256)
114
+ fail('INTEGRITY-MISMATCH', 'Installed-implementation catalog is missing or changed');
115
+ const value = installedImplementationsValue(decodeDistributionJson(utf8(content)));
116
+ return {
117
+ status: 'present',
118
+ format: value.format,
119
+ evaluators: value.evaluators,
120
+ operations: value.operations.map((operation) => operation.status === 'available' ? shipped(operation, verified.files) : operation),
121
+ release,
122
+ version: verified.version,
123
+ digest: catalog.sha256,
124
+ };
125
+ }
126
+ function joinRow(value) {
127
+ const row = object(value, JOIN_KEYS);
128
+ asWorkspaceHost(row['consumer']);
129
+ if (typeof row['implementation'] !== 'string' ||
130
+ !TOKEN.test(row['implementation']) ||
131
+ row['implementation'].length > 128 ||
132
+ !prose(row['version'], 128))
133
+ fail('INPUT-INVALID', 'Invalid join receipt');
134
+ for (const key of ['digest', 'release', 'consumerRevision'])
135
+ if (typeof row[key] !== 'string' || !HEX.test(row[key]))
136
+ fail('INPUT-INVALID', 'Invalid join receipt digest');
137
+ return row;
138
+ }
139
+ /** The joins recorded at `root`, one per consumer, or null when none was ever recorded. Refusals locate at `JOINS`. */
140
+ export function readJoins(rootInput) {
141
+ const root = workspace(rootInput);
142
+ return locate(JOINS, () => {
143
+ const content = text(bytes(root, JOINS));
144
+ if (content === null)
145
+ return null;
146
+ const row = object(decodeDistributionJson(content), ['format', 'joins']);
147
+ if (row['format'] !== JOINS_FORMAT || !Array.isArray(row['joins']) || row['joins'].length > ROWS)
148
+ fail('INPUT-INVALID', 'Invalid join receipts');
149
+ const joins = row['joins'].map(joinRow);
150
+ if (new Set(joins.map((join) => join.consumer)).size !== joins.length)
151
+ fail('INPUT-INVALID', 'Join receipts repeat a consumer');
152
+ return joins;
153
+ });
154
+ }
155
+ /** Replace `consumer`'s row with `row` (or drop it for null), keeping every other consumer's; with none left, delete. */
156
+ function writeJoin(root, consumer, row) {
157
+ const current = readJoins(root);
158
+ const others = (current ?? []).filter((join) => join.consumer !== consumer);
159
+ const joins = [...others, ...(row === null ? [] : [row])].sort((a, b) => byText(a.consumer, b.consumer));
160
+ if (current === null && joins.length === 0)
161
+ return;
162
+ if (current !== null && json(joins) === json(current))
163
+ return;
164
+ replace(root, JOINS, joins.length === 0 ? null : Buffer.from(json({ format: JOINS_FORMAT, joins })));
165
+ }
166
+ /**
167
+ * Run `work` under the host lock, as every host write runs. Review finding B-N4: the lock is taken first and a pending
168
+ * host journal is checked under it, as `applyHost` does, so no journal can appear between the check and the write.
169
+ */
170
+ function locked(root, work) {
171
+ const unlock = acquireHostRegistrationLock(root);
172
+ try {
173
+ assertHostRegistrationIdle(root);
174
+ return work();
175
+ }
176
+ finally {
177
+ unlock();
178
+ }
179
+ }
180
+ /**
181
+ * Record `host`'s join (design item 9) from its committed registration, under the host lock: the catalog of the payload
182
+ * that `<host>-workspace.json` names, read and checked by `readInstalledImplementations` at that state's own cache and
183
+ * release, at `consumerRevision`. The row is derived from the registration as written, never from what a caller
184
+ * expected to register, so it cannot name a catalog the registration does not use. With no registration, or a payload
185
+ * that carries no catalog, the host's row is dropped instead, so a stale join never outlives what it described; every
186
+ * other consumer's row is kept. Receipts that cannot be read refuse, located at `JOINS`, rather than be replaced.
187
+ */
188
+ export function joinHost(rootInput, hostInput, consumerRevision) {
189
+ const root = workspace(rootInput), host = asWorkspaceHost(hostInput);
190
+ if (!HEX.test(consumerRevision))
191
+ fail('INPUT-INVALID', 'Invalid consumer revision');
192
+ return locked(root, () => {
193
+ const path = `.ia/distributions/hosts/${host}-${HOST_REGISTRATION}.json`;
194
+ const state = locate(path, () => {
195
+ const content = bytes(root, path);
196
+ return saved(content === null ? null : utf8(content), host, HOST_REGISTRATION);
197
+ });
198
+ if (state === null) {
199
+ writeJoin(root, host, null);
200
+ return { status: 'unregistered' };
201
+ }
202
+ const catalog = readInstalledImplementations(state.cache, state.release);
203
+ if (catalog.status === 'unavailable') {
204
+ writeJoin(root, host, null);
205
+ return { status: 'unavailable', reason: catalog.reason };
206
+ }
207
+ const join = joinRow({
208
+ consumer: host,
209
+ implementation: INSTALLED_IMPLEMENTATIONS_ID,
210
+ version: catalog.version,
211
+ digest: catalog.digest,
212
+ release: catalog.release,
213
+ consumerRevision,
214
+ });
215
+ writeJoin(root, host, join);
216
+ return { status: 'joined', join };
217
+ });
218
+ }
219
+ /** Drop `host`'s join under the host lock, keeping every other consumer's; true when a row was removed. */
220
+ export function leaveHost(rootInput, hostInput) {
221
+ const root = workspace(rootInput), host = asWorkspaceHost(hostInput);
222
+ if (!existsSync(contained(root, JOINS)))
223
+ return false;
224
+ return locked(root, () => {
225
+ const present = (readJoins(root) ?? []).some((join) => join.consumer === host);
226
+ if (present)
227
+ writeJoin(root, host, null);
228
+ return present;
229
+ });
230
+ }
231
+ const failure = (error) => {
232
+ const code = error !== null && typeof error === 'object' && 'code' in error && typeof error.code === 'string'
233
+ ? error.code
234
+ : 'unreadable', message = error instanceof Error ? error.message : String(error);
235
+ // A message that already opens with its code is not prefixed again.
236
+ return { code, text: message.startsWith(code) ? message : `${code}: ${message}` };
237
+ };
238
+ /**
239
+ * The trust of this distribution module's own installation: when it runs from inside a materialized host payload, as the
240
+ * payload's launcher runs `ia-distribution` (and `ia` itself, whose payload copy carries no bundled pin), the release
241
+ * that payload's directory is named for and the IA home holding it. Run from a package install or a checkout, it pins no
242
+ * payload: null. Nothing is verified here; `joinedCatalog` verifies the payload, release.json against this name first,
243
+ * before it reads a catalog from it.
244
+ */
245
+ export function installationTrust() {
246
+ // <home>/hosts/<release>/runtime/node_modules/@inventarch/distribution/dist/implementations.js
247
+ const payload = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', '..', '..'), release = basename(payload);
248
+ return HEX.test(release) && basename(dirname(payload)) === 'hosts' && existsSync(resolve(payload, 'release.json'))
249
+ ? { home: dirname(dirname(payload)), release }
250
+ : null;
251
+ }
252
+ /**
253
+ * Verification refusals that mean the payload holds other bytes, entries or paths than its pins vouch for: changed or
254
+ * unlisted files, a link or junction, or more entries than a payload may hold. A missing file or payload is not damage.
255
+ */
256
+ const DAMAGE = new Set(['IA-DIST-INTEGRITY-MISMATCH', 'IA-DIST-PATH-UNSAFE', 'IA-DIST-LIMIT-EXCEEDED']);
257
+ /**
258
+ * The payload `trust` opens. `ia host` records a payload as verification resolved it, so its real path is one more
259
+ * spelling of the same entry; nothing a workspace names is ever opened to find out.
260
+ */
261
+ export function trustedPayload(trust) {
262
+ const payload = hostPayloadPath(trust.home, trust.release), materialized = existsSync(payload), spellings = new Set([pathKey(resolve(payload))]);
263
+ if (materialized)
264
+ try {
265
+ spellings.add(pathKey(realpathSync(payload)));
266
+ }
267
+ catch {
268
+ // The reader refuses it with its own code.
269
+ }
270
+ return { release: trust.release, home: trust.home, payload, materialized, spellings };
271
+ }
272
+ /**
273
+ * Why host `host`'s registration (`state`) and its join (at `joined`, or null for no join) do not bind through
274
+ * `trusted`, or null when they do: registered or joined for another release, the payload not materialized, or a
275
+ * registration naming another directory or another spelling of it (review finding B2-RC1). Compares spellings only:
276
+ * the registration's own path is never opened.
277
+ */
278
+ export function registrationUntrusted(trusted, host, state, joined) {
279
+ if (state.release !== trusted.release || (joined !== null && joined !== trusted.release))
280
+ return `host ${host} is registered for release ${state.release.slice(0, 12)}, not this installation's ${trusted.release.slice(0, 12)}`;
281
+ if (!trusted.materialized)
282
+ return `this installation's payload for host ${host} is not materialized in ${trusted.home}`;
283
+ if (!trusted.spellings.has(pathKey(resolve(state.cache))))
284
+ return `host ${host}'s registration names a payload other than ${trusted.payload} (another directory or another spelling of it)`;
285
+ return null;
286
+ }
287
+ export function joinedCatalog(rootInput, trust) {
288
+ const root = workspace(rootInput);
289
+ if (trust !== null && (!HEX.test(trust.release) || !isAbsolute(trust.home)))
290
+ fail('INPUT-INVALID', 'Invalid host trust');
291
+ let joins;
292
+ try {
293
+ joins = readJoins(root);
294
+ }
295
+ catch (error) {
296
+ return { status: 'unavailable', reason: `${JOINS} cannot be read (${failure(error).code})` };
297
+ }
298
+ if (joins === null || joins.length === 0)
299
+ return {
300
+ status: 'unavailable',
301
+ reason: 'no host has joined an installed-implementation catalog in this workspace; "ia host <host> --apply" records a join',
302
+ };
303
+ if (trust === null)
304
+ return {
305
+ status: 'unavailable',
306
+ reason: 'this installation carries no host payload of its own (or cannot resolve its IA home), so it trusts no join; run the ia that registered the host',
307
+ };
308
+ // The one payload this installation trusts, opened only in its IA home; a workspace's own paths are never followed.
309
+ // `ia host` records the payload as verification resolved it, so its real path is one more spelling of the same entry.
310
+ const trusted = trustedPayload(trust);
311
+ let catalog;
312
+ const reasons = [];
313
+ for (const join of joins) {
314
+ const host = join.consumer, path = `.ia/distributions/hosts/${host}-${HOST_REGISTRATION}.json`, rerun = `run "ia host ${host} --apply"`;
315
+ let state;
316
+ try {
317
+ state = locate(path, () => {
318
+ const content = bytes(root, path);
319
+ return saved(content === null ? null : utf8(content), host, HOST_REGISTRATION);
320
+ });
321
+ }
322
+ catch (error) {
323
+ reasons.push(`host ${host}'s registration cannot be read (${failure(error).code})`);
324
+ continue;
325
+ }
326
+ if (state === null) {
327
+ reasons.push(`host ${host} joined a catalog but is no longer registered`);
328
+ continue;
329
+ }
330
+ const untrusted = registrationUntrusted(trusted, host, state, join.release);
331
+ if (untrusted !== null) {
332
+ reasons.push(`${untrusted}; ${rerun}`);
333
+ continue;
334
+ }
335
+ const expected = trusted.payload;
336
+ if (catalog === undefined)
337
+ try {
338
+ catalog = readInstalledImplementations(expected, trust.release);
339
+ }
340
+ catch (error) {
341
+ const read = failure(error);
342
+ catalog = DAMAGE.has(read.code)
343
+ ? { status: 'damaged', reason: read.text }
344
+ : {
345
+ status: 'unavailable',
346
+ release: trust.release,
347
+ reason: `its payload catalog cannot be read (${read.text})`,
348
+ };
349
+ }
350
+ if (catalog.status === 'damaged')
351
+ return { status: 'damaged', consumer: host, release: trust.release, payload: expected, reason: catalog.reason };
352
+ if (catalog.status === 'unavailable') {
353
+ reasons.push(`host ${host}'s payload carries no catalog: ${catalog.reason}`);
354
+ continue;
355
+ }
356
+ if (catalog.digest !== join.digest) {
357
+ reasons.push(`host ${host}'s join names catalog ${join.digest.slice(0, 12)}, but its payload carries ${catalog.digest.slice(0, 12)}`);
358
+ continue;
359
+ }
360
+ return {
361
+ status: 'joined',
362
+ consumer: host,
363
+ release: catalog.release,
364
+ version: catalog.version,
365
+ digest: catalog.digest,
366
+ catalog,
367
+ };
368
+ }
369
+ return { status: 'unavailable', reason: reasons.join('; ') };
370
+ }
371
+ //# sourceMappingURL=implementations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implementations.js","sourceRoot":"","sources":["../src/implementations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAOpG,OAAO,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC9G,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5G;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;AAChE,O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,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC3D,QAAQ,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;QAClC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;QACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;QACpC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;KACtC,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AA0CD,kGAAkG;AAClG,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,uBAAuB,GAAG,sBAAsB,CAqE/F;AAkED,sGAAsG;AACtG,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,uBAAuB,GAC7B,sBAAsB,CAKxB"}
@@ -1,5 +1,5 @@
1
1
  import { EditorSnapshot } from '@inventarch/db/editor';
2
- import { decodeActivationPointer, decodeDistributionLock, decodeGenerationInputs, deriveGenerationInputs, DISTRIBUTION_ENGINE_VERSION, DISTRIBUTION_LIMITS, generationDigest, generationSources, installationWorkspace, metadataDigest, satisfies, } from '@inventarch/db/distribution';
2
+ import { decodeActivationPointer, decodeDistributionLock, decodeGenerationInputs, deriveGenerationInputs, DISTRIBUTION_ENGINE_VERSION, DISTRIBUTION_LIMITS, generationDigest, generationSources, installationWorkspace, metadataDigest, supportsDistributionLockEngine, } from '@inventarch/db/distribution';
3
3
  import { verifySelectedArchiveClosure } from './archive.js';
4
4
  import { fail } from './files.js';
5
5
  import { distributionSnapshot, verifyDistributionSnapshot } from './snapshot.js';
@@ -46,8 +46,8 @@ export function planInstallationSnapshot(input) {
46
46
  if (op !== 'restore' && (previous === null) !== (previousLock === null))
47
47
  fail('RESTORE-REQUIRED', 'Current installation requires explicit recovery or restore');
48
48
  const lock = decodeDistributionLock(row['lock']);
49
- if (!satisfies(DISTRIBUTION_ENGINE_VERSION, lock.engine))
50
- fail('CONFLICT', 'Lock engine compatibility differs');
49
+ if (!supportsDistributionLockEngine(DISTRIBUTION_ENGINE_VERSION, lock.engine))
50
+ fail('CONFLICT', `Lock engine compatibility differs: requires ${lock.engine}, this installer is ${DISTRIBUTION_ENGINE_VERSION}. Use a compatible IA installation; preserve the lock and archive engine ranges.`);
51
51
  const releases = selectedArchives(row['archives'], lock), inputs = deriveGenerationInputs(lock, releases);
52
52
  const pointer = decodeActivationPointer({
53
53
  formatVersion: 1,