@ai-ecoverse/slicc-kernel 1.164.3 → 1.164.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
@@ -3684,7 +3684,7 @@ function satisfies(version, range2) {
3684
3684
  }
3685
3685
 
3686
3686
  // src/version.ts
3687
- var KERNEL_VERSION = true ? "1.164.3" : "0.0.0-dev";
3687
+ var KERNEL_VERSION = true ? "1.164.4" : "0.0.0-dev";
3688
3688
  var OS_RELEASE = "6.0.0-slicc";
3689
3689
  function procVersion() {
3690
3690
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -4771,7 +4771,7 @@ var UnlinkedKeeper = class {
4771
4771
  async rm(path, options) {
4772
4772
  const target = fs.resolvePath("/", path);
4773
4773
  const kept = await keeper.peerKeep(target, false, () => keeper.removable(target, options));
4774
- if (kept.whole) return;
4774
+ if (kept.whole) return kept.undoing(async () => void 0);
4775
4775
  await kept.undoing(
4776
4776
  () => replace(target, async (gated, sealed) => {
4777
4777
  const pinned = await keeper.pin(target, gated, sealed);
@@ -4965,54 +4965,60 @@ var UnlinkedKeeper = class {
4965
4965
  void peers.ask(tab, { kept: { items: [], paths } }, PEER_RM_MS);
4966
4966
  throw fsError("EBUSY", `${target}: open in another tab that did not answer`);
4967
4967
  }
4968
- const { whole, moved: moved2 } = await this.setAside(peers, target, asked, heard);
4969
- return { whole, undoing: (op) => this.undoing(op, moved2) };
4968
+ const { whole, sends } = await this.setAside(target, asked);
4969
+ return { whole, undoing: (op) => this.undoing(op, peers, sends, heard) };
4970
4970
  }
4971
- async setAside(peers, target, asked, heard) {
4971
+ async setAside(target, asked) {
4972
4972
  const mine = this.heldWithin(target);
4973
4973
  const taken = /* @__PURE__ */ new Set();
4974
4974
  let whole = false;
4975
- const told = [];
4976
- const moved2 = [];
4977
- for (const [i, { tab, holders, paths }] of asked.entries()) {
4975
+ const sends = [];
4976
+ for (const { tab, holders, paths } of asked) {
4978
4977
  const items = [];
4979
4978
  for (const holder of holders) {
4980
4979
  const free = !mine.has(holder.path) && !taken.has(holder.path);
4981
4980
  const hidden = free ? await this.asideFor(holder.path, holder.instance) : void 0;
4982
4981
  if (hidden !== void 0) {
4983
4982
  taken.add(holder.path);
4984
- moved2.push({ tab, path: holder.path, hidden, fid: holder.fid });
4985
4983
  if (holder.path === target) whole = true;
4986
4984
  }
4987
4985
  items.push({ path: holder.path, hidden, fid: holder.fid });
4988
4986
  }
4989
- const answer2 = peers.ask(tab, { kept: { items, paths } }, PEER_RM_MS);
4990
- if (heard[i]) told.push(answer2);
4987
+ sends.push({ tab, items, paths });
4991
4988
  }
4992
- await Promise.all(told);
4993
- return { whole, moved: moved2 };
4989
+ return { whole, sends };
4994
4990
  }
4995
- async undoing(op, moved2) {
4991
+ async undoing(op, peers, sends, heard) {
4992
+ let failed3;
4993
+ let out;
4996
4994
  try {
4997
- return await op();
4995
+ out = await op();
4998
4996
  } catch (err) {
4999
- for (const { tab, path, hidden, fid } of moved2) {
5000
- const back = await this.serial(async () => {
5001
- if (await this.present(path)) return false;
5002
- return this.fs.rename(hidden, path).then(
5003
- () => true,
5004
- () => false
5005
- );
5006
- });
5007
- if (!back) continue;
5008
- void this.peers?.ask(
5009
- tab,
5010
- { kept: { items: [{ path, hidden: void 0, fid, undo: hidden }], paths: [] } },
5011
- PEER_RM_MS
5012
- );
4997
+ failed3 = err ?? new Error("failed");
4998
+ for (const send2 of sends) {
4999
+ for (const item of send2.items) {
5000
+ const { hidden, path } = item;
5001
+ if (hidden !== void 0 && await this.moveBack(hidden, path)) item.hidden = void 0;
5002
+ }
5013
5003
  }
5014
- throw err;
5015
5004
  }
5005
+ await Promise.all(
5006
+ sends.map(({ tab, items, paths }, i) => {
5007
+ const told = peers.ask(tab, { kept: { items, paths } }, PEER_RM_MS);
5008
+ return heard[i] ? told : void 0;
5009
+ })
5010
+ );
5011
+ if (failed3 !== void 0) throw failed3;
5012
+ return out;
5013
+ }
5014
+ moveBack(hidden, path) {
5015
+ return this.serial(async () => {
5016
+ if (await this.present(path)) return false;
5017
+ return this.fs.rename(hidden, path).then(
5018
+ () => true,
5019
+ () => false
5020
+ );
5021
+ });
5016
5022
  }
5017
5023
  async removable(target, options) {
5018
5024
  const st = await this.fs.lstat(target).catch(() => void 0);
@@ -9189,9 +9195,6 @@ var HeldPaths = class extends Map {
9189
9195
  this.uses.set(file, Math.max(fresh3.length, 1));
9190
9196
  this.unlinked.set(path, file);
9191
9197
  }
9192
- unkeepAt(path, hidden) {
9193
- for (const file of [...this.uses.keys()]) if (file.hidden === hidden) this.unkeep(path, file);
9194
- }
9195
9198
  unkeep(path, file) {
9196
9199
  for (const [id2, kept] of this.keptHandles) if (kept === file) this.keptHandles.delete(id2);
9197
9200
  this.uses.delete(file);
@@ -23791,12 +23794,8 @@ var RemoteWatch = class {
23791
23794
  if (data.holds !== void 0) this.heldBy(data);
23792
23795
  if (data.to === this.tab && (data.keeping || data.kept)) void this.keepAsked(data);
23793
23796
  }
23794
- keepChains = /* @__PURE__ */ new Map();
23795
23797
  keepAsked(data) {
23796
- const from = data.tab;
23797
- const next3 = (this.keepChains.get(from) ?? Promise.resolve()).then(() => this.keepOne(data));
23798
- this.keepChains.set(from, next3);
23799
- return next3;
23798
+ return this.keepOne(data);
23800
23799
  }
23801
23800
  async keepOne({ tab, seq: seq2, keeping, kept }) {
23802
23801
  const from = tab;
@@ -32571,52 +32570,49 @@ var Launcher = class {
32571
32570
  const gone = /* @__PURE__ */ new Set();
32572
32571
  const instance = this.unlinked.id;
32573
32572
  const ours = (hidden) => hidden.startsWith(`/${UNLINKED_DIR}/${instance}.p`) && /^[0-9a-f]+$/.test(hidden.slice(`/${UNLINKED_DIR}/${instance}.p`.length));
32574
- const open = (tab, paths) => {
32575
- for (const [key, release] of [...gates]) {
32573
+ const gate = async (tab, path) => {
32574
+ const release = await this.unlinked.gate.acquire(path);
32575
+ let done4 = false;
32576
+ const once2 = () => {
32577
+ if (done4) return;
32578
+ done4 = true;
32579
+ clearTimeout(timer);
32580
+ release();
32581
+ };
32582
+ const timer = setTimeout(once2, PEER_GATE_MS);
32583
+ if (gone.has(tab)) once2();
32584
+ return once2;
32585
+ };
32586
+ const open = async (tab, paths, all = false) => {
32587
+ for (const [key, queue] of [...gates]) {
32576
32588
  const [owner, path] = key.split("\0");
32577
32589
  if (owner !== tab || paths && !paths.includes(path)) continue;
32578
- gates.delete(key);
32579
- release();
32590
+ const taken = all ? queue.splice(0) : queue.splice(0, 1);
32591
+ if (queue.length === 0) gates.delete(key);
32592
+ for (const entry of taken) (await entry)();
32580
32593
  }
32581
32594
  };
32582
32595
  return {
32583
32596
  keeping: async (tab, paths) => {
32584
- for (const path of paths) {
32585
- if (gone.has(tab)) return;
32586
- const release = await this.unlinked.gate.acquire(path);
32597
+ if (gone.has(tab)) return;
32598
+ const mine = paths.map((path) => {
32587
32599
  const key = `${tab}\0${path}`;
32588
- let done4 = false;
32589
- const once2 = () => {
32590
- if (done4) return;
32591
- done4 = true;
32592
- clearTimeout(timer);
32593
- release();
32594
- };
32595
- const timer = setTimeout(() => {
32596
- if (gates.get(key) === once2) gates.delete(key);
32597
- once2();
32598
- }, PEER_GATE_MS);
32599
- if (gone.has(tab)) once2();
32600
- else gates.set(key, once2);
32601
- }
32600
+ const entry = gate(tab, path);
32601
+ gates.set(key, [...gates.get(key) ?? [], entry]);
32602
+ return entry;
32603
+ });
32604
+ await Promise.all(mine);
32602
32605
  },
32603
32606
  kept: async (tab, items, paths) => {
32604
- for (const { path, hidden, fid, undo } of items) {
32605
- if (undo !== void 0) this.unadopt(path, undo, fid);
32606
- else this.adoptKept(path, hidden, fid, ours);
32607
- }
32608
- open(tab, paths);
32607
+ for (const { path, hidden, fid } of items) this.adoptKept(path, hidden, fid, ours);
32608
+ await open(tab, paths);
32609
32609
  },
32610
32610
  left: (tab) => {
32611
32611
  gone.add(tab);
32612
- open(tab);
32612
+ void open(tab, void 0, true);
32613
32613
  }
32614
32614
  };
32615
32615
  }
32616
- unadopt(path, undo, fid) {
32617
- for (const holds2 of this.held) holds2.unkeepAt(path, undo);
32618
- void this.rootFs.announceHolds?.([[path, fid]], [], false);
32619
- }
32620
32616
  adoptKept(path, hidden, fid, ours) {
32621
32617
  if (hidden === void 0 || !ours(hidden)) {
32622
32618
  this.held.doubt([path]);