@inventarch/distribution 3.1.1 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LANGUAGE.md +2 -2
- package/SPEC.md +10 -0
- package/assets/host-launcher.mjs +130 -22
- package/dist/bounded-fetch.d.ts +7 -1
- package/dist/bounded-fetch.d.ts.map +1 -1
- package/dist/bounded-fetch.js +31 -2
- package/dist/bounded-fetch.js.map +1 -1
- package/dist/decisions.d.ts +3 -3
- package/dist/decisions.d.ts.map +1 -1
- package/dist/decisions.js +4 -4
- package/dist/decisions.js.map +1 -1
- package/dist/guard-registration.d.ts +2 -2
- package/dist/guard-registration.d.ts.map +1 -1
- package/dist/guard-registration.js +4 -4
- package/dist/guard-registration.js.map +1 -1
- package/dist/host-home.d.ts +1 -1
- package/dist/host-home.js +1 -1
- package/dist/host-observe.d.ts.map +1 -1
- package/dist/host-observe.js +4 -3
- package/dist/host-observe.js.map +1 -1
- package/dist/host.d.ts +2 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +3 -3
- package/dist/host.js.map +1 -1
- package/dist/install.js +1 -1
- package/dist/install.js.map +1 -1
- package/dist/inventory.d.ts.map +1 -1
- package/dist/inventory.js +92 -9
- package/dist/inventory.js.map +1 -1
- package/dist/lifecycle-registration.js +2 -2
- package/dist/lifecycle-registration.js.map +1 -1
- package/dist/plugin-home.js +1 -1
- package/dist/projection.d.ts +1 -1
- package/dist/projection.d.ts.map +1 -1
- package/dist/projection.js +2 -2
- package/dist/projection.js.map +1 -1
- package/dist/registry-admission.d.ts +1 -1
- package/dist/registry-admission.d.ts.map +1 -1
- package/dist/registry-admission.js +2 -2
- package/dist/registry-admission.js.map +1 -1
- package/dist/registry-resolve.js +1 -1
- package/dist/registry-source.d.ts +1 -1
- package/dist/registry-source.d.ts.map +1 -1
- package/dist/services.d.ts +4 -4
- package/dist/system-package.d.ts.map +1 -1
- package/dist/system-package.js +68 -6
- package/dist/system-package.js.map +1 -1
- package/dist/updates.d.ts +4 -4
- package/dist/updates.d.ts.map +1 -1
- package/dist/updates.js +4 -4
- package/dist/updates.js.map +1 -1
- package/package.json +7 -7
package/LANGUAGE.md
CHANGED
|
@@ -22,7 +22,7 @@ Spec source locators do not load documents. Resource capture and disclosure requ
|
|
|
22
22
|
| @convention | governance-system | Declares a convention in the shared governance shape. |
|
|
23
23
|
| @decision | work-system | Represents a choice that is needed or has been made: the question, options and decider, and once made, the choice and rationale. |
|
|
24
24
|
| @dimension | taxonomy | Defines a supported record dimension used by conditions and lookup. |
|
|
25
|
-
| @distribution | workspace-system | Declares root records from which a distributable closure is selected. |
|
|
25
|
+
| @distribution | workspace-system | Declares root records from which a distributable closure is selected, and optionally the host plugin product it describes. |
|
|
26
26
|
| @execution-binding | agent-composition-system | Connects a native target to a host-installed entry or operation descriptor. |
|
|
27
27
|
| @harness | agent-composition-system | Composes profiles and execution bindings in a workspace under a host contract. |
|
|
28
28
|
| @hook | hook-authoring-system | Represents a host event, tool/path selection and guard message. Registration and executing a guard require a host adapter. |
|
|
@@ -40,7 +40,7 @@ Spec source locators do not load documents. Resource capture and disclosure requ
|
|
|
40
40
|
| @placement | taxonomy | Defines source authority and reach metadata. |
|
|
41
41
|
| @plan | work-system | Represents an arrangement of milestones toward an intent; it heads the work hierarchy and has no parent. Plans do not nest. |
|
|
42
42
|
| @playbook | governance-system | Represents a procedure as phase/primitive cells. Cell delivery is generic; the authored method belongs to its author. |
|
|
43
|
-
| @predicate | taxonomy | Defines a directed relationship and its
|
|
43
|
+
| @predicate | taxonomy | Defines a directed relationship, its inverse spelling and its present phrase. |
|
|
44
44
|
| @primitive | taxonomy | Defines a cognitive primitive coordinate; a cell is selected using its phase and primitive. |
|
|
45
45
|
| @principle | governance-system | Declares a governing rationale in the shared governance shape. |
|
|
46
46
|
| @run | session-system | Represents a governed run identity, declared phase, status and owner. Declaration does not start execution. |
|
package/SPEC.md
CHANGED
|
@@ -4,6 +4,14 @@ Public language mechanism. The [language reference](LANGUAGE.md) defines vocabul
|
|
|
4
4
|
|
|
5
5
|
The [installed system-package API](references/system-package.md) verifies explicit per-system native ownership and exact selected dependencies without executing package code.
|
|
6
6
|
|
|
7
|
+
Verified reads (2026-10-16): the host launcher's cache walk (`assets/host-launcher.mjs`, which every launcher mode runs first), `installedDistributionDigest` (`./inventory`) and `verifySystemPackage` judge each file by the descriptor they read it through. Each opens a file before it is judged, never through a final link where the platform refuses one at the open and never waiting on a FIFO; its type, its size and, for the launcher, its link count come from that descriptor; the read stops one byte past that size; and afterwards its name must still hold that file. On Windows the open has neither guard, so a link swapped in after the listing is opened and read, and that last check refuses it. The runtime inventory and the package reader refuse a file of more than 2147483647 bytes, the most `readFileSync` reads, before reading it, the inventory with its one message and the package reader as `System package input exceeds 2147483647 bytes: <path>`; the launcher reads only a pinned file within its 256 MiB budget.
|
|
8
|
+
|
|
9
|
+
The launcher judges every entry not listed as a regular file by its lstat, as it judged every entry before, since Windows lists every reparse point as a link: a link or a special file refuses before anything is opened, a directory is walked, and an entry its lstat calls a file or a directory, such as a cloud placeholder or a deduplicated file, is judged as that. It refuses a link (`Plugin cache links are unsupported`), a special file or a file with a second link, the files it skips included (`Plugin cache file is aliased`), and an unpinned, resized, over-budget or changed file (`Plugin cache payload differs: <path>`). An entry its listed name no longer reaches, removed once it was listed or listed under a name that is not UTF-8, which Node decodes lossily on Linux, is never admitted: a pinned one is missing (`Plugin cache payload is missing`), and any other, a directory or a file the walk would skip included, refuses as `Plugin cache payload differs: <path>`. Of the failures that keep a file from opening, only that of a pinned file the walk may not read (EACCES, EPERM) prints the system's error; any other leaves the file to be judged by its name, and a pinned file that still failed to open refuses as `Plugin cache payload differs: <path>`. An entry it can list but not lstat, in a directory it can list but not enter, fails with the system's error, as before.
|
|
10
|
+
|
|
11
|
+
The runtime inventory judges every entry but a runtime file listed as a regular file by its lstat, as it judged every entry before, with the same consequences for a link, a special file, a directory and a reparse point. It admits hard links, and refuses a link, a special file, an entry its listed name no longer reaches, a file that changes while it is read and any open that fails, an unreadable file included, with its one message. An entry it can list but not lstat, in a directory it can list but not enter, fails with the system's error, as before, but for a runtime file, which it opens and so refuses with its one message.
|
|
12
|
+
|
|
13
|
+
The package reader (`verifySystemPackage`) refuses a link on the way by name before it opens the input. It admits store hard links; an input that is or becomes a link refuses as `System package input is aliased: <path>`, one that is no regular file as `System package input is not a regular file: <path>`, one whose name stops holding the file read or that changes while it is read as `System package input changed while it was read: <path>`, and a missing or unreadable input fails with the system's error, as before.
|
|
14
|
+
|
|
7
15
|
`packSnapshotSet` additionally accepts one root-authored release control at `.ia/src/releases/<distribution-name>.ia` per release. That file contains exactly the selected public `@distribution`, its meaning and its unconditional `@system` roots. The archive retains those exact source bytes and pins them; verification refuses extra records, relationships, nested declarations or roots differing from the manifest. Release roots still belong to native system folders, and whole selected systems remain the payload ownership unit. The installed generation loads the pinned control as an adopted root instance so direct distribution references continue to resolve. `packSnapshot` retains its existing native-folder declaration requirement.
|
|
8
16
|
|
|
9
17
|
Root release controls separate publication selection from vocabulary ownership. They do not create dependencies on every system named by other release controls. Per-system packages explicitly depend on workspace-system for their release declaration and generated installation workspace vocabulary. Workspace-system therefore keeps its agent/compliance foundation closure; generated teaching guides retain their actual schema dependencies. Native and npm versions remain independently selected.
|
|
@@ -25,6 +33,8 @@ Hook groups (`./guard-registration`; 2026-10-11): `planHookRegistration(root, {c
|
|
|
25
33
|
|
|
26
34
|
Registry collection kinds, source-only workspace adoption, kit installation, budgets and rollback are specified in [registry collections](references/registry-collections.md).
|
|
27
35
|
|
|
36
|
+
Transport (`./internal/bounded-fetch`; 2026-10-16): `fetchBounded` is the one GET behind registry documents and remote archives, under the bounds of the [registry spec](../../docs/specs/registry/README.md) §5.1 and §6.4: redirects refused, a 30-second timeout joined to the caller's signal, declared and streamed bytes bounded. Whatever its caller checked, it parses the URL with `new URL` and refuses only a URL that does not parse, whose scheme is not `https:` or that has a username or password. That refusal comes before any request, as `IA-DIST-INPUT-INVALID` with the message `<label> <url> is not a credential-free HTTPS URL`. It then requests the canonical form `new URL` writes. A query or a fragment passes, and a legitimate non-canonical HTTPS spelling, such as an uppercase host (`https://Registry.test/ia-registry.json`), an explicit `:443`, a percent-encoded host character, an IPv4 number form, a dot segment or an empty userinfo, is canonicalized and still accepted; fetch makes the request it made before this check, when it was handed that spelling itself, so a direct caller passing an HTTPS URL sees no break. Before this check, an `http:` URL was requested in clear text and a `data:` or `blob:` URL was read in process; a URL with any other scheme, such as `file:`, `ftp:` or `wss:`, got a `TypeError` from fetch, reported as `IA-DIST-ARTIFACT-UNAVAILABLE` with the message `<label> <url> failed: …`, as a credentialed or malformed URL did. All of them now refuse as `IA-DIST-INPUT-INVALID`, so both the code and the message change. Refusing another scheme is a defensive patch, not a contract change: the supported contract already excluded it. The [registry spec](../../docs/specs/registry/README.md) says "A registry base is a credential-free HTTPS URL or a local directory" (§3) and "HTTPS bases must carry no credentials, query or fragment, and other URL schemes refuse" (§4), and the archive check admits only HTTPS artifact URLs. Messages name the URL as the caller spelled it. Every URL built on a base that `parseRegistryBase` returns, and every URL the archive check admits, is already canonical and is requested unchanged. To migrate, a direct caller, or one that builds its own `RegistryBase`, can keep passing HTTPS URLs, in any spelling, or call `parseRegistryBase` to get the canonical form up front; a direct caller passing an `http:`, `data:` or `blob:` URL moves to an HTTPS URL or, for a registry, a local directory base. This is URL-shape hygiene, not host authorization: it does not keep a request from internal or loopback hosts, and it does not prevent DNS rebinding or other server-side request forgery.
|
|
37
|
+
|
|
28
38
|
An installation plan whose lock requires an unsupported distribution engine refuses with `IA-DIST-CONFLICT`, naming its required range and the current installer engine. Installed reads distinguish `engine-incompatible` from corrupt state through the database error reason. Neither restore nor recovery upgrades the running implementation; no fallback rewrites a lock or lowers an archive engine range. The compatibility and rollback procedure is documented in [README.md](README.md).
|
|
29
39
|
|
|
30
40
|
Explicit hook removal checks both Claude settings files before making changes. `assertRemovableHooks` refuses an IA hook group without matching ownership, including after the ownership file is lost or a workspace is moved, at the settings file that contains it. Its `unownedHook` detail identifies that group for manual recovery. It never adopts or deletes an unowned group; other settings and owned state remain intact. The ordinary modified/duplicate owned-group checks still apply. An explicit removal cannot report success while such a group remains active.
|
package/assets/host-launcher.mjs
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
// Packaged artifact entrypoint. Its inventory pin is inserted by release assembly.
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
closeSync,
|
|
5
|
+
constants,
|
|
6
|
+
fstatSync,
|
|
7
|
+
lstatSync,
|
|
8
|
+
openSync,
|
|
9
|
+
readFileSync,
|
|
10
|
+
readSync,
|
|
11
|
+
readdirSync,
|
|
12
|
+
realpathSync,
|
|
13
|
+
statSync,
|
|
14
|
+
} from 'node:fs';
|
|
4
15
|
import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
|
|
5
16
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
17
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'),
|
|
7
18
|
pin = '__INVENTORY_DIGEST__';
|
|
8
19
|
const hash = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
9
20
|
// `child` is `parent` or under it on disk, compared by device and inode from its deepest existing ancestor up, so another
|
|
10
|
-
// spelling a case- or normalization-folding volume opens as the same directory is inside too
|
|
21
|
+
// spelling a case- or normalization-folding volume opens as the same directory is inside too.
|
|
11
22
|
const within = (parent, child) => {
|
|
12
23
|
const target = statSync(parent, { bigint: true });
|
|
13
24
|
let entry = child;
|
|
@@ -40,29 +51,126 @@ try {
|
|
|
40
51
|
let count = 0,
|
|
41
52
|
total = 0,
|
|
42
53
|
entries = 0;
|
|
54
|
+
// The launcher's own files, and unpinned platform files, which the walk never reads.
|
|
55
|
+
const skipped = (rel, name, file) =>
|
|
56
|
+
rel === 'inventory.json' ||
|
|
57
|
+
rel === 'scripts/ia.mjs' ||
|
|
58
|
+
rel === 'release.json' ||
|
|
59
|
+
(!file && (name === '.DS_Store' || name.startsWith('._')));
|
|
60
|
+
// What the walk does with a file, from its stat (bigint): a link, a special file or a second link refuses; a skipped
|
|
61
|
+
// file is skipped (false); an unpinned, resized or over-budget file refuses; any other file is read and hashed (true).
|
|
62
|
+
const judge = (stat, rel, name, file) => {
|
|
63
|
+
if (stat.isSymbolicLink()) throw Error('Plugin cache links are unsupported');
|
|
64
|
+
if (!stat.isFile() || stat.nlink !== 1n) throw Error('Plugin cache file is aliased');
|
|
65
|
+
if (skipped(rel, name, file)) return false;
|
|
66
|
+
if (
|
|
67
|
+
!file ||
|
|
68
|
+
!Number.isSafeInteger(file.bytes) ||
|
|
69
|
+
stat.size !== BigInt(file.bytes) ||
|
|
70
|
+
(total += file.bytes) > 256 * 1024 * 1024
|
|
71
|
+
)
|
|
72
|
+
throw Error('Plugin cache payload differs: ' + rel);
|
|
73
|
+
return true;
|
|
74
|
+
};
|
|
75
|
+
// An entry its listed name no longer reaches: removed since its directory was read, or listed under a name that is not
|
|
76
|
+
// UTF-8, which Node decodes lossily on Linux. It is never admitted: a pinned one is left uncounted, so it is missing
|
|
77
|
+
// (false), and any other, one the walk would skip included, is no file the inventory pins.
|
|
78
|
+
const gone = (rel, file) => {
|
|
79
|
+
if (file) return false;
|
|
80
|
+
throw Error('Plugin cache payload differs: ' + rel);
|
|
81
|
+
};
|
|
82
|
+
// The lstat (bigint) of `path`, or undefined once its name reaches nothing. Every directory on the way was listed as
|
|
83
|
+
// one, so a loop on the way (ELOOP) is a link swapped in since.
|
|
84
|
+
const named = (path) => {
|
|
85
|
+
try {
|
|
86
|
+
return lstatSync(path, { bigint: true });
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (error.code === 'ENOENT' || error.code === 'ENOTDIR') return undefined;
|
|
89
|
+
if (error.code === 'ELOOP') throw Error('Plugin cache links are unsupported');
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
// Whether the file entry at `rel` is pinned and verified. It is opened before it is judged, so the file judged is the
|
|
94
|
+
// file hashed (CodeQL js/file-system-race): never through a link where the platform refuses one at the open, never
|
|
95
|
+
// waiting on a FIFO, read through that descriptor at most one byte past its pinned size, and still the file at `rel`
|
|
96
|
+
// afterwards, which on Windows, without either open flag, is the one check of a link swapped in after the listing.
|
|
97
|
+
const verified = (rel, name, file) => {
|
|
98
|
+
const full = join(root, rel);
|
|
99
|
+
let fd;
|
|
100
|
+
try {
|
|
101
|
+
fd = openSync(full, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
102
|
+
} catch (error) {
|
|
103
|
+
// Of the failures that keep a file from opening, only that of a pinned file the walk may not read (EACCES, EPERM)
|
|
104
|
+
// prints its system error, as before. A name that reaches nothing is gone, and a link the open refused (ELOOP;
|
|
105
|
+
// EMLINK on FreeBSD) is refused as one. Anything else whose open fails, a socket among them, is judged by its
|
|
106
|
+
// name, as before the walk opened files; a pinned file that some other failure kept from opening, one swapped back
|
|
107
|
+
// after the open or one the system would not open, cannot be verified and refuses as a payload that differs.
|
|
108
|
+
if (error.code === 'ENOENT' || error.code === 'ENOTDIR') return gone(rel, file);
|
|
109
|
+
if (error.code === 'ELOOP' || error.code === 'EMLINK') throw Error('Plugin cache links are unsupported');
|
|
110
|
+
const stat = named(full);
|
|
111
|
+
if (!stat) return gone(rel, file);
|
|
112
|
+
if (!judge(stat, rel, name, file)) return false;
|
|
113
|
+
if (error.code === 'EACCES' || error.code === 'EPERM') throw error;
|
|
114
|
+
throw Error('Plugin cache payload differs: ' + rel);
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const opened = fstatSync(fd, { bigint: true });
|
|
118
|
+
if (!judge(opened, rel, name, file)) return false;
|
|
119
|
+
const bytes = Buffer.alloc(file.bytes + 1);
|
|
120
|
+
let length = 0;
|
|
121
|
+
while (length < bytes.length) {
|
|
122
|
+
const read = readSync(fd, bytes, length, bytes.length - length, null);
|
|
123
|
+
if (!read) break;
|
|
124
|
+
length += read;
|
|
125
|
+
}
|
|
126
|
+
const after = fstatSync(fd, { bigint: true }),
|
|
127
|
+
stat = named(full);
|
|
128
|
+
if (!stat) return gone(rel, file);
|
|
129
|
+
if (stat.isSymbolicLink()) throw Error('Plugin cache links are unsupported');
|
|
130
|
+
if (!stat.isFile() || stat.nlink !== 1n) throw Error('Plugin cache file is aliased');
|
|
131
|
+
if (
|
|
132
|
+
stat.dev !== opened.dev ||
|
|
133
|
+
stat.ino !== opened.ino ||
|
|
134
|
+
after.size !== opened.size ||
|
|
135
|
+
after.mtimeNs !== opened.mtimeNs ||
|
|
136
|
+
after.ctimeNs !== opened.ctimeNs ||
|
|
137
|
+
length !== file.bytes ||
|
|
138
|
+
hash(bytes.subarray(0, length)) !== file.sha256
|
|
139
|
+
)
|
|
140
|
+
throw Error('Plugin cache payload differs: ' + rel);
|
|
141
|
+
return true;
|
|
142
|
+
} finally {
|
|
143
|
+
closeSync(fd);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
43
146
|
const visit = (path = '', depth = 0) => {
|
|
44
147
|
if (depth > 32) throw Error('Plugin cache directory depth exceeds 32');
|
|
45
|
-
|
|
148
|
+
let listed;
|
|
149
|
+
try {
|
|
150
|
+
listed = readdirSync(join(root, path), { withFileTypes: true });
|
|
151
|
+
} catch (error) {
|
|
152
|
+
// A directory its listed name no longer reaches is no part of the payload. It and every directory on its way were
|
|
153
|
+
// listed as directories (the root resolved), so one that loops (ELOOP) is a link swapped in since.
|
|
154
|
+
if (path && (error.code === 'ENOENT' || error.code === 'ENOTDIR'))
|
|
155
|
+
throw Error('Plugin cache payload differs: ' + path);
|
|
156
|
+
if (error.code === 'ELOOP') throw Error('Plugin cache links are unsupported');
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
for (const entry of listed) {
|
|
46
160
|
if (++entries > 20000) throw Error('Plugin cache filesystem inventory exceeds its bound');
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
(total += stat.size) > 256 * 1024 * 1024 ||
|
|
61
|
-
hash(readFileSync(full)) !== file.sha256
|
|
62
|
-
)
|
|
63
|
-
throw Error('Plugin cache payload differs: ' + rel);
|
|
64
|
-
count++;
|
|
65
|
-
}
|
|
161
|
+
const name = entry.name,
|
|
162
|
+
rel = path ? path + '/' + name : name,
|
|
163
|
+
file = expected.get(rel);
|
|
164
|
+
// A file the listing reports is judged by the descriptor it is read through. Any other entry is judged by its lstat,
|
|
165
|
+
// as the walk judged every entry before it opened files: Windows lists every reparse point as a link, so only a real
|
|
166
|
+
// link refuses as one, a placeholder or deduplicated entry is judged by the type its lstat gives, and an entry in a
|
|
167
|
+
// directory the walk can list but not enter fails with the lstat's error, as before.
|
|
168
|
+
const kind = entry.isFile() ? entry : named(join(root, rel));
|
|
169
|
+
if (!kind) gone(rel, file);
|
|
170
|
+
else if (kind.isSymbolicLink()) throw Error('Plugin cache links are unsupported');
|
|
171
|
+
else if (kind.isDirectory()) visit(rel, depth + 1);
|
|
172
|
+
else if (!kind.isFile()) throw Error('Plugin cache file is aliased');
|
|
173
|
+
else if (verified(rel, name, file)) count++;
|
|
66
174
|
}
|
|
67
175
|
};
|
|
68
176
|
visit();
|
package/dist/bounded-fetch.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ export interface BoundedFetch {
|
|
|
12
12
|
readonly optional?: boolean;
|
|
13
13
|
readonly signal?: AbortSignal | undefined;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* A 30 s timeout joined to the caller's signal, redirects refused, declared and streamed bytes bounded (spec §5.1, §6.4),
|
|
17
|
+
* and, whatever the caller checked, a request only for a URL that `new URL` parses as `https:` without a username or
|
|
18
|
+
* password, sent in the canonical form `new URL` writes; any other URL refuses as INPUT-INVALID, naming the URL after
|
|
19
|
+
* `label`. Messages name the URL as the caller spelled it. This is URL hygiene, not host authorization: it does not
|
|
20
|
+
* keep a request from internal, loopback or rebinding hosts.
|
|
21
|
+
*/
|
|
16
22
|
export declare function fetchBounded(request: BoundedFetch): Promise<Buffer | null>;
|
|
17
23
|
//# sourceMappingURL=bounded-fetch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounded-fetch.d.ts","sourceRoot":"","sources":["../src/bounded-fetch.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,CAAC;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAC3C;AACD
|
|
1
|
+
{"version":3,"file":"bounded-fetch.d.ts","sourceRoot":"","sources":["../src/bounded-fetch.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,CAAC;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAC3C;AACD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAehF"}
|
package/dist/bounded-fetch.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { DistributionError, fail } from './files.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* A 30 s timeout joined to the caller's signal, redirects refused, declared and streamed bytes bounded (spec §5.1, §6.4),
|
|
4
|
+
* and, whatever the caller checked, a request only for a URL that `new URL` parses as `https:` without a username or
|
|
5
|
+
* password, sent in the canonical form `new URL` writes; any other URL refuses as INPUT-INVALID, naming the URL after
|
|
6
|
+
* `label`. Messages name the URL as the caller spelled it. This is URL hygiene, not host authorization: it does not
|
|
7
|
+
* keep a request from internal, loopback or rebinding hosts.
|
|
8
|
+
*/
|
|
3
9
|
export async function fetchBounded(request) {
|
|
4
10
|
const { url, signal } = request;
|
|
5
11
|
// §6.4: a network failure, the 30 s timeout included, names the URL; only the caller's own abort stays an abort.
|
|
@@ -16,8 +22,31 @@ export async function fetchBounded(request) {
|
|
|
16
22
|
}
|
|
17
23
|
async function transfer(request) {
|
|
18
24
|
const { url, limit, label, oversize, optional = false, signal } = request;
|
|
25
|
+
const refuse = () => fail('INPUT-INVALID', `${label} ${url} is not a credential-free HTTPS URL`);
|
|
26
|
+
// The policy: `url` parses as a WHATWG URL with the `https:` scheme and no username or password. Nothing else
|
|
27
|
+
// refuses: a query or fragment passes, and a spelling that `new URL` rewrites (case, `:443`, a percent-encoded host
|
|
28
|
+
// character, an IPv4 number form, a dot segment) is requested in the canonical form it writes, which is the request
|
|
29
|
+
// fetch built when handed the spelling itself. A malformed or credentialed URL never got a request: fetch rejects it.
|
|
30
|
+
let parsed;
|
|
31
|
+
try {
|
|
32
|
+
parsed = new URL(url);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return refuse();
|
|
36
|
+
}
|
|
37
|
+
if (parsed.protocol !== 'https:' || parsed.username || parsed.password)
|
|
38
|
+
return refuse();
|
|
39
|
+
const href = parsed.href;
|
|
40
|
+
// `new URL` writes such a URL as `https://` and printable ASCII only: the host is lowercase ASCII (punycode for a
|
|
41
|
+
// non-ASCII name), and a control, space or non-ASCII character elsewhere is percent-encoded or, for a tab or newline,
|
|
42
|
+
// stripped. The test below therefore refuses nothing the checks above admit. It is the guard CodeQL reads
|
|
43
|
+
// (js/file-access-to-http): an anchored pattern listing every printable ASCII character, tested on the very string
|
|
44
|
+
// fetch receives, with a `return` that ends the refusing branch. Keep the literal inline, keep the `return`, and
|
|
45
|
+
// pass `href`, not `url`, to fetch.
|
|
46
|
+
if (!/^https:\/\/[a-zA-Z0-9!"#$%&'()*+,.\/:;<=>?@\[\\\]^_`{|}~-]+$/.test(href))
|
|
47
|
+
return refuse();
|
|
19
48
|
const timeout = AbortSignal.timeout(30_000), combined = signal === undefined ? timeout : AbortSignal.any([timeout, signal]);
|
|
20
|
-
const response = await fetch(
|
|
49
|
+
const response = await fetch(href, { redirect: 'error', signal: combined });
|
|
21
50
|
if (!response.ok || (!response.body && !optional)) {
|
|
22
51
|
await response.body?.cancel();
|
|
23
52
|
if (optional && response.status === 404)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounded-fetch.js","sourceRoot":"","sources":["../src/bounded-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAgBrD
|
|
1
|
+
{"version":3,"file":"bounded-fetch.js","sourceRoot":"","sources":["../src/bounded-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAgBrD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAqB;IACtD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAChC,iHAAiH;IACjH,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,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,CAAC;IAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/decisions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Host plugin distribution spec §
|
|
1
|
+
/** Host plugin distribution spec §7.2: answers to "initialize this repository?", kept in the IA home, never in the repository. */
|
|
2
2
|
export declare const DECISIONS = "state/decisions.json";
|
|
3
3
|
export type DeclineKind = 'today' | 'forever';
|
|
4
4
|
export interface Decision {
|
|
@@ -8,13 +8,13 @@ export interface Decision {
|
|
|
8
8
|
readonly host: string;
|
|
9
9
|
readonly path: string;
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
11
|
+
/** The git top level when inside a work tree, else the directory; its real path, case-folded on Windows. */
|
|
12
12
|
export declare function repositoryKey(directory: string, platform?: string): {
|
|
13
13
|
readonly key: string;
|
|
14
14
|
readonly path: string;
|
|
15
15
|
};
|
|
16
16
|
export declare const nextLocalMidnight: (at: Date) => Date;
|
|
17
|
-
/** §9
|
|
17
|
+
/** §9: an unreadable or malformed file reads as empty and says so. `reason` is the filesystem error's `code`, `'parse'` for JSON that does not parse, or `'schema'` for a wrong/missing schema or a row that fails `shaped`. */
|
|
18
18
|
export declare function readDecisions(home: string): {
|
|
19
19
|
readonly repositories: Readonly<Record<string, Decision>>;
|
|
20
20
|
readonly invalid: boolean;
|
package/dist/decisions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decisions.d.ts","sourceRoot":"","sources":["../src/decisions.ts"],"names":[],"mappings":"AAKA,
|
|
1
|
+
{"version":3,"file":"decisions.d.ts","sourceRoot":"","sources":["../src/decisions.ts"],"names":[],"mappings":"AAKA,kIAAkI;AAClI,eAAO,MAAM,SAAS,yBAAyB,CAAC;AAChD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,SAAS,CAAC;AAC9C,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,QAAQ,EAAE,g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, dirname, join, resolve } from 'node:path';
|
|
3
3
|
import { fail } from './files.js';
|
|
4
4
|
import { readHomeFile, writeHomeFile } from './ia-home.js';
|
|
5
|
-
/** Host plugin distribution spec §
|
|
5
|
+
/** Host plugin distribution spec §7.2: answers to "initialize this repository?", kept in the IA home, never in the repository. */
|
|
6
6
|
export const DECISIONS = 'state/decisions.json';
|
|
7
7
|
/** The realpath of the deepest existing ancestor of `directory`, with any not-yet-created tail segments appended literally: a decline recorded before `mkdir` then keys identically to one recorded after. `realpathSync.native` resolves links/junctions in the prefix and Windows 8.3 short names (e.g. `PROGRA~1`); `realpathSync` is the fallback if the native call throws. */
|
|
8
8
|
function realPrefix(directory) {
|
|
@@ -30,7 +30,7 @@ function realPrefix(directory) {
|
|
|
30
30
|
}
|
|
31
31
|
return remaining.length > 0 ? join(real, ...remaining) : real;
|
|
32
32
|
}
|
|
33
|
-
/**
|
|
33
|
+
/** The git top level when inside a work tree, else the directory; its real path, case-folded on Windows. */
|
|
34
34
|
export function repositoryKey(directory, platform = process.platform) {
|
|
35
35
|
const start = realPrefix(directory);
|
|
36
36
|
let path = start;
|
|
@@ -57,7 +57,7 @@ const shaped = (value) => {
|
|
|
57
57
|
? row['until'] === undefined
|
|
58
58
|
: row['decision'] === 'declined-today' && validAt(row['until']);
|
|
59
59
|
};
|
|
60
|
-
/** §9
|
|
60
|
+
/** §9: an unreadable or malformed file reads as empty and says so. `reason` is the filesystem error's `code`, `'parse'` for JSON that does not parse, or `'schema'` for a wrong/missing schema or a row that fails `shaped`. */
|
|
61
61
|
export function readDecisions(home) {
|
|
62
62
|
let text;
|
|
63
63
|
try {
|
|
@@ -90,7 +90,7 @@ export function decisionFor(home, directory, now = new Date()) {
|
|
|
90
90
|
const found = readDecisions(home).repositories[repositoryKey(directory).key];
|
|
91
91
|
return found !== undefined && live(found, now) ? found : null;
|
|
92
92
|
}
|
|
93
|
-
/** §9
|
|
93
|
+
/** §9: never overwrite a file that did not parse; expired entries are dropped on every write. */
|
|
94
94
|
function writable(home, now) {
|
|
95
95
|
const current = readDecisions(home);
|
|
96
96
|
if (current.invalid) {
|
package/dist/decisions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decisions.js","sourceRoot":"","sources":["../src/decisions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE3D,
|
|
1
|
+
{"version":3,"file":"decisions.js","sourceRoot":"","sources":["../src/decisions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE3D,kIAAkI;AAClI,MAAM,CAAC,MAAM,SAAS,GAAG,sBAAsB,CAAC;AAShD,oXAAoX;AACpX,SAAS,UAAU,CAAC,SAAiB;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAClC,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,IAAI,OAAO,GAAG,MAAM,CAAC;IACrB,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,IAAI,MAAM,KAAK,OAAO;YAAE,MAAM;QAC9B,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC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AK,SAAS;QAChB,CAAC,CAAC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;QACrE,CAAC,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACrH,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,YAAY,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjD,OAAO,QAAQ,CAAC;AAClB,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,SAAiB,EAAE,MAAY,IAAI,IAAI,EAAE;IACpF,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,EACtC,EAAE,GAAG,EAAE,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACpD,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACzB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -41,7 +41,7 @@ export interface GuardPlan {
|
|
|
41
41
|
readonly after: Side;
|
|
42
42
|
readonly digest: string;
|
|
43
43
|
}
|
|
44
|
-
/**
|
|
44
|
+
/** Explicit root, not claude-guard's CLAUDE_PROJECT_DIR, so the recorded root is the one run; on POSIX through `/bin/sh`, so a guard that cannot run denies (`FAIL_CLOSED`). */
|
|
45
45
|
export declare function guardGroup(launcher: string, root: string, platform?: NodeJS.Platform): Group;
|
|
46
46
|
/**
|
|
47
47
|
* The retained group must be the fixed guard derivation for its cache and root, in either form (`guardNode`); the
|
|
@@ -181,7 +181,7 @@ export declare function recoverGuardRegistration(rootInput: string): {
|
|
|
181
181
|
* and any failure to run the guard at all exits 2, naming the remedy on stderr, which Claude Code shows with the block.
|
|
182
182
|
* Claude Code lets a tool call through when a hook command cannot start or fails any other way, and blocks only on exit 2 or
|
|
183
183
|
* a deny (code.claude.com/docs/en/hooks); the guard's own decisions exit 0 and pass through unchanged. win32 has no
|
|
184
|
-
* `/bin/sh` and keeps the direct form, which still fails open
|
|
184
|
+
* `/bin/sh` and keeps the direct form, which still fails open.
|
|
185
185
|
*/
|
|
186
186
|
export declare const FAIL_CLOSED = "\"$0\" \"$@\" || { echo \"IA steward guard could not run: run ia doctor, then ia host claude --apply\" >&2; exit 2; }";
|
|
187
187
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard-registration.d.ts","sourceRoot":"","sources":["../src/guard-registration.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAejD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAoB/C,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AACpF,UAAU,IAAI;IACZ,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AACD,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS;QACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;QACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;QACjC,QAAQ,CAAC,OAAO,E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AM,GACZ,OAAO,CAaT;AACD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,EAChE,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,OAAO,CAGT"}
|
|
@@ -50,7 +50,7 @@ function fixedGroup(matcher, launcher, args, platform) {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
const GUARD_TIMEOUT = 10;
|
|
53
|
-
/**
|
|
53
|
+
/** Explicit root, not claude-guard's CLAUDE_PROJECT_DIR, so the recorded root is the one run; on POSIX through `/bin/sh`, so a guard that cannot run denies (`FAIL_CLOSED`). */
|
|
54
54
|
export function guardGroup(launcher, root, platform = process.platform) {
|
|
55
55
|
return fixedGroup(GUARD_MATCHER, launcher, ['--root', root], platform);
|
|
56
56
|
}
|
|
@@ -243,7 +243,7 @@ function planGuardWith(root, cache, removeId) {
|
|
|
243
243
|
const group = cache ? guardGroup(cache.launcher, root) : null, remaining = rows.filter((_row, at) => !matching.includes(at));
|
|
244
244
|
if (group && remaining.some((row) => json(row) === json(group)))
|
|
245
245
|
fail('LOCAL-MODIFICATION', 'An unmanaged identical guard group already exists');
|
|
246
|
-
// In place
|
|
246
|
+
// In place: replace or append the owned group, or remove it by index; every other byte is kept.
|
|
247
247
|
const existing = prior ? keptPaths(prior.existing, containers) : presentJson(before.config, containers), owned = ['hooks', 'PreToolUse', prior ? matching[0] : -1];
|
|
248
248
|
const edited = gone ? before.config : editJson(before.config, owned, group ?? undefined, existing), nextConfig = !gone && prior?.created && emptyJson(edited) ? null : edited;
|
|
249
249
|
const after = {
|
|
@@ -474,7 +474,7 @@ function planHooksWith(root, cache, desired, removeId) {
|
|
|
474
474
|
for (const [hook, group] of wanted)
|
|
475
475
|
if (rows.some((row, index) => !claimed.has(index) && json(row) === json(group)))
|
|
476
476
|
fail('LOCAL-MODIFICATION', `An unmanaged identical hook group already exists for ${hook}`);
|
|
477
|
-
// In place
|
|
477
|
+
// In place: replace each owned group whose derivation changed at its own index, append each new one in
|
|
478
478
|
// identity order, then remove the unwanted ones from the highest index down; every other byte is kept.
|
|
479
479
|
const existing = prior ? keptPaths(prior.existing, containers) : presentJson(before.config, containers);
|
|
480
480
|
let edited = before.config;
|
|
@@ -638,7 +638,7 @@ export function recoverGuardRegistration(rootInput) {
|
|
|
638
638
|
* and any failure to run the guard at all exits 2, naming the remedy on stderr, which Claude Code shows with the block.
|
|
639
639
|
* Claude Code lets a tool call through when a hook command cannot start or fails any other way, and blocks only on exit 2 or
|
|
640
640
|
* a deny (code.claude.com/docs/en/hooks); the guard's own decisions exit 0 and pass through unchanged. win32 has no
|
|
641
|
-
* `/bin/sh` and keeps the direct form, which still fails open
|
|
641
|
+
* `/bin/sh` and keeps the direct form, which still fails open.
|
|
642
642
|
*/
|
|
643
643
|
export const FAIL_CLOSED = '"$0" "$@" || { echo "IA steward guard could not run: run ia doctor, then ia host claude --apply" >&2; exit 2; }';
|
|
644
644
|
/**
|