@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.
@@ -1174,6 +1174,7 @@ function errnoError(code2, path) {
1174
1174
  function createSyncFsSabBridge(transport, opts = {}) {
1175
1175
  const timeoutMs2 = opts.timeoutMs ?? SYNC_FS_REQUEST_TIMEOUT_MS;
1176
1176
  let identity = {};
1177
+ let once = false;
1177
1178
  let last = null;
1178
1179
  function run(req, path, transfer) {
1179
1180
  last = null;
@@ -1192,7 +1193,9 @@ function createSyncFsSabBridge(transport, opts = {}) {
1192
1193
  throw errnoError("EIO", path);
1193
1194
  }
1194
1195
  const changing = (req, path, transfer) => {
1195
- const r = run({ ...req, ...identity }, path, transfer);
1196
+ const ask = once ? { identity: true } : identity;
1197
+ once = false;
1198
+ const r = run({ ...req, ...ask }, path, transfer);
1196
1199
  if (r.ok && r.kind === "json") last = parseSyncFsStat(r.json);
1197
1200
  };
1198
1201
  const io = (id) => ({
@@ -1289,7 +1292,14 @@ function createSyncFsSabBridge(transport, opts = {}) {
1289
1292
  identify: () => {
1290
1293
  identity = { identity: true };
1291
1294
  },
1292
- identified: () => last,
1295
+ identifyNext: () => {
1296
+ once = true;
1297
+ last = null;
1298
+ },
1299
+ identified: () => {
1300
+ once = false;
1301
+ return last;
1302
+ },
1293
1303
  lutimes: (path, atimeMs, mtimeMs, now) => {
1294
1304
  run({ op: "lutimes", path, atimeMs, mtimeMs, ...now ? { now } : {} }, path);
1295
1305
  },
@@ -2624,7 +2634,7 @@ var KERNEL_VERSION, OS_RELEASE;
2624
2634
  var init_version = __esm({
2625
2635
  "src/version.ts"() {
2626
2636
  "use strict";
2627
- KERNEL_VERSION = true ? "1.124.9" : "0.0.0-dev";
2637
+ KERNEL_VERSION = true ? "1.124.11" : "0.0.0-dev";
2628
2638
  OS_RELEASE = "6.0.0-slicc";
2629
2639
  }
2630
2640
  });
@@ -6589,7 +6599,7 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
6589
6599
  const { stats, lstats } = cache;
6590
6600
  const view = bridge.changes;
6591
6601
  const live = (miss, path) => miss.until > now() && (view === void 0 || miss.gen === void 0 || !view.changedSince(miss.gen, path).changed);
6592
- const seenAt = /* @__PURE__ */ new Map();
6602
+ const seen = new SeenAt(view, lstats);
6593
6603
  const gone = (path) => {
6594
6604
  for (let at = path.lastIndexOf("/"); at > 0; at = path.lastIndexOf("/", at - 1)) {
6595
6605
  const up = path.slice(0, at);
@@ -6605,13 +6615,14 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
6605
6615
  if (blind || view?.foreign()) return get();
6606
6616
  cache.fresh();
6607
6617
  let hit = map.get(path);
6618
+ if (hit !== void 0 && !("until" in hit) && seen.changed(map, path)) hit = void 0;
6608
6619
  if (hit === void 0 || "until" in hit && !live(hit, path)) {
6609
6620
  const missing2 = gone(path);
6610
6621
  if (missing2) throw missing2.error;
6611
6622
  const gen = view?.now();
6612
6623
  try {
6613
6624
  hit = get();
6614
- if (gen !== void 0 && map === lstats) seenAt.set(path, gen);
6625
+ if (gen !== void 0) seen.saw(map, path, gen);
6615
6626
  } catch (e) {
6616
6627
  hit = {
6617
6628
  error: e,
@@ -6649,6 +6660,17 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
6649
6660
  else cache.mutated([]);
6650
6661
  }
6651
6662
  };
6663
+ const relabeling = (p, op) => {
6664
+ if (exact || !bridge.identifyNext) return rewriting(p, op);
6665
+ bridge.identifyNext();
6666
+ try {
6667
+ return op();
6668
+ } finally {
6669
+ const st = bridge.identified?.() ?? null;
6670
+ if (st) cache.mutated([p], st.ino);
6671
+ else cache.mutated([]);
6672
+ }
6673
+ };
6652
6674
  const rewriting = (p, op, ...also) => {
6653
6675
  if (exact) return identified(p, op, also);
6654
6676
  const ino = cache.inoOf(p, () => bridge.stat(p));
@@ -6664,18 +6686,23 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
6664
6686
  readFile: (p) => bridge.readFile(p),
6665
6687
  readdir: (p) => bridge.readdir(p),
6666
6688
  readdirStat: (p) => {
6689
+ const gen = view?.now();
6667
6690
  const list = bridge.readdirStat(p);
6668
6691
  const base = p === "/" ? "" : p;
6669
6692
  for (const [name2, st] of list) {
6670
6693
  if (!st || blind) continue;
6671
- cache.put(lstats, `${base}/${name2}`, st);
6672
- if (!st.isSymbolicLink) cache.put(stats, `${base}/${name2}`, st);
6694
+ const at = `${base}/${name2}`;
6695
+ cache.put(lstats, at, st);
6696
+ if (gen !== void 0) seen.saw(lstats, at, gen);
6697
+ if (st.isSymbolicLink) continue;
6698
+ cache.put(stats, at, st);
6699
+ if (gen !== void 0) seen.saw(stats, at, gen);
6673
6700
  }
6674
6701
  return list;
6675
6702
  },
6676
6703
  readlink: (p) => {
6677
6704
  const known = blind ? void 0 : (cache.fresh(), lstats.get(p));
6678
- const gen = seenAt.get(p);
6705
+ const gen = seen.lstat(p);
6679
6706
  const current = view !== void 0 && gen !== void 0 && !view.changedSince(gen, p).changed;
6680
6707
  if (known && current && !("until" in known) && !known.isSymbolicLink) {
6681
6708
  throw syncError("EINVAL", `'${p}' is not a symbolic link`);
@@ -6700,8 +6727,8 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
6700
6727
  unlink: (p) => mutating(() => bridge.unlink(p)),
6701
6728
  rmdir: (p) => mutating(() => bridge.rmdir(p)),
6702
6729
  symlink: (target, link) => mutating(() => bridge.symlink(target, link), ...entry(link)),
6703
- chmod: (p, mode) => rewriting(p, () => bridge.chmod(p, mode)),
6704
- utimes: (p, a, m, now2) => rewriting(p, () => bridge.utimes(p, a, m, now2)),
6730
+ chmod: (p, mode) => relabeling(p, () => bridge.chmod(p, mode)),
6731
+ utimes: (p, a, m, now2) => relabeling(p, () => bridge.utimes(p, a, m, now2)),
6705
6732
  lutimes: (p, a, m, now2) => mutating(() => bridge.lutimes(p, a, m, now2)),
6706
6733
  ...bridge.hold ? { hold: bridge.hold.bind(bridge) } : {},
6707
6734
  ...bridge.access ? { access: bridge.access.bind(bridge) } : {},
@@ -6715,7 +6742,7 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
6715
6742
  mkfifo: (p, mode) => mutating(() => bridge.mkfifo?.(p, mode), ...entry(p))
6716
6743
  } : {},
6717
6744
  ...chown ? {
6718
- chown: (p, ...rest2) => rewriting(p, () => chown.call(bridge, p, ...rest2))
6745
+ chown: (p, ...rest2) => relabeling(p, () => chown.call(bridge, p, ...rest2))
6719
6746
  } : {},
6720
6747
  ...bridge.pread && bridge.pwrite && bridge.truncate ? {
6721
6748
  pread: bridge.pread.bind(bridge),
@@ -6746,7 +6773,7 @@ function pinnedIo2(bridge, handle, rewriting) {
6746
6773
  } : {}
6747
6774
  };
6748
6775
  }
6749
- var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING2, RING_SIZE2, SLOT2, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache;
6776
+ var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING2, RING_SIZE2, SLOT2, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt;
6750
6777
  var init_wasi_files = __esm({
6751
6778
  "src/process/wasi/wasi-files.ts"() {
6752
6779
  "use strict";
@@ -7105,6 +7132,37 @@ var init_wasi_files = __esm({
7105
7132
  this.byIno.clear();
7106
7133
  }
7107
7134
  };
7135
+ SEEN_CAP = 4096;
7136
+ SeenAt = class {
7137
+ view;
7138
+ lstats;
7139
+ links = /* @__PURE__ */ new Map();
7140
+ stats = /* @__PURE__ */ new Map();
7141
+ constructor(view, lstats) {
7142
+ this.view = view;
7143
+ this.lstats = lstats;
7144
+ }
7145
+ of(map) {
7146
+ return map === this.lstats ? this.links : this.stats;
7147
+ }
7148
+ lstat(path) {
7149
+ return this.links.get(path);
7150
+ }
7151
+ saw(map, path, gen) {
7152
+ const seen = this.of(map);
7153
+ if (seen.size >= SEEN_CAP) seen.clear();
7154
+ seen.set(path, gen);
7155
+ }
7156
+ changed(map, path) {
7157
+ if (this.view === void 0) return false;
7158
+ const seen = this.of(map);
7159
+ const gen = seen.get(path);
7160
+ if (gen === void 0) return true;
7161
+ const since = this.view.changedSince(gen, path);
7162
+ if (!since.changed) seen.set(path, since.now);
7163
+ return since.changed;
7164
+ }
7165
+ };
7108
7166
  }
7109
7167
  });
7110
7168