@ai-ecoverse/slicc-kernel 1.165.1 → 1.165.3

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.165.1" : "0.0.0-dev";
3687
+ var KERNEL_VERSION = true ? "1.165.3" : "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
@@ -6381,7 +6381,12 @@ var SHARED_TTL_MS = 100;
6381
6381
  var DIRTY = RING + RING_SIZE * SLOT;
6382
6382
  var FOREIGN = DIRTY + 1;
6383
6383
  var RENAMES = FOREIGN + 1;
6384
- var CHANGES_BYTES = (RENAMES + 1) * 4;
6384
+ var HELD = RENAMES + 1;
6385
+ var HELD_SLOTS = 1024;
6386
+ var CHANGES_BYTES = (HELD + HELD_SLOTS) * 4;
6387
+ function heldSlot(path) {
6388
+ return HELD + (changeHash(normal(path)) & HELD_SLOTS - 1);
6389
+ }
6385
6390
  function changeHash(path) {
6386
6391
  let h = 2166136261;
6387
6392
  for (let i = 0; i < path.length; i++) {
@@ -6415,6 +6420,13 @@ var FileChanges = class {
6415
6420
  flush() {
6416
6421
  Atomics.add(this.view, GEN, RING_SIZE + 1);
6417
6422
  }
6423
+ peerHeld(paths) {
6424
+ const on = new Set(paths.map(heldSlot));
6425
+ for (const slot2 of on) Atomics.store(this.view, slot2, 1);
6426
+ for (let slot2 = HELD; slot2 < HELD + HELD_SLOTS; slot2++) {
6427
+ if (!on.has(slot2)) Atomics.store(this.view, slot2, 0);
6428
+ }
6429
+ }
6418
6430
  renamed() {
6419
6431
  const seq2 = Atomics.add(this.view, RENAMES, 1) + 1 | 0;
6420
6432
  Atomics.notify(this.view, RENAMES);
@@ -6444,6 +6456,9 @@ var ChangeView = class {
6444
6456
  foreign() {
6445
6457
  return this.view.length > FOREIGN && Atomics.load(this.view, FOREIGN) === 1;
6446
6458
  }
6459
+ peerHeld(path) {
6460
+ return this.view.length > HELD && Atomics.load(this.view, heldSlot(path)) === 1;
6461
+ }
6447
6462
  renames() {
6448
6463
  return this.view.length > RENAMES ? Atomics.load(this.view, RENAMES) : 0;
6449
6464
  }
@@ -11809,6 +11824,14 @@ var Pages = class {
11809
11824
  pin() {
11810
11825
  this.pinned = true;
11811
11826
  }
11827
+ landed(at, length2) {
11828
+ const end = at + length2;
11829
+ for (let page = Math.floor(at / PAGE); page * PAGE < end; page++) {
11830
+ if (this.pages.has(page) && !this.dirty.has(page)) this.drop(page);
11831
+ }
11832
+ this.length = Math.max(this.length, end);
11833
+ this.stored = Math.max(this.stored, end);
11834
+ }
11812
11835
  reset(size) {
11813
11836
  if (this.pinned) return;
11814
11837
  for (const page of [...this.pages.keys()]) if (!this.dirty.has(page)) this.drop(page);
@@ -23613,6 +23636,7 @@ var RemoteWatch = class {
23613
23636
  quiet;
23614
23637
  crowd;
23615
23638
  gone;
23639
+ holdsChanged;
23616
23640
  renaming;
23617
23641
  renamed;
23618
23642
  ackers = /* @__PURE__ */ new Set();
@@ -23747,7 +23771,7 @@ var RemoteWatch = class {
23747
23771
  void this.locks.request(name2, async () => {
23748
23772
  this.mourned.delete(peer);
23749
23773
  this.others.delete(peer);
23750
- this.peerHolds.delete(peer);
23774
+ if (this.peerHolds.delete(peer)) this.holdsChanged?.();
23751
23775
  this.keeps?.left(peer);
23752
23776
  this.peers.delete(peer);
23753
23777
  this.ackers.delete(peer);
@@ -23822,6 +23846,7 @@ var RemoteWatch = class {
23822
23846
  for (const [path, fid] of add) held.set(path, fid);
23823
23847
  if (held.size > 0) this.peerHolds.set(from, held);
23824
23848
  else this.peerHolds.delete(from);
23849
+ this.holdsChanged?.();
23825
23850
  this.channel.postMessage({ ack: seq2, from: this.tab, to: from });
23826
23851
  }
23827
23852
  hold(add, drop, wait2) {
@@ -23924,7 +23949,7 @@ var RemoteWatch = class {
23924
23949
  if (!held.has(this.lockOf(tab))) {
23925
23950
  if (this.peers.delete(tab)) left = true;
23926
23951
  this.others.delete(tab);
23927
- this.peerHolds.delete(tab);
23952
+ if (this.peerHolds.delete(tab)) this.holdsChanged?.();
23928
23953
  this.keeps?.left(tab);
23929
23954
  this.ackers.delete(tab);
23930
23955
  this.holders.delete(tab);
@@ -25704,6 +25729,10 @@ var OpfsFs = class {
25704
25729
  announceHolds(add, drop, wait2) {
25705
25730
  return this.remote?.hold(add, drop, wait2) ?? Promise.resolve();
25706
25731
  }
25732
+ peerHolds(listener) {
25733
+ const remote = this.remote;
25734
+ if (remote) remote.holdsChanged = () => listener(remote.peerHeldPaths());
25735
+ }
25707
25736
  holdCounts() {
25708
25737
  const remote = this.remote;
25709
25738
  return remote && { ...remote.holdCounts(), held: remote.peerHeldPaths() };
@@ -26437,7 +26466,7 @@ var OpfsFs = class {
26437
26466
  const at = normalizePath(path);
26438
26467
  const movedAway = this.renamesInFlight() ? await this.writeWaits(at) : false;
26439
26468
  const ended = this.writeStarted(at);
26440
- try {
26469
+ const write = async () => {
26441
26470
  const [kept, target, existed] = await this.keptFor(path);
26442
26471
  if (kept) {
26443
26472
  try {
@@ -26453,6 +26482,9 @@ var OpfsFs = class {
26453
26482
  !existed && !movedAway && options?.create !== false
26454
26483
  );
26455
26484
  await this.writeAt(handle, target, path, offset, bytes);
26485
+ };
26486
+ try {
26487
+ await (this.remote?.peerHeld(at).length ? this.ending(path, write) : write());
26456
26488
  } finally {
26457
26489
  ended();
26458
26490
  }
@@ -32635,6 +32667,7 @@ var Launcher = class {
32635
32667
  return this.mounts.locate(path) === void 0 ? this.rootFs.bindId?.(path) : void 0;
32636
32668
  }
32637
32669
  flushingPeers(fs) {
32670
+ fs.peerHolds?.((paths) => this.changes.peerHeld(paths));
32638
32671
  const peers = fs.peers?.();
32639
32672
  if (!peers) return void 0;
32640
32673
  peers.watch((crowded) => {