@ai-ecoverse/slicc-kernel 1.196.18 → 1.196.19

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.
@@ -838,6 +838,123 @@ async function chownAs(fs, cred, path, change) {
838
838
  });
839
839
  }
840
840
 
841
+ // src/fs/private-rename.ts
842
+ var DRAIN_MS = 500;
843
+ var ADMISSION_MS = 5e3;
844
+ var within2 = (at, root) => at === root || root === "/" || at.startsWith(root + "/");
845
+ var PrivatePaths = class {
846
+ names;
847
+ bound = false;
848
+ shifted = false;
849
+ listing;
850
+ removing;
851
+ constructor(paths, listing, removing) {
852
+ this.listing = listing;
853
+ this.removing = removing;
854
+ this.names = new Set(paths.map(normalizePath));
855
+ }
856
+ touches(roots, names2 = this.names) {
857
+ for (const at of names2)
858
+ for (const root of roots) {
859
+ if (within2(at, root) || this.removing && within2(root, at)) return true;
860
+ if (this.listing && at === (root.slice(0, root.lastIndexOf("/")) || "/")) return true;
861
+ }
862
+ return false;
863
+ }
864
+ bind(path) {
865
+ if (this.shifted) return;
866
+ this.names.clear();
867
+ this.names.add(path);
868
+ this.bound = true;
869
+ }
870
+ moved(from, to) {
871
+ const names2 = this.redirected(from, to);
872
+ if (!names2.size) return;
873
+ this.shifted = true;
874
+ if (this.bound) this.names.clear();
875
+ for (const name2 of names2) this.names.add(name2);
876
+ }
877
+ redirected(from, to) {
878
+ const names2 = /* @__PURE__ */ new Set();
879
+ for (const path of this.names)
880
+ if (within2(path, from)) {
881
+ const next3 = resolvePath(to, path.slice(from.length).replace(/^\//, ""));
882
+ if (!this.names.has(next3)) names2.add(next3);
883
+ }
884
+ return names2;
885
+ }
886
+ };
887
+ var PrivateRename = class {
888
+ active = /* @__PURE__ */ new Set();
889
+ barriers = /* @__PURE__ */ new Map();
890
+ waiters = /* @__PURE__ */ new Set();
891
+ wait(take, ms) {
892
+ if (take()) return Promise.resolve();
893
+ return new Promise((resolve2, reject) => {
894
+ const wake = () => {
895
+ if (!take()) return;
896
+ this.waiters.delete(wake);
897
+ clearTimeout(timer);
898
+ resolve2();
899
+ };
900
+ const timer = setTimeout(() => {
901
+ this.waiters.delete(wake);
902
+ reject(fsError("EBUSY", "private rename"));
903
+ }, ms);
904
+ this.waiters.add(wake);
905
+ });
906
+ }
907
+ wake() {
908
+ for (const waiter of this.waiters) waiter();
909
+ }
910
+ blocked(op, names2 = op.names) {
911
+ for (const [barrier, draining] of this.barriers) {
912
+ if (!draining.has(op) && op.touches(barrier.names, names2)) return true;
913
+ }
914
+ return false;
915
+ }
916
+ enter(op) {
917
+ return this.wait(() => {
918
+ if (this.blocked(op)) return false;
919
+ this.active.add(op);
920
+ return true;
921
+ }, ADMISSION_MS);
922
+ }
923
+ leave(op) {
924
+ this.active.delete(op);
925
+ for (const draining of this.barriers.values()) draining.delete(op);
926
+ this.wake();
927
+ }
928
+ redirect(op, from, to) {
929
+ const names2 = op.redirected(from, to);
930
+ if (this.barriers.has(op) && names2.size) throw fsError("EBUSY", from);
931
+ return this.wait(() => {
932
+ if (this.blocked(op, names2)) return false;
933
+ for (const name2 of names2) op.names.add(name2);
934
+ return true;
935
+ }, ADMISSION_MS);
936
+ }
937
+ moved(from, to) {
938
+ for (const op of this.active) op.moved(from, to);
939
+ }
940
+ async exclusive(op, run2) {
941
+ const draining = /* @__PURE__ */ new Set();
942
+ await this.wait(() => {
943
+ if (this.blocked(op)) return false;
944
+ for (const active of this.active) if (active.touches(op.names)) draining.add(active);
945
+ this.barriers.set(op, draining);
946
+ return true;
947
+ }, ADMISSION_MS);
948
+ try {
949
+ await this.wait(() => ![...draining].some((active) => this.active.has(active)), DRAIN_MS);
950
+ return await run2();
951
+ } finally {
952
+ this.barriers.delete(op);
953
+ this.wake();
954
+ }
955
+ }
956
+ };
957
+
841
958
  // src/fs/integrity.ts
842
959
  var SOURCE_SUFFIXES = [
843
960
  ".js",
@@ -1059,14 +1176,14 @@ function protectedPrefixes(paths) {
1059
1176
  }
1060
1177
  return [...new Set(paths.map((p) => normalizePath(p)))];
1061
1178
  }
1062
- function within2(path, prefix) {
1179
+ function within3(path, prefix) {
1063
1180
  return prefix === "/" || path === prefix || path.startsWith(`${prefix}/`);
1064
1181
  }
1065
1182
  function isProtected(prefixes2, path) {
1066
- return prefixes2.some((prefix) => within2(path, prefix));
1183
+ return prefixes2.some((prefix) => within3(path, prefix));
1067
1184
  }
1068
1185
  function holdsProtected(prefixes2, path) {
1069
- return prefixes2.some((prefix) => within2(prefix, path));
1186
+ return prefixes2.some((prefix) => within3(prefix, path));
1070
1187
  }
1071
1188
  var MAX_LINKS2 = 40;
1072
1189
  function partsOf(path) {
@@ -1781,8 +1898,12 @@ var PAIRED = /* @__PURE__ */ new Set(["rename", "link", "copyFile"]);
1781
1898
  var LISTINGS = /* @__PURE__ */ new Set(["readdir", "readdirStat"]);
1782
1899
  var REMOVALS = /* @__PURE__ */ new Set(["rm", "rename"]);
1783
1900
  var RETRY = /* @__PURE__ */ Symbol("retry");
1901
+ var PRIVATE_COPY = /* @__PURE__ */ Symbol("private-copy");
1784
1902
  var ACK_SAMPLES = 4096;
1785
1903
  var INTENT_POLL_MS = 5;
1904
+ function needsCopy(handle, swap) {
1905
+ return swap || handle.kind === "directory" && !movable(handle);
1906
+ }
1786
1907
  function movable(handle) {
1787
1908
  return typeof handle.move === "function";
1788
1909
  }
@@ -1865,7 +1986,7 @@ function prefixes(path) {
1865
1986
  const parts2 = split(path);
1866
1987
  return parts2.map((_, i) => `/${parts2.slice(0, i + 1).join("/")}`);
1867
1988
  }
1868
- function within3(path, root) {
1989
+ function within4(path, root) {
1869
1990
  return path === root || path.startsWith(`${root}/`);
1870
1991
  }
1871
1992
  var unstored = () => Object.assign(new Error("the file system kept fewer bytes than were written"), {
@@ -1981,6 +2102,10 @@ function isHandle(child2) {
1981
2102
  var FILE_TIMES_MS = 100;
1982
2103
  var OpfsFs = class {
1983
2104
  root;
2105
+ privateRename;
2106
+ insidePrivateOp = false;
2107
+ privateRedirect;
2108
+ privateSession;
1984
2109
  meta;
1985
2110
  dirs = new PathMap();
1986
2111
  files = new PathMap();
@@ -2005,6 +2130,7 @@ var OpfsFs = class {
2005
2130
  renamePrefix;
2006
2131
  constructor(root, meta = new MemoryMeta(), channel, options = {}) {
2007
2132
  this.root = root;
2133
+ this.privateRename = channel === void 0 ? new PrivateRename() : void 0;
2008
2134
  this.meta = sidecar(meta);
2009
2135
  this.ranged = options.ranged === true;
2010
2136
  this.locks = options.locks === void 0 ? lockManager() : options.locks ?? void 0;
@@ -2584,6 +2710,7 @@ var OpfsFs = class {
2584
2710
  if (this.rejectLinks) throw fsError("ELOOP", path);
2585
2711
  const stored2 = link2.link;
2586
2712
  if (overPath(stored2)) throw fsError("ENAMETOOLONG", link2.path);
2713
+ const previous = current;
2587
2714
  const target = stored2 + current.slice(link2.path.length);
2588
2715
  if (target.split("/").includes("..") || longParent(stored2) !== void 0) {
2589
2716
  const resolved2 = await this.physical(parentOf4(link2.path), target, hops + 1, path);
@@ -2593,6 +2720,7 @@ var OpfsFs = class {
2593
2720
  current = resolvePath(parentOf4(link2.path), target);
2594
2721
  }
2595
2722
  this.crossing(path, current);
2723
+ await this.privateRedirect?.(previous, current);
2596
2724
  }
2597
2725
  }
2598
2726
  throw fsError("ELOOP", path);
@@ -2684,11 +2812,11 @@ var OpfsFs = class {
2684
2812
  movePending(from, to) {
2685
2813
  if (to !== void 0) {
2686
2814
  for (const path of [...this.fileTimes.keys()]) {
2687
- if (within3(path, to)) this.fileTimes.delete(path);
2815
+ if (within4(path, to)) this.fileTimes.delete(path);
2688
2816
  }
2689
2817
  }
2690
2818
  for (const [path, ms] of [...this.fileTimes]) {
2691
- if (!within3(path, from)) continue;
2819
+ if (!within4(path, from)) continue;
2692
2820
  this.fileTimes.delete(path);
2693
2821
  if (to !== void 0) this.fileTimes.set(to + path.slice(from.length), ms);
2694
2822
  }
@@ -2968,8 +3096,8 @@ var OpfsFs = class {
2968
3096
  const file = this.movingFiles.get(at);
2969
3097
  if (file !== void 0) return { done: file, away: true };
2970
3098
  for (const m of this.renamingDirs) {
2971
- if (within3(at, m.from)) return { done: m.done, away: true };
2972
- if (within3(at, m.to)) return { done: m.done, away: false };
3099
+ if (within4(at, m.from)) return { done: m.done, away: true };
3100
+ if (within4(at, m.to)) return { done: m.done, away: false };
2973
3101
  }
2974
3102
  return void 0;
2975
3103
  }
@@ -3005,7 +3133,7 @@ var OpfsFs = class {
3005
3133
  idle2.resolve();
3006
3134
  }
3007
3135
  async writesDrained(tree2) {
3008
- while ([...this.fileWrites.keys()].some((at) => within3(at, tree2))) {
3136
+ while ([...this.fileWrites.keys()].some((at) => within4(at, tree2))) {
3009
3137
  this.writesIdle ??= Promise.withResolvers();
3010
3138
  await this.writesIdle.promise;
3011
3139
  }
@@ -3082,6 +3210,7 @@ var OpfsFs = class {
3082
3210
  }
3083
3211
  async writeSession(path, truncate) {
3084
3212
  const [handle, , target] = await this.fileFor(path);
3213
+ this.privateSession?.bind(target);
3085
3214
  const writable3 = await this.retrying(
3086
3215
  path,
3087
3216
  () => this.io(handle.createWritable({ keepExistingData: !truncate })),
@@ -3464,15 +3593,14 @@ var OpfsFs = class {
3464
3593
  if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", to);
3465
3594
  const destination = resolvePath(parent.path, baseOf(to));
3466
3595
  this.refuse(destination, true);
3467
- if (directory) {
3468
- if (source.handle?.kind !== "directory") throw fsError("ENOTDIR", from);
3469
- if (source.path === destination) return;
3470
- }
3596
+ if (directory && source.handle?.kind !== "directory") throw fsError("ENOTDIR", from);
3597
+ if (source.path === destination) return;
3471
3598
  await this.entering(destination, () => this.moveTo(source, parent, destination, to, call));
3599
+ this.privateRename?.moved(source.path, destination);
3472
3600
  }
3473
3601
  async moveTo(source, parent, destination, to, call) {
3474
3602
  const sourceStat = await this.describe(source);
3475
- if (sourceStat.isDirectory && within3(destination, source.path)) throw fsError("EINVAL", to);
3603
+ if (sourceStat.isDirectory && within4(destination, source.path)) throw fsError("EINVAL", to);
3476
3604
  const target = await this.exactly(() => this.locate(destination, false)).catch((err) => {
3477
3605
  if (missing2(err)) return null;
3478
3606
  throw err;
@@ -3508,8 +3636,10 @@ var OpfsFs = class {
3508
3636
  let lock;
3509
3637
  const hooks = {};
3510
3638
  const staging = swap ? `.${name2}.${crypto.randomUUID()}` : name2;
3511
- const copying = swap || sourceStat.isDirectory && !movable(source.handle);
3639
+ const copying = needsCopy(source.handle, swap);
3512
3640
  const staged2 = resolvePath(parent.path, staging);
3641
+ if (this.usePrivateCopy(source.handle, copying))
3642
+ return this.privateCopy(source, parent, destination, target?.handle, moving);
3513
3643
  const place = async () => {
3514
3644
  this.forget(destination);
3515
3645
  const copies = /* @__PURE__ */ new Map();
@@ -3744,7 +3874,7 @@ var OpfsFs = class {
3744
3874
  for (const move of this.peerMoves.values()) {
3745
3875
  for (const tree2 of move.trees) {
3746
3876
  for (const mine of [from, to]) {
3747
- if (tree2.some((theirs) => within3(mine, theirs) || within3(theirs, mine))) return move;
3877
+ if (tree2.some((theirs) => within4(mine, theirs) || within4(theirs, mine))) return move;
3748
3878
  }
3749
3879
  }
3750
3880
  }
@@ -3836,6 +3966,95 @@ var OpfsFs = class {
3836
3966
  });
3837
3967
  return { ...session, close: () => session.close().finally(done5) };
3838
3968
  }
3969
+ async privateOp(name2, args, inner) {
3970
+ const gate = this.privateRename;
3971
+ if (!gate || this.insidePrivateOp) return inner.apply(this, args);
3972
+ const paths = name2 === "symlink" ? args.slice(1, 2) : args.slice(0, PAIRED.has(name2) ? 2 : 1);
3973
+ const op = new PrivatePaths(paths, LISTINGS.has(name2), REMOVALS.has(name2));
3974
+ const inside2 = view(this, {
3975
+ insidePrivateOp: true,
3976
+ privateSession: name2 === "writeSession" ? op : void 0,
3977
+ privateRedirect: (from, to) => gate.redirect(op, from, to)
3978
+ });
3979
+ await gate.enter(op);
3980
+ const leave = () => gate.leave(op);
3981
+ let sessionOwnsAdmission = false;
3982
+ try {
3983
+ if (name2 === "writeSession") {
3984
+ const session = await inner.apply(inside2, args);
3985
+ sessionOwnsAdmission = true;
3986
+ let closed;
3987
+ return { ...session, close: () => closed ??= session.close().finally(leave) };
3988
+ }
3989
+ if (name2 !== "rename") return await inner.apply(inside2, args);
3990
+ try {
3991
+ return await inner.apply(inside2, args);
3992
+ } catch (err) {
3993
+ if (err !== PRIVATE_COPY) throw err;
3994
+ }
3995
+ } finally {
3996
+ if (!sessionOwnsAdmission) leave();
3997
+ }
3998
+ const exclusive = view(inside2, { privateCopyReady: true });
3999
+ return gate.exclusive(op, () => inner.apply(exclusive, args));
4000
+ }
4001
+ privateCopyReady = false;
4002
+ usePrivateCopy(handle, staging) {
4003
+ if (!this.privateRename) return false;
4004
+ if (this.privateCopyReady) return true;
4005
+ if (staging || !movable(handle)) throw PRIVATE_COPY;
4006
+ return false;
4007
+ }
4008
+ async privateCopy(source, parent, to, target, owner) {
4009
+ const handle = source.handle;
4010
+ const dir = parent.handle;
4011
+ const name2 = baseOf(to);
4012
+ const copies = /* @__PURE__ */ new Map();
4013
+ const [entry] = await this.meta.get([source.path]);
4014
+ const root = { ino: occupied(entry).ino ?? inodeOf(source.path), ...owner };
4015
+ const intent = await this.intend({ from: source.path, to, root, privateCopy: true });
4016
+ try {
4017
+ await this.duplicate(handle, dir, name2, copies, "");
4018
+ } catch (err) {
4019
+ if (!target)
4020
+ await dir.removeEntry(name2, { recursive: true }).catch((e) => {
4021
+ if (e.name !== "NotFoundError") throw e;
4022
+ });
4023
+ else if (target.kind === "directory") {
4024
+ for await (const child2 of target.keys())
4025
+ await target.removeEntry(child2, { recursive: true });
4026
+ }
4027
+ this.forget(to);
4028
+ await this.meta.update(intent, () => void 0);
4029
+ throw translate(err, to, "write");
4030
+ }
4031
+ await this.commitPrivateCopy(source.path, to, root, intent, copies);
4032
+ }
4033
+ async commitPrivateCopy(from, to, root, intent, copies) {
4034
+ const { ino, ...owner } = root;
4035
+ const entries = await this.meta.get([from, to]);
4036
+ if (!entries[0]?.vacated || entries[1]?.ino !== ino) {
4037
+ await this.meta.move(
4038
+ from,
4039
+ to,
4040
+ (entry) => ({ ...occupied(entry), ...owner, ino, path: to, ctimeMs: Date.now() }),
4041
+ vacatedAt(from)
4042
+ );
4043
+ }
4044
+ this.movePending(from, to);
4045
+ await this.removePhysical(from, true);
4046
+ await this.meta.update(intent, () => void 0);
4047
+ await this.restamp(to, copies);
4048
+ this.changed(from, to);
4049
+ this.touch(Date.now(), parentOf4(from), parentOf4(to));
4050
+ }
4051
+ async duplicate(handle, parent, name2, copies, rest2) {
4052
+ if (handle.kind === "file") return this.copyBytes(handle, parent, name2, { copies }, rest2);
4053
+ const dir = await this.io(parent.getDirectoryHandle(name2, { create: true }));
4054
+ this.others++;
4055
+ for await (const child2 of handle.values())
4056
+ await this.duplicate(child2, dir, child2.name, copies, rest2 + "/" + child2.name);
4057
+ }
3839
4058
  renamingDirs = /* @__PURE__ */ new Set();
3840
4059
  intents = 0;
3841
4060
  async intend(rename, at = `${RENAMES2}/${crypto.randomUUID()}`) {
@@ -3898,6 +4117,28 @@ var OpfsFs = class {
3898
4117
  this.forget(to);
3899
4118
  try {
3900
4119
  const left = await this.real(from);
4120
+ if (current.rename.privateCopy) {
4121
+ if (left) {
4122
+ const src = await this.locate(from, false);
4123
+ const dir = await this.locate(parentOf4(to), true);
4124
+ const copies = /* @__PURE__ */ new Map();
4125
+ await this.duplicate(
4126
+ src.handle,
4127
+ dir.handle,
4128
+ baseOf(to),
4129
+ copies,
4130
+ ""
4131
+ );
4132
+ await this.commitPrivateCopy(
4133
+ from,
4134
+ to,
4135
+ root ?? { ino: inodeOf(from) },
4136
+ entry.path,
4137
+ copies
4138
+ );
4139
+ } else await this.meta.update(entry.path, () => void 0);
4140
+ return;
4141
+ }
3901
4142
  if (left && replace && await this.real(to))
3902
4143
  await PLAIN.rm.call(this, to, { recursive: true });
3903
4144
  if (left) {
@@ -4013,7 +4254,7 @@ var OpfsFs = class {
4013
4254
  }
4014
4255
  renameAt(at) {
4015
4256
  for (const m of this.renamingDirs) {
4016
- if (within3(at, m.from) || within3(at, m.to) || at === parentOf4(m.from) || at === parentOf4(m.to))
4257
+ if (within4(at, m.from) || within4(at, m.to) || at === parentOf4(m.from) || at === parentOf4(m.to))
4017
4258
  return m;
4018
4259
  }
4019
4260
  return void 0;
@@ -4049,7 +4290,10 @@ var OpfsFs = class {
4049
4290
  }
4050
4291
  async place(handle, dir, name2, copies, admitted) {
4051
4292
  if (await this.moved(handle, dir, name2, admitted)) return true;
4052
- if (!admitted) throw fsError("EBUSY", name2);
4293
+ if (!admitted) {
4294
+ if (this.privateRename) throw PRIVATE_COPY;
4295
+ throw fsError("EBUSY", name2);
4296
+ }
4053
4297
  const before = this.fileMoves;
4054
4298
  try {
4055
4299
  await this.copy(handle, dir, name2, { copies });
@@ -4097,21 +4341,7 @@ var OpfsFs = class {
4097
4341
  if (handle.kind === "file") {
4098
4342
  if (options.restoring && await this.handleExists(dir, name2)) return;
4099
4343
  if (await this.moveChild(handle, dir, name2)) return;
4100
- const file = await this.io(handle.getFile());
4101
- const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
4102
- const writable3 = await this.io(made2.createWritable());
4103
- try {
4104
- await writable3.write(file);
4105
- await writable3.close();
4106
- } catch (err) {
4107
- await writable3.abort().catch(nothing);
4108
- throw err;
4109
- }
4110
- options.copies?.set(rest2, {
4111
- before: options.copies.get(rest2)?.before ?? file.lastModified,
4112
- made: made2
4113
- });
4114
- return;
4344
+ return this.copyBytes(handle, dir, name2, options, rest2);
4115
4345
  }
4116
4346
  const target = await this.io(dir.getDirectoryHandle(name2, { create: true }));
4117
4347
  this.others++;
@@ -4119,6 +4349,22 @@ var OpfsFs = class {
4119
4349
  await this.copy(child2, target, child2.name, options, `${rest2}/${child2.name}`);
4120
4350
  }
4121
4351
  }
4352
+ async copyBytes(handle, dir, name2, options, rest2) {
4353
+ const file = await this.io(handle.getFile());
4354
+ const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
4355
+ const writable3 = await this.io(made2.createWritable());
4356
+ try {
4357
+ await writable3.write(file);
4358
+ await writable3.close();
4359
+ } catch (err) {
4360
+ await writable3.abort().catch(nothing);
4361
+ throw err;
4362
+ }
4363
+ options.copies?.set(rest2, {
4364
+ before: options.copies.get(rest2)?.before ?? file.lastModified,
4365
+ made: made2
4366
+ });
4367
+ }
4122
4368
  async symlink(target, path, owner) {
4123
4369
  if (overPath(target)) throw fsError("ENAMETOOLONG", path);
4124
4370
  const parent = await this.exactly(() => this.locate(parentOf4(path), true));
@@ -4286,7 +4532,7 @@ function nothing() {
4286
4532
  }
4287
4533
  function touches(at, trees, listing = true, removing = false) {
4288
4534
  return trees.some(
4289
- ([from, to]) => within3(at, from) || within3(at, to) || listing && (at === parentOf4(from) || at === parentOf4(to)) || removing && (at === "/" || within3(from, at) || within3(to, at))
4535
+ ([from, to]) => within4(at, from) || within4(at, to) || listing && (at === parentOf4(from) || at === parentOf4(to)) || removing && (at === "/" || within4(from, at) || within4(to, at))
4290
4536
  );
4291
4537
  }
4292
4538
  function byIntent(a, b) {
@@ -4331,6 +4577,7 @@ var WRITES = [
4331
4577
  const proto = OpfsFs.prototype;
4332
4578
  const inner = proto.createExclusive;
4333
4579
  proto.createExclusive = function(...args) {
4580
+ if (this.privateRename) return this.privateOp("createExclusive", args, inner);
4334
4581
  if (this.amongPeers()) return this.peerOp("createExclusive", args, inner);
4335
4582
  return this.alonePlain(inner, args);
4336
4583
  };
@@ -4344,6 +4591,7 @@ for (const [names2, op] of [
4344
4591
  const inner = proto[name2];
4345
4592
  proto[name2] = async function(...args) {
4346
4593
  try {
4594
+ if (this.privateRename) return await this.privateOp(name2, args, inner);
4347
4595
  if (op === "read") await this.settledRename(args[0]);
4348
4596
  if (this.amongPeers() || name2 === "writeSession")
4349
4597
  return await this.peerOp(name2, args, inner);
@@ -7074,7 +7322,7 @@ function parsePrefix(text) {
7074
7322
  if (length2 < 0 || length2 > max) return void 0;
7075
7323
  return { ...parsed3, length: length2 };
7076
7324
  }
7077
- function within4(prefix, addr) {
7325
+ function within5(prefix, addr) {
7078
7326
  if (prefix.v6 !== addr.v6) return false;
7079
7327
  const shift = BigInt((prefix.v6 ? 128 : 32) - prefix.length);
7080
7328
  return addr.bits >> shift === prefix.bits >> shift;
@@ -7114,9 +7362,9 @@ var Routes = class {
7114
7362
  if (!addr) return "unreachable";
7115
7363
  if (addr.v6 && addr.bits === 1n) return "loopback";
7116
7364
  if (!addr.v6 && addr.bits >> 24n === 127n) return "loopback";
7117
- if (RESERVED.some((p) => within4(p, addr))) return "reserved";
7365
+ if (RESERVED.some((p) => within5(p, addr))) return "reserved";
7118
7366
  if (addr.v6 && !this.ipv6) return "unreachable";
7119
- if (this.exit || this.table.some((p) => within4(p, addr))) return "uplink";
7367
+ if (this.exit || this.table.some((p) => within5(p, addr))) return "uplink";
7120
7368
  return "unreachable";
7121
7369
  }
7122
7370
  };
@@ -9626,7 +9874,7 @@ function satisfies(version, range2) {
9626
9874
  }
9627
9875
 
9628
9876
  // src/version.ts
9629
- var KERNEL_VERSION = true ? "1.196.18" : "0.0.0-dev";
9877
+ var KERNEL_VERSION = true ? "1.196.19" : "0.0.0-dev";
9630
9878
  var OS_RELEASE = "6.0.0-slicc";
9631
9879
  function procVersion() {
9632
9880
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -10788,7 +11036,7 @@ var PathMarks = class {
10788
11036
  this.naming.set(promise, paths);
10789
11037
  try {
10790
11038
  if (this.active.size) {
10791
- const pending = [...this.active].filter(([, at]) => paths.some((p) => within5(at, p)));
11039
+ const pending = [...this.active].filter(([, at]) => paths.some((p) => within6(at, p)));
10792
11040
  await Promise.all(pending.map(([done5]) => done5));
10793
11041
  }
10794
11042
  return await op();
@@ -10799,7 +11047,7 @@ var PathMarks = class {
10799
11047
  }
10800
11048
  async metadata(path, op) {
10801
11049
  while (this.naming.size) {
10802
- const pending = [...this.naming].filter(([, paths]) => paths.some((p) => within5(path, p)));
11050
+ const pending = [...this.naming].filter(([, paths]) => paths.some((p) => within6(path, p)));
10803
11051
  if (!pending.length) break;
10804
11052
  await Promise.all(pending.map(([done5]) => done5));
10805
11053
  }
@@ -10844,7 +11092,7 @@ var LOOKUP_OPS = [
10844
11092
  "readlink",
10845
11093
  "realpath"
10846
11094
  ];
10847
- var within5 = (path, target) => path === target || target === "/" || path.startsWith(`${target}/`);
11095
+ var within6 = (path, target) => path === target || target === "/" || path.startsWith(`${target}/`);
10848
11096
  var TOUCHED_MAX = 4096;
10849
11097
  var parentOf6 = (path) => path.slice(0, path.lastIndexOf("/")) || "/";
10850
11098
  var PEER_RM_MS = 1e3;
@@ -11088,7 +11336,7 @@ var UnlinkedKeeper = class {
11088
11336
  for (const holder of this.holders) {
11089
11337
  if (holder.owns(target)) continue;
11090
11338
  for (const path of holder.held()) {
11091
- if (!within5(path, target) || holder.isKept(path)) continue;
11339
+ if (!within6(path, target) || holder.isKept(path)) continue;
11092
11340
  held2.set(path, [...held2.get(path) ?? [], holder]);
11093
11341
  }
11094
11342
  }
@@ -13143,7 +13391,7 @@ var DEFAULT_UMASK = 18;
13143
13391
  function isModule(bytes) {
13144
13392
  return MAGIC.every((b, i) => bytes[i] === b);
13145
13393
  }
13146
- function within6(path, dir) {
13394
+ function within7(path, dir) {
13147
13395
  return path.startsWith(dir === "/" ? "/" : `${dir}/`);
13148
13396
  }
13149
13397
  var FreshModules = class {
@@ -13167,10 +13415,10 @@ var FreshModules = class {
13167
13415
  const target = normalizePath(to);
13168
13416
  if (source === target) return;
13169
13417
  for (const key of [...this.fresh.keys()]) {
13170
- if (key === target || within6(key, target)) this.fresh.delete(key);
13418
+ if (key === target || within7(key, target)) this.fresh.delete(key);
13171
13419
  }
13172
13420
  for (const [key, fresh4] of [...this.fresh]) {
13173
- if (key !== source && !within6(key, source)) continue;
13421
+ if (key !== source && !within7(key, source)) continue;
13174
13422
  this.fresh.delete(key);
13175
13423
  this.fresh.set(target + key.slice(source.length), fresh4);
13176
13424
  }
@@ -13212,7 +13460,7 @@ var FreshModules = class {
13212
13460
  await fs.rm(path, options);
13213
13461
  const at = normalizePath(path);
13214
13462
  for (const key of [...this.fresh.keys()]) {
13215
- if (key === at || within6(key, at)) this.fresh.delete(key);
13463
+ if (key === at || within7(key, at)) this.fresh.delete(key);
13216
13464
  }
13217
13465
  },
13218
13466
  rename: async (from, to) => {
@@ -13266,7 +13514,7 @@ var FreshModules = class {
13266
13514
  };
13267
13515
 
13268
13516
  // src/fs/text-busy.ts
13269
- var within7 = (path, prefix) => prefix === "/" || path === prefix || path.startsWith(`${prefix}/`);
13517
+ var within8 = (path, prefix) => prefix === "/" || path === prefix || path.startsWith(`${prefix}/`);
13270
13518
  var baseName = (path) => path.slice(path.lastIndexOf("/") + 1);
13271
13519
  var PLAIN_LIMIT = 4096;
13272
13520
  function busyError(path) {
@@ -13301,10 +13549,10 @@ var TextBusy = class {
13301
13549
  let changed2 = false;
13302
13550
  for (const run2 of this.runs) {
13303
13551
  if (run2.name === void 0) continue;
13304
- if (within7(run2.name, from)) {
13552
+ if (within8(run2.name, from)) {
13305
13553
  run2.name = to + run2.name.slice(from.length);
13306
13554
  changed2 = true;
13307
- } else if (within7(run2.name, to)) {
13555
+ } else if (within8(run2.name, to)) {
13308
13556
  run2.name = void 0;
13309
13557
  changed2 = true;
13310
13558
  }
@@ -13315,7 +13563,7 @@ var TextBusy = class {
13315
13563
  if (this.runs.size === 0) return;
13316
13564
  let changed2 = false;
13317
13565
  for (const run2 of this.runs) {
13318
- if (run2.name === void 0 || !within7(run2.name, path)) continue;
13566
+ if (run2.name === void 0 || !within8(run2.name, path)) continue;
13319
13567
  run2.name = void 0;
13320
13568
  changed2 = true;
13321
13569
  }
@@ -15957,7 +16205,7 @@ function linkedTo(mount, path) {
15957
16205
  return own?.kind !== "directory" && (attr2.nlink ?? 1) > 1;
15958
16206
  };
15959
16207
  }
15960
- var within8 = (path, target) => path === target || target === "/" || path.startsWith(`${target}/`);
16208
+ var within9 = (path, target) => path === target || target === "/" || path.startsWith(`${target}/`);
15961
16209
  var HeldSet = class extends Set {
15962
16210
  idle;
15963
16211
  moved;
@@ -15993,7 +16241,7 @@ var HeldSet = class extends Set {
15993
16241
  }
15994
16242
  };
15995
16243
  function heldUnder(held2, target) {
15996
- for (const paths of held2) for (const path of paths.keys()) if (within8(path, target)) return true;
16244
+ for (const paths of held2) for (const path of paths.keys()) if (within9(path, target)) return true;
15997
16245
  return false;
15998
16246
  }
15999
16247
  var HeldPaths = class extends Map {
@@ -16035,7 +16283,7 @@ var HeldPaths = class extends Map {
16035
16283
  if (this.bound.size === 0) return;
16036
16284
  for (const [handle, key] of this.handles) {
16037
16285
  if (!this.bound.has(handle) || this.keptHandles.has(handle)) continue;
16038
- if (exact2 ? key === over : within8(key, over)) this.doubted.set(handle, ++this.doubts);
16286
+ if (exact2 ? key === over : within9(key, over)) this.doubted.set(handle, ++this.doubts);
16039
16287
  }
16040
16288
  }
16041
16289
  heldIdentity(handle) {
@@ -16182,24 +16430,24 @@ var HeldPaths = class extends Map {
16182
16430
  return this.owning === path;
16183
16431
  }
16184
16432
  revoke(prefix) {
16185
- for (const path of this.keys()) if (within8(path, prefix)) this.revoked.add(path);
16433
+ for (const path of this.keys()) if (within9(path, prefix)) this.revoked.add(path);
16186
16434
  }
16187
16435
  renamed(from, to) {
16188
16436
  for (const [path, count3] of [...this]) {
16189
- if (!within8(path, from)) continue;
16437
+ if (!within9(path, from)) continue;
16190
16438
  const moved2 = to + path.slice(from.length);
16191
16439
  this.delete(path);
16192
16440
  this.set(moved2, (this.get(moved2) ?? 0) + count3);
16193
16441
  if (this.revoked.delete(path)) this.revoked.add(moved2);
16194
16442
  }
16195
16443
  for (const [path, count3] of [...this.opens]) {
16196
- if (!within8(path, from)) continue;
16444
+ if (!within9(path, from)) continue;
16197
16445
  const moved2 = to + path.slice(from.length);
16198
16446
  this.opens.delete(path);
16199
16447
  this.opens.set(moved2, (this.opens.get(moved2) ?? 0) + count3);
16200
16448
  }
16201
16449
  for (const [id2, key] of this.handles) {
16202
- if (within8(key, from)) this.handles.set(id2, to + key.slice(from.length));
16450
+ if (within9(key, from)) this.handles.set(id2, to + key.slice(from.length));
16203
16451
  }
16204
16452
  this.onMoved?.(from, to);
16205
16453
  }
@@ -16343,7 +16591,7 @@ var MountTable = class {
16343
16591
  });
16344
16592
  }
16345
16593
  under(path) {
16346
- for (const mount of this.mounts.values()) if (within8(mount.target, path)) return true;
16594
+ for (const mount of this.mounts.values()) if (within9(mount.target, path)) return true;
16347
16595
  return false;
16348
16596
  }
16349
16597
  linksAt(path) {
@@ -16356,7 +16604,7 @@ var MountTable = class {
16356
16604
  locate(path) {
16357
16605
  let best;
16358
16606
  for (const mount of this.mounts.values()) {
16359
- if (within8(path, mount.target) && (!best || mount.target.length > best.target.length))
16607
+ if (within9(path, mount.target) && (!best || mount.target.length > best.target.length))
16360
16608
  best = mount;
16361
16609
  }
16362
16610
  if (!best) return void 0;
@@ -16504,7 +16752,7 @@ var MountTable = class {
16504
16752
  async commitUnder(prefix) {
16505
16753
  const at = normalizePath(prefix);
16506
16754
  await Promise.all(
16507
- [...this.sessions.keys()].filter((p) => within8(p, at)).map((p) => this.commit(p))
16755
+ [...this.sessions.keys()].filter((p) => within9(p, at)).map((p) => this.commit(p))
16508
16756
  );
16509
16757
  }
16510
16758
  async commitOverlapping(real, offset, length2) {
@@ -16542,11 +16790,11 @@ var MountTable = class {
16542
16790
  mount.epoch++;
16543
16791
  const linked2 = mount.caps.links ? linkedTo(mount, path) : () => false;
16544
16792
  for (const [key, cached] of [...mount.attrs])
16545
- if (within8(key, path) || linked2(cached.value)) mount.attrs.delete(key);
16793
+ if (within9(key, path) || linked2(cached.value)) mount.attrs.delete(key);
16546
16794
  mount.lists.delete(path);
16547
16795
  mount.lists.delete(parentOf9(path));
16548
16796
  for (const [key, cached] of [...mount.lists])
16549
- if (within8(key, path) || cached.value.some((e) => linked2(e.attr))) mount.lists.delete(key);
16797
+ if (within9(key, path) || cached.value.some((e) => linked2(e.attr))) mount.lists.delete(key);
16550
16798
  }
16551
16799
  async getattr(mount, path, rel2, settled = false) {
16552
16800
  for (let round = 1; ; round++) {
@@ -16687,7 +16935,7 @@ var MountFs = class _MountFs {
16687
16935
  if (redirects >= MAX_LINKS6) throw errnoError("ELOOP", paths[0]);
16688
16936
  const at = paths.map((path) => {
16689
16937
  const real = normalizePath(path);
16690
- return within8(real, moved2.of) ? normalizePath(moved2.to + real.slice(moved2.of.length)) : real;
16938
+ return within9(real, moved2.of) ? normalizePath(moved2.to + real.slice(moved2.of.length)) : real;
16691
16939
  });
16692
16940
  return again(at, redirects + 1);
16693
16941
  }
@@ -28130,7 +28378,7 @@ function ranges(text) {
28130
28378
  return [Number.parseInt(lo, 16), Number.parseInt(hi, 16)];
28131
28379
  });
28132
28380
  }
28133
- function within9(table, code) {
28381
+ function within10(table, code) {
28134
28382
  let lo = 0;
28135
28383
  let hi = table.length - 1;
28136
28384
  while (lo <= hi) {
@@ -28153,10 +28401,10 @@ var LCAT = ranges(LCAT_TEXT);
28153
28401
  function prepFails(prepared) {
28154
28402
  const codes = Array.from(prepared, (ch) => ch.codePointAt(0) ?? 0);
28155
28403
  if (codes.length === 0) return true;
28156
- if (codes.some((c) => within9(PROHIBITED, c) || within9(UNASSIGNED, c))) return true;
28157
- if (!codes.some((c) => within9(RANDAL, c))) return false;
28158
- if (codes.some((c) => within9(LCAT, c))) return true;
28159
- return !within9(RANDAL, codes[0] ?? 0) || !within9(RANDAL, codes.at(-1) ?? 0);
28404
+ if (codes.some((c) => within10(PROHIBITED, c) || within10(UNASSIGNED, c))) return true;
28405
+ if (!codes.some((c) => within10(RANDAL, c))) return false;
28406
+ if (codes.some((c) => within10(LCAT, c))) return true;
28407
+ return !within10(RANDAL, codes[0] ?? 0) || !within10(RANDAL, codes.at(-1) ?? 0);
28160
28408
  }
28161
28409
 
28162
28410
  // src/kernel/net/sealed-scram.ts
@@ -30470,7 +30718,7 @@ function isMissing(err) {
30470
30718
  if (err?.code === "ENOENT") return true;
30471
30719
  return err instanceof Error && err.message.startsWith("ENOENT");
30472
30720
  }
30473
- function within10(path, root) {
30721
+ function within11(path, root) {
30474
30722
  return path === root || path.startsWith(root.endsWith("/") ? root : `${root}/`);
30475
30723
  }
30476
30724
  var VfsNode = class {
@@ -31034,12 +31282,12 @@ var VfsNodes = class {
31034
31282
  return node;
31035
31283
  }
31036
31284
  holds(prefix) {
31037
- for (const path of this.byPath.keys()) if (within10(path, prefix)) return true;
31285
+ for (const path of this.byPath.keys()) if (within11(path, prefix)) return true;
31038
31286
  return false;
31039
31287
  }
31040
31288
  writes(prefix) {
31041
31289
  for (const [path, node] of this.byPath)
31042
- if (node.writers > 0 && within10(path, prefix)) return true;
31290
+ if (node.writers > 0 && within11(path, prefix)) return true;
31043
31291
  return false;
31044
31292
  }
31045
31293
  closed(node, writable3 = false) {
@@ -31122,17 +31370,17 @@ var VfsNodes = class {
31122
31370
  this.byPath.get(path)?.reread();
31123
31371
  }
31124
31372
  rewrittenUnder(tree2) {
31125
- for (const [p, node] of this.byPath) if (within10(p, tree2)) node.reread();
31373
+ for (const [p, node] of this.byPath) if (within11(p, tree2)) node.reread();
31126
31374
  }
31127
31375
  doubted(path) {
31128
- for (const [p, node] of this.byPath) if (within10(p, path)) node.doubted();
31376
+ for (const [p, node] of this.byPath) if (within11(p, path)) node.doubted();
31129
31377
  }
31130
31378
  async flush(path) {
31131
- for (const [p, node] of this.byPath) if (within10(p, path)) await node.serial(() => node.flush());
31379
+ for (const [p, node] of this.byPath) if (within11(p, path)) await node.serial(() => node.flush());
31132
31380
  }
31133
31381
  async unlinking(path) {
31134
31382
  for (const [held2, node] of [...this.byPath]) {
31135
- if (!within10(held2, path)) continue;
31383
+ if (!within11(held2, path)) continue;
31136
31384
  await node.serial(async () => {
31137
31385
  await Promise.all([this.keepsOnDisk || node.keep(), node.limit(), node.retainMetadata()]);
31138
31386
  });
@@ -31140,14 +31388,14 @@ var VfsNodes = class {
31140
31388
  }
31141
31389
  revoke(prefix) {
31142
31390
  for (const [path, node] of [...this.byPath]) {
31143
- if (!within10(path, prefix)) continue;
31391
+ if (!within11(path, prefix)) continue;
31144
31392
  node.revoke();
31145
31393
  this.forget(node);
31146
31394
  }
31147
31395
  }
31148
31396
  unlinked(path) {
31149
31397
  for (const [held2, node] of [...this.byPath]) {
31150
- if (!within10(held2, path) || this.byPath.get(held2) !== node) continue;
31398
+ if (!within11(held2, path) || this.byPath.get(held2) !== node) continue;
31151
31399
  if (!this.dropName(held2, node)) this.orphan(node);
31152
31400
  }
31153
31401
  }
@@ -31155,8 +31403,8 @@ var VfsNodes = class {
31155
31403
  if (from === to) return;
31156
31404
  const moved2 = [];
31157
31405
  for (const [p, node] of [...this.byPath]) {
31158
- if (within10(p, from)) moved2.push([p, node]);
31159
- else if (within10(p, to) && this.byPath.get(p) === node && !this.dropName(p, node)) {
31406
+ if (within11(p, from)) moved2.push([p, node]);
31407
+ else if (within11(p, to) && this.byPath.get(p) === node && !this.dropName(p, node)) {
31160
31408
  this.orphan(node);
31161
31409
  }
31162
31410
  }
@@ -35823,7 +36071,7 @@ var PackageSwaps = class {
35823
36071
 
35824
36072
  // src/kernel/rename-log.ts
35825
36073
  var RENAME_LOG_SIZE = 4096;
35826
- function within11(path, root) {
36074
+ function within12(path, root) {
35827
36075
  return path === root || path.startsWith(root === "/" ? "/" : `${root}/`);
35828
36076
  }
35829
36077
  var RenameLog = class {
@@ -35850,9 +36098,9 @@ var RenameLog = class {
35850
36098
  const renames = [];
35851
36099
  let paths = [...held2];
35852
36100
  for (const { seq: seq2, from, to } of this.entries) {
35853
- if (seq2 <= seen || !paths.some((path) => within11(path, from))) continue;
36101
+ if (seq2 <= seen || !paths.some((path) => within12(path, from))) continue;
35854
36102
  renames.push([from, to]);
35855
- paths = paths.map((path) => within11(path, from) ? to + path.slice(from.length) : path);
36103
+ paths = paths.map((path) => within12(path, from) ? to + path.slice(from.length) : path);
35856
36104
  }
35857
36105
  return { now, renames };
35858
36106
  }
@@ -40108,9 +40356,9 @@ var Launcher = class {
40108
40356
  }
40109
40357
  packageRootIs(path) {
40110
40358
  const at = normalizePath(path);
40111
- const within12 = `${at}/`;
40359
+ const within13 = `${at}/`;
40112
40360
  const roots = [this.modulesDir, ...this.appended];
40113
- const root = PACKAGE_ROOT.exec(within12)?.[1] ?? packageRootOf(within12, roots);
40361
+ const root = PACKAGE_ROOT.exec(within13)?.[1] ?? packageRootOf(within13, roots);
40114
40362
  return root === at;
40115
40363
  }
40116
40364
  packageRoots(planned) {