@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.
@@ -788,35 +788,64 @@ function copying(bridge, mutating, entry) {
788
788
  copy: (from, to, mode, exclusive) => mutating(() => copy2.call(bridge, from, to, mode, exclusive), ...entry(to))
789
789
  };
790
790
  }
791
+ function listed({ cache, seen, filled }, p, list, gen, asked) {
792
+ const base = p === "/" ? "" : p;
793
+ for (const [name2, st] of list) {
794
+ if (!st) continue;
795
+ filled.set(st, asked);
796
+ const at = `${base}/${name2}`;
797
+ cache.put(cache.lstats, at, st);
798
+ if (gen !== void 0) seen.saw(cache.lstats, at, gen);
799
+ if (st.isSymbolicLink) continue;
800
+ cache.put(cache.stats, at, st);
801
+ if (gen !== void 0) seen.saw(cache.stats, at, gen);
802
+ }
803
+ }
804
+ function fetched({
805
+ view,
806
+ now,
807
+ seen,
808
+ filled,
809
+ cache
810
+ }, map, path, get) {
811
+ const gen = view?.now();
812
+ const asked = now();
813
+ let hit;
814
+ try {
815
+ hit = get();
816
+ if (gen !== void 0) seen.saw(map, path, gen);
817
+ } catch (e) {
818
+ hit = { error: e, until: asked + MISS_TTL_MS, ...gen !== void 0 ? { gen } : {} };
819
+ }
820
+ filled.set(hit, asked);
821
+ cache.put(map, path, hit);
822
+ return hit;
823
+ }
791
824
  function cachingBridge(bridge, now = () => performance.now(), shared) {
792
825
  const blind = shared !== void 0 && shared.length * 4 < SHARED_IDS_BYTES;
793
826
  const cache = new StatCache(blind ? void 0 : shared);
794
827
  const { stats, lstats } = cache;
795
828
  const view = bridge.changes;
796
- const live = (miss, path) => miss.until > now() && (view === void 0 || miss.gen === void 0 || !view.changedSince(miss.gen, path).changed);
829
+ const filled = new Fills(view, now);
830
+ const young = (entry2) => filled.young(entry2);
831
+ const live = (miss, path) => miss.until > now() && young(miss) && (view === void 0 || miss.gen === void 0 || !view.changedSince(miss.gen, path).changed);
797
832
  const seen = new SeenAt(view, lstats);
798
- const kept = remember(cache, seen, blind);
833
+ const kept = remember(cache, seen, blind, (entry2) => filled.set(entry2));
799
834
  const gone = (path) => goneAbove([lstats, stats], live, path);
835
+ const usable = (map, path) => {
836
+ const hit = map.get(path);
837
+ if (hit === void 0) return void 0;
838
+ if ("until" in hit) return live(hit, path) ? hit : void 0;
839
+ return young(hit) && !seen.changed(map, path) ? hit : void 0;
840
+ };
800
841
  const cached = (map, path, get) => {
801
- if (blind || view?.foreign()) return get();
842
+ if (blind) return get();
802
843
  cache.fresh();
803
- let hit = map.get(path);
804
- if (hit !== void 0 && !("until" in hit) && seen.changed(map, path)) hit = void 0;
805
- if (hit === void 0 || "until" in hit && !live(hit, path)) {
844
+ let hit = usable(map, path);
845
+ if (hit === void 0) {
806
846
  const missing2 = gone(path);
807
847
  if (missing2) throw missing2.error;
808
- const gen = view?.now();
809
- try {
810
- hit = get();
811
- if (gen !== void 0) seen.saw(map, path, gen);
812
- } catch (e) {
813
- hit = {
814
- error: e,
815
- until: now() + MISS_TTL_MS,
816
- ...gen !== void 0 ? { gen } : {}
817
- };
818
- }
819
- cache.put(map, path, hit);
848
+ hit = fetched({ view, now, seen, filled, cache }, map, path, get);
820
849
  }
821
850
  if ("until" in hit) throw hit.error;
822
851
  return hit;
@@ -873,24 +902,16 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
873
902
  readdir: (p) => bridge.readdir(p),
874
903
  readdirStat: (p) => {
875
904
  const gen = view?.now();
905
+ const asked = now();
876
906
  const list = bridge.readdirStat(p);
877
- const base = p === "/" ? "" : p;
878
- for (const [name2, st] of list) {
879
- if (!st || blind) continue;
880
- const at = `${base}/${name2}`;
881
- cache.put(lstats, at, st);
882
- if (gen !== void 0) seen.saw(lstats, at, gen);
883
- if (st.isSymbolicLink) continue;
884
- cache.put(stats, at, st);
885
- if (gen !== void 0) seen.saw(stats, at, gen);
886
- }
907
+ if (!blind) listed({ cache, seen, filled }, p, list, gen, asked);
887
908
  return list;
888
909
  },
889
910
  readlink: (p) => {
890
911
  const known = blind ? void 0 : (cache.fresh(), lstats.get(p));
891
912
  const gen = seen.lstat(p);
892
913
  const current = view !== void 0 && gen !== void 0 && !view.changedSince(gen, p).changed;
893
- if (known && current && !("until" in known) && !known.isSymbolicLink) {
914
+ if (known && current && !("until" in known) && young(known) && !known.isSymbolicLink) {
894
915
  throw syncError("EINVAL", `'${p}' is not a symbolic link`);
895
916
  }
896
917
  return bridge.readlink(p);
@@ -963,7 +984,7 @@ function pinnedIo(bridge, handle, rewriting) {
963
984
  } : {}
964
985
  };
965
986
  }
966
- var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, UMASK, RING, RING_SIZE, SLOT, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt, remember;
987
+ var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, SHARED_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, UMASK, RING, RING_SIZE, SLOT, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt, remember, Fills;
967
988
  var init_wasi_files = __esm({
968
989
  "src/process/wasi/wasi-files.ts"() {
969
990
  "use strict";
@@ -1190,6 +1211,7 @@ var init_wasi_files = __esm({
1190
1211
  };
1191
1212
  MAX_LINKS = 40;
1192
1213
  MISS_TTL_MS = 20;
1214
+ SHARED_TTL_MS = 100;
1193
1215
  CACHE_CAP = 8192;
1194
1216
  FS_GEN = 4;
1195
1217
  CRED_GEN = 5;
@@ -1354,13 +1376,30 @@ var init_wasi_files = __esm({
1354
1376
  return since.changed;
1355
1377
  }
1356
1378
  };
1357
- remember = (cache, seen, blind) => (path, made) => {
1379
+ remember = (cache, seen, blind, fill) => (path, made) => {
1358
1380
  if (!made || blind) return made;
1359
1381
  const { seen: at, ...st } = made;
1382
+ fill(st);
1360
1383
  cache.put(cache.stats, path, st);
1361
1384
  if (at !== void 0) seen.saw(cache.stats, path, at);
1362
1385
  return made;
1363
1386
  };
1387
+ Fills = class {
1388
+ at = /* @__PURE__ */ new WeakMap();
1389
+ view;
1390
+ now;
1391
+ constructor(view, now) {
1392
+ this.view = view;
1393
+ this.now = now;
1394
+ }
1395
+ set(entry, at = this.now()) {
1396
+ this.at.set(entry, at);
1397
+ }
1398
+ young(entry) {
1399
+ if (!this.view?.foreign()) return true;
1400
+ return this.now() - (this.at.get(entry) ?? Number.NEGATIVE_INFINITY) < SHARED_TTL_MS;
1401
+ }
1402
+ };
1364
1403
  }
1365
1404
  });
1366
1405
 
@@ -5925,8 +5964,8 @@ var init_wasi_host = __esm({
5925
5964
  }
5926
5965
  list(path) {
5927
5966
  const { fs } = this.o;
5928
- const listed = fs.readdirStat(path);
5929
- return { names: [".", "..", ...listed.map(([name2]) => name2)], stats: new Map(listed) };
5967
+ const listed2 = fs.readdirStat(path);
5968
+ return { names: [".", "..", ...listed2.map(([name2]) => name2)], stats: new Map(listed2) };
5930
5969
  }
5931
5970
  lstatOrNull(path) {
5932
5971
  try {
@@ -6440,7 +6479,7 @@ var KERNEL_VERSION, OS_RELEASE;
6440
6479
  var init_version = __esm({
6441
6480
  "src/version.ts"() {
6442
6481
  "use strict";
6443
- KERNEL_VERSION = true ? "1.130.0" : "0.0.0-dev";
6482
+ KERNEL_VERSION = true ? "1.130.1" : "0.0.0-dev";
6444
6483
  OS_RELEASE = "6.0.0-slicc";
6445
6484
  }
6446
6485
  });
@@ -8348,9 +8387,9 @@ function createNodeOps(h) {
8348
8387
  node.live.stat = void 0;
8349
8388
  },
8350
8389
  lookup(parent, name2) {
8351
- const listed = parent.live.listed?.get(name2);
8390
+ const listed2 = parent.live.listed?.get(name2);
8352
8391
  parent.live.listed?.delete(name2);
8353
- const st = listed ?? call2(() => bridgeOf(parent).lstat(childPath(parent, name2)));
8392
+ const st = listed2 ?? call2(() => bridgeOf(parent).lstat(childPath(parent, name2)));
8354
8393
  return makeNode(parent, name2, st);
8355
8394
  },
8356
8395
  mknod(parent, name2, mode) {
@@ -8424,10 +8463,10 @@ function createNodeOps(h) {
8424
8463
  call2(() => bridgeOf(parent).rmdir(childPath(parent, name2)));
8425
8464
  },
8426
8465
  readdir(node) {
8427
- const listed = call2(() => bridgeOf(node).readdirStat(liveNodePath(node)));
8466
+ const listed2 = call2(() => bridgeOf(node).readdirStat(liveNodePath(node)));
8428
8467
  node.live.listed = /* @__PURE__ */ new Map();
8429
- for (const [name2, st] of listed) if (st) node.live.listed.set(name2, st);
8430
- return [".", "..", ...listed.map(([name2]) => name2)];
8468
+ for (const [name2, st] of listed2) if (st) node.live.listed.set(name2, st);
8469
+ return [".", "..", ...listed2.map(([name2]) => name2)];
8431
8470
  },
8432
8471
  symlink(parent, newName, target) {
8433
8472
  parent.live.listed = void 0;
@@ -10461,7 +10500,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
10461
10500
  return dir;
10462
10501
  };
10463
10502
  const scans = /* @__PURE__ */ new Map();
10464
- const listed = (target) => {
10503
+ const listed2 = (target) => {
10465
10504
  let found = false;
10466
10505
  for (const [stream, pids] of scans) {
10467
10506
  if (Fs.streams && Fs.streams[stream.fd ?? -1] !== stream) scans.delete(stream);
@@ -10482,7 +10521,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
10482
10521
  ...procOps2,
10483
10522
  lookup: (parent, name2) => {
10484
10523
  if (/^[1-9]\d*$/.test(name2)) {
10485
- if (!infoOf(Number(name2)) && !listed(Number(name2))) throw error();
10524
+ if (!infoOf(Number(name2)) && !listed2(Number(name2))) throw error();
10486
10525
  return pidDir(name2, Number(name2));
10487
10526
  }
10488
10527
  if (name2 === "mounts") return file(parent, name2, () => mountTable(sys.mountList?.() ?? []));
@@ -10798,9 +10837,9 @@ function procfsBridge(fs, tree) {
10798
10837
  }
10799
10838
  }),
10800
10839
  () => {
10801
- const listed = fs.readdirStat(p);
10802
- if (p !== "/" || listed.some(([name2]) => name2 === "proc")) return listed;
10803
- return [...listed, ["proc", tree.stat("/proc")]];
10840
+ const listed2 = fs.readdirStat(p);
10841
+ if (p !== "/" || listed2.some(([name2]) => name2 === "proc")) return listed2;
10842
+ return [...listed2, ["proc", tree.stat("/proc")]];
10804
10843
  }
10805
10844
  ),
10806
10845
  rename: (from, to) => readOnly2(
@@ -15254,17 +15293,17 @@ function ptsBridge(fs, call2) {
15254
15293
  },
15255
15294
  readdir: (p) => {
15256
15295
  if (p === PTS) return names();
15257
- const listed = fs.readdir(p);
15258
- return p === "/dev" && !listed.includes("pts") ? [...listed, "pts"] : listed;
15296
+ const listed2 = fs.readdir(p);
15297
+ return p === "/dev" && !listed2.includes("pts") ? [...listed2, "pts"] : listed2;
15259
15298
  },
15260
15299
  readdirStat: (p) => {
15261
15300
  if (p === PTS) {
15262
15301
  const known = open();
15263
15302
  return names(known).map((name2) => listedEntry(name2, known));
15264
15303
  }
15265
- const listed = fs.readdirStat(p);
15266
- if (p !== "/dev" || listed.some(([name2]) => name2 === "pts")) return listed;
15267
- return [...listed, ["pts", dir()]];
15304
+ const listed2 = fs.readdirStat(p);
15305
+ if (p !== "/dev" || listed2.some(([name2]) => name2 === "pts")) return listed2;
15306
+ return [...listed2, ["pts", dir()]];
15268
15307
  }
15269
15308
  };
15270
15309
  return new Proxy(fs, {