@ai-ecoverse/slicc-kernel 1.178.2 → 1.178.3

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.
@@ -1339,8 +1339,8 @@ var RemoteWatch = class {
1339
1339
  const { held = [], pending = [] } = await this.locks.query();
1340
1340
  if (![...held, ...pending].some((lock) => lock.name === name2)) {
1341
1341
  this.mourned.delete(peer);
1342
- const live = this.peers.has(peer) || this.flushes.has(peer);
1343
- if (tries > 1 && live) {
1342
+ const live2 = this.peers.has(peer) || this.flushes.has(peer);
1343
+ if (tries > 1 && live2) {
1344
1344
  setTimeout(() => void this.mourn(peer, tries - 1), MOURN_RETRY_MS);
1345
1345
  } else this.flushedAt(peer);
1346
1346
  return;
@@ -1830,11 +1830,11 @@ async function positioned(handle, op) {
1830
1830
  }
1831
1831
  return;
1832
1832
  }
1833
- const writable2 = await handle.createWritable({ keepExistingData: true });
1833
+ const writable3 = await handle.createWritable({ keepExistingData: true });
1834
1834
  try {
1835
1835
  await op({
1836
1836
  write: async (at, bytes) => {
1837
- await writable2.write({
1837
+ await writable3.write({
1838
1838
  type: "write",
1839
1839
  position: at,
1840
1840
  data: bytes
@@ -1842,15 +1842,15 @@ async function positioned(handle, op) {
1842
1842
  extent.wrote(at + bytes.length);
1843
1843
  },
1844
1844
  truncate: async (n) => {
1845
- await writable2.truncate(n);
1845
+ await writable3.truncate(n);
1846
1846
  extent.cut(n);
1847
1847
  }
1848
1848
  });
1849
1849
  } catch (err) {
1850
- await writable2.abort();
1850
+ await writable3.abort();
1851
1851
  throw err;
1852
1852
  }
1853
- await writable2.close();
1853
+ await writable3.close();
1854
1854
  if (extent.big()) extent.check((await handle.getFile()).size);
1855
1855
  }
1856
1856
  function syncAccessHandles(scope = globalThis) {
@@ -2936,21 +2936,21 @@ var OpfsFs = class {
2936
2936
  }
2937
2937
  async writeSession(path, truncate) {
2938
2938
  const [handle, , target] = await this.fileFor(path);
2939
- const writable2 = await this.retrying(
2939
+ const writable3 = await this.retrying(
2940
2940
  path,
2941
2941
  () => this.io(handle.createWritable({ keepExistingData: !truncate })),
2942
2942
  true
2943
2943
  );
2944
2944
  return {
2945
- write: (at, bytes) => writable2.write({ type: "write", position: at, data: bytes }).catch((err) => {
2945
+ write: (at, bytes) => writable3.write({ type: "write", position: at, data: bytes }).catch((err) => {
2946
2946
  throw translate(err, path, "write", false);
2947
2947
  }),
2948
- truncate: (size) => writable2.truncate(size).catch((err) => {
2948
+ truncate: (size) => writable3.truncate(size).catch((err) => {
2949
2949
  throw translate(err, path, "write", false);
2950
2950
  }),
2951
2951
  close: async () => {
2952
2952
  this.wrote(handle);
2953
- await writable2.close().catch((err) => {
2953
+ await writable3.close().catch((err) => {
2954
2954
  this.wrote(handle);
2955
2955
  throw translate(err, path, "commit", false);
2956
2956
  });
@@ -3002,19 +3002,19 @@ var OpfsFs = class {
3002
3002
  const [file, existed, target] = await this.fileFor(path, owner?.existing !== true);
3003
3003
  if (!existed) await this.stampNew(target, owner, false);
3004
3004
  if (!existed && content.length === 0) return;
3005
- let writable2;
3005
+ let writable3;
3006
3006
  this.wrote(file);
3007
3007
  try {
3008
- writable2 = await this.io(file.createWritable());
3009
- await writable2.write(content);
3010
- await writable2.close();
3008
+ writable3 = await this.io(file.createWritable());
3009
+ await writable3.write(content);
3010
+ await writable3.close();
3011
3011
  if (typeof content !== "string" && content.length >= CHECKED_BYTES) {
3012
3012
  const extent = new Extent();
3013
3013
  extent.cut(content.length);
3014
3014
  extent.check((await file.getFile()).size);
3015
3015
  }
3016
3016
  } catch (err) {
3017
- await writable2?.abort().catch(() => void 0);
3017
+ await writable3?.abort().catch(() => void 0);
3018
3018
  throw translate(err, path, "commit", false);
3019
3019
  } finally {
3020
3020
  this.wrote(file);
@@ -3739,7 +3739,7 @@ var OpfsFs = class {
3739
3739
  created4 = true;
3740
3740
  }
3741
3741
  let target = destination;
3742
- let writable2;
3742
+ let writable3;
3743
3743
  let handle;
3744
3744
  try {
3745
3745
  const kept = created4 ? this.files.get(destination) : void 0;
@@ -3758,11 +3758,11 @@ var OpfsFs = class {
3758
3758
  if (entry?.fifo || entry?.socket) throw fsError("ENXIO", to);
3759
3759
  }
3760
3760
  this.wrote(handle);
3761
- writable2 = await handle.createWritable();
3762
- await writable2.write(file);
3763
- await writable2.close();
3761
+ writable3 = await handle.createWritable();
3762
+ await writable3.write(file);
3763
+ await writable3.close();
3764
3764
  } catch (err) {
3765
- await writable2?.abort().catch(() => void 0);
3765
+ await writable3?.abort().catch(() => void 0);
3766
3766
  if (created4) await this.rm(target, { file: true }).catch(() => void 0);
3767
3767
  throw translate(err, to, "commit", false);
3768
3768
  } finally {
@@ -3851,10 +3851,10 @@ var OpfsFs = class {
3851
3851
  }
3852
3852
  if (handle.kind === "file") {
3853
3853
  const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
3854
- const writable2 = await this.io(made2.createWritable());
3854
+ const writable3 = await this.io(made2.createWritable());
3855
3855
  const file = await this.io(handle.getFile());
3856
- await writable2.write(file);
3857
- await writable2.close();
3856
+ await writable3.write(file);
3857
+ await writable3.close();
3858
3858
  copies?.set(rest2, { before: copies.get(rest2)?.before ?? file.lastModified, made: made2 });
3859
3859
  return;
3860
3860
  }
@@ -8777,7 +8777,7 @@ function satisfies(version, range2) {
8777
8777
  }
8778
8778
 
8779
8779
  // src/version.ts
8780
- var KERNEL_VERSION = true ? "1.178.2" : "0.0.0-dev";
8780
+ var KERNEL_VERSION = true ? "1.178.3" : "0.0.0-dev";
8781
8781
  var OS_RELEASE = "6.0.0-slicc";
8782
8782
  function procVersion() {
8783
8783
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -17089,11 +17089,11 @@ function systemFile(name2, listing, now, memory) {
17089
17089
  listing.processes.reduce((sum2, p) => sum2 + p.memory, 0)
17090
17090
  );
17091
17091
  }
17092
- const live = listing.processes.filter((p) => p.state !== "Z");
17092
+ const live2 = listing.processes.filter((p) => p.state !== "Z");
17093
17093
  if (name2 === "loadavg") {
17094
17094
  const last = Math.max(0, ...listing.processes.map((p) => p.pid));
17095
17095
  const [one, five, fifteen] = (listing.load ?? [0, 0, 0]).map((n) => n.toFixed(2));
17096
- return `${one} ${five} ${fifteen} 1/${live.length} ${last}
17096
+ return `${one} ${five} ${fifteen} 1/${live2.length} ${last}
17097
17097
  `;
17098
17098
  }
17099
17099
  const sum = (key) => listing.cpu?.[key] ?? listing.processes.reduce((n, p) => n + (p[key] ?? 0), 0);
@@ -19582,30 +19582,49 @@ function timestampKey(owner, type) {
19582
19582
  }
19583
19583
  return parent ? JSON.stringify(["ppid", parent.pid, parent.started]) : void 0;
19584
19584
  }
19585
+ function boundKey(bound3) {
19586
+ return JSON.stringify(
19587
+ Object.keys(bound3).sort().map((path) => [path, bound3[path]])
19588
+ );
19589
+ }
19590
+ function writable2(bound3) {
19591
+ return bound3 !== void 0 && Object.keys(bound3).length > 0;
19592
+ }
19593
+ function live(stamp, policy, now) {
19594
+ return stamp.at <= now && (policy.minutes < 0 || now - stamp.at < policy.minutes * MINUTE_MS2);
19595
+ }
19585
19596
  var Timestamps = class {
19586
19597
  users = /* @__PURE__ */ new Map();
19587
19598
  now;
19588
19599
  constructor(now) {
19589
19600
  this.now = now;
19590
19601
  }
19591
- current(owner, policy) {
19602
+ current(owner, policy, bound3) {
19592
19603
  if (policy.minutes === 0) return false;
19593
19604
  const key = timestampKey(owner, policy.type);
19594
- const at = key === void 0 ? void 0 : this.users.get(owner.uid)?.get(key);
19595
- if (at === void 0) return false;
19605
+ const stamp = key === void 0 ? void 0 : this.users.get(owner.uid)?.get(key);
19606
+ if (stamp === void 0) return false;
19596
19607
  const now = this.now();
19597
- return at <= now && (policy.minutes < 0 || now - at < policy.minutes * MINUTE_MS2);
19608
+ if (!live(stamp, policy, now)) {
19609
+ this.drop(owner.uid, key);
19610
+ return false;
19611
+ }
19612
+ if (!writable2(bound3)) return true;
19613
+ return stamp.covered.has(boundKey(bound3));
19598
19614
  }
19599
- stamp(owner, policy) {
19615
+ stamp(owner, policy, bound3) {
19600
19616
  const key = policy.minutes === 0 ? void 0 : timestampKey(owner, policy.type);
19601
19617
  if (key === void 0) return false;
19602
19618
  const now = this.now();
19603
19619
  const records = this.users.get(owner.uid) ?? /* @__PURE__ */ new Map();
19604
19620
  this.users.set(owner.uid, records);
19621
+ const prior = records.get(key);
19622
+ const covered = prior !== void 0 && live(prior, policy, now) ? prior.covered : /* @__PURE__ */ new Set();
19623
+ if (writable2(bound3)) covered.add(boundKey(bound3));
19605
19624
  records.delete(key);
19606
- records.set(key, now);
19607
- for (const [old, at] of records) {
19608
- const stale = policy.minutes > 0 && (at > now || now - at >= policy.minutes * MINUTE_MS2);
19625
+ records.set(key, { at: now, covered });
19626
+ for (const [old, stamp] of records) {
19627
+ const stale = policy.minutes > 0 && !live(stamp, policy, now);
19609
19628
  if (stale || records.size > TIMESTAMPS_MAX) records.delete(old);
19610
19629
  }
19611
19630
  return true;
@@ -19619,6 +19638,11 @@ var Timestamps = class {
19619
19638
  remove(uid) {
19620
19639
  this.users.delete(uid);
19621
19640
  }
19641
+ drop(uid, key) {
19642
+ const records = this.users.get(uid);
19643
+ records?.delete(key);
19644
+ if (records?.size === 0) this.users.delete(uid);
19645
+ }
19622
19646
  };
19623
19647
 
19624
19648
  // src/sudoers.ts
@@ -20248,12 +20272,12 @@ function usable(parsed2) {
20248
20272
  function policyOf(settings) {
20249
20273
  return { type: settings.timestampType, minutes: settings.timestampTimeout };
20250
20274
  }
20251
- function described(rule, writable2) {
20275
+ function described(rule, writable3) {
20252
20276
  const cmnd = rule.cmnd === "*" ? "ALL" : commandText(rule.cmnd);
20253
20277
  const cwd = rule.cwd === void 0 ? "" : `CWD=${quoteWord(rule.cwd)} `;
20254
20278
  const stdin = rule.stdin === void 0 ? "" : "STDIN=none ";
20255
20279
  const sums = Object.entries(rule.sha256 ?? {}).map(([path, hex4]) => `SHA256=${quoteWord(path)}:${hex4} `).join("");
20256
- const flag = writable2 ? " # user-writable command" : "";
20280
+ const flag = writable3 ? " # user-writable command" : "";
20257
20281
  return ` (${rule.target}) ${cwd}${stdin}${sums}${rule.nopasswd ? "NOPASSWD: " : ""}${cmnd}${flag}`;
20258
20282
  }
20259
20283
  var Sudo = class {
@@ -20546,8 +20570,8 @@ var Sudo = class {
20546
20570
  `sudo: ${self.name} is not allowed to run ${quoted} as ${target.name}`
20547
20571
  );
20548
20572
  }
20549
- if (!parsed2.reset && this.timestamps.current(s.owner, s.policy)) {
20550
- this.timestamps.stamp(s.owner, s.policy);
20573
+ if (!parsed2.reset && this.timestamps.current(s.owner, s.policy, bound3)) {
20574
+ this.timestamps.stamp(s.owner, s.policy, bound3);
20551
20575
  this.logged(s, cwd, argv);
20552
20576
  return grant();
20553
20577
  }
@@ -20562,7 +20586,7 @@ var Sudo = class {
20562
20586
  if (!now) return failed2("ENOENT", `sudo: ${word}: command not found`);
20563
20587
  const shown2 = recordable(cwd, [...parsed2.command, ...Object.keys(bound3)]);
20564
20588
  const result = answer2.answer === "once" ? grant() : await this.always(self, target, { cwd, argv, bound: bound3 }, now, shown2, grant);
20565
- if (!("error" in result)) this.stamped(s, answer2);
20589
+ if (!("error" in result)) this.stamped(s, answer2, bound3);
20566
20590
  return result;
20567
20591
  });
20568
20592
  }
@@ -20596,8 +20620,8 @@ var Sudo = class {
20596
20620
  this.pending.delete(uid);
20597
20621
  }
20598
20622
  }
20599
- stamped(s, answer2) {
20600
- if (answer2.person && !s.parsed.reset) this.timestamps.stamp(s.owner, s.policy);
20623
+ stamped(s, answer2, bound3 = {}) {
20624
+ if (answer2.person && !s.parsed.reset) this.timestamps.stamp(s.owner, s.policy, bound3);
20601
20625
  }
20602
20626
  logged(s, cwd, argv) {
20603
20627
  const { caller, self, target, owner, policy } = s;
@@ -26954,18 +26978,18 @@ var VfsNodes = class {
26954
26978
  if (id2 !== void 0) this.know(node, id2);
26955
26979
  return node;
26956
26980
  }
26957
- open(path, pin, writable2 = false, id2, ino) {
26981
+ open(path, pin, writable3 = false, id2, ino) {
26958
26982
  const found = this.named(path, id2);
26959
26983
  const same3 = !found || ino === void 0 || found.ino === void 0 || found.ino === ino;
26960
26984
  if (found && !same3) this.orphan(found);
26961
26985
  const node = (same3 ? found : void 0) ?? this.create(path, id2, new VfsNode(this.fs, path, void 0, false, false, pin));
26962
26986
  node.ino ??= ino;
26963
26987
  node.opens++;
26964
- if (writable2) node.writers++;
26988
+ if (writable3) node.writers++;
26965
26989
  if (node.opens === 1) this.opened?.(node);
26966
26990
  return node;
26967
26991
  }
26968
- adopt(path, contents2, dirty, writable2 = false, id2) {
26992
+ adopt(path, contents2, dirty, writable3 = false, id2) {
26969
26993
  let node = this.named(path, id2);
26970
26994
  if (!node) {
26971
26995
  node = this.create(path, id2, new VfsNode(this.fs, path, contents2, false, dirty));
@@ -26973,7 +26997,7 @@ var VfsNodes = class {
26973
26997
  node.replace(contents2);
26974
26998
  }
26975
26999
  node.opens++;
26976
- if (writable2) node.writers++;
27000
+ if (writable3) node.writers++;
26977
27001
  if (node.opens === 1) this.opened?.(node);
26978
27002
  return node;
26979
27003
  }
@@ -26986,11 +27010,11 @@ var VfsNodes = class {
26986
27010
  if (node.writers > 0 && within9(path, prefix)) return true;
26987
27011
  return false;
26988
27012
  }
26989
- closed(node, writable2 = false) {
27013
+ closed(node, writable3 = false) {
26990
27014
  node.opens--;
26991
- if (writable2) node.writers--;
27015
+ if (writable3) node.writers--;
26992
27016
  if (node.opens > 0) {
26993
- if (writable2 && node.writers === 0) this.onClosed?.(node.path);
27017
+ if (writable3 && node.writers === 0) this.onClosed?.(node.path);
26994
27018
  return;
26995
27019
  }
26996
27020
  this.forget(node);
@@ -27309,8 +27333,8 @@ function keepingOpen(fs, nodes, changed = () => {
27309
27333
  function vfsFile(fs, opts, nodes) {
27310
27334
  const access2 = opts.flags & O_ACCMODE;
27311
27335
  const readable2 = access2 !== O_WRONLY;
27312
- const writable2 = access2 === O_WRONLY || access2 === O_RDWR;
27313
- const node = !nodes || opts.orphan ? new VfsNode(fs, opts.path, opts.contents, opts.orphan === true, opts.dirty === true) : opts.contents !== void 0 ? nodes.adopt(opts.path, opts.contents, opts.dirty === true, writable2, opts.id) : nodes.open(opts.path, opts.pin, writable2, opts.id, opts.ino);
27336
+ const writable3 = access2 === O_WRONLY || access2 === O_RDWR;
27337
+ const node = !nodes || opts.orphan ? new VfsNode(fs, opts.path, opts.contents, opts.orphan === true, opts.dirty === true) : opts.contents !== void 0 ? nodes.adopt(opts.path, opts.contents, opts.dirty === true, writable3, opts.id) : nodes.open(opts.path, opts.pin, writable3, opts.id, opts.ino);
27314
27338
  let openError;
27315
27339
  const atOpen = (op) => {
27316
27340
  void node.serial(op).catch((err) => {
@@ -27337,7 +27361,7 @@ function vfsFile(fs, opts, nodes) {
27337
27361
  offset += out.length;
27338
27362
  return out;
27339
27363
  }) : void 0,
27340
- write: writable2 ? (bytes) => serial(async () => {
27364
+ write: writable3 ? (bytes) => serial(async () => {
27341
27365
  if (opts.flags & O_APPEND) offset = await node.append(bytes);
27342
27366
  else offset += await node.pwrite(bytes, offset);
27343
27367
  return bytes.length;
@@ -27356,11 +27380,11 @@ function vfsFile(fs, opts, nodes) {
27356
27380
  return node.pread(max, at);
27357
27381
  }),
27358
27382
  pwrite: (bytes, at) => serial(() => {
27359
- if (!writable2) throw new KernelError("EBADF");
27383
+ if (!writable3) throw new KernelError("EBADF");
27360
27384
  return node.pwrite(bytes, at);
27361
27385
  }),
27362
27386
  resize: (size) => serial(() => {
27363
- if (!writable2) throw new KernelError("EBADF");
27387
+ if (!writable3) throw new KernelError("EBADF");
27364
27388
  return node.truncate(size);
27365
27389
  }),
27366
27390
  stat: () => serial(async () => ({
@@ -27376,7 +27400,7 @@ function vfsFile(fs, opts, nodes) {
27376
27400
  takeOpenError();
27377
27401
  await node.flush();
27378
27402
  } finally {
27379
- nodes?.closed(node, writable2);
27403
+ nodes?.closed(node, writable3);
27380
27404
  }
27381
27405
  })
27382
27406
  });
@@ -29105,8 +29129,8 @@ var WasmProcess = class {
29105
29129
  };
29106
29130
  withDl(state) {
29107
29131
  if (this.dlLog.length === 0) return state;
29108
- const { next: next3, handle, free, live } = this.closures;
29109
- const dl = { log: [...this.dlLog], next: next3, handle, free: [...free], live: [...live] };
29132
+ const { next: next3, handle, free, live: live2 } = this.closures;
29133
+ const dl = { log: [...this.dlLog], next: next3, handle, free: [...free], live: [...live2] };
29110
29134
  return { ...state, dl };
29111
29135
  }
29112
29136
  seedDl(dl) {
@@ -32330,7 +32354,7 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
32330
32354
  if (remote.client.token === remote.token && !remote.client.gone) return remote;
32331
32355
  throw fsError2("ESTALE", "the folder was granted again, so this open file is gone");
32332
32356
  };
32333
- const live = (fh) => {
32357
+ const live2 = (fh) => {
32334
32358
  const remote = handles.get(fh);
32335
32359
  if (!remote) throw fsError2("EBADF", `handle ${fh}`);
32336
32360
  return fresh3(remote);
@@ -32349,7 +32373,7 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
32349
32373
  }, againMs);
32350
32374
  timer.unref?.();
32351
32375
  });
32352
- async function writable2(client, path, flags2) {
32376
+ async function writable3(client, path, flags2) {
32353
32377
  const { ifMatch: _, ...asked } = flags2;
32354
32378
  const opening2 = () => client.call("open", { path: rel(path), ...asked });
32355
32379
  try {
@@ -32380,7 +32404,7 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
32380
32404
  async open(path, flags2) {
32381
32405
  const client = current();
32382
32406
  const token = client.token;
32383
- const { opened: opened2, restore } = await writable2(client, path, flags2);
32407
+ const { opened: opened2, restore } = await writable3(client, path, flags2);
32384
32408
  if (flags2.ifMatch !== void 0 && opened2.attr?.etag !== flags2.ifMatch) {
32385
32409
  await client.call("release", { fh: opened2.fh }, true);
32386
32410
  throw fsError2("ESTALE", `${path} changed on the host while it was being read`);
@@ -32395,7 +32419,7 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
32395
32419
  return nextFh;
32396
32420
  },
32397
32421
  async read(fh, offset, size) {
32398
- const remote = live(fh);
32422
+ const remote = live2(fh);
32399
32423
  return remote.client.read(
32400
32424
  remote.fh,
32401
32425
  offset,
@@ -32404,7 +32428,7 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
32404
32428
  );
32405
32429
  },
32406
32430
  async write(fh, offset, bytes) {
32407
- const remote = live(fh);
32431
+ const remote = live2(fh);
32408
32432
  const most = remote.client.maxIo;
32409
32433
  for (let at = 0; at < bytes.length; at += most) {
32410
32434
  await remote.client.write(remote.fh, offset + at, bytes.subarray(at, at + most));