@ai-ecoverse/slicc-kernel 1.147.9 → 1.148.0

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
+ async fileId(path) {
1568
+ const found = await this.locate(path, true);
1569
+ const [entry] = await this.meta.get([found.path]);
1570
+ if (entry?.fid !== void 0) return entry.fid;
1571
+ const fid = crypto.randomUUID();
1572
+ await this.meta.update(found.path, (now) => ({
1573
+ ...occupied(now),
1574
+ path: found.path,
1575
+ fid: now?.fid ?? fid
1576
+ }));
1577
+ const [stored] = await this.meta.get([found.path]);
1578
+ return stored?.fid ?? fid;
1579
+ }
1565
1580
  heldUnder = () => [];
1566
1581
  heldBy(held) {
1567
1582
  this.heldUnder = held;
@@ -1851,7 +1866,7 @@ var OpfsFs = class {
1851
1866
  }
1852
1867
  missed(path) {
1853
1868
  if (this.absent.size >= ABSENT_NAMES) this.absent.clear();
1854
- this.absent.set(path, performance.now());
1869
+ this.absent.set(path, { at: performance.now(), op: this.lookups });
1855
1870
  }
1856
1871
  remember(path, handle, looked = false) {
1857
1872
  if (handle.kind !== "file") {
@@ -1892,7 +1907,11 @@ var OpfsFs = class {
1892
1907
  if (name2 === void 0) throw fsError("EBUSY", path);
1893
1908
  return [`/${parts2.join("/")}`, name2];
1894
1909
  }
1910
+ recent(seen, lookups) {
1911
+ return this.lookups - seen.op < lookups && performance.now() - seen.at < GLANCE_CAP_MS;
1912
+ }
1895
1913
  async handle(path) {
1914
+ this.lookups++;
1896
1915
  if (split(path).length === 0) return this.root;
1897
1916
  const cached = this.files.get(path);
1898
1917
  const fresh2 = cached && performance.now() - (this.found.get(cached) ?? -CHECK_MS) < CHECK_MS;
@@ -1912,7 +1931,7 @@ var OpfsFs = class {
1912
1931
  const kept = this.dirs.get(path);
1913
1932
  if (kept && await this.current(path, kept)) return kept;
1914
1933
  const gone = this.absent.get(path);
1915
- if (gone !== void 0 && this.exact === 0 && performance.now() - gone < ABSENT_MS) {
1934
+ if (gone !== void 0 && this.exact === 0 && this.recent(gone, ABSENT_LOOKUPS)) {
1916
1935
  throw translate({ name: "NotFoundError" }, path);
1917
1936
  }
1918
1937
  const seen = this.changes;
@@ -2115,15 +2134,16 @@ var OpfsFs = class {
2115
2134
  glanced(handle) {
2116
2135
  if (this.exact > 0) return void 0;
2117
2136
  const seen = this.glances.get(handle);
2118
- const fresh2 = seen && seen.changes === this.changes && performance.now() - seen.at < GLANCE_MS;
2137
+ const fresh2 = seen && seen.changes === this.changes && this.recent(seen, GLANCE_LOOKUPS);
2119
2138
  return fresh2 ? seen.file : void 0;
2120
2139
  }
2121
2140
  async glance(handle) {
2122
2141
  const at = performance.now();
2142
+ const op = this.lookups;
2123
2143
  const before = this.changes;
2124
2144
  this.calls++;
2125
2145
  const file = await handle.getFile();
2126
- if (before === this.changes) this.glances.set(handle, { at, file, changes: before });
2146
+ if (before === this.changes) this.glances.set(handle, { at, op, file, changes: before });
2127
2147
  else this.glances.delete(handle);
2128
2148
  return file;
2129
2149
  }
@@ -2154,6 +2174,7 @@ var OpfsFs = class {
2154
2174
  atime: new Date(meta?.atimeMs ?? mtime),
2155
2175
  ctime: new Date(Math.max(touched ?? meta?.ctimeMs ?? mtime, modified)),
2156
2176
  ino: meta?.ino ?? inodeOf(path),
2177
+ ...meta?.fid !== void 0 ? { fid: meta.fid } : {},
2157
2178
  ...this.ranged && !directory ? { ranged: true } : {}
2158
2179
  };
2159
2180
  }
@@ -7819,7 +7840,7 @@ function satisfies(version, range2) {
7819
7840
  }
7820
7841
 
7821
7842
  // src/version.ts
7822
- var KERNEL_VERSION = true ? "1.147.9" : "0.0.0-dev";
7843
+ var KERNEL_VERSION = true ? "1.148.0" : "0.0.0-dev";
7823
7844
  var OS_RELEASE = "6.0.0-slicc";
7824
7845
  function procVersion() {
7825
7846
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -13422,6 +13443,7 @@ function statJson(s) {
13422
13443
  atimeMs: s.atime.getTime(),
13423
13444
  ctimeMs: s.ctime.getTime(),
13424
13445
  ino: s.ino,
13446
+ ...s.fid !== void 0 ? { fid: s.fid } : {},
13425
13447
  ...s.nlink !== void 0 ? { nlink: s.nlink } : {},
13426
13448
  ...s.dev !== void 0 ? { dev: s.dev } : {},
13427
13449
  ...s.readonly ? { readonly: true } : {},
@@ -30154,7 +30176,9 @@ var Launcher = class {
30154
30176
  ];
30155
30177
  if (after.exeId === void 0) return gone;
30156
30178
  return this.reread(target, read).then(
30157
- (again) => id2().then((last) => [again, last]),
30179
+ (again) => id2().then(
30180
+ (last) => [again, last.exeId === after.exeId ? last : gone[1]]
30181
+ ),
30158
30182
  () => gone
30159
30183
  );
30160
30184
  }
@@ -30172,8 +30196,13 @@ var Launcher = class {
30172
30196
  if (target.abi !== "wasi" || (target.copy ?? target.glue) !== target.wasm) {
30173
30197
  return Promise.resolve({});
30174
30198
  }
30199
+ const assign = this.mounts.locate(target.wasm) === void 0 ? this.rootFs.fileId : void 0;
30175
30200
  return this.base.stat(target.wasm).then(
30176
- (st) => exeIdOf(fileIdentity(st.ino, st.mtime.getTime())),
30201
+ async (st) => {
30202
+ const fid = st.fid ?? await assign?.call(this.rootFs, target.wasm);
30203
+ if (fid === void 0) return exeIdOf(fileIdentity(st.ino, st.mtime.getTime()));
30204
+ return { exeId: `fid:${fid}:${st.mtime.getTime()}` };
30205
+ },
30177
30206
  () => ({})
30178
30207
  );
30179
30208
  }