@ai-ecoverse/slicc-kernel 1.130.0 → 1.130.1

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.
@@ -1802,9 +1802,9 @@ function createNodeOps(h) {
1802
1802
  node.live.stat = void 0;
1803
1803
  },
1804
1804
  lookup(parent, name2) {
1805
- const listed = parent.live.listed?.get(name2);
1805
+ const listed2 = parent.live.listed?.get(name2);
1806
1806
  parent.live.listed?.delete(name2);
1807
- const st = listed ?? call2(() => bridgeOf(parent).lstat(childPath(parent, name2)));
1807
+ const st = listed2 ?? call2(() => bridgeOf(parent).lstat(childPath(parent, name2)));
1808
1808
  return makeNode(parent, name2, st);
1809
1809
  },
1810
1810
  mknod(parent, name2, mode) {
@@ -1878,10 +1878,10 @@ function createNodeOps(h) {
1878
1878
  call2(() => bridgeOf(parent).rmdir(childPath(parent, name2)));
1879
1879
  },
1880
1880
  readdir(node) {
1881
- const listed = call2(() => bridgeOf(node).readdirStat(liveNodePath(node)));
1881
+ const listed2 = call2(() => bridgeOf(node).readdirStat(liveNodePath(node)));
1882
1882
  node.live.listed = /* @__PURE__ */ new Map();
1883
- for (const [name2, st] of listed) if (st) node.live.listed.set(name2, st);
1884
- return [".", "..", ...listed.map(([name2]) => name2)];
1883
+ for (const [name2, st] of listed2) if (st) node.live.listed.set(name2, st);
1884
+ return [".", "..", ...listed2.map(([name2]) => name2)];
1885
1885
  },
1886
1886
  symlink(parent, newName, target) {
1887
1887
  parent.live.listed = void 0;
@@ -2664,7 +2664,7 @@ var KERNEL_VERSION, OS_RELEASE;
2664
2664
  var init_version = __esm({
2665
2665
  "src/version.ts"() {
2666
2666
  "use strict";
2667
- KERNEL_VERSION = true ? "1.130.0" : "0.0.0-dev";
2667
+ KERNEL_VERSION = true ? "1.130.1" : "0.0.0-dev";
2668
2668
  OS_RELEASE = "6.0.0-slicc";
2669
2669
  }
2670
2670
  });
@@ -5634,7 +5634,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
5634
5634
  return dir;
5635
5635
  };
5636
5636
  const scans = /* @__PURE__ */ new Map();
5637
- const listed = (target) => {
5637
+ const listed2 = (target) => {
5638
5638
  let found = false;
5639
5639
  for (const [stream, pids] of scans) {
5640
5640
  if (Fs.streams && Fs.streams[stream.fd ?? -1] !== stream) scans.delete(stream);
@@ -5655,7 +5655,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
5655
5655
  ...procOps2,
5656
5656
  lookup: (parent, name2) => {
5657
5657
  if (/^[1-9]\d*$/.test(name2)) {
5658
- if (!infoOf(Number(name2)) && !listed(Number(name2))) throw error();
5658
+ if (!infoOf(Number(name2)) && !listed2(Number(name2))) throw error();
5659
5659
  return pidDir(name2, Number(name2));
5660
5660
  }
5661
5661
  if (name2 === "mounts") return file(parent, name2, () => mountTable(sys.mountList?.() ?? []));
@@ -6725,35 +6725,64 @@ function copying(bridge, mutating, entry) {
6725
6725
  copy: (from, to, mode, exclusive) => mutating(() => copy2.call(bridge, from, to, mode, exclusive), ...entry(to))
6726
6726
  };
6727
6727
  }
6728
+ function listed({ cache, seen, filled }, p, list, gen, asked) {
6729
+ const base = p === "/" ? "" : p;
6730
+ for (const [name2, st] of list) {
6731
+ if (!st) continue;
6732
+ filled.set(st, asked);
6733
+ const at = `${base}/${name2}`;
6734
+ cache.put(cache.lstats, at, st);
6735
+ if (gen !== void 0) seen.saw(cache.lstats, at, gen);
6736
+ if (st.isSymbolicLink) continue;
6737
+ cache.put(cache.stats, at, st);
6738
+ if (gen !== void 0) seen.saw(cache.stats, at, gen);
6739
+ }
6740
+ }
6741
+ function fetched({
6742
+ view,
6743
+ now,
6744
+ seen,
6745
+ filled,
6746
+ cache
6747
+ }, map, path, get) {
6748
+ const gen = view?.now();
6749
+ const asked = now();
6750
+ let hit;
6751
+ try {
6752
+ hit = get();
6753
+ if (gen !== void 0) seen.saw(map, path, gen);
6754
+ } catch (e) {
6755
+ hit = { error: e, until: asked + MISS_TTL_MS, ...gen !== void 0 ? { gen } : {} };
6756
+ }
6757
+ filled.set(hit, asked);
6758
+ cache.put(map, path, hit);
6759
+ return hit;
6760
+ }
6728
6761
  function cachingBridge(bridge, now = () => performance.now(), shared) {
6729
6762
  const blind = shared !== void 0 && shared.length * 4 < SHARED_IDS_BYTES;
6730
6763
  const cache = new StatCache(blind ? void 0 : shared);
6731
6764
  const { stats, lstats } = cache;
6732
6765
  const view = bridge.changes;
6733
- const live = (miss, path) => miss.until > now() && (view === void 0 || miss.gen === void 0 || !view.changedSince(miss.gen, path).changed);
6766
+ const filled = new Fills(view, now);
6767
+ const young = (entry2) => filled.young(entry2);
6768
+ const live = (miss, path) => miss.until > now() && young(miss) && (view === void 0 || miss.gen === void 0 || !view.changedSince(miss.gen, path).changed);
6734
6769
  const seen = new SeenAt(view, lstats);
6735
- const kept = remember(cache, seen, blind);
6770
+ const kept = remember(cache, seen, blind, (entry2) => filled.set(entry2));
6736
6771
  const gone = (path) => goneAbove([lstats, stats], live, path);
6772
+ const usable = (map, path) => {
6773
+ const hit = map.get(path);
6774
+ if (hit === void 0) return void 0;
6775
+ if ("until" in hit) return live(hit, path) ? hit : void 0;
6776
+ return young(hit) && !seen.changed(map, path) ? hit : void 0;
6777
+ };
6737
6778
  const cached = (map, path, get) => {
6738
- if (blind || view?.foreign()) return get();
6779
+ if (blind) return get();
6739
6780
  cache.fresh();
6740
- let hit = map.get(path);
6741
- if (hit !== void 0 && !("until" in hit) && seen.changed(map, path)) hit = void 0;
6742
- if (hit === void 0 || "until" in hit && !live(hit, path)) {
6781
+ let hit = usable(map, path);
6782
+ if (hit === void 0) {
6743
6783
  const missing2 = gone(path);
6744
6784
  if (missing2) throw missing2.error;
6745
- const gen = view?.now();
6746
- try {
6747
- hit = get();
6748
- if (gen !== void 0) seen.saw(map, path, gen);
6749
- } catch (e) {
6750
- hit = {
6751
- error: e,
6752
- until: now() + MISS_TTL_MS,
6753
- ...gen !== void 0 ? { gen } : {}
6754
- };
6755
- }
6756
- cache.put(map, path, hit);
6785
+ hit = fetched({ view, now, seen, filled, cache }, map, path, get);
6757
6786
  }
6758
6787
  if ("until" in hit) throw hit.error;
6759
6788
  return hit;
@@ -6810,24 +6839,16 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
6810
6839
  readdir: (p) => bridge.readdir(p),
6811
6840
  readdirStat: (p) => {
6812
6841
  const gen = view?.now();
6842
+ const asked = now();
6813
6843
  const list = bridge.readdirStat(p);
6814
- const base = p === "/" ? "" : p;
6815
- for (const [name2, st] of list) {
6816
- if (!st || blind) continue;
6817
- const at = `${base}/${name2}`;
6818
- cache.put(lstats, at, st);
6819
- if (gen !== void 0) seen.saw(lstats, at, gen);
6820
- if (st.isSymbolicLink) continue;
6821
- cache.put(stats, at, st);
6822
- if (gen !== void 0) seen.saw(stats, at, gen);
6823
- }
6844
+ if (!blind) listed({ cache, seen, filled }, p, list, gen, asked);
6824
6845
  return list;
6825
6846
  },
6826
6847
  readlink: (p) => {
6827
6848
  const known = blind ? void 0 : (cache.fresh(), lstats.get(p));
6828
6849
  const gen = seen.lstat(p);
6829
6850
  const current = view !== void 0 && gen !== void 0 && !view.changedSince(gen, p).changed;
6830
- if (known && current && !("until" in known) && !known.isSymbolicLink) {
6851
+ if (known && current && !("until" in known) && young(known) && !known.isSymbolicLink) {
6831
6852
  throw syncError("EINVAL", `'${p}' is not a symbolic link`);
6832
6853
  }
6833
6854
  return bridge.readlink(p);
@@ -6900,7 +6921,7 @@ function pinnedIo2(bridge, handle, rewriting) {
6900
6921
  } : {}
6901
6922
  };
6902
6923
  }
6903
- var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, UMASK2, RING2, RING_SIZE2, SLOT2, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt, remember;
6924
+ var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, SHARED_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, UMASK2, RING2, RING_SIZE2, SLOT2, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt, remember, Fills;
6904
6925
  var init_wasi_files = __esm({
6905
6926
  "src/process/wasi/wasi-files.ts"() {
6906
6927
  "use strict";
@@ -7127,6 +7148,7 @@ var init_wasi_files = __esm({
7127
7148
  };
7128
7149
  MAX_LINKS = 40;
7129
7150
  MISS_TTL_MS = 20;
7151
+ SHARED_TTL_MS = 100;
7130
7152
  CACHE_CAP = 8192;
7131
7153
  FS_GEN = 4;
7132
7154
  CRED_GEN = 5;
@@ -7291,13 +7313,30 @@ var init_wasi_files = __esm({
7291
7313
  return since.changed;
7292
7314
  }
7293
7315
  };
7294
- remember = (cache, seen, blind) => (path, made) => {
7316
+ remember = (cache, seen, blind, fill) => (path, made) => {
7295
7317
  if (!made || blind) return made;
7296
7318
  const { seen: at, ...st } = made;
7319
+ fill(st);
7297
7320
  cache.put(cache.stats, path, st);
7298
7321
  if (at !== void 0) seen.saw(cache.stats, path, at);
7299
7322
  return made;
7300
7323
  };
7324
+ Fills = class {
7325
+ at = /* @__PURE__ */ new WeakMap();
7326
+ view;
7327
+ now;
7328
+ constructor(view, now) {
7329
+ this.view = view;
7330
+ this.now = now;
7331
+ }
7332
+ set(entry, at = this.now()) {
7333
+ this.at.set(entry, at);
7334
+ }
7335
+ young(entry) {
7336
+ if (!this.view?.foreign()) return true;
7337
+ return this.now() - (this.at.get(entry) ?? Number.NEGATIVE_INFINITY) < SHARED_TTL_MS;
7338
+ }
7339
+ };
7301
7340
  }
7302
7341
  });
7303
7342
 
@@ -11378,8 +11417,8 @@ var init_wasi_host = __esm({
11378
11417
  }
11379
11418
  list(path) {
11380
11419
  const { fs } = this.o;
11381
- const listed = fs.readdirStat(path);
11382
- return { names: [".", "..", ...listed.map(([name2]) => name2)], stats: new Map(listed) };
11420
+ const listed2 = fs.readdirStat(path);
11421
+ return { names: [".", "..", ...listed2.map(([name2]) => name2)], stats: new Map(listed2) };
11383
11422
  }
11384
11423
  lstatOrNull(path) {
11385
11424
  try {
@@ -12184,9 +12223,9 @@ function procfsBridge(fs, tree) {
12184
12223
  }
12185
12224
  }),
12186
12225
  () => {
12187
- const listed = fs.readdirStat(p);
12188
- if (p !== "/" || listed.some(([name2]) => name2 === "proc")) return listed;
12189
- return [...listed, ["proc", tree.stat("/proc")]];
12226
+ const listed2 = fs.readdirStat(p);
12227
+ if (p !== "/" || listed2.some(([name2]) => name2 === "proc")) return listed2;
12228
+ return [...listed2, ["proc", tree.stat("/proc")]];
12190
12229
  }
12191
12230
  ),
12192
12231
  rename: (from, to) => readOnly2(
@@ -12428,17 +12467,17 @@ function ptsBridge(fs, call2) {
12428
12467
  },
12429
12468
  readdir: (p) => {
12430
12469
  if (p === PTS) return names();
12431
- const listed = fs.readdir(p);
12432
- return p === "/dev" && !listed.includes("pts") ? [...listed, "pts"] : listed;
12470
+ const listed2 = fs.readdir(p);
12471
+ return p === "/dev" && !listed2.includes("pts") ? [...listed2, "pts"] : listed2;
12433
12472
  },
12434
12473
  readdirStat: (p) => {
12435
12474
  if (p === PTS) {
12436
12475
  const known = open();
12437
12476
  return names(known).map((name2) => listedEntry(name2, known));
12438
12477
  }
12439
- const listed = fs.readdirStat(p);
12440
- if (p !== "/dev" || listed.some(([name2]) => name2 === "pts")) return listed;
12441
- return [...listed, ["pts", dir()]];
12478
+ const listed2 = fs.readdirStat(p);
12479
+ if (p !== "/dev" || listed2.some(([name2]) => name2 === "pts")) return listed2;
12480
+ return [...listed2, ["pts", dir()]];
12442
12481
  }
12443
12482
  };
12444
12483
  return new Proxy(fs, {