@inventarch/distribution 3.5.1 → 3.6.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/SPEC.md CHANGED
@@ -50,6 +50,6 @@ Payload verification within one command: `hostVerifier()` (`./host-observe`) mem
50
50
 
51
51
  Each selection is represented by its immutable distribution generation and archive-qualified source occurrences, using the caller's explicit floor. Every archive carrying authoring metadata contributes only its own pinned files and native source/revision binding; several providers do not collide merely because they use the same relative resource path. A provider cannot borrow an undeclared dependency or another archive's asset ownership. Both sides receive identical validation before registration comparison, including unchanged legacy-gap handling. The public request/result types remain unchanged. Capture/view/resource/index/proof digests reflect the corrected selected provenance; callers must recompute them, never reuse an assessment produced for flattened sources. Readiness is structural only, with semantic evaluation still `not-evaluated` and publication authority retained by the host.
52
52
 
53
- Committed bootstrap (2026-10-30, kit discovery `kit-discovery-committed-bootstrap`): `./bootstrap` publishes `planBootstrap(root, host, version, remove?)` and `applyBootstrap(plan)` for the hosts whose `hosts.ts` row declares `bootstrap` (`BOOTSTRAP_HOSTS`: claude, codex and copilot). A row names the instruction files that gain one block between `BLOCK_BEGIN` and `BLOCK_END`, naming `ia_session` and the lanes `ia:work`, `ia:knowledge` and `ia:delivery`, and the MCP files that gain one server named `ia`: `.mcp.json` and `.github/mcp.json` under `mcpServers` (the latter `type: "local"` with `tools: ["*"]`, Copilot CLI's project file), `.vscode/mcp.json` under `servers` with `type: "stdio"`, and `.codex/config.toml` as a marked `[mcp_servers.ia]` block (`reconcileConfig`, id `bootstrap`). Each server is `npx -y @inventarch/mcp-door@<version>`, an exact version, with no path, so the files are committable. Every other byte is kept; a rerun at another version updates only the server; `remove` takes out exactly the block and the server and deletes a file left empty. A server named `ia` that is not such a launch, an incomplete or repeated block, or an instruction file holding a generated position packet's provenance line refuses with `LOCAL-MODIFICATION`; an exact-version check refuses `INPUT-INVALID`. `applyBootstrap` plans again and refuses `STALE-PLAN` when any file changed, then writes each changed file atomically, mode 0o644. No state under `.ia/distributions/` or the IA home is written. The Copilot row is `partial` with no workspace registration; the Codex row now declares hooks, and the steward-guard observation in `host-observe.ts` stays Claude's.
53
+ Committed bootstrap (2026-10-30, kit discovery `kit-discovery-committed-bootstrap`): `./bootstrap` publishes `planBootstrap(root, host, version, remove?)` and `applyBootstrap(plan)` for the hosts whose `hosts.ts` row declares `bootstrap` (`BOOTSTRAP_HOSTS`: claude, codex and copilot). A row names the instruction files that gain one block between `BLOCK_BEGIN` and `BLOCK_END`. The block (`instructionBlock({contributing})`, the same text for every host) states that reading, building, testing, editing and submitting a change need no binding, plugin, door or private access and points at `CONTRIBUTING.md` when the root holds a plain, unaliased file of that name no larger than 1 MiB (the name is matched exactly in the folder listing, then checked by a metadata probe; a directory, link, hard link, oversized or unreadable entry selects the repository's own contributing guide, and no such entry makes planning, applying or removing fail); then, only for a task that needs a method, names `ia_session` and the lanes `ia:work`, `ia:knowledge` and `ia:delivery`; then carries `BOOTSTRAP_SENTENCE` (an operation that needs a bound method or private authority refuses alone, naming it; everything else continues), the advice to continue on the public path and run `ia doctor` when the `ia` MCP server is unavailable, and `BOOTSTRAP_MARKER`, `ia-bootstrap v1 public-contribution=available needs-method=ia:work,ia:knowledge,ia:delivery needs-authority=declared-operations` (parse rule `^ia-bootstrap v1( [a-z-]+=\S+)+$`, unknown keys ignored). The block is written in the file's first line ending (CRLF or LF; a lone CR is not recognised), or LF for an empty file, and a file without a final newline gains one before it. A block written by an earlier text is replaced in place, and its closing line's terminator is rewritten in that ending too (none at the end of the file stays none); every other byte of the file is kept. The MCP servers follow. Each of these MCP files gains one server named `ia`: `.mcp.json` and `.github/mcp.json` under `mcpServers` (the latter `type: "local"` with `tools: ["*"]`, Copilot CLI's project file), `.vscode/mcp.json` under `servers` with `type: "stdio"`, and `.codex/config.toml` as a marked `[mcp_servers.ia]` block (`reconcileConfig`, id `bootstrap`). Each server is `npx -y @inventarch/mcp-door@<version>`, an exact version, with no path, so the files are committable. Every other byte is kept; a rerun at another version rewrites only that `ia` server entry, where the instruction block above is replaced in place; `remove` takes out the block and the server, trimming exactly the one separator that install added before the block (so the round trip is exact for a non-blank file that ends in a newline; a file with no final newline gains one; a file left whitespace-only is deleted), and deletes a file left empty. A server named `ia` that is not such a launch, an incomplete or repeated block, or an instruction file holding a generated position packet's provenance line refuses with `LOCAL-MODIFICATION`; an exact-version check refuses `INPUT-INVALID`. `applyBootstrap` plans again and refuses `STALE-PLAN` when any file changed, then writes each changed file atomically, mode 0o644. No state under `.ia/distributions/` or the IA home is written. The Copilot row is `partial` with no workspace registration; the Codex row now declares hooks, and the steward-guard observation in `host-observe.ts` stays Claude's.
54
54
 
55
- IA home configuration (2026-10-30): `readIaConfig(home)` reads `<IA home>/config.json`'s two booleans, `updateCheck` and `accountOffer`, each default true, and ignores every other key; `accountOfferEnabled(config)` is false only for `"accountOffer": false`, which suppresses the `ia` plugin's once-per-session account offer.
55
+ IA home configuration (2026-10-30): `readIaConfig(home)` reads `<IA home>/config.json`'s two booleans, `updateCheck` and `accountOffer`, each default true, and one string, `worktreeRoot`, where the console makes a batch's worktrees, and ignores every other key; `accountOfferEnabled(config)` is false only for `"accountOffer": false`, which suppresses the `ia` plugin's once-per-session account offer.
@@ -30,8 +30,21 @@ export declare const doorLaunch: (version: string) => {
30
30
  readonly command: "npx";
31
31
  readonly args: readonly string[];
32
32
  };
33
- /** The instruction block, the same text for every host. */
34
- export declare function instructionBlock(): string;
33
+ /**
34
+ * The marker line every committed bootstrap block carries: one line that says, in a form a program can read, that
35
+ * contributing needs no binding and which operations do. Parse it with `^ia-bootstrap v1( [a-z-]+=\S+)+$`; a key a
36
+ * reader does not know is ignored.
37
+ */
38
+ export declare const BOOTSTRAP_MARKER = "ia-bootstrap v1 public-contribution=available needs-method=ia:work,ia:knowledge,ia:delivery needs-authority=declared-operations";
39
+ /** The one prose sentence, on a single line, that names what needs a bound method or private authority. */
40
+ export declare const BOOTSTRAP_SENTENCE = "Operations that need a bound method or private authority refuse alone, naming it; everything else continues.";
41
+ /**
42
+ * The instruction block, the same text for every host. Reading, building, testing, editing and submitting need no
43
+ * binding, plugin, door or private access; routing through the lanes applies only when a task needs a method.
44
+ */
45
+ export declare function instructionBlock(options?: {
46
+ readonly contributing: boolean;
47
+ }): string;
35
48
  /** The plan of the committed bootstrap for one host at root: each file's next text and what changes. */
36
49
  export declare function planBootstrap(rootInput: string, host: BootstrapHost, version: string, remove?: boolean): BootstrapPlan;
37
50
  /** Writes a plan, refusing when any file changed since it was made. Committed files are written world-readable. */
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAmB,aAAa,EAAE,MAAM,YAAY,CAAC;AAGjE;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,YAAY,yBAAyB,CAAC;AACnD,eAAO,MAAM,WAAW,yFAAyF,CAAC;AAClH,eAAO,MAAM,SAAS,8BAA8B,CAAC;AAKrD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,KAAK,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AACD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;CAC1C;AAED,0FAA0F;AAC1F,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,KAAG;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CAAC;CAC1C;AAED,0FAA0F;AAC1F,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,KAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAGtG,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,oIACsG,CAAC;AACpI,2GAA2G;AAC3G,eAAO,MAAM,kBAAkB,iHACiF,CAAC;AAEjH;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE;IAAE,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;CAA4B,GAAG,MAAM,CAgB9G;AA2HD,wGAAwG;AACxG,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,aAAa,CAwBpH;AAED,mHAAmH;AACnH,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,aAAa,EAAE,CAO5E"}
package/dist/bootstrap.js CHANGED
@@ -1,6 +1,7 @@
1
+ import { lstatSync, readdirSync } from 'node:fs';
1
2
  import { parse } from 'smol-toml';
2
3
  import { reconcileConfig } from './config.js';
3
- import { bytes, fail, json, replace, utf8, workspace } from './files.js';
4
+ import { bytes, contained, fail, json, replace, utf8, workspace } from './files.js';
4
5
  import { bootstrapRow } from './hosts.js';
5
6
  import { editJson } from './json-edit.js';
6
7
  /**
@@ -24,13 +25,31 @@ export const doorLaunch = (version) => ({
24
25
  command: 'npx',
25
26
  args: ['-y', `${DOOR_PACKAGE}@${version}`],
26
27
  });
27
- /** The instruction block, the same text for every host. */
28
- export function instructionBlock() {
28
+ /**
29
+ * The marker line every committed bootstrap block carries: one line that says, in a form a program can read, that
30
+ * contributing needs no binding and which operations do. Parse it with `^ia-bootstrap v1( [a-z-]+=\S+)+$`; a key a
31
+ * reader does not know is ignored.
32
+ */
33
+ export const BOOTSTRAP_MARKER = 'ia-bootstrap v1 public-contribution=available needs-method=ia:work,ia:knowledge,ia:delivery needs-authority=declared-operations';
34
+ /** The one prose sentence, on a single line, that names what needs a bound method or private authority. */
35
+ export const BOOTSTRAP_SENTENCE = 'Operations that need a bound method or private authority refuse alone, naming it; everything else continues.';
36
+ /**
37
+ * The instruction block, the same text for every host. Reading, building, testing, editing and submitting need no
38
+ * binding, plugin, door or private access; routing through the lanes applies only when a task needs a method.
39
+ */
40
+ export function instructionBlock(options = { contributing: false }) {
41
+ const guide = options.contributing ? 'follow `CONTRIBUTING.md`' : "follow the repository's own contributing guide";
29
42
  return [
30
43
  BLOCK_BEGIN,
31
44
  '## IA',
32
45
  '',
33
- `This repository is an IA workspace. Start each session by calling \`ia_session\` on the \`${BOOTSTRAP_SERVER}\` MCP server. For any task, use one lane: \`ia:work\`, \`ia:knowledge\` or \`ia:delivery\`. Call \`ia_catalogue {lane}\`, map the request to one item's \`key\`, then call \`ia_method {key}\` and follow the packet it returns. If context was lost, call \`ia_method\` again with the key and task the session briefing names.`,
46
+ `This repository is an IA workspace. Reading, building, testing, editing and submitting a change need no binding, plugin, door or private access; ${guide}.`,
47
+ '',
48
+ `When a task needs a method (a plan, a decision, a record, a delivery step), start the session by calling \`ia_session\` on the \`${BOOTSTRAP_SERVER}\` MCP server, then use one lane: \`ia:work\`, \`ia:knowledge\` or \`ia:delivery\`. Call \`ia_catalogue {lane}\`, map the request to one item's \`key\`, then call \`ia_method {key}\` and follow the packet it returns. If context was lost, call \`ia_method\` again with the key and task the session briefing names.`,
49
+ '',
50
+ `${BOOTSTRAP_SENTENCE} If the \`${BOOTSTRAP_SERVER}\` MCP server is unavailable, continue on the public path and run \`ia doctor\`.`,
51
+ '',
52
+ BOOTSTRAP_MARKER,
34
53
  BLOCK_END,
35
54
  '',
36
55
  ].join('\n');
@@ -56,28 +75,34 @@ function isDoorLaunch(value) {
56
75
  typeof row.args[1] === 'string' &&
57
76
  row.args[1].startsWith(`${DOOR_PACKAGE}@`));
58
77
  }
59
- function markdown(path, current, remove) {
78
+ function markdown(path, current, remove, contributing) {
60
79
  const text = current ?? '';
61
80
  if (GENERATED.test(text))
62
81
  fail('LOCAL-MODIFICATION', `${path} is a generated position packet; keep it machine-local, or remove that registration before committing a bootstrap here`);
63
82
  const start = text.indexOf(BLOCK_BEGIN), endAt = text.indexOf(BLOCK_END);
64
- const block = instructionBlock();
83
+ // The block is written in the file's own line ending (its first one; LF for an empty file), so no file ends up mixed.
84
+ // Only LF and CRLF are recognised: a lone CR is not a line ending here, and a file with only those gets LF.
85
+ const eol = /\r?\n/.exec(text)?.[0] ?? '\n';
86
+ const block = instructionBlock({ contributing }).replace(/\n/g, eol);
65
87
  if (start < 0 && endAt < 0) {
66
88
  if (remove)
67
89
  return current;
68
90
  if (text === '')
69
91
  return block;
70
- return `${text}${text.endsWith('\n') ? '' : '\n'}\n${block}`;
92
+ return `${text}${text.endsWith('\n') ? '' : eol}${eol}${block}`;
71
93
  }
72
94
  if (start < 0 || endAt < start || text.indexOf(BLOCK_BEGIN, start + 1) >= 0)
73
95
  fail('LOCAL-MODIFICATION', `${path} holds an incomplete or repeated IA bootstrap block`);
74
96
  let after = text.slice(endAt + BLOCK_END.length);
75
- if (after.startsWith('\n'))
76
- after = after.slice(1);
97
+ // The closing line is rewritten in the file's own ending too; at the end of the file it stays without one.
98
+ const found = after.startsWith('\r\n') ? 2 : after.startsWith('\n') ? 1 : 0;
99
+ const terminator = found === 0 ? '' : eol;
100
+ after = after.slice(found);
77
101
  const before = text.slice(0, start);
78
102
  if (!remove)
79
- return before + block + after;
80
- const kept = (before.replace(/\n+$/, '\n') + after).replace(/^\n+/, '');
103
+ return before + block.slice(0, -eol.length) + terminator + after;
104
+ // Install adds one blank separator line before the block (the file's first line when it had none); take out only that.
105
+ const kept = before === '' ? after.replace(/^(?:\r?\n)+/, '') : before.replace(/(\r?\n)\r?\n$/, '$1') + after;
81
106
  return kept.trim() === '' ? null : kept;
82
107
  }
83
108
  function jsonFile(path, format, current, version, remove) {
@@ -132,6 +157,23 @@ function tomlFile(path, current, version, remove) {
132
157
  const combined = reconcileConfig(text, TOML_ID, previous, next, 'mcp_servers');
133
158
  return combined.trim() === '' ? null : combined;
134
159
  }
160
+ /**
161
+ * Whether `CONTRIBUTING.md` is a plain file the block may name. A probe, never a read: a directory, a link, a hard link,
162
+ * an oversized file or anything unreadable only selects the generic wording, so no guide can make a bootstrap fail.
163
+ * The name is matched exactly in the folder listing first, so `contributing.md` selects the same wording on a
164
+ * case-insensitive volume as on a case-sensitive one.
165
+ */
166
+ function hasContributingGuide(root) {
167
+ try {
168
+ if (!readdirSync(root).includes('CONTRIBUTING.md'))
169
+ return false;
170
+ const stat = lstatSync(contained(root, 'CONTRIBUTING.md'));
171
+ return stat.isFile() && stat.nlink === 1 && stat.size <= 1024 * 1024;
172
+ }
173
+ catch {
174
+ return false;
175
+ }
176
+ }
135
177
  /** The plan of the committed bootstrap for one host at root: each file's next text and what changes. */
136
178
  export function planBootstrap(rootInput, host, version, remove = false) {
137
179
  const root = workspace(rootInput);
@@ -143,9 +185,10 @@ export function planBootstrap(rootInput, host, version, remove = false) {
143
185
  return content === null ? null : utf8(content);
144
186
  };
145
187
  const action = (before, after) => before === after ? 'unchanged' : before === null ? 'create' : after === null ? 'remove' : 'update';
188
+ const contributing = hasContributingGuide(root);
146
189
  const files = [];
147
190
  for (const path of row.bootstrap.instructions) {
148
- const before = read(path), after = markdown(path, before, remove);
191
+ const before = read(path), after = markdown(path, before, remove, contributing);
149
192
  files.push({ path, kind: 'instructions', action: action(before, after), after });
150
193
  }
151
194
  for (const { file, format } of row.bootstrap.mcp) {
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,KAAK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,IAAI,IAAI,CAAC,KAAK;QAC3B,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW;YAC7B,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;IACvG,OAAO,IAAI,CAAC,KAAK,CAAC;AACpB,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { DistributionError } from './files.js';
2
+ /** How long a change waits for another holder before it refuses; a hold lasts milliseconds. */
3
+ export declare const HOME_LOCK_WAIT_MS = 10000;
4
+ export interface LockOwner {
5
+ readonly token: string;
6
+ readonly pid: number;
7
+ /** The process's start time as the platform reports it, or null where this module cannot read one. */
8
+ readonly start: string | null;
9
+ readonly host: string;
10
+ readonly createdAt: string;
11
+ }
12
+ /** The process start time in clock ticks since boot on Linux (`/proc`); null where nothing cheap reports one. */
13
+ export declare function processStart(pid: number): string | null;
14
+ /** `process.kill(pid, 0)` throwing ESRCH is the only "not running"; EPERM and anything else count as running. */
15
+ export declare function pidRunning(pid: number): boolean;
16
+ /**
17
+ * Why a lock's owner can no longer hold it, judged on this host only: its pid is not running, or the pid now names
18
+ * another process (its start time differs, where the platform reports one). Null when the owner may still hold it: it
19
+ * runs, or it is on another host, where nothing here can tell.
20
+ */
21
+ export declare function ownerGone(owner: LockOwner): 'not-running' | 'reused' | null;
22
+ export declare function parseOwner(text: string): LockOwner | null;
23
+ export interface HomeLockOptions {
24
+ /** How long to wait for another holder before refusing; `HOME_LOCK_WAIT_MS` unless a caller shortens it. */
25
+ readonly waitMs?: number;
26
+ /** Reads the lock file to name its holder in the refusal. */
27
+ readonly read?: (path: string) => string;
28
+ /** Removes this call's staging file. */
29
+ readonly removeStage?: (path: string) => void;
30
+ /** Called after each attempt that found the lock held, before the wait; tests use it to observe real contention. */
31
+ readonly onBlocked?: () => void;
32
+ /** Removes this call's own lock at release. */
33
+ readonly removeLock?: (path: string) => void;
34
+ /** Stops the wait for another holder: the call then rejects with the signal's reason, having published no lock. */
35
+ readonly signal?: AbortSignal | undefined;
36
+ }
37
+ /**
38
+ * Another owner still held the lock after the wait. `held` describes that owner (or why it could not be read) and
39
+ * `host` names its host, or "its host" when unknown; a caller words its own refusal around them.
40
+ */
41
+ export declare class HomeLockedError extends Error {
42
+ readonly lock: string;
43
+ readonly held: string;
44
+ readonly host: string;
45
+ readonly code = "IA-DIST-HOME-LOCKED";
46
+ constructor(lock: string, held: string, host: string);
47
+ }
48
+ /**
49
+ * This call's own lock could not be removed after its action completed: the action's change was made, and the lock it
50
+ * leaves blocks every later change to that store until it is deleted.
51
+ */
52
+ export declare class HomeLockLeftError extends DistributionError {
53
+ readonly lock: string;
54
+ constructor(lock: string, reason: string);
55
+ }
56
+ /**
57
+ * Runs `action` holding the lock `<home>/<name>`. Creates the home as a write would. Rejects with `HomeLockedError` when
58
+ * another holder is still there after `waitMs`, measured on a monotonic clock, or with `signal`'s reason as soon as that
59
+ * fires while no lock is published; it never removes another holder's lock. `action` is synchronous and runs in the same
60
+ * synchronous step that publishes the lock, together with the release, so nothing else (no timer, I/O callback or queued
61
+ * microtask) runs while this call holds the lock.
62
+ * Once this call's lock is published, everything that follows (removing the staging file, the action) runs inside the
63
+ * `finally` that releases it. A release Windows refuses for a moment is retried; one that still fails leaves the lock
64
+ * and throws `IA-DIST-HOME-LOCK-LEFT` naming it, unless the action threw, whose error then stands.
65
+ */
66
+ export declare function withHomeLock<T>(home: string, name: string, action: () => T, options?: HomeLockOptions): Promise<T>;
67
+ //# sourceMappingURL=home-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"home-lock.d.ts","sourceRoot":"","sources":["../src/home-lock.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,+FAA+F;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,KAAK;IAGtC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAJvB,QAAQ,CAAC,IAAI,yBAAyB;gBAE3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM;CAKxB;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,iBAAiB;IAEpD,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM;CASjB;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAClC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,EACf,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,CAAC,CAAC,CAkDZ"}
@@ -0,0 +1,281 @@
1
+ /**
2
+ * An owner-stamped lock on one store in the IA home (host plugin distribution §3): every read-modify-write of such a
3
+ * store (`tracked-workspaces.json`, `state/update-check.json`) holds `<IA home>/<name>` from before it reads to after it
4
+ * replaces, so two processes cannot both start from the same contents and lose one change.
5
+ *
6
+ * The lock is a file created whole with its owner in it (`{token, pid, start, host, createdAt}`), staged beside it and
7
+ * hard-linked into place, so no reader ever sees it empty. A holder removes only the lock it published itself. A lock
8
+ * some other owner holds is never renamed or deleted, whether that owner is running or gone and however old the lock
9
+ * is: two processes taking over one dead owner's lock at once can each remove the other's, so no takeover is safe with
10
+ * these file operations alone. A holder that is killed therefore leaves a lock that blocks every change until a person
11
+ * deletes it: the call waits, then throws `HomeLockedError` naming the lock path and its owner, and says when that
12
+ * owner is on this host and its pid is no longer running. The wait runs on a timer, so a signal handler gets to run during
13
+ * it: a call given an `AbortSignal` stops waiting as soon as that signal fires, removing only its own staging file.
14
+ */
15
+ import { hostname } from 'node:os';
16
+ import { randomUUID } from 'node:crypto';
17
+ import { linkSync, mkdirSync, readFileSync, rmSync, unlinkSync, writeFileSync } from 'node:fs';
18
+ import { dirname, join } from 'node:path';
19
+ import { performance } from 'node:perf_hooks';
20
+ import { setTimeout as delay } from 'node:timers/promises';
21
+ import { DistributionError } from './files.js';
22
+ import { ensureIaHome } from './ia-home.js';
23
+ /** How long a change waits for another holder before it refuses; a hold lasts milliseconds. */
24
+ export const HOME_LOCK_WAIT_MS = 10_000;
25
+ const LOCK_POLL_MS = 25;
26
+ /** What Windows reports for a moment while another process (an indexer, antivirus) holds a file open. */
27
+ const TRANSIENT = ['EPERM', 'EBUSY', 'EACCES'];
28
+ /** How many times a release is tried, `LOCK_POLL_MS` apart, before the lock is reported left behind. */
29
+ const RELEASE_ATTEMPTS = 40;
30
+ /** The process start time in clock ticks since boot on Linux (`/proc`); null where nothing cheap reports one. */
31
+ export function processStart(pid) {
32
+ if (process.platform !== 'linux')
33
+ return null;
34
+ try {
35
+ const stat = readFileSync(`/proc/${pid}/stat`, 'utf8');
36
+ return stat.slice(stat.lastIndexOf(')') + 2).split(' ')[19] ?? null;
37
+ }
38
+ catch {
39
+ return null;
40
+ }
41
+ }
42
+ /** `process.kill(pid, 0)` throwing ESRCH is the only "not running"; EPERM and anything else count as running. */
43
+ export function pidRunning(pid) {
44
+ try {
45
+ process.kill(pid, 0);
46
+ return true;
47
+ }
48
+ catch (error) {
49
+ return error.code !== 'ESRCH';
50
+ }
51
+ }
52
+ /**
53
+ * Why a lock's owner can no longer hold it, judged on this host only: its pid is not running, or the pid now names
54
+ * another process (its start time differs, where the platform reports one). Null when the owner may still hold it: it
55
+ * runs, or it is on another host, where nothing here can tell.
56
+ */
57
+ export function ownerGone(owner) {
58
+ if (owner.host !== hostname())
59
+ return null;
60
+ if (!pidRunning(owner.pid))
61
+ return 'not-running';
62
+ const now = owner.start === null ? null : processStart(owner.pid);
63
+ return now !== null && now !== owner.start ? 'reused' : null;
64
+ }
65
+ export function parseOwner(text) {
66
+ try {
67
+ const value = JSON.parse(text);
68
+ const { token, pid, start, host, createdAt } = value;
69
+ if (typeof token === 'string' &&
70
+ typeof pid === 'number' &&
71
+ Number.isSafeInteger(pid) &&
72
+ pid > 0 &&
73
+ (start === null || typeof start === 'string') &&
74
+ typeof host === 'string' &&
75
+ typeof createdAt === 'string')
76
+ return { token, pid, start, host, createdAt };
77
+ }
78
+ catch {
79
+ /* Reported as unreadable. */
80
+ }
81
+ return null;
82
+ }
83
+ /** Blocks the thread: only for the retries of a refusal Windows gives for a moment, never the wait for a holder. */
84
+ const sleep = (ms) => void Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
85
+ const codeOf = (error) => error.code ?? '';
86
+ /**
87
+ * `ensureIaHome`, again when a process creating the same home at the same moment holds its marker open: Windows then
88
+ * refuses the rename over it (EPERM, EBUSY, EACCES) for a few milliseconds. Any other error is the caller's.
89
+ */
90
+ function ensureHome(home) {
91
+ for (let attempt = 1;; attempt += 1) {
92
+ try {
93
+ return ensureIaHome(home);
94
+ }
95
+ catch (error) {
96
+ if (attempt >= 40 || !TRANSIENT.includes(codeOf(error)))
97
+ throw error;
98
+ sleep(LOCK_POLL_MS);
99
+ }
100
+ }
101
+ }
102
+ function holderOf(lock, read) {
103
+ let text;
104
+ try {
105
+ text = read(lock);
106
+ }
107
+ catch (error) {
108
+ // Only a lock that is no longer there counts as released; any other failure is a lock nobody can describe.
109
+ return codeOf(error) === 'ENOENT' ? 'gone' : { unreadable: codeOf(error) || error.message };
110
+ }
111
+ const owner = parseOwner(text);
112
+ return owner === null ? { unreadable: '' } : { owner };
113
+ }
114
+ /**
115
+ * Another owner still held the lock after the wait. `held` describes that owner (or why it could not be read) and
116
+ * `host` names its host, or "its host" when unknown; a caller words its own refusal around them.
117
+ */
118
+ export class HomeLockedError extends Error {
119
+ lock;
120
+ held;
121
+ host;
122
+ code = 'IA-DIST-HOME-LOCKED';
123
+ constructor(lock, held, host) {
124
+ super(`${lock} is locked by another ia process (${held})`);
125
+ this.lock = lock;
126
+ this.held = held;
127
+ this.host = host;
128
+ this.name = 'HomeLockedError';
129
+ }
130
+ }
131
+ /**
132
+ * This call's own lock could not be removed after its action completed: the action's change was made, and the lock it
133
+ * leaves blocks every later change to that store until it is deleted.
134
+ */
135
+ export class HomeLockLeftError extends DistributionError {
136
+ lock;
137
+ constructor(lock, reason) {
138
+ super('IA-DIST-HOME-LOCK-LEFT', `${lock} could not be removed (${reason}); this process no longer holds it, so delete it`, lock);
139
+ this.lock = lock;
140
+ this.name = 'HomeLockLeftError';
141
+ }
142
+ }
143
+ /**
144
+ * Runs `action` holding the lock `<home>/<name>`. Creates the home as a write would. Rejects with `HomeLockedError` when
145
+ * another holder is still there after `waitMs`, measured on a monotonic clock, or with `signal`'s reason as soon as that
146
+ * fires while no lock is published; it never removes another holder's lock. `action` is synchronous and runs in the same
147
+ * synchronous step that publishes the lock, together with the release, so nothing else (no timer, I/O callback or queued
148
+ * microtask) runs while this call holds the lock.
149
+ * Once this call's lock is published, everything that follows (removing the staging file, the action) runs inside the
150
+ * `finally` that releases it. A release Windows refuses for a moment is retried; one that still fails leaves the lock
151
+ * and throws `IA-DIST-HOME-LOCK-LEFT` naming it, unless the action threw, whose error then stands.
152
+ */
153
+ export async function withHomeLock(home, name, action, options = {}) {
154
+ const { waitMs = HOME_LOCK_WAIT_MS, read = (path) => readFileSync(path, 'utf8'), removeStage = (path) => rmSync(path, { force: true }), onBlocked = () => { }, removeLock = unlinkSync, signal, } = options;
155
+ ensureHome(home);
156
+ const lock = join(home, name);
157
+ mkdirSync(dirname(lock), { recursive: true });
158
+ const owner = {
159
+ token: randomUUID(),
160
+ pid: process.pid,
161
+ start: processStart(process.pid),
162
+ host: hostname(),
163
+ createdAt: new Date().toISOString(),
164
+ };
165
+ const stage = `${lock}.${owner.token}.tmp`;
166
+ writeFileSync(stage, JSON.stringify(owner) + '\n', { flag: 'wx', mode: 0o600 });
167
+ let outcome;
168
+ // Called by `acquire` right after the link that publishes the lock, before its promise settles: the lock is never
169
+ // held across a yield. It records the outcome rather than throwing, so a failure here is never taken for a refusal.
170
+ const held = () => {
171
+ let failed = false;
172
+ try {
173
+ removeStage(stage);
174
+ outcome = { value: action() };
175
+ }
176
+ catch (error) {
177
+ failed = true;
178
+ outcome = { error };
179
+ }
180
+ finally {
181
+ const left = release(lock, owner.token, removeLock);
182
+ if (left !== null && !failed)
183
+ outcome = { error: left };
184
+ }
185
+ };
186
+ try {
187
+ await acquire(stage, lock, waitMs, read, onBlocked, signal, held);
188
+ }
189
+ catch (error) {
190
+ try {
191
+ removeStage(stage);
192
+ }
193
+ catch {
194
+ /* A stray staging file holds no lock; the refusal is what the caller needs. */
195
+ }
196
+ throw error;
197
+ }
198
+ if (outcome === undefined)
199
+ throw new Error(`${lock} was acquired without running its action`);
200
+ if ('error' in outcome)
201
+ throw outcome.error;
202
+ return outcome.value;
203
+ }
204
+ /**
205
+ * Removes `lock` when it is still this call's (`token`). A lock already gone is released; Windows refusing the read or
206
+ * the removal for a moment (EPERM, EBUSY, EACCES) is retried. Returns the refusal to report when the lock is left
207
+ * behind, which would otherwise block every later change until its pid is found dead by hand, or null.
208
+ */
209
+ function release(lock, token, remove) {
210
+ for (let attempt = 1;; attempt += 1) {
211
+ try {
212
+ if (parseOwner(readFileSync(lock, 'utf8'))?.token === token)
213
+ remove(lock);
214
+ return null;
215
+ }
216
+ catch (error) {
217
+ const code = codeOf(error);
218
+ if (code === 'ENOENT')
219
+ return null;
220
+ if (attempt < RELEASE_ATTEMPTS && TRANSIENT.includes(code)) {
221
+ sleep(LOCK_POLL_MS);
222
+ continue;
223
+ }
224
+ return new HomeLockLeftError(lock, code || error.message);
225
+ }
226
+ }
227
+ }
228
+ /**
229
+ * Publishes `stage` as `lock`, polling on a timer while another holder has it; refuses once `waitMs` has passed after a
230
+ * failure, and stops with `signal`'s reason before any attempt once that has fired. `held` runs right after the link
231
+ * that publishes the lock, in the same synchronous step.
232
+ */
233
+ async function acquire(stage, lock, waitMs, read, onBlocked, signal, held) {
234
+ const started = performance.now();
235
+ for (let lastLook = false;;) {
236
+ signal?.throwIfAborted();
237
+ try {
238
+ linkSync(stage, lock);
239
+ }
240
+ catch (error) {
241
+ if (codeOf(error) !== 'EEXIST')
242
+ throw error;
243
+ onBlocked();
244
+ if (performance.now() - started < waitMs) {
245
+ // The timer rejects only for the signal, which the top of the loop reports.
246
+ await delay(LOCK_POLL_MS, undefined, signal === undefined ? {} : { signal }).catch(() => { });
247
+ continue;
248
+ }
249
+ const holder = holderOf(lock, read);
250
+ // A lock released between the failed link and the read earns one more link, never another wait.
251
+ if (holder === 'gone' && !lastLook) {
252
+ lastLook = true;
253
+ continue;
254
+ }
255
+ throw locked(lock, holder);
256
+ }
257
+ // Published: the held section runs now, in this same step, and never throws.
258
+ held();
259
+ return;
260
+ }
261
+ }
262
+ function locked(lock, holder) {
263
+ let held, host = 'its host';
264
+ if (holder === 'gone')
265
+ held = 'its owner could not be read (ENOENT)';
266
+ else if ('unreadable' in holder)
267
+ held =
268
+ holder.unreadable === '' ? 'its owner could not be read' : `its owner could not be read (${holder.unreadable})`;
269
+ else {
270
+ const { owner } = holder;
271
+ host = owner.host;
272
+ held = `held since ${owner.createdAt} by pid ${owner.pid} on ${owner.host}`;
273
+ const gone = ownerGone(owner);
274
+ if (gone === 'not-running')
275
+ held += `; pid ${owner.pid} is not running on this host`;
276
+ else if (gone === 'reused')
277
+ held += `; pid ${owner.pid} is now another process`;
278
+ }
279
+ return new HomeLockedError(lock, held, host);
280
+ }
281
+ //# sourceMappingURL=home-lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"home-lock.js","sourceRoot":"","sources":["../src/home-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAA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BAA6B,CAAC,CAAC,CAAC,gCAAgC,MAAM,CAAC,UAAU,GAAG,CAAC;SAC/G,CAAC;QACJ,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QAClB,IAAI,GAAG,cAAc,KAAK,CAAC,SAAS,WAAW,KAAK,CAAC,GAAG,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;QAC5E,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,IAAI,KAAK,aAAa;YAAE,IAAI,IAAI,SAAS,KAAK,CAAC,GAAG,8BAA8B,CAAC;aAChF,IAAI,IAAI,KAAK,QAAQ;YAAE,IAAI,IAAI,SAAS,KAAK,CAAC,GAAG,yBAAyB,CAAC;IAClF,CAAC;IACD,OAAO,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC"}
package/dist/install.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { ActivationPointer, DistributionLock } from '@inventarch/db/distribution';
2
2
  import type { VerifiedArchive } from './archive.js';
3
3
  import { type InstallOperation } from './installation-core.js';
4
+ import type { ExpandedCollection } from './kit-collections.js';
4
5
  export type { InstallOperation } from './installation-core.js';
5
6
  export interface InstallationPlan {
6
7
  readonly formatVersion: 1;
@@ -24,6 +25,17 @@ export interface InstallationPlan {
24
25
  }
25
26
  export interface InstallOptions {
26
27
  readonly checkpoint?: (name: string) => void;
28
+ /**
29
+ * The registry collections this operation expanded (`resolveFromRegistries`'s `expandedCollections`); their identity
30
+ * is recorded beside the lock (kit-collections.ts). Every apply merges the record, so an operation that names none
31
+ * still removes the rows whose members it moved.
32
+ */
33
+ readonly collections?: readonly ExpandedCollection[];
34
+ /**
35
+ * The lock requests this operation counts as named by the user (kit-collections.ts `KitCollections.named`); the record
36
+ * keeps each one a recorded collection also lists.
37
+ */
38
+ readonly named?: readonly string[];
27
39
  }
28
40
  /** The workspace archive cache: `<digest>.ia.tgz` files only, each written once by `cacheArchive`. */
29
41
  export declare const ARCHIVE_CACHE = ".ia/distributions/cache";
@@ -37,6 +49,11 @@ export declare function cacheSelectedArchiveClosure(rootInput: string, lockInput
37
49
  export declare function readCachedArchiveSelection(rootInput: string, lockInput: unknown): ReadonlyMap<string, Buffer>;
38
50
  export declare function cachedReleases(root: string, lock: DistributionLock): ReadonlyMap<string, VerifiedArchive>;
39
51
  export declare function planInstallation(rootInput: string, lockInput: unknown, operation: InstallOperation): InstallationPlan;
52
+ /**
53
+ * Whether applying `plan` now would write `.ia/kit-collections.json`: the same merge the apply makes, against the lock
54
+ * on disk, so a preview can name the record among the files it would write.
55
+ */
56
+ export declare function collectionsWouldChange(plan: InstallationPlan, expanded: readonly ExpandedCollection[], named?: readonly string[]): boolean;
40
57
  export declare function applyInstallation(input: unknown, options?: InstallOptions): {
41
58
  status: 'installed';
42
59
  generation: string;