@ai-ecoverse/slicc-kernel 1.143.0 → 1.143.2

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.
@@ -6725,7 +6725,7 @@ var KERNEL_VERSION, OS_RELEASE;
6725
6725
  var init_version = __esm({
6726
6726
  "src/version.ts"() {
6727
6727
  "use strict";
6728
- KERNEL_VERSION = true ? "1.143.0" : "0.0.0-dev";
6728
+ KERNEL_VERSION = true ? "1.143.2" : "0.0.0-dev";
6729
6729
  OS_RELEASE = "6.0.0-slicc";
6730
6730
  }
6731
6731
  });
package/dist/node.js CHANGED
@@ -4553,6 +4553,7 @@ var escapeRoot = (name2) => name2.replace(/[%:]/g, (c) => `%${c.charCodeAt(0).to
4553
4553
  var LEGACY_RENAME_LOCK = /^slicc-rename:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
4554
4554
  var PAIRED = /* @__PURE__ */ new Set(["rename", "link", "copyFile"]);
4555
4555
  var LISTINGS = /* @__PURE__ */ new Set(["readdir", "readdirStat"]);
4556
+ var REMOVALS = /* @__PURE__ */ new Set(["rm", "rename"]);
4556
4557
  var RETRY = /* @__PURE__ */ Symbol("retry");
4557
4558
  var ACK_SAMPLES = 4096;
4558
4559
  var INTENT_POLL_MS = 5;
@@ -6027,10 +6028,11 @@ var OpfsFs = class {
6027
6028
  const running = [...this.inflight];
6028
6029
  const reached = await Promise.all(
6029
6030
  running.map(async (op) => {
6030
- if (op.paths.some((at) => touches(at, trees))) return true;
6031
+ const near = (at) => touches(at, trees, true, op.removing === true);
6032
+ if (op.paths.some(near)) return true;
6031
6033
  for (const at of op.paths) {
6032
6034
  const forms = await this.resolvedForms(at);
6033
- if (forms.some((form) => touches(form, trees))) return true;
6035
+ if (forms.some(near)) return true;
6034
6036
  }
6035
6037
  return false;
6036
6038
  })
@@ -6047,10 +6049,10 @@ var OpfsFs = class {
6047
6049
  })
6048
6050
  );
6049
6051
  }
6050
- peerAt(at, listing) {
6052
+ peerAt(at, listing, removing = false) {
6051
6053
  for (const move of this.peerMoves.values()) {
6052
6054
  if (this.ownLocks.has(move.lock)) continue;
6053
- if (touches(at, move.trees, listing)) return move;
6055
+ if (touches(at, move.trees, listing, removing)) return move;
6054
6056
  }
6055
6057
  return void 0;
6056
6058
  }
@@ -6085,11 +6087,11 @@ var OpfsFs = class {
6085
6087
  this.peerWaits.set(move.lock, wait2);
6086
6088
  return wait2;
6087
6089
  }
6088
- async peerSettled(at, listing) {
6090
+ async peerSettled(at, listing, removing) {
6089
6091
  await this.lookForRenames();
6090
6092
  for (let reals; ; ) {
6091
6093
  const forms = [at, ...reals ?? []];
6092
- const move = forms.map((form) => this.peerAt(form, listing)).find(Boolean);
6094
+ const move = forms.map((form) => this.peerAt(form, listing, removing)).find(Boolean);
6093
6095
  if (move) {
6094
6096
  this.peerWaited++;
6095
6097
  await this.peerMoved(move);
@@ -6127,13 +6129,14 @@ var OpfsFs = class {
6127
6129
  async peerOp(name2, args, inner) {
6128
6130
  const paths = (name2 === "symlink" ? args.slice(1, 2) : PAIRED.has(name2) ? args.slice(0, 2) : args.slice(0, 1)).filter((path) => typeof path === "string").map(normalizePath);
6129
6131
  const listing = LISTINGS.has(name2);
6132
+ const removing = REMOVALS.has(name2);
6130
6133
  const checked = [...paths];
6131
6134
  while (this.amongPeers()) {
6132
6135
  checked.length = 0;
6133
- for (const at of paths) checked.push(...await this.peerSettled(at, listing));
6134
- if (!checked.some((at) => this.peerAt(at, listing))) break;
6136
+ for (const at of paths) checked.push(...await this.peerSettled(at, listing, removing));
6137
+ if (!checked.some((at) => this.peerAt(at, listing, removing))) break;
6135
6138
  }
6136
- const busy = { paths: checked, release: () => void 0 };
6139
+ const busy = { paths: checked, removing, release: () => void 0 };
6137
6140
  const done4 = () => {
6138
6141
  this.inflight.delete(busy);
6139
6142
  busy.waiting?.resolve();
@@ -6558,9 +6561,9 @@ var OpfsFs = class {
6558
6561
  function nothing() {
6559
6562
  return void 0;
6560
6563
  }
6561
- function touches(at, trees, listing = true) {
6564
+ function touches(at, trees, listing = true, removing = false) {
6562
6565
  return trees.some(
6563
- ([from, to]) => within3(at, from) || within3(at, to) || listing && (at === parentOf4(from) || at === parentOf4(to))
6566
+ ([from, to]) => within3(at, from) || within3(at, to) || listing && (at === parentOf4(from) || at === parentOf4(to)) || removing && (at === "/" || within3(from, at) || within3(to, at))
6564
6567
  );
6565
6568
  }
6566
6569
  function byIntent(a, b) {
@@ -7979,7 +7982,7 @@ function satisfies(version, range2) {
7979
7982
  }
7980
7983
 
7981
7984
  // src/version.ts
7982
- var KERNEL_VERSION = true ? "1.143.0" : "0.0.0-dev";
7985
+ var KERNEL_VERSION = true ? "1.143.2" : "0.0.0-dev";
7983
7986
  var OS_RELEASE = "6.0.0-slicc";
7984
7987
  function procVersion() {
7985
7988
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -10512,7 +10515,7 @@ function route(watch, type, path) {
10512
10515
  }
10513
10516
  function routed(watch, root, type, path) {
10514
10517
  if (path === root || type === "rename" && root !== "/" && under3(root, path)) {
10515
- noted(watch, { type, filename: baseOf3(root) });
10518
+ noted(watch, { type, filename: watch.names.get(root) ?? baseOf3(root) });
10516
10519
  if (type === "rename") noted(watch, { ended: true });
10517
10520
  return true;
10518
10521
  }
@@ -10522,6 +10525,11 @@ function routed(watch, root, type, path) {
10522
10525
  } else return false;
10523
10526
  return true;
10524
10527
  }
10528
+ function remapped(root, from, to) {
10529
+ if (root === from) return to;
10530
+ if (from !== "/" && root.startsWith(`${from}/`)) return to + root.slice(from.length);
10531
+ return void 0;
10532
+ }
10525
10533
  var FsWatchers = class {
10526
10534
  watchers = /* @__PURE__ */ new Set();
10527
10535
  typed = /* @__PURE__ */ new Set();
@@ -10556,6 +10564,7 @@ var FsWatchers = class {
10556
10564
  const other = alias === void 0 ? main : normalizePath(alias);
10557
10565
  const watch = {
10558
10566
  roots: other === main ? [main] : [main, other],
10567
+ names: /* @__PURE__ */ new Map(),
10559
10568
  recursive,
10560
10569
  notes: [],
10561
10570
  overflowed: false,
@@ -10605,6 +10614,35 @@ var FsWatchers = class {
10605
10614
  for (const watch of [...this.typed]) route(watch, type, at);
10606
10615
  }
10607
10616
  }
10617
+ moved(from, to) {
10618
+ const source = normalizePath(from);
10619
+ const target = normalizePath(to);
10620
+ const followed2 = /* @__PURE__ */ new Set();
10621
+ for (const watch of this.typed) {
10622
+ const [main] = watch.roots;
10623
+ const roots = watch.roots.map((root) => remapped(root, source, target) ?? root);
10624
+ if (roots.every((root, i) => root === watch.roots[i])) continue;
10625
+ followed2.add(watch);
10626
+ const names2 = /* @__PURE__ */ new Map();
10627
+ watch.roots.forEach((root, i) => {
10628
+ names2.set(roots[i], watch.names.get(root) ?? baseOf3(root));
10629
+ });
10630
+ watch.names = names2;
10631
+ watch.roots = [...new Set(roots)];
10632
+ if (main === source) {
10633
+ noted(watch, { type: "rename", filename: names2.get(target), moved: true });
10634
+ }
10635
+ }
10636
+ return followed2;
10637
+ }
10638
+ renamed(from, to) {
10639
+ const followed2 = this.moved(from, to);
10640
+ if (this.typed.size === 0) return;
10641
+ for (const path of [from, to]) {
10642
+ const at = normalizePath(path);
10643
+ for (const watch of [...this.typed]) if (!followed2.has(watch)) route(watch, "rename", at);
10644
+ }
10645
+ }
10608
10646
  changed(...paths) {
10609
10647
  this.report(paths);
10610
10648
  this.emit("change", paths);
@@ -10708,7 +10746,16 @@ var FsWatchers = class {
10708
10746
  }
10709
10747
  },
10710
10748
  rm: reshaping(after(fs.rm.bind(fs), (path) => [path], "rename")),
10711
- rename: reshaping(after(fs.rename.bind(fs), (from, to) => [from, to], "rename")),
10749
+ rename: reshaping(async (from, to) => {
10750
+ let done4 = false;
10751
+ try {
10752
+ await fs.rename(from, to);
10753
+ done4 = true;
10754
+ } finally {
10755
+ this.report([from, to]);
10756
+ if (done4) this.renamed(from, to);
10757
+ }
10758
+ }),
10712
10759
  link: reshaping(
10713
10760
  after(
10714
10761
  (from, to, follow2) => fs.link(from, to, follow2),
@@ -13583,7 +13630,7 @@ async function guardAndResolve(entry, path, req) {
13583
13630
  entry: { ...entry, fs: noLinks }
13584
13631
  };
13585
13632
  }
13586
- var REMOVALS = /* @__PURE__ */ new Set(["unlink", "rmdir", "rm"]);
13633
+ var REMOVALS2 = /* @__PURE__ */ new Set(["unlink", "rmdir", "rm"]);
13587
13634
  var CREATIONS = /* @__PURE__ */ new Set([
13588
13635
  "write",
13589
13636
  "mkdir",
@@ -13629,7 +13676,7 @@ async function dispatchPath(entry, req) {
13629
13676
  const { fs, cwd } = entry;
13630
13677
  try {
13631
13678
  const path = fs.resolvePath(cwd, req.path);
13632
- const device = REMOVALS.has(req.op) ? devRemoval(path, entry.cred?.()) : void 0;
13679
+ const device = REMOVALS2.has(req.op) ? devRemoval(path, entry.cred?.()) : void 0;
13633
13680
  if (device) return { ok: false, errno: device, message: `${path}: a device entry stays` };
13634
13681
  const made2 = await newDevName(entry, path, req);
13635
13682
  if (made2) return made2;