@ai-ecoverse/slicc-kernel 1.147.8 → 1.147.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.
@@ -1277,8 +1277,9 @@ async function swapped(op) {
1277
1277
  }
1278
1278
  var MAX_LINKS2 = 40;
1279
1279
  var CHECK_MS = 1e3;
1280
- var ABSENT_MS = 2;
1281
- var GLANCE_MS = 2;
1280
+ var ABSENT_LOOKUPS = 256;
1281
+ var GLANCE_LOOKUPS = 64;
1282
+ var GLANCE_CAP_MS = 100;
1282
1283
  var ABSENT_NAMES = 4096;
1283
1284
  var FILE_HANDLES = 4096;
1284
1285
  var STALE = /* @__PURE__ */ new Set(["NotFoundError", "TypeMismatchError"]);
@@ -1493,6 +1494,7 @@ var OpfsFs = class {
1493
1494
  dirs = new PathMap();
1494
1495
  files = new PathMap();
1495
1496
  absent = new PathMap();
1497
+ lookups = 0;
1496
1498
  changes = 0;
1497
1499
  replacing = Promise.resolve();
1498
1500
  replacements = 0;
@@ -1562,6 +1564,19 @@ var OpfsFs = class {
1562
1564
  for (const path of paths) this.forget(path);
1563
1565
  this.channel?.postMessage(paths);
1564
1566
  }
1567
+ heldUnder = () => [];
1568
+ heldBy(held) {
1569
+ this.heldUnder = held;
1570
+ }
1571
+ async pinHeld(dir) {
1572
+ const held = this.heldUnder(dir);
1573
+ if (held.length === 0) return;
1574
+ const known = await this.meta.get(held);
1575
+ const bare = held.filter((_, i) => known[i]?.ino === void 0);
1576
+ for (const p of bare) {
1577
+ await this.meta.update(p, (entry) => ({ ...occupied(entry), path: p, ino: inodeOf(p) }));
1578
+ }
1579
+ }
1565
1580
  remoteChanges(listener) {
1566
1581
  return this.remote?.listen(listener) ?? (() => {
1567
1582
  });
@@ -1838,7 +1853,7 @@ var OpfsFs = class {
1838
1853
  }
1839
1854
  missed(path) {
1840
1855
  if (this.absent.size >= ABSENT_NAMES) this.absent.clear();
1841
- this.absent.set(path, performance.now());
1856
+ this.absent.set(path, { at: performance.now(), op: this.lookups });
1842
1857
  }
1843
1858
  remember(path, handle, looked = false) {
1844
1859
  if (handle.kind !== "file") {
@@ -1879,7 +1894,11 @@ var OpfsFs = class {
1879
1894
  if (name2 === void 0) throw fsError("EBUSY", path);
1880
1895
  return [`/${parts2.join("/")}`, name2];
1881
1896
  }
1897
+ recent(seen, lookups) {
1898
+ return this.lookups - seen.op < lookups && performance.now() - seen.at < GLANCE_CAP_MS;
1899
+ }
1882
1900
  async handle(path) {
1901
+ this.lookups++;
1883
1902
  if (split(path).length === 0) return this.root;
1884
1903
  const cached = this.files.get(path);
1885
1904
  const fresh2 = cached && performance.now() - (this.found.get(cached) ?? -CHECK_MS) < CHECK_MS;
@@ -1899,7 +1918,7 @@ var OpfsFs = class {
1899
1918
  const kept = this.dirs.get(path);
1900
1919
  if (kept && await this.current(path, kept)) return kept;
1901
1920
  const gone = this.absent.get(path);
1902
- if (gone !== void 0 && this.exact === 0 && performance.now() - gone < ABSENT_MS) {
1921
+ if (gone !== void 0 && this.exact === 0 && this.recent(gone, ABSENT_LOOKUPS)) {
1903
1922
  throw translate({ name: "NotFoundError" }, path);
1904
1923
  }
1905
1924
  const seen = this.changes;
@@ -2102,15 +2121,16 @@ var OpfsFs = class {
2102
2121
  glanced(handle) {
2103
2122
  if (this.exact > 0) return void 0;
2104
2123
  const seen = this.glances.get(handle);
2105
- const fresh2 = seen && seen.changes === this.changes && performance.now() - seen.at < GLANCE_MS;
2124
+ const fresh2 = seen && seen.changes === this.changes && this.recent(seen, GLANCE_LOOKUPS);
2106
2125
  return fresh2 ? seen.file : void 0;
2107
2126
  }
2108
2127
  async glance(handle) {
2109
2128
  const at = performance.now();
2129
+ const op = this.lookups;
2110
2130
  const before = this.changes;
2111
2131
  this.calls++;
2112
2132
  const file = await handle.getFile();
2113
- if (before === this.changes) this.glances.set(handle, { at, file, changes: before });
2133
+ if (before === this.changes) this.glances.set(handle, { at, op, file, changes: before });
2114
2134
  else this.glances.delete(handle);
2115
2135
  return file;
2116
2136
  }
@@ -2692,6 +2712,7 @@ var OpfsFs = class {
2692
2712
  if (targetStat?.isDirectory && (await this.readdir(destination)).length > 0) {
2693
2713
  throw fsError("ENOTEMPTY", to);
2694
2714
  }
2715
+ if (sourceStat.isDirectory) await this.pinHeld(source.path);
2695
2716
  const now = Date.now();
2696
2717
  const moving = await this.movedOwner(source);
2697
2718
  const carry = (entry2) => ({
@@ -7805,7 +7826,7 @@ function satisfies(version, range2) {
7805
7826
  }
7806
7827
 
7807
7828
  // src/version.ts
7808
- var KERNEL_VERSION = true ? "1.147.8" : "0.0.0-dev";
7829
+ var KERNEL_VERSION = true ? "1.147.10" : "0.0.0-dev";
7809
7830
  var OS_RELEASE = "6.0.0-slicc";
7810
7831
  function procVersion() {
7811
7832
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -29317,6 +29338,9 @@ var Launcher = class {
29317
29338
  this.watchers.heard("rename", change.trees ?? []);
29318
29339
  });
29319
29340
  const holders = [this.held, this.openFiles];
29341
+ options.fs.heldBy?.(
29342
+ (dir) => holders.flatMap((set3) => [...set3].flatMap((holder) => [...holder.held()])).filter((p) => p.startsWith(`${dir}/`) && this.mounts.locate(p) === void 0)
29343
+ );
29320
29344
  this.unlinked = new UnlinkedKeeper(
29321
29345
  fs,
29322
29346
  { [Symbol.iterator]: () => holders.flatMap((set3) => [...set3]).values() },