@ai-ecoverse/slicc-kernel 1.103.1 → 1.103.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.
@@ -2434,7 +2434,7 @@ function mountVfsIntoEmscripten(Fs, deps) {
2434
2434
  linuxRmdir(Fs);
2435
2435
  if (deps.cred) Fs.sliccCred = deps.cred;
2436
2436
  try {
2437
- Fs.chdir(deps.cwd);
2437
+ (Fs.sliccChdirAt ?? Fs.chdir).call(Fs, deps.cwd);
2438
2438
  } catch (err) {
2439
2439
  warn(`cannot chdir to ${deps.cwd}: errno ${err.errno}`);
2440
2440
  }
@@ -2491,7 +2491,7 @@ var KERNEL_VERSION, OS_RELEASE;
2491
2491
  var init_version = __esm({
2492
2492
  "src/version.ts"() {
2493
2493
  "use strict";
2494
- KERNEL_VERSION = true ? "1.103.1" : "0.0.0-dev";
2494
+ KERNEL_VERSION = true ? "1.103.3" : "0.0.0-dev";
2495
2495
  OS_RELEASE = "6.0.0-slicc";
2496
2496
  }
2497
2497
  });
@@ -3394,6 +3394,7 @@ function kernelUname(imports, hostname, memory, glue) {
3394
3394
  function kernelChdir(Fs) {
3395
3395
  const { chdir, lookupPath, ErrnoError } = Fs;
3396
3396
  if (!chdir || !lookupPath || !ErrnoError) return;
3397
+ Fs.sliccChdirAt = chdir;
3397
3398
  Fs.chdir = (path) => {
3398
3399
  const { node } = lookupPath.call(Fs, path, { follow: true });
3399
3400
  const directory = Fs.isDir?.(node.mode) === true;
@@ -4556,6 +4557,7 @@ function createProcessKernel(deps) {
4556
4557
  argv,
4557
4558
  env: env ?? deps.env,
4558
4559
  cwd: cwd ?? Fs.cwd(),
4560
+ ...cwd !== null ? { chdir: true } : {},
4559
4561
  stdio,
4560
4562
  ...inherit.length > 0 ? { inherit } : {},
4561
4563
  ...exec ? { exec } : {},
@@ -6261,15 +6263,37 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
6261
6263
  const blind = shared !== void 0 && shared.length * 4 < SHARED_IDS_BYTES;
6262
6264
  const cache = new StatCache(blind ? void 0 : shared);
6263
6265
  const { stats, lstats } = cache;
6266
+ const view = bridge.changes;
6267
+ const live = (miss, path) => miss.until > now() && (view === void 0 || miss.gen === void 0 || !view.changedSince(miss.gen, path).changed);
6268
+ const seenAt = /* @__PURE__ */ new Map();
6269
+ const gone = (path) => {
6270
+ for (let at = path.lastIndexOf("/"); at > 0; at = path.lastIndexOf("/", at - 1)) {
6271
+ const up = path.slice(0, at);
6272
+ for (const map of [lstats, stats]) {
6273
+ const hit = map.get(up);
6274
+ const code2 = hit && "until" in hit ? hit.error.code : void 0;
6275
+ if (hit && "until" in hit && code2 === "ENOENT" && live(hit, up)) return hit;
6276
+ }
6277
+ }
6278
+ return void 0;
6279
+ };
6264
6280
  const cached = (map, path, get) => {
6265
6281
  if (blind) return get();
6266
6282
  cache.fresh();
6267
6283
  let hit = map.get(path);
6268
- if (hit === void 0 || "until" in hit && hit.until <= now()) {
6284
+ if (hit === void 0 || "until" in hit && !live(hit, path)) {
6285
+ const missing2 = gone(path);
6286
+ if (missing2) throw missing2.error;
6287
+ const gen = view?.now();
6269
6288
  try {
6270
6289
  hit = get();
6290
+ if (gen !== void 0 && map === lstats) seenAt.set(path, gen);
6271
6291
  } catch (e) {
6272
- hit = { error: e, until: now() + MISS_TTL_MS };
6292
+ hit = {
6293
+ error: e,
6294
+ until: now() + MISS_TTL_MS,
6295
+ ...gen !== void 0 ? { gen } : {}
6296
+ };
6273
6297
  }
6274
6298
  cache.put(map, path, hit);
6275
6299
  }
@@ -6325,7 +6349,15 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
6325
6349
  }
6326
6350
  return list;
6327
6351
  },
6328
- readlink: (p) => bridge.readlink(p),
6352
+ readlink: (p) => {
6353
+ const known = blind ? void 0 : (cache.fresh(), lstats.get(p));
6354
+ const gen = seenAt.get(p);
6355
+ const current = view !== void 0 && gen !== void 0 && !view.changedSince(gen, p).changed;
6356
+ if (known && current && !("until" in known) && !known.isSymbolicLink) {
6357
+ throw syncError("EINVAL", `'${p}' is not a symbolic link`);
6358
+ }
6359
+ return bridge.readlink(p);
6360
+ },
6329
6361
  stat: (p) => cached(stats, p, () => bridge.stat(p)),
6330
6362
  lstat: (p) => cached(lstats, p, () => bridge.lstat(p)),
6331
6363
  exists: (p) => {
@@ -6392,6 +6424,7 @@ var init_wasi_files = __esm({
6392
6424
  "src/process/wasi/wasi-files.ts"() {
6393
6425
  "use strict";
6394
6426
  init_ranged();
6427
+ init_sync_fs_wire();
6395
6428
  WasiError = class extends Error {
6396
6429
  code;
6397
6430
  constructor(code2) {
@@ -9476,7 +9509,9 @@ var init_wasix_process = __esm({
9476
9509
  });
9477
9510
  }
9478
9511
  spawn(req, exec = false) {
9479
- const { stdio, inherit, cwd, opened: opened2 } = this.childFds(req.ops ?? []);
9512
+ const ops = req.ops ?? [];
9513
+ const { stdio, inherit, cwd, opened: opened2 } = this.childFds(ops);
9514
+ const moved = ops.some((op) => op.cmd === "chdir" || op.cmd === "fchdir");
9480
9515
  try {
9481
9516
  const spawn = {
9482
9517
  op: "proc-spawn",
@@ -9484,6 +9519,7 @@ var init_wasix_process = __esm({
9484
9519
  argv: req.argv.length > 0 ? req.argv : [req.name],
9485
9520
  env: req.env ?? this.environment(),
9486
9521
  cwd,
9522
+ ...moved ? { chdir: true } : {},
9487
9523
  stdio,
9488
9524
  inherit,
9489
9525
  ...exec ? { exec } : {},
@@ -9766,6 +9802,7 @@ function processes(host, call2, inThread) {
9766
9802
  argv: o.argv,
9767
9803
  env: o.env ?? { ...host.o.env },
9768
9804
  cwd: o.cwd ?? host.cwd,
9805
+ ...o.cwd !== void 0 ? { chdir: true } : {},
9769
9806
  stdio,
9770
9807
  ...inThread ? {} : { restart: true }
9771
9808
  };
@@ -13201,6 +13238,7 @@ function childOps(kernel, io, defaults, sync) {
13201
13238
  ...named,
13202
13239
  env: { ...o.env ?? defaults.env },
13203
13240
  cwd: o.cwd ?? defaults.cwd,
13241
+ ...o.cwd !== void 0 ? { chdir: true } : {},
13204
13242
  stdio,
13205
13243
  ...group,
13206
13244
  ...death
@@ -14649,6 +14687,7 @@ function runSync(kernel, d, o) {
14649
14687
  ...named,
14650
14688
  env: { ...o.env ?? d.env },
14651
14689
  cwd: o.cwd === void 0 ? d.cwd : d.resolve(o.cwd),
14690
+ ...o.cwd === void 0 ? {} : { chdir: true },
14652
14691
  ...group,
14653
14692
  stdin: stdioOf(o.stdin),
14654
14693
  ...input ? { input } : {},