@ai-ecoverse/slicc-kernel 1.124.9 → 1.124.10

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.
@@ -740,7 +740,7 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
740
740
  const { stats, lstats } = cache;
741
741
  const view = bridge.changes;
742
742
  const live = (miss, path) => miss.until > now() && (view === void 0 || miss.gen === void 0 || !view.changedSince(miss.gen, path).changed);
743
- const seenAt = /* @__PURE__ */ new Map();
743
+ const seen = new SeenAt(view, lstats);
744
744
  const gone = (path) => {
745
745
  for (let at = path.lastIndexOf("/"); at > 0; at = path.lastIndexOf("/", at - 1)) {
746
746
  const up = path.slice(0, at);
@@ -756,13 +756,14 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
756
756
  if (blind || view?.foreign()) return get();
757
757
  cache.fresh();
758
758
  let hit = map.get(path);
759
+ if (hit !== void 0 && !("until" in hit) && seen.changed(map, path)) hit = void 0;
759
760
  if (hit === void 0 || "until" in hit && !live(hit, path)) {
760
761
  const missing2 = gone(path);
761
762
  if (missing2) throw missing2.error;
762
763
  const gen = view?.now();
763
764
  try {
764
765
  hit = get();
765
- if (gen !== void 0 && map === lstats) seenAt.set(path, gen);
766
+ if (gen !== void 0) seen.saw(map, path, gen);
766
767
  } catch (e) {
767
768
  hit = {
768
769
  error: e,
@@ -815,18 +816,23 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
815
816
  readFile: (p) => bridge.readFile(p),
816
817
  readdir: (p) => bridge.readdir(p),
817
818
  readdirStat: (p) => {
819
+ const gen = view?.now();
818
820
  const list = bridge.readdirStat(p);
819
821
  const base = p === "/" ? "" : p;
820
822
  for (const [name2, st] of list) {
821
823
  if (!st || blind) continue;
822
- cache.put(lstats, `${base}/${name2}`, st);
823
- if (!st.isSymbolicLink) cache.put(stats, `${base}/${name2}`, st);
824
+ const at = `${base}/${name2}`;
825
+ cache.put(lstats, at, st);
826
+ if (gen !== void 0) seen.saw(lstats, at, gen);
827
+ if (st.isSymbolicLink) continue;
828
+ cache.put(stats, at, st);
829
+ if (gen !== void 0) seen.saw(stats, at, gen);
824
830
  }
825
831
  return list;
826
832
  },
827
833
  readlink: (p) => {
828
834
  const known = blind ? void 0 : (cache.fresh(), lstats.get(p));
829
- const gen = seenAt.get(p);
835
+ const gen = seen.lstat(p);
830
836
  const current = view !== void 0 && gen !== void 0 && !view.changedSince(gen, p).changed;
831
837
  if (known && current && !("until" in known) && !known.isSymbolicLink) {
832
838
  throw syncError("EINVAL", `'${p}' is not a symbolic link`);
@@ -897,7 +903,7 @@ function pinnedIo(bridge, handle, rewriting) {
897
903
  } : {}
898
904
  };
899
905
  }
900
- var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING, RING_SIZE, SLOT, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache;
906
+ var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING, RING_SIZE, SLOT, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt;
901
907
  var init_wasi_files = __esm({
902
908
  "src/process/wasi/wasi-files.ts"() {
903
909
  "use strict";
@@ -1256,6 +1262,37 @@ var init_wasi_files = __esm({
1256
1262
  this.byIno.clear();
1257
1263
  }
1258
1264
  };
1265
+ SEEN_CAP = 4096;
1266
+ SeenAt = class {
1267
+ view;
1268
+ lstats;
1269
+ links = /* @__PURE__ */ new Map();
1270
+ stats = /* @__PURE__ */ new Map();
1271
+ constructor(view, lstats) {
1272
+ this.view = view;
1273
+ this.lstats = lstats;
1274
+ }
1275
+ of(map) {
1276
+ return map === this.lstats ? this.links : this.stats;
1277
+ }
1278
+ lstat(path) {
1279
+ return this.links.get(path);
1280
+ }
1281
+ saw(map, path, gen) {
1282
+ const seen = this.of(map);
1283
+ if (seen.size >= SEEN_CAP) seen.clear();
1284
+ seen.set(path, gen);
1285
+ }
1286
+ changed(map, path) {
1287
+ if (this.view === void 0) return false;
1288
+ const seen = this.of(map);
1289
+ const gen = seen.get(path);
1290
+ if (gen === void 0) return true;
1291
+ const since = this.view.changedSince(gen, path);
1292
+ if (!since.changed) seen.set(path, since.now);
1293
+ return since.changed;
1294
+ }
1295
+ };
1259
1296
  }
1260
1297
  });
1261
1298
 
@@ -5451,7 +5488,7 @@ var KERNEL_VERSION, OS_RELEASE;
5451
5488
  var init_version = __esm({
5452
5489
  "src/version.ts"() {
5453
5490
  "use strict";
5454
- KERNEL_VERSION = true ? "1.124.9" : "0.0.0-dev";
5491
+ KERNEL_VERSION = true ? "1.124.10" : "0.0.0-dev";
5455
5492
  OS_RELEASE = "6.0.0-slicc";
5456
5493
  }
5457
5494
  });