@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.
@@ -9365,7 +9365,7 @@ function satisfies(version, range2) {
9365
9365
  }
9366
9366
 
9367
9367
  // src/version.ts
9368
- var KERNEL_VERSION = true ? "1.195.26" : "0.0.0-dev";
9368
+ var KERNEL_VERSION = true ? "1.195.27" : "0.0.0-dev";
9369
9369
  var OS_RELEASE = "6.0.0-slicc";
9370
9370
  function procVersion() {
9371
9371
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -9774,12 +9774,12 @@ function binfmtEntry(pkg, key, value2) {
9774
9774
  return { name: key, pkg, command: value2, preserveArgv0: false };
9775
9775
  }
9776
9776
  async function scanBinfmts(fs, modules, warn = () => {
9777
- }) {
9777
+ }, readManifest = (path) => fs.readFile(path)) {
9778
9778
  const found = /* @__PURE__ */ new Map();
9779
9779
  for (const pkg of await packagesIn(fs, modules)) {
9780
9780
  let manifest;
9781
9781
  try {
9782
- manifest = JSON.parse(await fs.readFile(`${pkg}/package.json`));
9782
+ manifest = JSON.parse(await readManifest(`${pkg}/package.json`));
9783
9783
  } catch {
9784
9784
  continue;
9785
9785
  }
@@ -21709,6 +21709,9 @@ var SealedBroker = class {
21709
21709
 
21710
21710
  // src/sudo-files.ts
21711
21711
  var HEADER_BYTES = 256;
21712
+ async function fingerprint(bytes) {
21713
+ return { head: new Uint8Array(bytes.subarray(0, HEADER_BYTES)), hash: await sha256(bytes) };
21714
+ }
21712
21715
  var SudoReads = class {
21713
21716
  access;
21714
21717
  reads = /* @__PURE__ */ new Map();
@@ -21722,18 +21725,26 @@ var SudoReads = class {
21722
21725
  bytes(real) {
21723
21726
  let read = this.reads.get(real);
21724
21727
  if (!read) {
21725
- const saved = this.snapshots.get(real);
21726
- read = (saved ? Promise.resolve(saved) : this.access.read(real)).then(
21727
- async (data) => ({
21728
- head: new Uint8Array(data.subarray(0, HEADER_BYTES)),
21729
- hash: await sha256(data)
21730
- }),
21731
- () => void 0
21732
- );
21728
+ read = this.raw(real).then(fingerprint, () => void 0);
21733
21729
  this.reads.set(real, read);
21734
21730
  }
21735
21731
  return read;
21736
21732
  }
21733
+ raw(real) {
21734
+ const saved = this.snapshots.get(real);
21735
+ return saved ? Promise.resolve(saved) : this.access.read(real);
21736
+ }
21737
+ async manifest(path, verify) {
21738
+ const real = await this.access.real(path);
21739
+ this.saw(path, real);
21740
+ const bytes = new Uint8Array(await this.raw(real));
21741
+ await verify(real, bytes);
21742
+ const read = await fingerprint(bytes);
21743
+ const earlier = this.reads.get(real);
21744
+ const consistent = !earlier || (await earlier)?.hash === read.hash;
21745
+ this.reads.set(real, Promise.resolve(consistent ? read : void 0));
21746
+ return new TextDecoder().decode(bytes);
21747
+ }
21737
21748
  saw(path, real) {
21738
21749
  const seen = this.names.get(path);
21739
21750
  this.names.set(path, seen === void 0 || seen === real ? real : "");
@@ -33986,7 +33997,7 @@ function header3(headers, name2) {
33986
33997
  const values = headers.filter(([n]) => n.toLowerCase() === name2).map(([, v]) => v);
33987
33998
  return values.length > 0 ? values.join(", ") : void 0;
33988
33999
  }
33989
- function fingerprint(headers) {
34000
+ function fingerprint2(headers) {
33990
34001
  const fields = MATCHED.map((name2) => header3(headers, name2) ?? "");
33991
34002
  return JSON.stringify([...fields, header3(headers, "authorization") !== void 0]);
33992
34003
  }
@@ -34057,7 +34068,7 @@ function replayingHops(inner, heldMs = HELD_MS) {
34057
34068
  const owner = caller ?? KERNEL;
34058
34069
  const key = keyOf3(owner, request3.method, request3.url);
34059
34070
  const waiting = held2.get(key);
34060
- if (waiting && waiting.fingerprint === fingerprint(request3.headers)) {
34071
+ if (waiting && waiting.fingerprint === fingerprint2(request3.headers)) {
34061
34072
  held2.delete(key);
34062
34073
  clearTimeout(waiting.timer);
34063
34074
  return replay(waiting);
@@ -34068,7 +34079,7 @@ function replayingHops(inner, heldMs = HELD_MS) {
34068
34079
  return replay({
34069
34080
  owner,
34070
34081
  method: request3.method,
34071
- fingerprint: fingerprint(request3.headers),
34082
+ fingerprint: fingerprint2(request3.headers),
34072
34083
  hops: response.redirects,
34073
34084
  final: response
34074
34085
  });
@@ -37361,21 +37372,31 @@ var Launcher = class {
37361
37372
  const roots = await Promise.all(homes.map((home) => pnpmGlobalRoots(this.base, home)));
37362
37373
  return new Set(roots.flat());
37363
37374
  }
37364
- interpreters(scope = "") {
37375
+ interpreters(scope = "", reads) {
37365
37376
  if (this.leaseImage) return Promise.resolve([]);
37377
+ if (reads) return this.scanInterpreters(scope, reads);
37366
37378
  let found = this.binfmts.get(scope);
37367
37379
  if (!found) {
37368
- found = this.roots(scope).then(
37369
- (roots) => scanBinfmts(this.scanned, roots, (message3) => {
37370
- if (this.warned.has(message3)) return;
37371
- this.warned.add(message3);
37372
- console.warn(message3);
37373
- })
37374
- );
37380
+ found = this.scanInterpreters(scope);
37375
37381
  this.binfmts.set(scope, found);
37376
37382
  }
37377
37383
  return found;
37378
37384
  }
37385
+ async scanInterpreters(scope, reads) {
37386
+ const read = reads && ((path) => reads.manifest(path, async (real, bytes) => {
37387
+ await this.integrity?.checkSnapshot(path, real, bytes, KERNEL_CALLER);
37388
+ }));
37389
+ return scanBinfmts(
37390
+ this.scanned,
37391
+ await this.roots(scope),
37392
+ (message3) => {
37393
+ if (this.warned.has(message3)) return;
37394
+ this.warned.add(message3);
37395
+ console.warn(message3);
37396
+ },
37397
+ read
37398
+ );
37399
+ }
37379
37400
  async tiers(scope = "", appended2) {
37380
37401
  const system = [
37381
37402
  [this.modulesDir],
@@ -37648,15 +37669,15 @@ var Launcher = class {
37648
37669
  if (!reader || !this.dac) return true;
37649
37670
  return (await access(this.fs, reader, path, R_OK)).denied === void 0;
37650
37671
  }
37651
- async binfmtOf(path, head, scope, reader) {
37672
+ async binfmtOf(path, head, scope, reader, reads) {
37652
37673
  const shown2 = await this.mayRead(reader, path) ? head : void 0;
37653
- return binfmtFor(await this.interpreters(scope), path, shown2);
37674
+ return binfmtFor(await this.interpreters(scope, reads), path, shown2);
37654
37675
  }
37655
37676
  async interpreterWords(head, script, who) {
37656
37677
  const bang = shebang(head);
37657
37678
  if (bang) return { words: bang, kept: [], binfmts: [] };
37658
37679
  if (isWasm(head)) return void 0;
37659
- const binfmt = await this.binfmtOf(script, head, who.scope, who.reader);
37680
+ const binfmt = await this.binfmtOf(script, head, who.scope, who.reader, who.reads);
37660
37681
  if (!binfmt) return void 0;
37661
37682
  const kept = binfmt.preserveArgv0 ? [who.argv0 ?? who.argv[0]] : [];
37662
37683
  return { words: [binfmt.command], kept, binfmts: [`${binfmt.pkg}/package.json`] };