@dsh-enhanced/lark-channel 0.1.64 → 0.1.66
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/README.md +20 -6
- package/cordis.patch.yml +1 -0
- package/docs/operations.md +1 -1
- package/docs/progress-security.md +3 -0
- package/docs/rsi-setup.md +11 -7
- package/docs/setup.md +2 -1
- package/lib/adapter.d.ts +8 -0
- package/lib/adapter.d.ts.map +1 -1
- package/lib/adapter.js +34 -2
- package/lib/adapter.js.map +1 -1
- package/lib/config.d.ts +4 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +52 -8
- package/lib/config.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +24 -1
- package/lib/index.js.map +1 -1
- package/lib/progress.d.ts +11 -1
- package/lib/progress.d.ts.map +1 -1
- package/lib/progress.js +13 -1
- package/lib/progress.js.map +1 -1
- package/lib/rsi-authority-runtime.d.ts +1 -0
- package/lib/rsi-authority-runtime.d.ts.map +1 -1
- package/lib/rsi-authority-runtime.js +121 -18
- package/lib/rsi-authority-runtime.js.map +1 -1
- package/lib/rsi-bootstrap-manifest.d.ts +12 -5
- package/lib/rsi-bootstrap-manifest.d.ts.map +1 -1
- package/lib/rsi-bootstrap-manifest.js +63 -9
- package/lib/rsi-bootstrap-manifest.js.map +1 -1
- package/lib/rsi-bootstrap.js +3 -3
- package/lib/rsi-bootstrap.js.map +1 -1
- package/lib/rsi-build.d.ts +12 -0
- package/lib/rsi-build.d.ts.map +1 -1
- package/lib/rsi-build.js +55 -5
- package/lib/rsi-build.js.map +1 -1
- package/lib/rsi-creation-build.d.ts +3 -0
- package/lib/rsi-creation-build.d.ts.map +1 -1
- package/lib/rsi-creation-build.js +45 -0
- package/lib/rsi-creation-build.js.map +1 -1
- package/lib/rsi-host-update.d.ts +51 -0
- package/lib/rsi-host-update.d.ts.map +1 -1
- package/lib/rsi-host-update.js +61 -1
- package/lib/rsi-host-update.js.map +1 -1
- package/lib/rsi-install.d.ts +10 -3
- package/lib/rsi-install.d.ts.map +1 -1
- package/lib/rsi-install.js +65 -15
- package/lib/rsi-install.js.map +1 -1
- package/lib/rsi-linux-cgroup-roots.d.ts +3 -0
- package/lib/rsi-linux-cgroup-roots.d.ts.map +1 -0
- package/lib/rsi-linux-cgroup-roots.js +3 -0
- package/lib/rsi-linux-cgroup-roots.js.map +1 -0
- package/lib/rsi-linux-creation-build.d.ts +36 -0
- package/lib/rsi-linux-creation-build.d.ts.map +1 -0
- package/lib/rsi-linux-creation-build.js +213 -0
- package/lib/rsi-linux-creation-build.js.map +1 -0
- package/lib/rsi-linux-native-materialize.d.ts +31 -0
- package/lib/rsi-linux-native-materialize.d.ts.map +1 -0
- package/lib/rsi-linux-native-materialize.js +162 -0
- package/lib/rsi-linux-native-materialize.js.map +1 -0
- package/lib/rsi-linux-native-relocation.d.ts +120 -0
- package/lib/rsi-linux-native-relocation.d.ts.map +1 -0
- package/lib/rsi-linux-native-relocation.js +1555 -0
- package/lib/rsi-linux-native-relocation.js.map +1 -0
- package/lib/rsi-linux-native-resources.d.ts +97 -0
- package/lib/rsi-linux-native-resources.d.ts.map +1 -0
- package/lib/rsi-linux-native-resources.js +521 -0
- package/lib/rsi-linux-native-resources.js.map +1 -0
- package/lib/rsi-linux-repository-bootstrap.d.ts +17 -0
- package/lib/rsi-linux-repository-bootstrap.d.ts.map +1 -0
- package/lib/rsi-linux-repository-bootstrap.js +317 -0
- package/lib/rsi-linux-repository-bootstrap.js.map +1 -0
- package/lib/rsi-linux-runner-states.d.ts +20 -0
- package/lib/rsi-linux-runner-states.d.ts.map +1 -0
- package/lib/rsi-linux-runner-states.js +70 -0
- package/lib/rsi-linux-runner-states.js.map +1 -0
- package/lib/rsi-linux-runtime-bootstrap.d.ts +10 -0
- package/lib/rsi-linux-runtime-bootstrap.d.ts.map +1 -0
- package/lib/rsi-linux-runtime-bootstrap.js +38 -0
- package/lib/rsi-linux-runtime-bootstrap.js.map +1 -0
- package/lib/rsi-linux-source-build.d.ts +28 -0
- package/lib/rsi-linux-source-build.d.ts.map +1 -0
- package/lib/rsi-linux-source-build.js +43 -0
- package/lib/rsi-linux-source-build.js.map +1 -0
- package/lib/rsi-local-install.d.ts +2 -0
- package/lib/rsi-local-install.d.ts.map +1 -1
- package/lib/rsi-local-install.js +42 -1
- package/lib/rsi-local-install.js.map +1 -1
- package/lib/rsi-local-pair-install.d.ts +15 -0
- package/lib/rsi-local-pair-install.d.ts.map +1 -1
- package/lib/rsi-local-pair-install.js +21 -6
- package/lib/rsi-local-pair-install.js.map +1 -1
- package/lib/rsi-local-resources.d.ts +2 -2
- package/lib/rsi-local-resources.d.ts.map +1 -1
- package/lib/rsi-local-resources.js +5 -0
- package/lib/rsi-local-resources.js.map +1 -1
- package/lib/rsi-local-update-build.d.ts +25 -6
- package/lib/rsi-local-update-build.d.ts.map +1 -1
- package/lib/rsi-local-update-build.js +46 -7
- package/lib/rsi-local-update-build.js.map +1 -1
- package/lib/rsi-local-update.d.ts +5 -2
- package/lib/rsi-local-update.d.ts.map +1 -1
- package/lib/rsi-local-update.js +6 -5
- package/lib/rsi-local-update.js.map +1 -1
- package/lib/rsi-plugin-creation.d.ts +16 -1
- package/lib/rsi-plugin-creation.d.ts.map +1 -1
- package/lib/rsi-plugin-creation.js +60 -14
- package/lib/rsi-plugin-creation.js.map +1 -1
- package/lib/rsi-plugin-revision.d.ts +35 -0
- package/lib/rsi-plugin-revision.d.ts.map +1 -0
- package/lib/rsi-plugin-revision.js +200 -0
- package/lib/rsi-plugin-revision.js.map +1 -0
- package/lib/rsi-profile.d.ts +8 -0
- package/lib/rsi-profile.d.ts.map +1 -1
- package/lib/rsi-profile.js +55 -2
- package/lib/rsi-profile.js.map +1 -1
- package/lib/rsi-release-build.d.ts +24 -8
- package/lib/rsi-release-build.d.ts.map +1 -1
- package/lib/rsi-release-build.js +89 -37
- package/lib/rsi-release-build.js.map +1 -1
- package/lib/rsi-scanner-retirement-config.d.ts +34 -0
- package/lib/rsi-scanner-retirement-config.d.ts.map +1 -0
- package/lib/rsi-scanner-retirement-config.js +272 -0
- package/lib/rsi-scanner-retirement-config.js.map +1 -0
- package/lib/rsi-scanner-retirement-runtime.d.ts +23 -0
- package/lib/rsi-scanner-retirement-runtime.d.ts.map +1 -0
- package/lib/rsi-scanner-retirement-runtime.js +98 -0
- package/lib/rsi-scanner-retirement-runtime.js.map +1 -0
- package/lib/rsi-scanner-retirement-stage.d.ts +55 -0
- package/lib/rsi-scanner-retirement-stage.d.ts.map +1 -0
- package/lib/rsi-scanner-retirement-stage.js +183 -0
- package/lib/rsi-scanner-retirement-stage.js.map +1 -0
- package/lib/rsi-scanner-retirement-transition.d.ts +57 -0
- package/lib/rsi-scanner-retirement-transition.d.ts.map +1 -0
- package/lib/rsi-scanner-retirement-transition.js +320 -0
- package/lib/rsi-scanner-retirement-transition.js.map +1 -0
- package/lib/rsi-setup.d.ts +20 -0
- package/lib/rsi-setup.d.ts.map +1 -1
- package/lib/rsi-setup.js +102 -5
- package/lib/rsi-setup.js.map +1 -1
- package/lib/rsi-source-maintenance.d.ts +9 -1
- package/lib/rsi-source-maintenance.d.ts.map +1 -1
- package/lib/rsi-source-maintenance.js +64 -5
- package/lib/rsi-source-maintenance.js.map +1 -1
- package/lib/rsi-source-update.js +2 -2
- package/lib/rsi-source-update.js.map +1 -1
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +1 -0
- package/lib/service.js.map +1 -1
- package/lib/setup-profile.d.ts.map +1 -1
- package/lib/setup-profile.js +1 -0
- package/lib/setup-profile.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +21 -21
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { chmod, lstat, mkdir, mkdtemp, readdir, rm, stat } from 'node:fs/promises';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
5
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
6
|
+
import { linuxRuntimeDigest } from '@dsh-enhanced/assistant-isolation';
|
|
7
|
+
import { rsiBuildResources as io } from './rsi-build.js';
|
|
8
|
+
import { discoverLinuxCgroupRoots, RsiLinuxCgroupUnavailableError } from './rsi-linux-cgroup-roots.js';
|
|
9
|
+
import { prepareLinuxRsiRepositoryRuntime, readLinuxRsiRepositoryRuntime } from './rsi-linux-repository-bootstrap.js';
|
|
10
|
+
import { LinuxRsiRuntimeUnavailableError } from './rsi-linux-runtime-bootstrap.js';
|
|
11
|
+
/** Missing host prerequisites (cgroup delegation, user-namespace subordinate
|
|
12
|
+
* allocations, the C compiler, the fixed runtime) stop installation as
|
|
13
|
+
* not-ready. Integrity and identity failures stay hard Error failures. */
|
|
14
|
+
export class RsiLinuxCreationBuildUnavailableError extends Error {
|
|
15
|
+
code = 'rsi-linux-creation-build-unavailable';
|
|
16
|
+
constructor(message) { super(`rsi Linux creation build unavailable: ${message}`); }
|
|
17
|
+
}
|
|
18
|
+
const PROFILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u;
|
|
19
|
+
const COMMIT = /^[a-f0-9]{40}$/u;
|
|
20
|
+
const PEER_SPECIFIER = '@dsh-enhanced/assistant-verifier/linux-behavior-runtime';
|
|
21
|
+
const SUBORDINATE_PATTERN = /^subordinate \S+ allocation is unavailable$/u;
|
|
22
|
+
// Sorted exact receipt content (everything except receiptDigest itself).
|
|
23
|
+
const CONTENT_KEYS = ['backend', 'behavior', 'behaviorDigest', 'buildRuntimeDigest', 'cgroupRoots', 'dshHome',
|
|
24
|
+
'lockSha256', 'preparationDigest', 'profile', 'repositoryRuntimeDigest', 'schemaVersion', 'sourceCommit',
|
|
25
|
+
'systemSnapshotDigest', 'userNamespaceDigest'].sort();
|
|
26
|
+
const sha = (value) => createHash('sha256').update(value).digest('hex');
|
|
27
|
+
const digest = (value) => sha(JSON.stringify(value));
|
|
28
|
+
const canonical = (value) => isAbsolute(value) && resolve(value) === value && !value.includes('\0');
|
|
29
|
+
function fail(message) { throw new Error(`rsi Linux creation build: ${message}`); }
|
|
30
|
+
async function exists(path) {
|
|
31
|
+
try {
|
|
32
|
+
await lstat(path);
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error.code === 'ENOENT')
|
|
37
|
+
return false;
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const requirePeer = createRequire(import.meta.url);
|
|
42
|
+
/** The verifier behavior runtime is an optional peer loaded only when Linux
|
|
43
|
+
* native creation is actually prepared; a missing peer is a fatal opt-in gap,
|
|
44
|
+
* not an environment not-ready condition. */
|
|
45
|
+
function behaviorPeer() {
|
|
46
|
+
try {
|
|
47
|
+
requirePeer.resolve(PEER_SPECIFIER);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error.code === 'MODULE_NOT_FOUND'
|
|
51
|
+
|| error.code === 'ERR_MODULE_NOT_FOUND') {
|
|
52
|
+
fail(`opted-in Linux plugin creation requires installed peer ${PEER_SPECIFIER}`);
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
const peer = requirePeer(PEER_SPECIFIER);
|
|
57
|
+
if (typeof peer.prepareLinuxPluginBehaviorRuntime !== 'function'
|
|
58
|
+
|| typeof peer.readLinuxPluginBehaviorDeploymentPreparation !== 'function'
|
|
59
|
+
|| typeof peer.linuxPluginBehaviorRuntimeDigest !== 'function') {
|
|
60
|
+
fail('installed Linux behavior runtime peer is unavailable; update the assistant-verifier peer');
|
|
61
|
+
}
|
|
62
|
+
return peer;
|
|
63
|
+
}
|
|
64
|
+
/** Map missing host prerequisites to the not-ready error. Abort reasons,
|
|
65
|
+
* cgroup/runtime unavailable errors and integrity failures pass through. */
|
|
66
|
+
async function environmentGap(label, signal, operation) {
|
|
67
|
+
try {
|
|
68
|
+
return await operation();
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (error instanceof RsiLinuxCgroupUnavailableError || error instanceof LinuxRsiRuntimeUnavailableError)
|
|
72
|
+
throw error;
|
|
73
|
+
if (signal.aborted)
|
|
74
|
+
throw error;
|
|
75
|
+
const code = error.code;
|
|
76
|
+
const message = error.message ?? '';
|
|
77
|
+
if (code === 'ENOENT' || SUBORDINATE_PATTERN.test(message)) {
|
|
78
|
+
throw new RsiLinuxCreationBuildUnavailableError(`${label}: ${message}`);
|
|
79
|
+
}
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function project(receipt) {
|
|
84
|
+
return { schemaVersion: 3, backend: 'linux-native', sourceCommit: receipt.sourceCommit,
|
|
85
|
+
behavior: receipt.behavior, cgroupRoots: receipt.cgroupRoots, buildRuntimeDigest: receipt.buildRuntimeDigest };
|
|
86
|
+
}
|
|
87
|
+
async function validateIdentity(input) {
|
|
88
|
+
input.signal?.throwIfAborted();
|
|
89
|
+
if (!canonical(input.dshHome) || !PROFILE.test(input.profile) || !canonical(input.stateRoot)
|
|
90
|
+
|| input.stateRoot === '/' || input.source.schemaVersion !== 1
|
|
91
|
+
|| !COMMIT.test(input.source.sourceCommit))
|
|
92
|
+
fail('invalid creation bootstrap identity');
|
|
93
|
+
await io.directory(input.dshHome);
|
|
94
|
+
await io.directory(input.stateRoot);
|
|
95
|
+
}
|
|
96
|
+
async function replayExisting(input, final, repository, cgroupRoots, peer, signal) {
|
|
97
|
+
await io.directory(final);
|
|
98
|
+
if (!isDeepStrictEqual(await readdir(final), ['bootstrap.json']))
|
|
99
|
+
fail('behavior workspace incomplete or unexpected');
|
|
100
|
+
const receipt = JSON.parse((await io.readStable(join(final, 'bootstrap.json'), 65_536, true)).toString('utf8'));
|
|
101
|
+
const { receiptDigest, ...content } = receipt;
|
|
102
|
+
if (Object.keys(content).sort().join() !== CONTENT_KEYS.join()
|
|
103
|
+
|| digest(content) !== receiptDigest || receipt.schemaVersion !== 3 || receipt.backend !== 'linux-native'
|
|
104
|
+
|| receipt.dshHome !== input.dshHome || receipt.profile !== input.profile
|
|
105
|
+
|| receipt.sourceCommit !== input.source.sourceCommit || receipt.lockSha256 !== repository.lockSha256
|
|
106
|
+
|| !isDeepStrictEqual(receipt.cgroupRoots, cgroupRoots))
|
|
107
|
+
fail('Linux creation receipt differs');
|
|
108
|
+
const runtimeDigest = linuxRuntimeDigest(repository.runtime);
|
|
109
|
+
// The deployment reopen binds the retained observer even when the build-time
|
|
110
|
+
// base receipt is later retired; it never invokes the compiler or Docker.
|
|
111
|
+
const deployment = await environmentGap('reopen Linux behavior preparation', signal, () => peer.readLinuxPluginBehaviorDeploymentPreparation({ runtime: receipt.behavior, signal }));
|
|
112
|
+
if (receipt.repositoryRuntimeDigest !== runtimeDigest
|
|
113
|
+
|| receipt.systemSnapshotDigest !== digest(repository.systemSnapshot)
|
|
114
|
+
|| receipt.userNamespaceDigest !== digest(repository.userNamespace)
|
|
115
|
+
|| receipt.buildRuntimeDigest !== deployment.baseRuntimeDigest
|
|
116
|
+
|| receipt.buildRuntimeDigest !== runtimeDigest
|
|
117
|
+
|| receipt.preparationDigest !== deployment.preparationDigest
|
|
118
|
+
|| !isDeepStrictEqual(receipt.behavior, deployment.descriptor)
|
|
119
|
+
|| receipt.behaviorDigest !== peer.linuxPluginBehaviorRuntimeDigest(deployment.descriptor)) {
|
|
120
|
+
fail('Linux creation receipt differs from the prepared repository or behavior runtime');
|
|
121
|
+
}
|
|
122
|
+
signal.throwIfAborted();
|
|
123
|
+
return project(receipt);
|
|
124
|
+
}
|
|
125
|
+
/** Caller holds the DSH_HOME lifecycle lock. Prepare or replay the immutable
|
|
126
|
+
* Linux native behavior runtime used for creation review and adoption. */
|
|
127
|
+
export async function prepareLinuxRsiCreationBuildEnvironment(input) {
|
|
128
|
+
await validateIdentity(input);
|
|
129
|
+
const peer = behaviorPeer();
|
|
130
|
+
const behaviorRoot = join(input.stateRoot, 'linux-creation-behavior');
|
|
131
|
+
const parent = join(input.dshHome, 'rsi-linux-creation-builds');
|
|
132
|
+
try {
|
|
133
|
+
await mkdir(parent, { mode: 0o700 });
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (error.code !== 'EEXIST')
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
await io.directory(parent);
|
|
140
|
+
const final = join(parent, input.profile);
|
|
141
|
+
const signal = AbortSignal.any([input.signal ?? new AbortController().signal, AbortSignal.timeout(2_400_000)]);
|
|
142
|
+
const stage = await mkdtemp(join(parent, `.${input.profile}-stage-`));
|
|
143
|
+
await chmod(stage, 0o700);
|
|
144
|
+
let claimed;
|
|
145
|
+
try {
|
|
146
|
+
// schema4: fresh readable clone of the schema3 base, npm layout, system
|
|
147
|
+
// snapshot and subordinate user-namespace mapping.
|
|
148
|
+
const repository = await environmentGap('prepare Linux repository runtime', signal, () => prepareLinuxRsiRepositoryRuntime({
|
|
149
|
+
dshHome: input.dshHome, profile: input.profile, source: input.source, signal,
|
|
150
|
+
...(input.nodeArchivePath ? { nodeArchivePath: input.nodeArchivePath } : {}),
|
|
151
|
+
...(input.pnpmArchivePath ? { pnpmArchivePath: input.pnpmArchivePath } : {}),
|
|
152
|
+
...(input.pnpmExeArchivePath ? { pnpmExeArchivePath: input.pnpmExeArchivePath } : {}),
|
|
153
|
+
...(input.pnpmNativeArchivePath ? { pnpmNativeArchivePath: input.pnpmNativeArchivePath } : {}),
|
|
154
|
+
}));
|
|
155
|
+
const cgroupRoots = await discoverLinuxCgroupRoots({ signal });
|
|
156
|
+
if (await exists(final))
|
|
157
|
+
return await replayExisting(input, final, repository, cgroupRoots, peer, signal);
|
|
158
|
+
// The single shared observer runtime; its sibling lock and rollback live
|
|
159
|
+
// in the verifier peer. A missing /usr/bin/cc is a not-ready host gap.
|
|
160
|
+
const descriptor = await environmentGap('compile Linux behavior runtime', signal, () => peer.prepareLinuxPluginBehaviorRuntime({ runtime: repository.runtime, root: behaviorRoot, signal }));
|
|
161
|
+
const deployment = await peer.readLinuxPluginBehaviorDeploymentPreparation({ runtime: descriptor, signal });
|
|
162
|
+
const runtimeDigest = linuxRuntimeDigest(repository.runtime);
|
|
163
|
+
if (!isDeepStrictEqual(deployment.descriptor, descriptor)
|
|
164
|
+
|| deployment.baseRuntimeDigest !== runtimeDigest)
|
|
165
|
+
fail('behavior preparation is not bound to the repository runtime');
|
|
166
|
+
signal.throwIfAborted();
|
|
167
|
+
const content = {
|
|
168
|
+
schemaVersion: 3, backend: 'linux-native', sourceCommit: input.source.sourceCommit,
|
|
169
|
+
behavior: descriptor, cgroupRoots, dshHome: input.dshHome, profile: input.profile,
|
|
170
|
+
lockSha256: repository.lockSha256, buildRuntimeDigest: deployment.baseRuntimeDigest,
|
|
171
|
+
preparationDigest: deployment.preparationDigest,
|
|
172
|
+
behaviorDigest: peer.linuxPluginBehaviorRuntimeDigest(descriptor),
|
|
173
|
+
repositoryRuntimeDigest: runtimeDigest, systemSnapshotDigest: digest(repository.systemSnapshot),
|
|
174
|
+
userNamespaceDigest: digest(repository.userNamespace),
|
|
175
|
+
};
|
|
176
|
+
await mkdir(final, { mode: 0o700 });
|
|
177
|
+
const identity = await stat(final);
|
|
178
|
+
claimed = { dev: identity.dev, ino: identity.ino };
|
|
179
|
+
await io.writeExclusive(join(final, 'bootstrap.json'), Buffer.from(JSON.stringify({ ...content, receiptDigest: digest(content) })));
|
|
180
|
+
await io.syncDirectory(final);
|
|
181
|
+
await io.syncDirectory(parent);
|
|
182
|
+
return project({ ...content, receiptDigest: digest(content) });
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
if (claimed) {
|
|
186
|
+
const current = await lstat(final).catch(() => undefined);
|
|
187
|
+
if (current?.isDirectory() && current.dev === claimed.dev && current.ino === claimed.ino
|
|
188
|
+
&& (await readdir(final)).every(name => name === 'bootstrap.json'))
|
|
189
|
+
await rm(final, { recursive: true, force: true });
|
|
190
|
+
}
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
finally {
|
|
194
|
+
await rm(stage, { recursive: true, force: true });
|
|
195
|
+
await io.syncDirectory(parent);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/** Verify an existing Linux creation family without preparing missing inputs.
|
|
199
|
+
* Fixed runtime integrity probes, read-only cgroup discovery and retained
|
|
200
|
+
* observer verification remain part of reopening the recorded receipts. */
|
|
201
|
+
export async function readLinuxRsiCreationBuildEnvironment(input) {
|
|
202
|
+
await validateIdentity(input);
|
|
203
|
+
const peer = behaviorPeer();
|
|
204
|
+
const parent = join(input.dshHome, 'rsi-linux-creation-builds'), final = join(parent, input.profile);
|
|
205
|
+
const signal = input.signal ?? new AbortController().signal;
|
|
206
|
+
await io.directory(parent);
|
|
207
|
+
const repository = await readLinuxRsiRepositoryRuntime({
|
|
208
|
+
dshHome: input.dshHome, profile: input.profile, source: input.source, signal,
|
|
209
|
+
});
|
|
210
|
+
const cgroupRoots = await discoverLinuxCgroupRoots({ signal });
|
|
211
|
+
return await replayExisting(input, final, repository, cgroupRoots, peer, signal);
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=rsi-linux-creation-build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsi-linux-creation-build.js","sourceRoot":"","sources":["../src/rsi-linux-creation-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAqB,M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6BAA6B,CAAC;QACrD,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM;KAC7E,CAAC,CAAA;IACF,MAAM,WAAW,GAAG,MAAM,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IAC9D,OAAO,MAAM,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;AAClF,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RsiLinuxSourceBuildPreparation } from './rsi-linux-source-build.js';
|
|
2
|
+
import { type LinuxRsiNativeRelocatedFamily, type LinuxRsiNativeRelocationProof } from './rsi-linux-native-relocation.js';
|
|
3
|
+
export interface LinuxRsiNativeMaterializeInput {
|
|
4
|
+
/** Home holding the freshly prepared candidate families. */
|
|
5
|
+
candidateHome: string;
|
|
6
|
+
/** Private staged Home that will be renamed onto `logicalHome` later. */
|
|
7
|
+
stagePhysicalHome: string;
|
|
8
|
+
/** Absolute path the staged Home will occupy after the cutover. */
|
|
9
|
+
logicalHome: string;
|
|
10
|
+
/** Set when that path is already occupied by the live Home being cut over
|
|
11
|
+
* in place (the Docker -> Linux-native staging case). It must equal
|
|
12
|
+
* `logicalHome`; the relocation then stages beside the live Home instead of
|
|
13
|
+
* refusing an occupied logical Home. Replay ignores it. */
|
|
14
|
+
existingLogicalHome?: string;
|
|
15
|
+
profile: string;
|
|
16
|
+
/** Sealed proof from an earlier run over the same Homes, when replaying. */
|
|
17
|
+
relocation?: LinuxRsiNativeRelocationProof;
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
}
|
|
20
|
+
export interface LinuxRsiNativeMaterializeOutput {
|
|
21
|
+
relocation: LinuxRsiNativeRelocationProof;
|
|
22
|
+
family: LinuxRsiNativeRelocatedFamily;
|
|
23
|
+
sourceBuild: RsiLinuxSourceBuildPreparation;
|
|
24
|
+
/** Digest of the candidate Home's creation receipt, for equality with the
|
|
25
|
+
* digest the owner-program preparation recorded. */
|
|
26
|
+
candidateReceiptSha256: string;
|
|
27
|
+
/** Digest of the staged creation receipt, recorded in the transaction. */
|
|
28
|
+
receiptSha256: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function materializeLinuxRsiNativeInStage(input: LinuxRsiNativeMaterializeInput): Promise<LinuxRsiNativeMaterializeOutput>;
|
|
31
|
+
//# sourceMappingURL=rsi-linux-native-materialize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsi-linux-native-materialize.d.ts","sourceRoot":"","sources":["../src/rsi-linux-native-materialize.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAA;AACjF,OAAO,EAEL,KAAK,6BAA6B,EAAE,KAAK,6BAA6B,EACvE,MAAM,kCAAkC,CAAA;AAmHzC,MAAM,WAAW,8BAA8B;IAC7C,4DAA4D;IAC5D,aAAa,EAAE,MAAM,CAAA;IACrB,yEAAyE;IACzE,iBAAiB,EAAE,MAAM,CAAA;IACzB,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAA;IACnB;;;+DAG2D;IAC3D,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,4EAA4E;IAC5E,UAAU,CAAC,EAAE,6BAA6B,CAAA;IAC1C,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,MAAM,WAAW,+BAA+B;IAC9C,UAAU,EAAE,6BAA6B,CAAA;IACzC,MAAM,EAAE,6BAA6B,CAAA;IACrC,WAAW,EAAE,8BAA8B,CAAA;IAC3C;wDACoD;IACpD,sBAAsB,EAAE,MAAM,CAAA;IAC9B,0EAA0E;IAC1E,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,wBAAsB,gCAAgC,CACpD,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,+BAA+B,CAAC,CA8BjF"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { lstat, open } from 'node:fs/promises';
|
|
4
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
5
|
+
import { openLinuxRsiNativeRelocatedFamily, relocateLinuxRsiNativeFamily, } from './rsi-linux-native-relocation.js';
|
|
6
|
+
/** Compose the relocation primitive into the stage seam the owner-program
|
|
7
|
+
* transaction needs: move the five Linux-native families from a candidate Home
|
|
8
|
+
* into the staged Home, then hand back the typed build environments, the
|
|
9
|
+
* prepared source build and the creation-receipt digests the caller compares
|
|
10
|
+
* against the candidate preparation.
|
|
11
|
+
*
|
|
12
|
+
* This runs strictly before the rename(2) cutover, so it never calls the stock
|
|
13
|
+
* readers (`readLinuxRsiRuntime`, `readLinuxRsiRepositoryRuntime`,
|
|
14
|
+
* `readLinuxRsiCreationBuildEnvironment`, `readRsiReleaseBuildEnvironment`):
|
|
15
|
+
* they probe the host or the logical Home and only accept a Home at its final
|
|
16
|
+
* path. The relocation proof itself is the pre-cutover acceptance gate; the
|
|
17
|
+
* stock readers remain the post-cutover acceptance test.
|
|
18
|
+
*
|
|
19
|
+
* The seam is replayable. A caller that already relocated this pair of Homes in
|
|
20
|
+
* an earlier process passes the sealed proof back in; the proof is re-verified
|
|
21
|
+
* against the staged Home instead of relocating a second time (a second
|
|
22
|
+
* relocation would fail on the existing destinations).
|
|
23
|
+
*
|
|
24
|
+
* When the caller is staging an in-place cutover, the logical Home is the live
|
|
25
|
+
* Home and already exists; `existingLogicalHome` attests that fact so the
|
|
26
|
+
* relocation stages beside it instead of refusing an occupied Home. The staged
|
|
27
|
+
* receipts still record the logical Home and the sealed proof is unchanged.
|
|
28
|
+
*
|
|
29
|
+
* It never cleans up. On any failure — including a crash or abort after the
|
|
30
|
+
* first copy — the staged Home holds an unsealed partial relocation and the
|
|
31
|
+
* sealed proof is gone, so a retry without that proof fails closed on the
|
|
32
|
+
* occupied destinations. The caller owns `stagePhysicalHome` as a disposable
|
|
33
|
+
* directory and must delete and recreate it before retrying. */
|
|
34
|
+
const PROFILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u;
|
|
35
|
+
const COMMIT = /^[a-f0-9]{40}$/u;
|
|
36
|
+
const MAX_RECEIPT_BYTES = 4 * 1024 * 1024;
|
|
37
|
+
const stamp = (info) => JSON.stringify([info.dev, info.ino, info.uid, info.mode, info.size,
|
|
38
|
+
info.mtimeMs, info.ctimeMs]);
|
|
39
|
+
function fail(message) { throw new Error(`rsi Linux native materialize: ${message}`); }
|
|
40
|
+
function sha256(bytes) { return createHash('sha256').update(bytes).digest('hex'); }
|
|
41
|
+
function canonicalHome(value, name) {
|
|
42
|
+
if (typeof value !== 'string' || !isAbsolute(value) || value !== resolve(value) || value === '/'
|
|
43
|
+
|| [...value].some(character => character.charCodeAt(0) < 32))
|
|
44
|
+
fail(`invalid ${name}`);
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
function overlap(first, second) {
|
|
48
|
+
return first === second || first.startsWith(`${second}/`) || second.startsWith(`${first}/`);
|
|
49
|
+
}
|
|
50
|
+
function identity(input) {
|
|
51
|
+
const candidateHome = canonicalHome(input.candidateHome, 'candidate Home');
|
|
52
|
+
const stagePhysicalHome = canonicalHome(input.stagePhysicalHome, 'staged Home');
|
|
53
|
+
const logicalHome = canonicalHome(input.logicalHome, 'logical Home');
|
|
54
|
+
if (input.existingLogicalHome !== undefined) {
|
|
55
|
+
canonicalHome(input.existingLogicalHome, 'existing logical Home');
|
|
56
|
+
if (input.existingLogicalHome !== logicalHome)
|
|
57
|
+
fail('existing logical Home is not this logical Home');
|
|
58
|
+
}
|
|
59
|
+
if (typeof input.profile !== 'string' || !PROFILE.test(input.profile))
|
|
60
|
+
fail('invalid profile');
|
|
61
|
+
if (overlap(candidateHome, stagePhysicalHome) || overlap(candidateHome, logicalHome)
|
|
62
|
+
|| overlap(stagePhysicalHome, logicalHome))
|
|
63
|
+
fail('candidate, staged and logical Homes must be disjoint');
|
|
64
|
+
}
|
|
65
|
+
/** Read one receipt exactly once, requiring the same owner-private, single-link,
|
|
66
|
+
* no-symlink shape the stock readers accept. Hashing and parsing the same buffer
|
|
67
|
+
* keeps the recorded digest bound to the parsed program identity. */
|
|
68
|
+
async function readReceipt(path) {
|
|
69
|
+
let info;
|
|
70
|
+
try {
|
|
71
|
+
info = await lstat(path);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if (error.code === 'ENOENT')
|
|
75
|
+
fail(`missing creation receipt: ${path}`);
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
if (!info.isFile() || info.isSymbolicLink() || info.nlink !== 1 || info.size > MAX_RECEIPT_BYTES
|
|
79
|
+
|| info.uid !== process.getuid?.() || info.mode & 0o077 || info.size === 0) {
|
|
80
|
+
fail(`unsafe creation receipt: ${path}`);
|
|
81
|
+
}
|
|
82
|
+
const fd = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
83
|
+
try {
|
|
84
|
+
if (stamp(await fd.stat()) !== stamp(info))
|
|
85
|
+
fail(`creation receipt changed: ${path}`);
|
|
86
|
+
const bytes = await fd.readFile();
|
|
87
|
+
if (bytes.byteLength !== info.size || stamp(await fd.stat()) !== stamp(info)
|
|
88
|
+
|| stamp(await lstat(path)) !== stamp(info))
|
|
89
|
+
fail(`creation receipt changed: ${path}`);
|
|
90
|
+
return { path, bytes, sha256: sha256(bytes) };
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
await fd.close();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function receiptSha256(path) { return (await readReceipt(path)).sha256; }
|
|
97
|
+
/** The candidate receipt names the program being staged; reject a mismatch
|
|
98
|
+
* before spending minutes on the relocation copy. */
|
|
99
|
+
function candidateReceipt(bytes, path, home, profile) {
|
|
100
|
+
let parsed;
|
|
101
|
+
try {
|
|
102
|
+
parsed = JSON.parse(Buffer.from(bytes).toString('utf8'));
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
fail(`invalid creation receipt: ${path}`);
|
|
106
|
+
}
|
|
107
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
108
|
+
fail(`invalid creation receipt: ${path}`);
|
|
109
|
+
const receipt = parsed;
|
|
110
|
+
if (receipt.schemaVersion !== 3 || receipt.backend !== 'linux-native'
|
|
111
|
+
|| receipt.dshHome !== home || receipt.profile !== profile)
|
|
112
|
+
fail(`candidate creation receipt differs: ${path}`);
|
|
113
|
+
}
|
|
114
|
+
async function readCandidateReceipt(home, profile) {
|
|
115
|
+
const path = join(home, 'rsi-linux-creation-builds', profile, 'bootstrap.json');
|
|
116
|
+
const receipt = await readReceipt(path);
|
|
117
|
+
candidateReceipt(receipt.bytes, path, home, profile);
|
|
118
|
+
const record = JSON.parse(Buffer.from(receipt.bytes).toString('utf8'));
|
|
119
|
+
if (typeof record.sourceCommit !== 'string' || !COMMIT.test(record.sourceCommit)) {
|
|
120
|
+
fail(`candidate creation receipt lacks a source commit: ${path}`);
|
|
121
|
+
}
|
|
122
|
+
return { path, sha256: receipt.sha256, sourceCommit: record.sourceCommit };
|
|
123
|
+
}
|
|
124
|
+
export async function materializeLinuxRsiNativeInStage(input) {
|
|
125
|
+
identity(input);
|
|
126
|
+
input.signal?.throwIfAborted();
|
|
127
|
+
const { candidateHome, stagePhysicalHome, logicalHome, profile } = input;
|
|
128
|
+
const candidate = await readCandidateReceipt(candidateHome, profile);
|
|
129
|
+
input.signal?.throwIfAborted();
|
|
130
|
+
let relocation = input.relocation;
|
|
131
|
+
if (relocation === undefined) {
|
|
132
|
+
relocation = await relocateLinuxRsiNativeFamily({ sourceHome: candidateHome, physicalHome: stagePhysicalHome,
|
|
133
|
+
logicalHome, profile, ...(input.existingLogicalHome === undefined
|
|
134
|
+
? {} : { existingLogicalHome: input.existingLogicalHome }),
|
|
135
|
+
...(input.signal === undefined ? {} : { signal: input.signal }) });
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
proofIdentity(relocation, input);
|
|
139
|
+
}
|
|
140
|
+
const family = await openLinuxRsiNativeRelocatedFamily(relocation);
|
|
141
|
+
input.signal?.throwIfAborted();
|
|
142
|
+
if (family.runtime.sourceCommit !== candidate.sourceCommit)
|
|
143
|
+
fail('staged program differs from candidate');
|
|
144
|
+
const receipt = await receiptSha256(join(stagePhysicalHome, 'rsi-linux-creation-builds', profile, 'bootstrap.json'));
|
|
145
|
+
return {
|
|
146
|
+
relocation,
|
|
147
|
+
family,
|
|
148
|
+
sourceBuild: { backend: 'linux-native', repository: family.repository, cgroupRoots: family.creationBuild.cgroupRoots },
|
|
149
|
+
candidateReceiptSha256: candidate.sha256,
|
|
150
|
+
receiptSha256: receipt,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function proofIdentity(proof, input) {
|
|
154
|
+
const record = proof;
|
|
155
|
+
if (record.schemaVersion !== 1 || record.backend !== 'linux-native')
|
|
156
|
+
fail('invalid replay relocation proof');
|
|
157
|
+
if (record.sourceHome !== input.candidateHome || record.physicalHome !== input.stagePhysicalHome
|
|
158
|
+
|| record.logicalHome !== input.logicalHome || record.profile !== input.profile) {
|
|
159
|
+
fail('replay relocation proof does not describe this Home pair');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=rsi-linux-native-materialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsi-linux-native-materialize.js","sourceRoot":"","sources":["../src/rsi-linux-native-materialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,SAAS,EAAc,MAAM,SAAS,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,IAAI,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linux-behavior-runtime';
|
|
2
|
+
import type { LinuxRsiCreationBuildEnvironment } from './rsi-linux-creation-build.js';
|
|
3
|
+
import type { LinuxRsiRepositoryBuildEnvironment } from './rsi-linux-repository-bootstrap.js';
|
|
4
|
+
import type { LinuxRsiBuildEnvironment } from './rsi-linux-runtime-bootstrap.js';
|
|
5
|
+
import type { NativeRsiReleaseBuildEnvironment } from './rsi-release-build.js';
|
|
6
|
+
/** Receipt-relocation primitive for moving one prepared Linux-native DSH Home
|
|
7
|
+
* from a Docker volume onto a native filesystem without re-preparing it.
|
|
8
|
+
* Source receipts are authenticated before any byte is copied; the copied
|
|
9
|
+
* trees and the rewritten receipts are bound together in a sealed proof whose
|
|
10
|
+
* logical paths survive the later same-filesystem rename(2). */
|
|
11
|
+
export interface LinuxRsiNativeRelocationInput {
|
|
12
|
+
sourceHome: string;
|
|
13
|
+
physicalHome: string;
|
|
14
|
+
logicalHome: string;
|
|
15
|
+
profile: string;
|
|
16
|
+
/** Attests that `logicalHome` is the live Home already occupying its final
|
|
17
|
+
* path (the in-place Docker -> Linux-native cutover case). It must be the
|
|
18
|
+
* exact `logicalHome` value and resolve to itself; it then substitutes for
|
|
19
|
+
* the "logical Home already exists" refusal instead of weakening any other
|
|
20
|
+
* check, and the relocated receipts still record the logical Home. */
|
|
21
|
+
existingLogicalHome?: string;
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
}
|
|
24
|
+
export interface LinuxRsiNativeRelocationElement {
|
|
25
|
+
name: 'runtime' | 'repository-runtime' | 'system' | 'behavior-runtime' | 'release-toolchain' | 'release-store' | 'release-cache';
|
|
26
|
+
logicalPath: string;
|
|
27
|
+
physicalPath: string;
|
|
28
|
+
dev: number;
|
|
29
|
+
ino: number;
|
|
30
|
+
sha256: string;
|
|
31
|
+
entries: number;
|
|
32
|
+
bytes: number;
|
|
33
|
+
}
|
|
34
|
+
export interface LinuxRsiNativeRelocationProof {
|
|
35
|
+
schemaVersion: 1;
|
|
36
|
+
backend: 'linux-native';
|
|
37
|
+
profile: string;
|
|
38
|
+
sourceHome: string;
|
|
39
|
+
physicalHome: string;
|
|
40
|
+
logicalHome: string;
|
|
41
|
+
behaviorRootRelative: string;
|
|
42
|
+
elements: LinuxRsiNativeRelocationElement[];
|
|
43
|
+
digests: {
|
|
44
|
+
runtime: string;
|
|
45
|
+
repository: string;
|
|
46
|
+
behavior: string;
|
|
47
|
+
creation: string;
|
|
48
|
+
release: string;
|
|
49
|
+
relocation: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Relocate one prepared Linux-native DSH Home onto a fresh physical Home.
|
|
53
|
+
* The source is authenticated before copying and never modified. An
|
|
54
|
+
* `existingLogicalHome` attestation only replaces the "logical Home already
|
|
55
|
+
* exists" refusal; every other check and the proof shape stay the same. */
|
|
56
|
+
export declare function relocateLinuxRsiNativeFamily(input: LinuxRsiNativeRelocationInput): Promise<LinuxRsiNativeRelocationProof>;
|
|
57
|
+
/** Re-derive a relocation proof from its physical Home without ever reading the
|
|
58
|
+
* logical Home; the proof must still describe a byte-identical, un-opened copy. */
|
|
59
|
+
export declare function verifyLinuxRsiNativeRelocation(proof: LinuxRsiNativeRelocationProof): Promise<void>;
|
|
60
|
+
/** The prepared families a verified relocation proof stands for, projected back
|
|
61
|
+
* into their typed build-environment shapes. Callers get the same values the
|
|
62
|
+
* stock readers would produce after the rename(2) cutover, without any host
|
|
63
|
+
* probe or logical-Home read (both are only valid post-cutover). */
|
|
64
|
+
export interface LinuxRsiNativeRelocatedFamily {
|
|
65
|
+
runtime: LinuxRsiBuildEnvironment;
|
|
66
|
+
repository: LinuxRsiRepositoryBuildEnvironment;
|
|
67
|
+
behavior: LinuxPluginBehaviorRuntime;
|
|
68
|
+
creationBuild: LinuxRsiCreationBuildEnvironment;
|
|
69
|
+
release: NativeRsiReleaseBuildEnvironment;
|
|
70
|
+
}
|
|
71
|
+
/** Verify a relocation proof and return its typed families in one pass, so the
|
|
72
|
+
* ~585 MB release trees are hashed once instead of twice. */
|
|
73
|
+
export declare function openLinuxRsiNativeRelocatedFamily(proof: LinuxRsiNativeRelocationProof): Promise<LinuxRsiNativeRelocatedFamily>;
|
|
74
|
+
/** Re-open a verified relocation at another physical Home; callers may only
|
|
75
|
+
* supply the proof's own physical Home or its logical Home.
|
|
76
|
+
*
|
|
77
|
+
* The one supported case is the rename(2) cutover: `rename` preserves dev/ino,
|
|
78
|
+
* so the staged trees keep their sealed content identity while their paths move
|
|
79
|
+
* under the live Home. Receipts record logical paths, so only the element and
|
|
80
|
+
* receipt roots change; the proof itself stays the sealed staged record and is
|
|
81
|
+
* never rewritten. */
|
|
82
|
+
export declare function openLinuxRsiNativeRelocatedFamilyAt(proof: LinuxRsiNativeRelocationProof, physicalHome: string): Promise<LinuxRsiNativeRelocatedFamily>;
|
|
83
|
+
/** A resource-only proof; this neither establishes pre-owner eligibility nor
|
|
84
|
+
* reads, creates or migrates owner authority. The outer installer owns that gate. */
|
|
85
|
+
type BaseElementName = 'runtime' | 'release-toolchain' | 'release-store' | 'release-cache';
|
|
86
|
+
export interface LinuxRsiNativeBaseRelocationProof {
|
|
87
|
+
schemaVersion: 1;
|
|
88
|
+
backend: 'linux-native';
|
|
89
|
+
purpose: 'pre-owner-base';
|
|
90
|
+
profile: string;
|
|
91
|
+
sourceHome: string;
|
|
92
|
+
physicalHome: string;
|
|
93
|
+
logicalHome: string;
|
|
94
|
+
elements: (Omit<LinuxRsiNativeRelocationElement, 'name'> & {
|
|
95
|
+
name: BaseElementName;
|
|
96
|
+
})[];
|
|
97
|
+
digests: {
|
|
98
|
+
runtime: string;
|
|
99
|
+
release: string;
|
|
100
|
+
relocation: string;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export interface LinuxRsiNativeRelocatedBase {
|
|
104
|
+
runtime: LinuxRsiBuildEnvironment;
|
|
105
|
+
release: NativeRsiReleaseBuildEnvironment;
|
|
106
|
+
}
|
|
107
|
+
/** Read existing receipts through their canonical logical Home spelling. Only
|
|
108
|
+
* same-inode moves are supported: ordinary copied runtime roots fail dev/ino.
|
|
109
|
+
* Release schema 2 carries content pins, not historical root inode fields. */
|
|
110
|
+
export declare function inspectLinuxRsiNativeBaseAt(input: {
|
|
111
|
+
logicalHome: string;
|
|
112
|
+
physicalHome: string;
|
|
113
|
+
profile: string;
|
|
114
|
+
signal?: AbortSignal;
|
|
115
|
+
}): Promise<LinuxRsiNativeRelocatedBase>;
|
|
116
|
+
export declare function openLinuxRsiNativeRelocatedBase(proof: LinuxRsiNativeBaseRelocationProof): Promise<LinuxRsiNativeRelocatedBase>;
|
|
117
|
+
export declare function openLinuxRsiNativeRelocatedBaseAt(proof: LinuxRsiNativeBaseRelocationProof, physicalHome: string): Promise<LinuxRsiNativeRelocatedBase>;
|
|
118
|
+
export declare function relocateLinuxRsiNativeBase(input: LinuxRsiNativeRelocationInput): Promise<LinuxRsiNativeBaseRelocationProof>;
|
|
119
|
+
export {};
|
|
120
|
+
//# sourceMappingURL=rsi-linux-native-relocation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsi-linux-native-relocation.d.ts","sourceRoot":"","sources":["../src/rsi-linux-native-relocation.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yDAAyD,CAAA;AAEzG,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAA;AACrF,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,qCAAqC,CAAA;AAC7F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAChF,OAAO,KAAK,EAAE,gCAAgC,EAAyB,MAAM,wBAAwB,CAAA;AAErG;;;;gEAIgE;AAEhE,MAAM,WAAW,6BAA6B;IAC5C,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf;;;;0EAIsE;IAC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