@ai-ecoverse/slicc-kernel 1.124.9 → 1.124.11

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,
@@ -800,6 +801,17 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
800
801
  else cache.mutated([]);
801
802
  }
802
803
  };
804
+ const relabeling = (p, op) => {
805
+ if (exact || !bridge.identifyNext) return rewriting(p, op);
806
+ bridge.identifyNext();
807
+ try {
808
+ return op();
809
+ } finally {
810
+ const st = bridge.identified?.() ?? null;
811
+ if (st) cache.mutated([p], st.ino);
812
+ else cache.mutated([]);
813
+ }
814
+ };
803
815
  const rewriting = (p, op, ...also) => {
804
816
  if (exact) return identified(p, op, also);
805
817
  const ino = cache.inoOf(p, () => bridge.stat(p));
@@ -815,18 +827,23 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
815
827
  readFile: (p) => bridge.readFile(p),
816
828
  readdir: (p) => bridge.readdir(p),
817
829
  readdirStat: (p) => {
830
+ const gen = view?.now();
818
831
  const list = bridge.readdirStat(p);
819
832
  const base = p === "/" ? "" : p;
820
833
  for (const [name2, st] of list) {
821
834
  if (!st || blind) continue;
822
- cache.put(lstats, `${base}/${name2}`, st);
823
- if (!st.isSymbolicLink) cache.put(stats, `${base}/${name2}`, st);
835
+ const at = `${base}/${name2}`;
836
+ cache.put(lstats, at, st);
837
+ if (gen !== void 0) seen.saw(lstats, at, gen);
838
+ if (st.isSymbolicLink) continue;
839
+ cache.put(stats, at, st);
840
+ if (gen !== void 0) seen.saw(stats, at, gen);
824
841
  }
825
842
  return list;
826
843
  },
827
844
  readlink: (p) => {
828
845
  const known = blind ? void 0 : (cache.fresh(), lstats.get(p));
829
- const gen = seenAt.get(p);
846
+ const gen = seen.lstat(p);
830
847
  const current = view !== void 0 && gen !== void 0 && !view.changedSince(gen, p).changed;
831
848
  if (known && current && !("until" in known) && !known.isSymbolicLink) {
832
849
  throw syncError("EINVAL", `'${p}' is not a symbolic link`);
@@ -851,8 +868,8 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
851
868
  unlink: (p) => mutating(() => bridge.unlink(p)),
852
869
  rmdir: (p) => mutating(() => bridge.rmdir(p)),
853
870
  symlink: (target, link) => mutating(() => bridge.symlink(target, link), ...entry(link)),
854
- chmod: (p, mode) => rewriting(p, () => bridge.chmod(p, mode)),
855
- utimes: (p, a, m, now2) => rewriting(p, () => bridge.utimes(p, a, m, now2)),
871
+ chmod: (p, mode) => relabeling(p, () => bridge.chmod(p, mode)),
872
+ utimes: (p, a, m, now2) => relabeling(p, () => bridge.utimes(p, a, m, now2)),
856
873
  lutimes: (p, a, m, now2) => mutating(() => bridge.lutimes(p, a, m, now2)),
857
874
  ...bridge.hold ? { hold: bridge.hold.bind(bridge) } : {},
858
875
  ...bridge.access ? { access: bridge.access.bind(bridge) } : {},
@@ -866,7 +883,7 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
866
883
  mkfifo: (p, mode) => mutating(() => bridge.mkfifo?.(p, mode), ...entry(p))
867
884
  } : {},
868
885
  ...chown ? {
869
- chown: (p, ...rest2) => rewriting(p, () => chown.call(bridge, p, ...rest2))
886
+ chown: (p, ...rest2) => relabeling(p, () => chown.call(bridge, p, ...rest2))
870
887
  } : {},
871
888
  ...bridge.pread && bridge.pwrite && bridge.truncate ? {
872
889
  pread: bridge.pread.bind(bridge),
@@ -897,7 +914,7 @@ function pinnedIo(bridge, handle, rewriting) {
897
914
  } : {}
898
915
  };
899
916
  }
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;
917
+ 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
918
  var init_wasi_files = __esm({
902
919
  "src/process/wasi/wasi-files.ts"() {
903
920
  "use strict";
@@ -1256,6 +1273,37 @@ var init_wasi_files = __esm({
1256
1273
  this.byIno.clear();
1257
1274
  }
1258
1275
  };
1276
+ SEEN_CAP = 4096;
1277
+ SeenAt = class {
1278
+ view;
1279
+ lstats;
1280
+ links = /* @__PURE__ */ new Map();
1281
+ stats = /* @__PURE__ */ new Map();
1282
+ constructor(view, lstats) {
1283
+ this.view = view;
1284
+ this.lstats = lstats;
1285
+ }
1286
+ of(map) {
1287
+ return map === this.lstats ? this.links : this.stats;
1288
+ }
1289
+ lstat(path) {
1290
+ return this.links.get(path);
1291
+ }
1292
+ saw(map, path, gen) {
1293
+ const seen = this.of(map);
1294
+ if (seen.size >= SEEN_CAP) seen.clear();
1295
+ seen.set(path, gen);
1296
+ }
1297
+ changed(map, path) {
1298
+ if (this.view === void 0) return false;
1299
+ const seen = this.of(map);
1300
+ const gen = seen.get(path);
1301
+ if (gen === void 0) return true;
1302
+ const since = this.view.changedSince(gen, path);
1303
+ if (!since.changed) seen.set(path, since.now);
1304
+ return since.changed;
1305
+ }
1306
+ };
1259
1307
  }
1260
1308
  });
1261
1309
 
@@ -5451,7 +5499,7 @@ var KERNEL_VERSION, OS_RELEASE;
5451
5499
  var init_version = __esm({
5452
5500
  "src/version.ts"() {
5453
5501
  "use strict";
5454
- KERNEL_VERSION = true ? "1.124.9" : "0.0.0-dev";
5502
+ KERNEL_VERSION = true ? "1.124.11" : "0.0.0-dev";
5455
5503
  OS_RELEASE = "6.0.0-slicc";
5456
5504
  }
5457
5505
  });
@@ -7411,6 +7459,7 @@ function errnoError(code2, path) {
7411
7459
  function createSyncFsSabBridge(transport, opts = {}) {
7412
7460
  const timeoutMs2 = opts.timeoutMs ?? SYNC_FS_REQUEST_TIMEOUT_MS;
7413
7461
  let identity = {};
7462
+ let once = false;
7414
7463
  let last = null;
7415
7464
  function run(req, path, transfer) {
7416
7465
  last = null;
@@ -7429,7 +7478,9 @@ function createSyncFsSabBridge(transport, opts = {}) {
7429
7478
  throw errnoError("EIO", path);
7430
7479
  }
7431
7480
  const changing = (req, path, transfer) => {
7432
- const r = run({ ...req, ...identity }, path, transfer);
7481
+ const ask = once ? { identity: true } : identity;
7482
+ once = false;
7483
+ const r = run({ ...req, ...ask }, path, transfer);
7433
7484
  if (r.ok && r.kind === "json") last = parseSyncFsStat(r.json);
7434
7485
  };
7435
7486
  const io = (id) => ({
@@ -7526,7 +7577,14 @@ function createSyncFsSabBridge(transport, opts = {}) {
7526
7577
  identify: () => {
7527
7578
  identity = { identity: true };
7528
7579
  },
7529
- identified: () => last,
7580
+ identifyNext: () => {
7581
+ once = true;
7582
+ last = null;
7583
+ },
7584
+ identified: () => {
7585
+ once = false;
7586
+ return last;
7587
+ },
7530
7588
  lutimes: (path, atimeMs, mtimeMs, now) => {
7531
7589
  run({ op: "lutimes", path, atimeMs, mtimeMs, ...now ? { now } : {} }, path);
7532
7590
  },