@sentropic/artifacts 0.2.20 → 0.2.21
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/CHANGELOG.md +14 -0
- package/dist/mcp-core.d.ts +1 -1
- package/dist/mcp-core.js +1 -1
- package/dist/server/build-contract.d.ts +15 -1
- package/dist/server/build-contract.js +14 -5
- package/dist/server/build-dependencies.d.ts +12 -1
- package/dist/server/build-dependencies.js +41 -13
- package/dist/server/build-integrity.d.ts +48 -0
- package/dist/server/build-integrity.js +70 -0
- package/dist/server/build-output.d.ts +22 -0
- package/dist/server/build-output.js +40 -0
- package/dist/server/build-receipt.d.ts +51 -0
- package/dist/server/build-receipt.js +76 -0
- package/dist/server/failures.d.ts +2 -2
- package/dist/server/failures.js +1 -1
- package/dist/server/live-mutations.d.ts +1 -1
- package/dist/server/live-mutations.js +3 -2
- package/dist/server/live-read.d.ts +1 -1
- package/dist/server/live-read.js +2 -1
- package/dist/server/live-store.d.ts +2 -1
- package/dist/server/live-store.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.21
|
|
4
|
+
|
|
5
|
+
- Add the GB1 build validators on `@sentropic/artifacts/server/build-contract`: full dependency
|
|
6
|
+
integrity coverage with a sealed host integrity map (`dependency_integrity_missing`,
|
|
7
|
+
`dependency_integrity_mismatch`), script-package qualification rows, the mandatory
|
|
8
|
+
builder-attested receipt schema and verifier (§8.4 join, served-byte anti-repack), and the
|
|
9
|
+
candidate output ceiling gate (`dist_over_limits`). Tarball-bundled dependencies are exempt
|
|
10
|
+
from the lock closure check. Additive; no new export path.
|
|
11
|
+
- The live runtime record follows A-LIVE Amendment 1: `idleDeadline` is 900 s after the last
|
|
12
|
+
access and the absolute `maximumLifetimeAt` is removed.
|
|
13
|
+
- `@sentropic/artifacts/live-host` is unchanged (HostLedger and AcceptOptions frozen).
|
|
14
|
+
- `ARTIFACTS_PROVIDER_VERSION` is `0.2.21` (it equals the package version). Tool definitions are
|
|
15
|
+
unchanged; the provider manifest digest changes only through `version`.
|
|
16
|
+
|
|
3
17
|
## 0.2.20
|
|
4
18
|
|
|
5
19
|
- Add the `@sentropic/artifacts/live-host` subpath: single live-host candidate digest with pinned vectors,
|
package/dist/mcp-core.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { createRadarKeyDerivation } from './server/command-identity.js';
|
|
|
10
10
|
export type { ArtifactKeyDerivationBinding } from './server/command-identity.js';
|
|
11
11
|
export declare const ARTIFACTS_PROVIDER_ID = "sentropic.artifacts";
|
|
12
12
|
export declare const ARTIFACTS_APP_ID = "sentropic-artifacts";
|
|
13
|
-
export declare const ARTIFACTS_PROVIDER_VERSION = "0.2.
|
|
13
|
+
export declare const ARTIFACTS_PROVIDER_VERSION = "0.2.21";
|
|
14
14
|
export declare const ARTIFACTS_TOOL_NAMES: readonly ["artifacts_get_template", "artifacts_get_api_guide", "artifacts_ensure", "artifacts_publish", "artifacts_create_upload", "artifacts_commit_upload", "artifacts_list", "artifacts_get", "artifacts_get_source", "artifacts_fork", "artifacts_set_access", "artifacts_promote", "artifacts_renew", "artifacts_delete", "artifacts_restore", "artifacts_list_versions", "artifacts_revert", "artifacts_lookup_people", "artifacts_list_access", "artifacts_publish_bundle", "artifacts_revoke_reader_consent", "artifacts_create_upload_page", "artifacts_list_assets", "artifacts_publish_bundle_v2", "artifacts_list_app_sources", "artifacts_fetch_app_source", "artifacts_git_attach", "artifacts_git_commit", "artifacts_git_publish", "artifacts_git_live", "artifacts_live_write", "artifacts_live_read", "artifacts_live_reset", "artifacts_live_status", "artifacts_live_control"];
|
|
15
15
|
export type ArtifactsToolName = (typeof ARTIFACTS_TOOL_NAMES)[number];
|
|
16
16
|
export interface ArtifactsToolDefinition {
|
package/dist/mcp-core.js
CHANGED
|
@@ -7,7 +7,7 @@ export * from './profile/index.js';
|
|
|
7
7
|
export { createRadarKeyDerivation } from './server/command-identity.js';
|
|
8
8
|
export const ARTIFACTS_PROVIDER_ID = 'sentropic.artifacts';
|
|
9
9
|
export const ARTIFACTS_APP_ID = 'sentropic-artifacts';
|
|
10
|
-
export const ARTIFACTS_PROVIDER_VERSION = '0.2.
|
|
10
|
+
export const ARTIFACTS_PROVIDER_VERSION = '0.2.21';
|
|
11
11
|
export const ARTIFACTS_TOOL_NAMES = ARTIFACT_CAPABILITY_NAMES;
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
13
13
|
// Byte-stable tool definitions (MCP tool-definition stability rule).
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { type HostIntegrityMap } from './build-integrity.js';
|
|
2
|
+
/** Named GB1 port for the supervisor (W3) and the builder service (W7); one public subpath. */
|
|
3
|
+
export { approvedIntegrity, hostIntegrityMapDigest, lockfileSha256, type DependencyIntegrityInventory, type DependencyIntegrityRecord, type HostIntegrityMap, type HostIntegrityMapEntry, } from './build-integrity.js';
|
|
4
|
+
export type { BuildDependencyEvidence, ScriptQualificationRecord } from './build-dependencies.js';
|
|
5
|
+
export { validateBuildOutput, type AdmittedOutputFile, type BuildOutputEntry } from './build-output.js';
|
|
6
|
+
export { candidateInventoryDigest, verifyBuilderReceipt, verifyServedCandidate, type BuilderAttestedEvidence, type BuilderReceiptExpectation, type BuilderReceiptMismatch, type CandidateFileDigest, } from './build-receipt.js';
|
|
1
7
|
/** Frozen G0 v3 §4.1 fields. Install permissions belong to the host. */
|
|
2
8
|
export interface ArtifactBuildDescriptor {
|
|
3
9
|
readonly version: 1;
|
|
@@ -17,6 +23,10 @@ export interface ArtifactBuildSnapshot {
|
|
|
17
23
|
readonly subPath: string;
|
|
18
24
|
readonly files: Readonly<Record<string, string>>;
|
|
19
25
|
readonly postinstallAllowlist?: readonly PostinstallAllowlistEntry[];
|
|
26
|
+
/** Host qualification rows for disabled hooks (A-LIVE §7.3); never an execution grant. */
|
|
27
|
+
readonly scriptQualification?: readonly PostinstallAllowlistEntry[];
|
|
28
|
+
/** Host-sealed integrity map for entries lacking literal SRI (A-LIVE §7.2). */
|
|
29
|
+
readonly integrityMap?: HostIntegrityMap;
|
|
20
30
|
readonly allowedRegistries?: readonly string[];
|
|
21
31
|
}
|
|
22
32
|
export interface ArtifactBuildTuple {
|
|
@@ -49,7 +59,12 @@ export declare function buildJson(text: string | undefined): Record<string, unkn
|
|
|
49
59
|
export declare function buildPath(value: unknown): value is string;
|
|
50
60
|
/** Validation only: no filesystem, network, install, shell or script execution. */
|
|
51
61
|
export declare function validateArtifactBuild(snapshot: ArtifactBuildSnapshot): {
|
|
62
|
+
readonly postinstall: readonly PostinstallAllowlistEntry[];
|
|
63
|
+
readonly scriptQualification: readonly import("./build-dependencies.js").ScriptQualificationRecord[];
|
|
64
|
+
readonly integrity: import("./build-integrity.js").DependencyIntegrityInventory;
|
|
52
65
|
readonly descriptor: ArtifactBuildDescriptor;
|
|
66
|
+
readonly descriptorDigest: string;
|
|
67
|
+
readonly lockfileDigest: string;
|
|
53
68
|
readonly installDirectory: string;
|
|
54
69
|
readonly scriptDirectory: string;
|
|
55
70
|
readonly install: {
|
|
@@ -60,5 +75,4 @@ export declare function validateArtifactBuild(snapshot: ArtifactBuildSnapshot):
|
|
|
60
75
|
readonly command: "npm";
|
|
61
76
|
readonly args: readonly ["run", string];
|
|
62
77
|
};
|
|
63
|
-
readonly postinstall: readonly PostinstallAllowlistEntry[];
|
|
64
78
|
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { ArtifactOperationError } from './failures.js';
|
|
2
2
|
import { validateBuildDependencies } from './build-dependencies.js';
|
|
3
|
+
import { lockfileSha256, sha256Hex } from './build-integrity.js';
|
|
4
|
+
/** Named GB1 port for the supervisor (W3) and the builder service (W7); one public subpath. */
|
|
5
|
+
export { approvedIntegrity, hostIntegrityMapDigest, lockfileSha256, } from './build-integrity.js';
|
|
6
|
+
export { validateBuildOutput } from './build-output.js';
|
|
7
|
+
export { candidateInventoryDigest, verifyBuilderReceipt, verifyServedCandidate, } from './build-receipt.js';
|
|
3
8
|
export function buildRecord(value) {
|
|
4
9
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
5
10
|
}
|
|
@@ -23,7 +28,8 @@ export function validateArtifactBuild(snapshot) {
|
|
|
23
28
|
const invalid = () => { throw new ArtifactOperationError('build_descriptor_invalid'); };
|
|
24
29
|
if (snapshot.subPath !== '' && !buildPath(snapshot.subPath))
|
|
25
30
|
invalid();
|
|
26
|
-
const
|
|
31
|
+
const descriptorText = snapshot.files[join(snapshot.subPath, 'sentropic.artifact.json')];
|
|
32
|
+
const value = buildJson(descriptorText);
|
|
27
33
|
const fields = ['version', 'buildScript', 'outputDir', 'lockfilePath', 'entry', 'publicEnvNames'];
|
|
28
34
|
if (Object.keys(value).some(key => !fields.includes(key)) || value.version !== 1
|
|
29
35
|
|| typeof value.buildScript !== 'string' || !/^[A-Za-z0-9:_-]+$/.test(value.buildScript)
|
|
@@ -42,17 +48,20 @@ export function validateArtifactBuild(snapshot) {
|
|
|
42
48
|
throw new ArtifactOperationError('build_script_missing');
|
|
43
49
|
if (!Object.hasOwn(snapshot.files, descriptor.lockfilePath))
|
|
44
50
|
throw new ArtifactOperationError('lock_missing');
|
|
45
|
-
const
|
|
51
|
+
const lockText = snapshot.files[descriptor.lockfilePath];
|
|
52
|
+
const lock = buildJson(lockText);
|
|
46
53
|
const installDirectory = descriptor.lockfilePath.includes('/')
|
|
47
54
|
? descriptor.lockfilePath.slice(0, descriptor.lockfilePath.lastIndexOf('/')) : '';
|
|
48
55
|
if (installDirectory && snapshot.subPath !== installDirectory
|
|
49
56
|
&& !snapshot.subPath.startsWith(`${installDirectory}/`))
|
|
50
57
|
invalid();
|
|
51
|
-
const
|
|
58
|
+
const lockfileDigest = lockfileSha256(lockText);
|
|
59
|
+
const evidence = validateBuildDependencies(snapshot, lock, installDirectory, lockfileDigest);
|
|
52
60
|
return {
|
|
53
|
-
descriptor,
|
|
61
|
+
descriptor, descriptorDigest: sha256Hex(descriptorText), lockfileDigest,
|
|
62
|
+
installDirectory, scriptDirectory: snapshot.subPath,
|
|
54
63
|
install: { command: 'npm', args: ['ci', '--ignore-scripts'] },
|
|
55
64
|
build: { command: 'npm', args: ['run', descriptor.buildScript] },
|
|
56
|
-
|
|
65
|
+
...evidence,
|
|
57
66
|
};
|
|
58
67
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
import type { ArtifactBuildSnapshot, PostinstallAllowlistEntry } from './build-contract.js';
|
|
2
|
+
import { type DependencyIntegrityInventory } from './build-integrity.js';
|
|
3
|
+
/** A-LIVE §7.3 host qualification row: literal lockfile SRI only; disabled rows never authorize execution. */
|
|
4
|
+
export interface ScriptQualificationRecord extends PostinstallAllowlistEntry {
|
|
5
|
+
readonly source: 'lockfile';
|
|
6
|
+
readonly execution: 'disabled' | 'allowlisted';
|
|
7
|
+
}
|
|
8
|
+
export interface BuildDependencyEvidence {
|
|
9
|
+
readonly postinstall: readonly PostinstallAllowlistEntry[];
|
|
10
|
+
readonly scriptQualification: readonly ScriptQualificationRecord[];
|
|
11
|
+
readonly integrity: DependencyIntegrityInventory;
|
|
12
|
+
}
|
|
2
13
|
/** Validate the lock-indexed install closure, including host-owned lifecycle permissions. */
|
|
3
|
-
export declare function validateBuildDependencies(snapshot: ArtifactBuildSnapshot, lock: Record<string, unknown>, installDirectory: string):
|
|
14
|
+
export declare function validateBuildDependencies(snapshot: ArtifactBuildSnapshot, lock: Record<string, unknown>, installDirectory: string, lockfileDigest: string): BuildDependencyEvidence;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ArtifactOperationError } from './failures.js';
|
|
2
2
|
import { buildJson, buildPath, buildRecord } from './build-contract.js';
|
|
3
|
+
import { dependencyIntegrity } from './build-integrity.js';
|
|
3
4
|
const sections = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
|
|
4
5
|
function refuse() { throw new ArtifactOperationError('dep_outside_lock'); }
|
|
6
|
+
const SEMVER = /^\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?(?:\+[A-Za-z0-9.-]+)?$/;
|
|
5
7
|
function registryUrl(value, registries) {
|
|
6
8
|
if (typeof value !== 'string')
|
|
7
9
|
return false;
|
|
@@ -25,7 +27,7 @@ function registrySpec(value) {
|
|
|
25
27
|
return /^[A-Za-z0-9~^*<>=| .+-]+$/.test(alias ? alias[1] : value);
|
|
26
28
|
}
|
|
27
29
|
/** Validate the lock-indexed install closure, including host-owned lifecycle permissions. */
|
|
28
|
-
export function validateBuildDependencies(snapshot, lock, installDirectory) {
|
|
30
|
+
export function validateBuildDependencies(snapshot, lock, installDirectory, lockfileDigest) {
|
|
29
31
|
if ((lock.lockfileVersion !== 2 && lock.lockfileVersion !== 3) || !buildRecord(lock.packages)
|
|
30
32
|
|| !buildRecord(lock.packages['']))
|
|
31
33
|
throw new ArtifactOperationError('build_descriptor_invalid');
|
|
@@ -42,7 +44,10 @@ export function validateBuildDependencies(snapshot, lock, installDirectory) {
|
|
|
42
44
|
};
|
|
43
45
|
const registries = snapshot.allowedRegistries ?? ['https://registry.npmjs.org/'];
|
|
44
46
|
const allowlist = snapshot.postinstallAllowlist ?? [];
|
|
47
|
+
const qualified = snapshot.scriptQualification ?? [];
|
|
45
48
|
const postinstall = [];
|
|
49
|
+
const scriptQualification = [];
|
|
50
|
+
const lockName = (path, raw) => typeof raw.name === 'string' ? raw.name : path.split('node_modules/').at(-1);
|
|
46
51
|
const repositoryPath = (path) => installDirectory ? `${installDirectory}/${path}` : path;
|
|
47
52
|
const workspaceTargets = new Set();
|
|
48
53
|
for (const [path, raw] of Object.entries(packages)) {
|
|
@@ -60,18 +65,33 @@ export function validateBuildDependencies(snapshot, lock, installDirectory) {
|
|
|
60
65
|
refuse();
|
|
61
66
|
}
|
|
62
67
|
}
|
|
68
|
+
const remote = [];
|
|
69
|
+
for (const [path, raw] of Object.entries(packages)) {
|
|
70
|
+
if (!buildRecord(raw) || raw.link === true || path === '' || workspaceTargets.has(path))
|
|
71
|
+
continue;
|
|
72
|
+
const name = lockName(path, raw);
|
|
73
|
+
if ((raw.resolved !== undefined && !registryUrl(raw.resolved, registries)) || typeof name !== 'string'
|
|
74
|
+
|| typeof raw.version !== 'string' || !SEMVER.test(raw.version))
|
|
75
|
+
refuse();
|
|
76
|
+
remote.push({ path, name, version: raw.version, resolved: raw.resolved, integrity: raw.integrity });
|
|
77
|
+
}
|
|
78
|
+
// Every remote byte sequence is covered before any dependency or script rule admits the lock.
|
|
79
|
+
const integrity = dependencyIntegrity(remote, lockfileDigest, snapshot.integrityMap, value => registryUrl(value, registries));
|
|
80
|
+
const evidence = new Map(integrity.entries.map(entry => [entry.path, entry]));
|
|
63
81
|
for (const [path, raw] of Object.entries(packages)) {
|
|
64
82
|
if (!buildRecord(raw))
|
|
65
83
|
refuse();
|
|
66
84
|
if (raw.link === true)
|
|
67
85
|
continue;
|
|
68
86
|
const local = path === '' || workspaceTargets.has(path);
|
|
69
|
-
if (!local && (!registryUrl(raw.resolved, registries) || typeof raw.version !== 'string'
|
|
70
|
-
|| !/^\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?(?:\+[A-Za-z0-9.-]+)?$/.test(raw.version)
|
|
71
|
-
|| typeof raw.integrity !== 'string' || !raw.integrity))
|
|
72
|
-
refuse();
|
|
73
87
|
const manifestPath = repositoryPath(path ? `${path}/package.json` : 'package.json');
|
|
74
88
|
const manifest = local ? buildJson(snapshot.files[manifestPath]) : raw;
|
|
89
|
+
// Bundled dependencies ship inside the locked tarball, whose verified integrity covers their bytes.
|
|
90
|
+
const bundle = local ? undefined : raw.bundleDependencies;
|
|
91
|
+
if (bundle !== undefined && bundle !== true
|
|
92
|
+
&& (!Array.isArray(bundle) || bundle.some(name => typeof name !== 'string')))
|
|
93
|
+
refuse();
|
|
94
|
+
const bundled = (name) => bundle === true || (Array.isArray(bundle) && bundle.includes(name));
|
|
75
95
|
for (const source of [raw, manifest]) {
|
|
76
96
|
for (const section of sections) {
|
|
77
97
|
const dependencies = source[section];
|
|
@@ -83,7 +103,7 @@ export function validateBuildDependencies(snapshot, lock, installDirectory) {
|
|
|
83
103
|
if (!registrySpec(spec) || !/^(?:@[A-Za-z0-9._-]+\/)?[A-Za-z0-9._-]+$/.test(name))
|
|
84
104
|
refuse();
|
|
85
105
|
if ((section === 'dependencies' || (local && section === 'devDependencies'))
|
|
86
|
-
&& !lockedPackage(path, name))
|
|
106
|
+
&& !(section === 'dependencies' && bundled(name)) && !lockedPackage(path, name))
|
|
87
107
|
refuse();
|
|
88
108
|
}
|
|
89
109
|
}
|
|
@@ -106,17 +126,25 @@ export function validateBuildDependencies(snapshot, lock, installDirectory) {
|
|
|
106
126
|
|| ['preinstall', 'install', 'postinstall', 'prepare'].some(name => Object.hasOwn(scripts, name));
|
|
107
127
|
if (!hasScript)
|
|
108
128
|
continue;
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
129
|
+
// Only a literal lockfile SRI can close the exact G0 triple; a host-map value never qualifies (A-LIVE §7.3).
|
|
130
|
+
const record = evidence.get(path);
|
|
131
|
+
const entry = { package: local ? manifest.name : lockName(path, raw), version: raw.version,
|
|
132
|
+
integrity: record?.source === 'lockfile' ? record.integrity : undefined };
|
|
133
|
+
if (typeof entry.package !== 'string' || typeof entry.version !== 'string' || entry.integrity === undefined) {
|
|
114
134
|
throw new ArtifactOperationError('install_script_not_allowlisted');
|
|
115
135
|
}
|
|
116
|
-
|
|
136
|
+
const triple = { package: entry.package, version: entry.version, integrity: entry.integrity };
|
|
137
|
+
const same = (row) => row.package === triple.package
|
|
138
|
+
&& row.version === triple.version && row.integrity === triple.integrity;
|
|
139
|
+
const execution = allowlist.some(same) ? 'allowlisted' : qualified.some(same) ? 'disabled' : undefined;
|
|
140
|
+
if (execution === undefined)
|
|
141
|
+
throw new ArtifactOperationError('install_script_not_allowlisted');
|
|
142
|
+
if (execution === 'allowlisted')
|
|
143
|
+
postinstall.push(triple);
|
|
144
|
+
scriptQualification.push({ ...triple, source: 'lockfile', execution });
|
|
117
145
|
}
|
|
118
146
|
const scriptKey = snapshot.subPath.slice(installDirectory ? installDirectory.length + 1 : 0);
|
|
119
147
|
if (scriptKey && !workspaceTargets.has(scriptKey))
|
|
120
148
|
refuse();
|
|
121
|
-
return postinstall;
|
|
149
|
+
return { postinstall, scriptQualification, integrity };
|
|
122
150
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** A-LIVE §7.2: host-sealed value for one lock entry; never supplied by the branch or the cache. */
|
|
2
|
+
export interface HostIntegrityMapEntry {
|
|
3
|
+
readonly path: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly version: string;
|
|
6
|
+
readonly registryUrl: string;
|
|
7
|
+
readonly integrity: string;
|
|
8
|
+
}
|
|
9
|
+
/** Immutable host map tied to the exact lock bytes; the host authenticates its seal before use. */
|
|
10
|
+
export interface HostIntegrityMap {
|
|
11
|
+
readonly lockfileDigest: string;
|
|
12
|
+
readonly entries: readonly HostIntegrityMapEntry[];
|
|
13
|
+
}
|
|
14
|
+
/** Remote lock entry fields the coverage rule reads; `resolved` is already an approved URL. */
|
|
15
|
+
export interface RemoteLockEntry {
|
|
16
|
+
readonly path: string;
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly version: string;
|
|
19
|
+
readonly resolved?: string;
|
|
20
|
+
readonly integrity?: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface DependencyIntegrityRecord {
|
|
23
|
+
readonly path: string;
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly version: string;
|
|
26
|
+
readonly registryUrl: string;
|
|
27
|
+
readonly integrity: string;
|
|
28
|
+
readonly source: 'lockfile' | 'host_map';
|
|
29
|
+
}
|
|
30
|
+
/** Complete remote-package inventory; `mapDigest` binds the approved map into cache and build receipts. */
|
|
31
|
+
export interface DependencyIntegrityInventory {
|
|
32
|
+
readonly mapDigest: string | null;
|
|
33
|
+
readonly lockfileSri: number;
|
|
34
|
+
readonly hostMap: number;
|
|
35
|
+
readonly entries: readonly DependencyIntegrityRecord[];
|
|
36
|
+
}
|
|
37
|
+
export declare const sha256Hex: (text: string) => string;
|
|
38
|
+
/** SHA-256 of the exact lockfile text read at the pinned commit. */
|
|
39
|
+
export declare const lockfileSha256: (lockText: string) => string;
|
|
40
|
+
/** npm SRI carrying at least one SHA-256-or-stronger digest; SHA-1-only or malformed values never qualify. */
|
|
41
|
+
export declare function approvedIntegrity(value: unknown): value is string;
|
|
42
|
+
/** Canonical map digest: entries ordered by path, fixed field order. */
|
|
43
|
+
export declare function hostIntegrityMapDigest(map: HostIntegrityMap): string;
|
|
44
|
+
/**
|
|
45
|
+
* Cover every remote lock entry by literal lockfile SRI or the sealed host map, before any fetch.
|
|
46
|
+
* No trust on first use, no reuse across versions or paths, no SHA-1-only pin, no contradicting value.
|
|
47
|
+
*/
|
|
48
|
+
export declare function dependencyIntegrity(remote: readonly RemoteLockEntry[], lockfileDigest: string, map: HostIntegrityMap | undefined, approvedRegistryUrl: (url: unknown) => boolean): DependencyIntegrityInventory;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { ArtifactOperationError } from './failures.js';
|
|
3
|
+
export const sha256Hex = (text) => createHash('sha256').update(text, 'utf8').digest('hex');
|
|
4
|
+
/** SHA-256 of the exact lockfile text read at the pinned commit. */
|
|
5
|
+
export const lockfileSha256 = (lockText) => sha256Hex(lockText);
|
|
6
|
+
const SRI_BYTES = { sha256: 32, sha384: 48, sha512: 64 };
|
|
7
|
+
/** npm SRI carrying at least one SHA-256-or-stronger digest; SHA-1-only or malformed values never qualify. */
|
|
8
|
+
export function approvedIntegrity(value) {
|
|
9
|
+
if (typeof value !== 'string' || value.length > 1024)
|
|
10
|
+
return false;
|
|
11
|
+
let strong = false;
|
|
12
|
+
for (const token of value.split(' ')) {
|
|
13
|
+
const match = /^(sha1|sha256|sha384|sha512)-([A-Za-z0-9+/]+={0,2})$/.exec(token);
|
|
14
|
+
if (!match)
|
|
15
|
+
return false;
|
|
16
|
+
const bytes = SRI_BYTES[match[1]];
|
|
17
|
+
if (bytes === undefined)
|
|
18
|
+
continue;
|
|
19
|
+
if (match[2].length !== Math.ceil(bytes / 3) * 4 || Buffer.from(match[2], 'base64').length !== bytes)
|
|
20
|
+
return false;
|
|
21
|
+
strong = true;
|
|
22
|
+
}
|
|
23
|
+
return strong;
|
|
24
|
+
}
|
|
25
|
+
/** Canonical map digest: entries ordered by path, fixed field order. */
|
|
26
|
+
export function hostIntegrityMapDigest(map) {
|
|
27
|
+
const rows = map.entries.map(entry => [entry.path, entry.name, entry.version, entry.registryUrl, entry.integrity]);
|
|
28
|
+
rows.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));
|
|
29
|
+
return sha256Hex(JSON.stringify(['sentropic.integrity-map/v1', map.lockfileDigest, rows]));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Cover every remote lock entry by literal lockfile SRI or the sealed host map, before any fetch.
|
|
33
|
+
* No trust on first use, no reuse across versions or paths, no SHA-1-only pin, no contradicting value.
|
|
34
|
+
*/
|
|
35
|
+
export function dependencyIntegrity(remote, lockfileDigest, map, approvedRegistryUrl) {
|
|
36
|
+
const mismatch = () => { throw new ArtifactOperationError('dependency_integrity_mismatch'); };
|
|
37
|
+
const mapped = new Map();
|
|
38
|
+
if (map !== undefined) {
|
|
39
|
+
if (map?.lockfileDigest !== lockfileDigest || !Array.isArray(map.entries))
|
|
40
|
+
mismatch();
|
|
41
|
+
const locked = new Map(remote.map(entry => [entry.path, entry]));
|
|
42
|
+
for (const entry of map.entries) {
|
|
43
|
+
const lock = locked.get(entry?.path);
|
|
44
|
+
if (lock === undefined || mapped.has(entry.path) || entry.name !== lock.name || entry.version !== lock.version
|
|
45
|
+
|| !approvedRegistryUrl(entry.registryUrl) || !approvedIntegrity(entry.integrity)
|
|
46
|
+
|| (lock.resolved !== undefined && lock.resolved !== entry.registryUrl)
|
|
47
|
+
|| (approvedIntegrity(lock.integrity) && lock.integrity !== entry.integrity))
|
|
48
|
+
mismatch();
|
|
49
|
+
mapped.set(entry.path, entry);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const entries = remote.map((lock) => {
|
|
53
|
+
const host = mapped.get(lock.path);
|
|
54
|
+
const literal = approvedIntegrity(lock.integrity) ? lock.integrity : undefined;
|
|
55
|
+
if (literal === undefined && host === undefined)
|
|
56
|
+
throw new ArtifactOperationError('dependency_integrity_missing');
|
|
57
|
+
const registryUrl = lock.resolved ?? host?.registryUrl;
|
|
58
|
+
// A literal pin without a locked URL names no approved registry location.
|
|
59
|
+
if (registryUrl === undefined)
|
|
60
|
+
throw new ArtifactOperationError('dep_outside_lock');
|
|
61
|
+
const base = { path: lock.path, name: lock.name, version: lock.version, registryUrl };
|
|
62
|
+
return literal !== undefined ? { ...base, integrity: literal, source: 'lockfile' }
|
|
63
|
+
: { ...base, integrity: host.integrity, source: 'host_map' };
|
|
64
|
+
});
|
|
65
|
+
const lockfileSri = entries.filter(entry => entry.source === 'lockfile').length;
|
|
66
|
+
return {
|
|
67
|
+
mapDigest: map === undefined ? null : hostIntegrityMapDigest(map),
|
|
68
|
+
lockfileSri, hostMap: entries.length - lockfileSri, entries,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type PublicationLimits } from './publication-limits.js';
|
|
2
|
+
/** One entry of the stable output snapshot, relative to the descriptor outputDir; directories are implicit. */
|
|
3
|
+
export interface BuildOutputEntry {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly kind: 'file' | 'symlink' | 'other';
|
|
6
|
+
readonly bytes: number;
|
|
7
|
+
}
|
|
8
|
+
export interface AdmittedOutputFile {
|
|
9
|
+
readonly path: string;
|
|
10
|
+
readonly bytes: number;
|
|
11
|
+
readonly mimeType: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A-LIVE §8.3 / G0 §4.1 pre-flight on the supervisor's inventory, after build processes ended and before
|
|
15
|
+
* hashing or upload: regular files only, canonical unique paths, a mapped MIME type, the descriptor entry
|
|
16
|
+
* present, and the stricter of profile and server ceilings (255 files, 16 MiB per file, 64 MiB in total).
|
|
17
|
+
* Structural faults are verification_failed; ceiling overflow is dist_over_limits; nothing is uploaded.
|
|
18
|
+
*/
|
|
19
|
+
export declare function validateBuildOutput(entries: readonly BuildOutputEntry[], options?: {
|
|
20
|
+
entry?: string;
|
|
21
|
+
limits?: Partial<PublicationLimits>;
|
|
22
|
+
}): readonly AdmittedOutputFile[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ArtifactOperationError } from './failures.js';
|
|
2
|
+
import { isWithinMimeCeiling, mimeTypeForPath } from './mime.js';
|
|
3
|
+
import { publicationLimits } from './publication-limits.js';
|
|
4
|
+
const outputPath = (value) => typeof value === 'string' && Buffer.byteLength(value) <= 1024
|
|
5
|
+
&& !/[\\%?#:\u0000-\u001f\u007f]/.test(value) && value.split('/').every(part => part !== '' && part !== '.' && part !== '..');
|
|
6
|
+
/**
|
|
7
|
+
* A-LIVE §8.3 / G0 §4.1 pre-flight on the supervisor's inventory, after build processes ended and before
|
|
8
|
+
* hashing or upload: regular files only, canonical unique paths, a mapped MIME type, the descriptor entry
|
|
9
|
+
* present, and the stricter of profile and server ceilings (255 files, 16 MiB per file, 64 MiB in total).
|
|
10
|
+
* Structural faults are verification_failed; ceiling overflow is dist_over_limits; nothing is uploaded.
|
|
11
|
+
*/
|
|
12
|
+
export function validateBuildOutput(entries, options = {}) {
|
|
13
|
+
const limits = publicationLimits(options.limits);
|
|
14
|
+
const invalid = () => { throw new ArtifactOperationError('verification_failed'); };
|
|
15
|
+
const over = () => { throw new ArtifactOperationError('dist_over_limits'); };
|
|
16
|
+
if (!Array.isArray(entries) || entries.length === 0)
|
|
17
|
+
invalid();
|
|
18
|
+
if (entries.length > limits.maxFiles)
|
|
19
|
+
over();
|
|
20
|
+
const seen = new Set();
|
|
21
|
+
let total = 0;
|
|
22
|
+
const files = entries.map((entry) => {
|
|
23
|
+
if (entry?.kind !== 'file' || !outputPath(entry.path) || seen.has(entry.path)
|
|
24
|
+
|| !Number.isSafeInteger(entry.bytes) || entry.bytes < 0)
|
|
25
|
+
invalid();
|
|
26
|
+
seen.add(entry.path);
|
|
27
|
+
const mimeType = mimeTypeForPath(entry.path);
|
|
28
|
+
if (mimeType === undefined || !isWithinMimeCeiling(mimeType))
|
|
29
|
+
return invalid();
|
|
30
|
+
if (entry.bytes > limits.maxFileBytes)
|
|
31
|
+
over();
|
|
32
|
+
total += entry.bytes;
|
|
33
|
+
if (total > limits.maxTotalBytes)
|
|
34
|
+
over();
|
|
35
|
+
return { path: entry.path, bytes: entry.bytes, mimeType };
|
|
36
|
+
});
|
|
37
|
+
if (options.entry !== undefined && !seen.has(options.entry))
|
|
38
|
+
invalid();
|
|
39
|
+
return files.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
40
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** One candidate output file as hashed by the trusted supervisor from the stable output snapshot. */
|
|
2
|
+
export interface CandidateFileDigest {
|
|
3
|
+
readonly path: string;
|
|
4
|
+
readonly bytes: number;
|
|
5
|
+
readonly sha256: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A-LIVE §8.4 builder-attested evidence, sealed outside repository code. Every field is mandatory;
|
|
9
|
+
* unknown fields are additive and ignored. releaseId/manifestDigest stay null until publication.
|
|
10
|
+
*/
|
|
11
|
+
export interface BuilderAttestedEvidence {
|
|
12
|
+
readonly storageScopeId: string;
|
|
13
|
+
readonly artifactId: string;
|
|
14
|
+
readonly bindingGeneration: number;
|
|
15
|
+
readonly jobId: string;
|
|
16
|
+
readonly runId: string;
|
|
17
|
+
readonly attempt: number;
|
|
18
|
+
readonly commitSha: string;
|
|
19
|
+
readonly treeSha: string;
|
|
20
|
+
readonly descriptorDigest: string;
|
|
21
|
+
readonly lockfileDigest: string;
|
|
22
|
+
/** Digest of the integrity-map/cache receipt that admitted the dependency closure. */
|
|
23
|
+
readonly integrityReceiptDigest: string;
|
|
24
|
+
readonly builderImageDigest: string;
|
|
25
|
+
readonly platform: string;
|
|
26
|
+
readonly nodeVersion: string;
|
|
27
|
+
readonly npmVersion: string;
|
|
28
|
+
readonly publicEnvHashes: Readonly<Record<string, string>>;
|
|
29
|
+
readonly stagingPolicy: string;
|
|
30
|
+
readonly stagingDigest: string;
|
|
31
|
+
readonly candidateDigest: string;
|
|
32
|
+
readonly candidateFiles: readonly CandidateFileDigest[];
|
|
33
|
+
readonly releaseId: string | null;
|
|
34
|
+
readonly manifestDigest: string | null;
|
|
35
|
+
}
|
|
36
|
+
/** Server-resolved job, sealed handoff and admitted inputs the evidence must join exactly. */
|
|
37
|
+
export type BuilderReceiptExpectation = Pick<BuilderAttestedEvidence, typeof JOINS[number][0]>;
|
|
38
|
+
/** Closed `git_build_job_mismatch` reasons; no foreign job, scope or digest value is disclosed. */
|
|
39
|
+
export type BuilderReceiptMismatch = 'scope' | 'job' | 'source' | 'inputs' | 'candidate';
|
|
40
|
+
declare const JOINS: readonly [readonly ["storageScopeId", "scope"], readonly ["artifactId", "scope"], readonly ["bindingGeneration", "scope"], readonly ["jobId", "job"], readonly ["runId", "job"], readonly ["attempt", "job"], readonly ["commitSha", "source"], readonly ["treeSha", "source"], readonly ["descriptorDigest", "inputs"], readonly ["lockfileDigest", "inputs"], readonly ["integrityReceiptDigest", "inputs"], readonly ["builderImageDigest", "inputs"], readonly ["platform", "inputs"], readonly ["publicEnvHashes", "inputs"], readonly ["stagingPolicy", "inputs"], readonly ["stagingDigest", "inputs"], readonly ["candidateDigest", "candidate"]];
|
|
41
|
+
/** Canonical candidate manifest digest over every file (path, size, SHA-256); file order is irrelevant. */
|
|
42
|
+
export declare function candidateInventoryDigest(files: readonly CandidateFileDigest[]): string;
|
|
43
|
+
/**
|
|
44
|
+
* Pure verdict (BR-82 pattern, G0 §4.3): mandatory schema, candidate digest recomputed from the complete
|
|
45
|
+
* file inventory, then the exact join against server evidence. Authentication, single use and expiry of
|
|
46
|
+
* the supervisor handoff belong to the SG4b handoff, not to this function.
|
|
47
|
+
*/
|
|
48
|
+
export declare function verifyBuilderReceipt(evidence: unknown, expected: BuilderReceiptExpectation): BuilderAttestedEvidence;
|
|
49
|
+
/** Anti-repack: the re-read uploaded bytes must hash to the sealed candidate digest. */
|
|
50
|
+
export declare function verifyServedCandidate(evidence: BuilderAttestedEvidence, served: readonly CandidateFileDigest[]): void;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { sha256Hex } from './build-integrity.js';
|
|
2
|
+
import { ArtifactOperationError } from './failures.js';
|
|
3
|
+
import { isGitSha } from './git-port-policy.js';
|
|
4
|
+
import { SERVER_MAX_FILES_PER_RELEASE, SERVER_MAX_FILE_BYTES } from './publication-limits.js';
|
|
5
|
+
const JOINS = [
|
|
6
|
+
['storageScopeId', 'scope'], ['artifactId', 'scope'], ['bindingGeneration', 'scope'],
|
|
7
|
+
['jobId', 'job'], ['runId', 'job'], ['attempt', 'job'], ['commitSha', 'source'], ['treeSha', 'source'],
|
|
8
|
+
['descriptorDigest', 'inputs'], ['lockfileDigest', 'inputs'], ['integrityReceiptDigest', 'inputs'],
|
|
9
|
+
['builderImageDigest', 'inputs'], ['platform', 'inputs'], ['publicEnvHashes', 'inputs'],
|
|
10
|
+
['stagingPolicy', 'inputs'], ['stagingDigest', 'inputs'], ['candidateDigest', 'candidate'],
|
|
11
|
+
];
|
|
12
|
+
const HEX = /^[a-f0-9]{64}$/;
|
|
13
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
14
|
+
const VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
15
|
+
const id = (value) => typeof value === 'string' && value.length > 0 && value.length <= 256
|
|
16
|
+
&& value.trim() === value && !/[\u0000-\u001f\u007f]/.test(value);
|
|
17
|
+
const count = (value, min) => Number.isSafeInteger(value) && value >= min;
|
|
18
|
+
const record = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
19
|
+
const path = (value) => typeof value === 'string' && Buffer.byteLength(value) <= 1024
|
|
20
|
+
&& !/[\\%?#:\u0000-\u001f\u007f]/.test(value) && value.split('/').every(part => part !== '' && part !== '.' && part !== '..');
|
|
21
|
+
const canonicalEnv = (hashes) => JSON.stringify(Object.entries(hashes).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
|
|
22
|
+
/** Canonical candidate manifest digest over every file (path, size, SHA-256); file order is irrelevant. */
|
|
23
|
+
export function candidateInventoryDigest(files) {
|
|
24
|
+
const rows = files.map(file => [file.path, file.bytes, file.sha256]);
|
|
25
|
+
rows.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));
|
|
26
|
+
return sha256Hex(JSON.stringify(['sentropic.build-candidate/v1', rows]));
|
|
27
|
+
}
|
|
28
|
+
function schema(value) {
|
|
29
|
+
if (!record(value))
|
|
30
|
+
return false;
|
|
31
|
+
const files = value.candidateFiles;
|
|
32
|
+
const env = value.publicEnvHashes;
|
|
33
|
+
return id(value.storageScopeId) && typeof value.artifactId === 'string' && UUID.test(value.artifactId)
|
|
34
|
+
&& count(value.bindingGeneration, 1) && id(value.jobId) && id(value.runId) && count(value.attempt, 1)
|
|
35
|
+
&& typeof value.commitSha === 'string' && isGitSha(value.commitSha)
|
|
36
|
+
&& typeof value.treeSha === 'string' && isGitSha(value.treeSha)
|
|
37
|
+
&& [value.descriptorDigest, value.lockfileDigest, value.integrityReceiptDigest, value.stagingDigest,
|
|
38
|
+
value.candidateDigest].every(digest => typeof digest === 'string' && HEX.test(digest))
|
|
39
|
+
&& typeof value.builderImageDigest === 'string' && /^sha256:[a-f0-9]{64}$/.test(value.builderImageDigest)
|
|
40
|
+
&& typeof value.platform === 'string' && /^[a-z0-9]+\/[a-z0-9_]+(?:\/[a-z0-9]+)?$/.test(value.platform)
|
|
41
|
+
&& typeof value.nodeVersion === 'string' && VERSION.test(value.nodeVersion)
|
|
42
|
+
&& typeof value.npmVersion === 'string' && VERSION.test(value.npmVersion)
|
|
43
|
+
&& record(env) && Object.entries(env).every(([name, hash]) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(name)
|
|
44
|
+
&& typeof hash === 'string' && HEX.test(hash))
|
|
45
|
+
&& id(value.stagingPolicy)
|
|
46
|
+
&& (value.releaseId === null || (typeof value.releaseId === 'string' && UUID.test(value.releaseId)))
|
|
47
|
+
&& (value.manifestDigest === null || (typeof value.manifestDigest === 'string' && HEX.test(value.manifestDigest)))
|
|
48
|
+
&& Array.isArray(files) && files.length > 0 && files.length <= SERVER_MAX_FILES_PER_RELEASE
|
|
49
|
+
&& new Set(files.map(file => file?.path)).size === files.length
|
|
50
|
+
&& files.every(file => record(file) && path(file.path) && count(file.bytes, 0)
|
|
51
|
+
&& file.bytes <= SERVER_MAX_FILE_BYTES && typeof file.sha256 === 'string' && HEX.test(file.sha256));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Pure verdict (BR-82 pattern, G0 §4.3): mandatory schema, candidate digest recomputed from the complete
|
|
55
|
+
* file inventory, then the exact join against server evidence. Authentication, single use and expiry of
|
|
56
|
+
* the supervisor handoff belong to the SG4b handoff, not to this function.
|
|
57
|
+
*/
|
|
58
|
+
export function verifyBuilderReceipt(evidence, expected) {
|
|
59
|
+
if (!schema(evidence) || candidateInventoryDigest(evidence.candidateFiles) !== evidence.candidateDigest) {
|
|
60
|
+
throw new ArtifactOperationError('verification_failed');
|
|
61
|
+
}
|
|
62
|
+
for (const [key, reason] of JOINS) {
|
|
63
|
+
const same = key === 'publicEnvHashes'
|
|
64
|
+
? record(expected.publicEnvHashes) && canonicalEnv(evidence.publicEnvHashes) === canonicalEnv(expected.publicEnvHashes)
|
|
65
|
+
: evidence[key] === expected[key];
|
|
66
|
+
if (!same)
|
|
67
|
+
throw new ArtifactOperationError('git_build_job_mismatch', { publicDetails: { reason } });
|
|
68
|
+
}
|
|
69
|
+
return Object.freeze({ ...evidence });
|
|
70
|
+
}
|
|
71
|
+
/** Anti-repack: the re-read uploaded bytes must hash to the sealed candidate digest. */
|
|
72
|
+
export function verifyServedCandidate(evidence, served) {
|
|
73
|
+
if (!Array.isArray(served) || candidateInventoryDigest(served) !== evidence.candidateDigest) {
|
|
74
|
+
throw new ArtifactOperationError('verification_failed');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -5,7 +5,7 @@ export type ArtifactCommitState = 'not_committed' | 'committed' | 'unknown';
|
|
|
5
5
|
export type ArtifactInternalKey = string & {
|
|
6
6
|
readonly __brand: 'internal-key';
|
|
7
7
|
};
|
|
8
|
-
export type ArtifactErrorKind = LiveErrorCode | 'provider_unavailable' | 'command_conflict' | 'pointer_conflict' | 'unauthorized_at_commit' | 'capability_unselected' | 'admission_unavailable' | 'invalid_request' | 'anonymous' | 'access_denied' | 'not_found' | 'gone' | 'release_unavailable' | 'limit_exceeded' | 'unprocessable' | 'verification_failed' | 'edit_mismatch' | 'precondition_required' | 'git_binding_conflict' | 'git_repo_not_registered' | 'git_ref_not_allowed' | 'git_head_moved' | 'git_path_refused' | 'git_branch_missing' | 'build_descriptor_invalid' | 'build_script_missing' | 'lock_missing' | 'dep_outside_lock' | 'install_script_not_allowlisted';
|
|
8
|
+
export type ArtifactErrorKind = LiveErrorCode | 'provider_unavailable' | 'command_conflict' | 'pointer_conflict' | 'unauthorized_at_commit' | 'capability_unselected' | 'admission_unavailable' | 'invalid_request' | 'anonymous' | 'access_denied' | 'not_found' | 'gone' | 'release_unavailable' | 'limit_exceeded' | 'unprocessable' | 'verification_failed' | 'edit_mismatch' | 'precondition_required' | 'git_binding_conflict' | 'git_repo_not_registered' | 'git_ref_not_allowed' | 'git_head_moved' | 'git_path_refused' | 'git_branch_missing' | 'build_descriptor_invalid' | 'build_script_missing' | 'lock_missing' | 'dep_outside_lock' | 'install_script_not_allowlisted' | 'dist_over_limits';
|
|
9
9
|
/** Optimistic-concurrency payload: the caller re-reads and merges against this. */
|
|
10
10
|
export interface ArtifactConflictDetails {
|
|
11
11
|
readonly artifactId?: string;
|
|
@@ -49,7 +49,7 @@ export interface ArtifactOperationalFailure extends ArtifactFailureFields {
|
|
|
49
49
|
}
|
|
50
50
|
export interface ArtifactOrdinaryFailure extends Omit<ArtifactFailureFields, 'variant' | 'retriable'> {
|
|
51
51
|
readonly kind: 'ordinary';
|
|
52
|
-
readonly category: 'invalid_request' | 'not_found' | 'gone' | 'release_unavailable' | 'limit_exceeded' | LiveErrorCode | 'unprocessable' | 'verification_failed' | 'edit_mismatch' | 'precondition_required' | 'build_descriptor_invalid' | 'build_script_missing' | 'lock_missing' | 'dep_outside_lock' | 'install_script_not_allowlisted' | 'git_path_refused' | 'git_branch_missing' | 'git_ref_not_allowed' | 'git_repo_not_registered';
|
|
52
|
+
readonly category: 'invalid_request' | 'not_found' | 'gone' | 'release_unavailable' | 'limit_exceeded' | LiveErrorCode | 'unprocessable' | 'verification_failed' | 'edit_mismatch' | 'precondition_required' | 'build_descriptor_invalid' | 'build_script_missing' | 'lock_missing' | 'dep_outside_lock' | 'install_script_not_allowlisted' | 'dist_over_limits' | 'git_path_refused' | 'git_branch_missing' | 'git_ref_not_allowed' | 'git_repo_not_registered';
|
|
53
53
|
readonly retriable: false;
|
|
54
54
|
}
|
|
55
55
|
/** Entry authority outcomes are separate from ordinary and operational failures. */
|
package/dist/server/failures.js
CHANGED
|
@@ -32,7 +32,7 @@ const DOMAIN_STATUS = {
|
|
|
32
32
|
not_found: 404, gone: 410, release_unavailable: 410, limit_exceeded: 413, unprocessable: 422, verification_failed: 422, edit_mismatch: 422,
|
|
33
33
|
precondition_required: 428,
|
|
34
34
|
build_descriptor_invalid: 422, build_script_missing: 422, lock_missing: 422,
|
|
35
|
-
dep_outside_lock: 422, install_script_not_allowlisted: 422,
|
|
35
|
+
dep_outside_lock: 422, install_script_not_allowlisted: 422, dist_over_limits: 422,
|
|
36
36
|
git_path_refused: 422, git_branch_missing: 422, git_ref_not_allowed: 422, git_repo_not_registered: 422,
|
|
37
37
|
};
|
|
38
38
|
function field(value, name) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type LiveBaseTree } from './live-tree.js';
|
|
2
2
|
import { type LiveAuthority, type LiveServiceDeps } from './live-contracts.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type LiveOverlayEntry, type LiveTransaction } from './live-store.js';
|
|
4
4
|
export declare const liveBusy: (reason: import('./live-errors.js').LiveConflictReason) => never;
|
|
5
5
|
export declare function mutateLive(input: {
|
|
6
6
|
deps: LiveServiceDeps;
|
|
@@ -3,6 +3,7 @@ import { ArtifactOperationError } from './failures.js';
|
|
|
3
3
|
import { persistLiveOverlay } from './live-drafts.js';
|
|
4
4
|
import { applyLiveMutation, liveTreeSha } from './live-tree.js';
|
|
5
5
|
import { liveResponse } from './live-contracts.js';
|
|
6
|
+
import { LIVE_IDLE_THRESHOLD_MS } from './live-store.js';
|
|
6
7
|
export const liveBusy = (reason) => {
|
|
7
8
|
throw new ArtifactOperationError('git_live_conflict', { publicDetails: { reason } });
|
|
8
9
|
};
|
|
@@ -68,14 +69,14 @@ export async function mutateLive(input) {
|
|
|
68
69
|
origin: operation === 'live_control' ? 'explicit' : 'implicit', rowVersion: 1,
|
|
69
70
|
ownerId: authority.ownerId, podUid: null, sourceRevision: record.revision,
|
|
70
71
|
baseHeadSha: record.baseHeadSha, liveTreeSha: record.liveTreeSha,
|
|
71
|
-
idleDeadline: new Date(now +
|
|
72
|
+
idleDeadline: new Date(now + LIVE_IDLE_THRESHOLD_MS).toISOString(),
|
|
72
73
|
activeAttemptId: null, stateDetail: null };
|
|
73
74
|
Object.assign(record.runtime, { sourceRevision: record.revision, baseHeadSha: record.baseHeadSha,
|
|
74
75
|
liveTreeSha: record.liveTreeSha, rowVersion: record.runtime.rowVersion + 1 });
|
|
75
76
|
if (operation === 'live_control')
|
|
76
77
|
record.runtime.renewOnReady = true;
|
|
77
78
|
record.runtime.lastAccessAt = new Date(now).toISOString();
|
|
78
|
-
record.runtime.idleDeadline = new Date(now +
|
|
79
|
+
record.runtime.idleDeadline = new Date(now + LIVE_IDLE_THRESHOLD_MS).toISOString();
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
return { action, result: { ...liveResponse(record, currentHeadSha, now), state: record.runtime?.phase ?? 'DORMANT',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GitPort } from './git-port.js';
|
|
2
2
|
import type { LiveAuthority, LiveInvocation } from './live-contracts.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type LiveDraftRecord, type LiveOverlayEntry } from './live-store.js';
|
|
4
4
|
import type { LiveBaseTree } from './live-tree.js';
|
|
5
5
|
export declare function readLivePage(input: {
|
|
6
6
|
git: GitPort;
|
package/dist/server/live-read.js
CHANGED
|
@@ -2,6 +2,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { ArtifactOperationError } from './failures.js';
|
|
3
3
|
import { gitPath } from './git-port-policy.js';
|
|
4
4
|
import { liveDigest } from './live-crypto.js';
|
|
5
|
+
import { LIVE_IDLE_THRESHOLD_MS } from './live-store.js';
|
|
5
6
|
export async function readLivePage(input) {
|
|
6
7
|
const { git, authority, record, overlay, base, args, invocation, kind, now } = input;
|
|
7
8
|
let snapshot = { actorId: invocation.actorId, revision: record.revision,
|
|
@@ -89,7 +90,7 @@ export async function readLivePage(input) {
|
|
|
89
90
|
}
|
|
90
91
|
if (kind === 'read' && record.runtime) {
|
|
91
92
|
record.runtime.lastAccessAt = new Date(now).toISOString();
|
|
92
|
-
record.runtime.idleDeadline = new Date(now +
|
|
93
|
+
record.runtime.idleDeadline = new Date(now + LIVE_IDLE_THRESHOLD_MS).toISOString();
|
|
93
94
|
}
|
|
94
95
|
return kind === 'read' ? { files, nextCursor } : { diff, files: recipe, deletes, nextCursor };
|
|
95
96
|
}
|
|
@@ -3,6 +3,8 @@ export interface LiveIdentity {
|
|
|
3
3
|
artifactId: string;
|
|
4
4
|
bindingGeneration: number;
|
|
5
5
|
}
|
|
6
|
+
/** A-LIVE Amendment 1: idle strictly after 900 s since the last qualifying access; there is no absolute lifetime. */
|
|
7
|
+
export declare const LIVE_IDLE_THRESHOLD_MS = 900000;
|
|
6
8
|
export interface LiveOverlayEntry {
|
|
7
9
|
path: string;
|
|
8
10
|
text: string | null;
|
|
@@ -20,7 +22,6 @@ export interface LiveRuntimeState {
|
|
|
20
22
|
baseHeadSha: string;
|
|
21
23
|
liveTreeSha: string;
|
|
22
24
|
idleDeadline: string;
|
|
23
|
-
maximumLifetimeAt: string;
|
|
24
25
|
activeAttemptId: string | null;
|
|
25
26
|
stateDetail: string | null;
|
|
26
27
|
appliedRevision: string | null;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createKeyMutex } from './ports.js';
|
|
2
2
|
import { ArtifactOperationError } from './failures.js';
|
|
3
|
+
/** A-LIVE Amendment 1: idle strictly after 900 s since the last qualifying access; there is no absolute lifetime. */
|
|
4
|
+
export const LIVE_IDLE_THRESHOLD_MS = 900_000;
|
|
3
5
|
export const liveIdentityKey = (identity) => JSON.stringify([
|
|
4
6
|
identity.storageScopeId, identity.artifactId, identity.bindingGeneration
|
|
5
7
|
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentropic/artifacts",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
4
4
|
"description": "Generic configurable artifacts MCP and artifact service: StorageScope/Artifact/Binding/Release model, canonical manifests, object authorization, idempotent intents (spec-v8 §9).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|