@ai-ecoverse/slicc-kernel 1.195.26 → 1.195.27

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.
@@ -5156,7 +5156,7 @@ function satisfies(version, range2) {
5156
5156
  }
5157
5157
 
5158
5158
  // src/version.ts
5159
- var KERNEL_VERSION = true ? "1.195.26" : "0.0.0-dev";
5159
+ var KERNEL_VERSION = true ? "1.195.27" : "0.0.0-dev";
5160
5160
  var OS_RELEASE = "6.0.0-slicc";
5161
5161
  function procVersion() {
5162
5162
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -5565,12 +5565,12 @@ function binfmtEntry(pkg, key, value2) {
5565
5565
  return { name: key, pkg, command: value2, preserveArgv0: false };
5566
5566
  }
5567
5567
  async function scanBinfmts(fs, modules, warn = () => {
5568
- }) {
5568
+ }, readManifest = (path) => fs.readFile(path)) {
5569
5569
  const found = /* @__PURE__ */ new Map();
5570
5570
  for (const pkg of await packagesIn(fs, modules)) {
5571
5571
  let manifest;
5572
5572
  try {
5573
- manifest = JSON.parse(await fs.readFile(`${pkg}/package.json`));
5573
+ manifest = JSON.parse(await readManifest(`${pkg}/package.json`));
5574
5574
  } catch {
5575
5575
  continue;
5576
5576
  }
@@ -18176,6 +18176,9 @@ var SealedBroker = class {
18176
18176
 
18177
18177
  // src/sudo-files.ts
18178
18178
  var HEADER_BYTES = 256;
18179
+ async function fingerprint(bytes) {
18180
+ return { head: new Uint8Array(bytes.subarray(0, HEADER_BYTES)), hash: await sha2562(bytes) };
18181
+ }
18179
18182
  var SudoReads = class {
18180
18183
  access;
18181
18184
  reads = /* @__PURE__ */ new Map();
@@ -18189,18 +18192,26 @@ var SudoReads = class {
18189
18192
  bytes(real2) {
18190
18193
  let read = this.reads.get(real2);
18191
18194
  if (!read) {
18192
- const saved = this.snapshots.get(real2);
18193
- read = (saved ? Promise.resolve(saved) : this.access.read(real2)).then(
18194
- async (data) => ({
18195
- head: new Uint8Array(data.subarray(0, HEADER_BYTES)),
18196
- hash: await sha2562(data)
18197
- }),
18198
- () => void 0
18199
- );
18195
+ read = this.raw(real2).then(fingerprint, () => void 0);
18200
18196
  this.reads.set(real2, read);
18201
18197
  }
18202
18198
  return read;
18203
18199
  }
18200
+ raw(real2) {
18201
+ const saved = this.snapshots.get(real2);
18202
+ return saved ? Promise.resolve(saved) : this.access.read(real2);
18203
+ }
18204
+ async manifest(path, verify) {
18205
+ const real2 = await this.access.real(path);
18206
+ this.saw(path, real2);
18207
+ const bytes = new Uint8Array(await this.raw(real2));
18208
+ await verify(real2, bytes);
18209
+ const read = await fingerprint(bytes);
18210
+ const earlier = this.reads.get(real2);
18211
+ const consistent = !earlier || (await earlier)?.hash === read.hash;
18212
+ this.reads.set(real2, Promise.resolve(consistent ? read : void 0));
18213
+ return new TextDecoder().decode(bytes);
18214
+ }
18204
18215
  saw(path, real2) {
18205
18216
  const seen = this.names.get(path);
18206
18217
  this.names.set(path, seen === void 0 || seen === real2 ? real2 : "");
@@ -31090,7 +31101,7 @@ function header3(headers, name2) {
31090
31101
  const values = headers.filter(([n]) => n.toLowerCase() === name2).map(([, v]) => v);
31091
31102
  return values.length > 0 ? values.join(", ") : void 0;
31092
31103
  }
31093
- function fingerprint(headers) {
31104
+ function fingerprint2(headers) {
31094
31105
  const fields2 = MATCHED.map((name2) => header3(headers, name2) ?? "");
31095
31106
  return JSON.stringify([...fields2, header3(headers, "authorization") !== void 0]);
31096
31107
  }
@@ -31161,7 +31172,7 @@ function replayingHops(inner, heldMs = HELD_MS) {
31161
31172
  const owner = caller ?? KERNEL;
31162
31173
  const key = keyOf4(owner, request2.method, request2.url);
31163
31174
  const waiting2 = held2.get(key);
31164
- if (waiting2 && waiting2.fingerprint === fingerprint(request2.headers)) {
31175
+ if (waiting2 && waiting2.fingerprint === fingerprint2(request2.headers)) {
31165
31176
  held2.delete(key);
31166
31177
  clearTimeout(waiting2.timer);
31167
31178
  return replay(waiting2);
@@ -31172,7 +31183,7 @@ function replayingHops(inner, heldMs = HELD_MS) {
31172
31183
  return replay({
31173
31184
  owner,
31174
31185
  method: request2.method,
31175
- fingerprint: fingerprint(request2.headers),
31186
+ fingerprint: fingerprint2(request2.headers),
31176
31187
  hops: response.redirects,
31177
31188
  final: response
31178
31189
  });
@@ -36944,21 +36955,31 @@ var Launcher = class {
36944
36955
  const roots = await Promise.all(homes.map((home) => pnpmGlobalRoots(this.base, home)));
36945
36956
  return new Set(roots.flat());
36946
36957
  }
36947
- interpreters(scope = "") {
36958
+ interpreters(scope = "", reads) {
36948
36959
  if (this.leaseImage) return Promise.resolve([]);
36960
+ if (reads) return this.scanInterpreters(scope, reads);
36949
36961
  let found = this.binfmts.get(scope);
36950
36962
  if (!found) {
36951
- found = this.roots(scope).then(
36952
- (roots) => scanBinfmts(this.scanned, roots, (message3) => {
36953
- if (this.warned.has(message3)) return;
36954
- this.warned.add(message3);
36955
- console.warn(message3);
36956
- })
36957
- );
36963
+ found = this.scanInterpreters(scope);
36958
36964
  this.binfmts.set(scope, found);
36959
36965
  }
36960
36966
  return found;
36961
36967
  }
36968
+ async scanInterpreters(scope, reads) {
36969
+ const read = reads && ((path) => reads.manifest(path, async (real2, bytes) => {
36970
+ await this.integrity?.checkSnapshot(path, real2, bytes, KERNEL_CALLER);
36971
+ }));
36972
+ return scanBinfmts(
36973
+ this.scanned,
36974
+ await this.roots(scope),
36975
+ (message3) => {
36976
+ if (this.warned.has(message3)) return;
36977
+ this.warned.add(message3);
36978
+ console.warn(message3);
36979
+ },
36980
+ read
36981
+ );
36982
+ }
36962
36983
  async tiers(scope = "", appended2) {
36963
36984
  const system = [
36964
36985
  [this.modulesDir],
@@ -37231,15 +37252,15 @@ var Launcher = class {
37231
37252
  if (!reader || !this.dac) return true;
37232
37253
  return (await access(this.fs, reader, path, R_OK)).denied === void 0;
37233
37254
  }
37234
- async binfmtOf(path, head, scope, reader) {
37255
+ async binfmtOf(path, head, scope, reader, reads) {
37235
37256
  const shown2 = await this.mayRead(reader, path) ? head : void 0;
37236
- return binfmtFor(await this.interpreters(scope), path, shown2);
37257
+ return binfmtFor(await this.interpreters(scope, reads), path, shown2);
37237
37258
  }
37238
37259
  async interpreterWords(head, script, who) {
37239
37260
  const bang = shebang(head);
37240
37261
  if (bang) return { words: bang, kept: [], binfmts: [] };
37241
37262
  if (isWasm(head)) return void 0;
37242
- const binfmt = await this.binfmtOf(script, head, who.scope, who.reader);
37263
+ const binfmt = await this.binfmtOf(script, head, who.scope, who.reader, who.reads);
37243
37264
  if (!binfmt) return void 0;
37244
37265
  const kept = binfmt.preserveArgv0 ? [who.argv0 ?? who.argv[0]] : [];
37245
37266
  return { words: [binfmt.command], kept, binfmts: [`${binfmt.pkg}/package.json`] };