@ai-ecoverse/slicc-kernel 1.146.3 → 1.146.4

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.
package/dist/node.js CHANGED
@@ -3305,7 +3305,7 @@ function satisfies(version, range2) {
3305
3305
  }
3306
3306
 
3307
3307
  // src/version.ts
3308
- var KERNEL_VERSION = true ? "1.146.3" : "0.0.0-dev";
3308
+ var KERNEL_VERSION = true ? "1.146.4" : "0.0.0-dev";
3309
3309
  var OS_RELEASE = "6.0.0-slicc";
3310
3310
  function procVersion() {
3311
3311
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -6386,16 +6386,16 @@ var FreshModules = class {
6386
6386
  if (size < MAGIC.length && this.fresh.has(normalizePath(path))) await decide(path);
6387
6387
  };
6388
6388
  }
6389
- const bound2 = /* @__PURE__ */ new WeakMap();
6389
+ const bound3 = /* @__PURE__ */ new WeakMap();
6390
6390
  return new Proxy(fs, {
6391
6391
  get(target, key, receiver) {
6392
6392
  if (Object.hasOwn(overrides, key)) return overrides[key];
6393
6393
  const value2 = Reflect.get(target, key, receiver);
6394
6394
  if (typeof value2 !== "function") return value2;
6395
- let method = bound2.get(value2);
6395
+ let method = bound3.get(value2);
6396
6396
  if (method === void 0) {
6397
6397
  method = value2.bind(target);
6398
- bound2.set(value2, method);
6398
+ bound3.set(value2, method);
6399
6399
  }
6400
6400
  return method;
6401
6401
  }
@@ -8038,6 +8038,12 @@ var HeldSet = class extends Set {
8038
8038
  holds2.onIdle = this.idle;
8039
8039
  return super.add(holds2);
8040
8040
  }
8041
+ doubt(paths, over) {
8042
+ for (const holds2 of this) {
8043
+ for (const path of paths) holds2.doubt(path, true);
8044
+ if (over !== void 0) holds2.doubt(over);
8045
+ }
8046
+ }
8041
8047
  delete(holds2) {
8042
8048
  const removed = super.delete(holds2);
8043
8049
  for (const path of /* @__PURE__ */ new Set([...holds2.keys(), ...holds2.opens.keys()])) this.idle(path);
@@ -8059,6 +8065,9 @@ var HeldPaths = class extends Map {
8059
8065
  uses = /* @__PURE__ */ new Map();
8060
8066
  lastHandle = 0;
8061
8067
  owning;
8068
+ bound = /* @__PURE__ */ new Map();
8069
+ doubted = /* @__PURE__ */ new Map();
8070
+ doubts = 0;
8062
8071
  onIdle;
8063
8072
  keyOf(path) {
8064
8073
  return this.aliases.get(path) ?? path;
@@ -8079,6 +8088,21 @@ var HeldPaths = class extends Map {
8079
8088
  handlesAt(path) {
8080
8089
  return [...this.handles].filter(([, key]) => key === path).map(([id2]) => id2);
8081
8090
  }
8091
+ doubt(over, exact = false) {
8092
+ if (this.bound.size === 0) return;
8093
+ for (const [handle, key] of this.handles) {
8094
+ if (!this.bound.has(handle) || this.keptHandles.has(handle)) continue;
8095
+ if (exact ? key === over : within5(key, over)) this.doubted.set(handle, ++this.doubts);
8096
+ }
8097
+ }
8098
+ boundIno(handle) {
8099
+ const doubt = this.doubted.get(handle);
8100
+ const ino = this.bound.get(handle);
8101
+ return doubt === void 0 || ino === void 0 ? void 0 : { ino, doubt };
8102
+ }
8103
+ trust(handle, doubt) {
8104
+ if (this.doubted.get(handle) === doubt) this.doubted.delete(handle);
8105
+ }
8082
8106
  keptFor(handle) {
8083
8107
  return this.keptHandles.get(handle);
8084
8108
  }
@@ -8115,8 +8139,16 @@ var HeldPaths = class extends Map {
8115
8139
  for (const file of [...this.uses.keys()]) this.letGo(file, true);
8116
8140
  this.keptHandles.clear();
8117
8141
  }
8118
- hold(path, on, open = false, real, handle) {
8119
- if (open) return this.holdOpen(path, on, real, handle);
8142
+ hold(path, on, open = false, real, handle, ino) {
8143
+ if (open) {
8144
+ const made2 = this.holdOpen(path, on, real, handle);
8145
+ if (handle !== void 0) {
8146
+ this.bound.delete(handle);
8147
+ this.doubted.delete(handle);
8148
+ }
8149
+ if (made2 !== void 0 && ino !== void 0) this.bound.set(made2, ino);
8150
+ return made2;
8151
+ }
8120
8152
  this.holdWrite(path, on);
8121
8153
  return void 0;
8122
8154
  }
@@ -9795,7 +9827,7 @@ async function holdOp(entry, path, req) {
9795
9827
  await stillThere(entry, path, req);
9796
9828
  if (req.nofollow && !await ownEntry(entry, path, real ?? path)) continue;
9797
9829
  if (!r || !r.missed(path) && !r.changedSince(path, gen) && !r.inFlight?.(path))
9798
- return json2(entry.hold?.(path, on, open, real) ?? null);
9830
+ return json2(entry.hold?.(path, on, open, real, void 0, req.ino) ?? null);
9799
9831
  }
9800
9832
  }
9801
9833
  entry.hold?.(path, on, open, void 0, req.handle);
@@ -9945,10 +9977,26 @@ async function linkedElsewhere(fs, path, from) {
9945
9977
  return !(source && source.ino === st.ino && source.dev === st.dev);
9946
9978
  }
9947
9979
  async function keptOr(entry, path, handle) {
9948
- if (handle !== void 0) return entry.keptFor?.(handle)?.hidden ?? path;
9980
+ if (handle !== void 0) {
9981
+ const hidden = entry.keptFor?.(handle)?.hidden;
9982
+ if (hidden !== void 0) return hidden;
9983
+ await bound(entry, path, handle);
9984
+ return path;
9985
+ }
9949
9986
  const kept = entry.unlinked?.(path);
9950
9987
  return kept && !await entry.fs.exists(path) ? kept.hidden : path;
9951
9988
  }
9989
+ async function bound(entry, path, handle) {
9990
+ const bound3 = entry.boundIno?.(handle);
9991
+ if (bound3 === void 0) return;
9992
+ const now = await entry.fs.stat(path).catch(() => void 0);
9993
+ if (now?.ino === bound3.ino) {
9994
+ entry.trust?.(handle, bound3.doubt);
9995
+ return;
9996
+ }
9997
+ staleFds++;
9998
+ throw syncError("ESTALE", path);
9999
+ }
9952
10000
  async function keptStat(entry, req) {
9953
10001
  const hidden = entry.keptFor?.(req.handle ?? -1)?.hidden;
9954
10002
  if (hidden === void 0)
@@ -9975,6 +10023,10 @@ var served = 0;
9975
10023
  function servedFsCalls() {
9976
10024
  return served;
9977
10025
  }
10026
+ var staleFds = 0;
10027
+ function staleFdCount() {
10028
+ return staleFds;
10029
+ }
9978
10030
  async function dispatchSyncFs(req) {
9979
10031
  served++;
9980
10032
  const entry = resolveSyncFsToken(req.token);
@@ -10750,6 +10802,8 @@ var SYS_TREE = {
10750
10802
  slicc_cwd_checks: (listing) => `${listing.cwdChecks ?? 0}
10751
10803
  `,
10752
10804
  slicc_rename_ack_busy: (listing) => `${listing.renameAcks?.busy ?? 0}
10805
+ `,
10806
+ slicc_stale_fds: (listing) => `${listing.staleFds ?? 0}
10753
10807
  `,
10754
10808
  slicc_rename_acks: (listing) => {
10755
10809
  const samples = [...listing.renameAcks?.ackMs ?? []].sort((a, b) => a - b);
@@ -15262,7 +15316,7 @@ async function writeAll2(file, bytes) {
15262
15316
  const write = file.write;
15263
15317
  for (let at = 0; at < bytes.length; ) at += await write.call(file, bytes.subarray(at));
15264
15318
  }
15265
- function bound(file, key) {
15319
+ function bound2(file, key) {
15266
15320
  const method = file[key];
15267
15321
  return typeof method === "function" ? { [key]: method.bind(file) } : {};
15268
15322
  }
@@ -15354,9 +15408,9 @@ function scrubbed(inner, scrubber, idleMs = SCRUB_IDLE_MS) {
15354
15408
  later(stream2.idle());
15355
15409
  };
15356
15410
  return new OpenFile({
15357
- ...bound(file, "read"),
15358
- ...bound(file, "peek"),
15359
- ...bound(file, "stat"),
15411
+ ...bound2(file, "read"),
15412
+ ...bound2(file, "peek"),
15413
+ ...bound2(file, "stat"),
15360
15414
  poll: () => {
15361
15415
  const state = pollFile(file);
15362
15416
  return quiet3() ? state : { ...state, writable: false };
@@ -21075,7 +21129,9 @@ function holdingToken(opts, holds2, caller) {
21075
21129
  ...opts.statfs ? { statfs: opts.statfs } : {},
21076
21130
  ...opts.renames ? { renames: opts.renames } : {},
21077
21131
  ...opts.renameSeq ? { renameSeq: opts.renameSeq } : {},
21078
- hold: (path, on, open, real, handle) => holds2.hold(path, on, open, real, handle),
21132
+ hold: (path, on, open, real, handle, ino) => holds2.hold(path, on, open, real, handle, ino),
21133
+ boundIno: holds2.boundIno.bind(holds2),
21134
+ trust: holds2.trust.bind(holds2),
21079
21135
  keptFor: (handle) => holds2.keptFor(handle),
21080
21136
  unlinked: (path) => holds2.keptAt(path),
21081
21137
  gate: (path, op) => opts.unlinkGate && holds2.holding(path) ? opts.unlinkGate.run(holds2.keyOf(path), op) : op(),
@@ -28145,6 +28201,7 @@ var Launcher = class {
28145
28201
  this.openFiles.add(this.nodes);
28146
28202
  options.fs.onPeer?.(() => this.flushOpen());
28147
28203
  options.fs.remoteChanges?.((change) => {
28204
+ this.held.doubt(change.paths, change.moved?.to);
28148
28205
  if (change.moved) this.moved(change.moved.from, change.moved.to);
28149
28206
  this.changes.flush();
28150
28207
  this.cwds.touched(change.paths, change.trees);
@@ -29157,7 +29214,8 @@ var Launcher = class {
29157
29214
  opfsCalls: this.rootFs.opfsCalls?.() ?? 0,
29158
29215
  opfsOps: this.rootFs.opfsOps?.() ?? 0,
29159
29216
  cwdChecks: this.cwds.checks,
29160
- renameAcks: this.rootFs.renameWaits?.()
29217
+ renameAcks: this.rootFs.renameWaits?.(),
29218
+ staleFds: staleFdCount()
29161
29219
  }),
29162
29220
  sudo: (call, signal) => this.sudo(pid, call, signal),
29163
29221
  crontab: (call) => this.crontab(pid, call),
@@ -30135,6 +30193,7 @@ var Launcher = class {
30135
30193
  this.renameLog.add(from, to);
30136
30194
  if (source) return;
30137
30195
  for (const nodes of this.openFiles) nodes.renamed(from, to);
30196
+ for (const holds2 of this.held) holds2.renamed(from, to);
30138
30197
  this.watchers.moved(from, to);
30139
30198
  }
30140
30199
  processChain(fs, nodes, unlinked) {