@wenathlan/saddle 2.0.165 → 2.0.166

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/modalities.ts CHANGED
@@ -1309,7 +1309,10 @@ export async function sigv4sign(options: {
1309
1309
  const regionkey = await hmac(datekey, options.region);
1310
1310
  const servicekey = await hmac(regionkey, options.service);
1311
1311
  const derived = await hmac(servicekey, "aws4_request");
1312
- const signature = tohex(derived);
1312
+ // the real chain closes the way aws pins it: the derived signing key
1313
+ // signs the string-to-sign — the signature is the hmac of the ladder's
1314
+ // last key over the canonical request's digest, never the key itself.
1315
+ const signature = tohex(await hmac(derived, stringtosign));
1313
1316
  return {
1314
1317
  amzdate,
1315
1318
  datestamp,
@@ -1952,15 +1955,34 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
1952
1955
  slug: "virtualdrivers",
1953
1956
  num: 7,
1954
1957
  lane: "vm",
1955
- operate: async () => ({
1956
- stdout:
1957
- "driver manifest: virtualcpu (topology solver), virtualgpu (device bank, mig slicing), virtualmemory (page-aligned windows), nvml-shim (the identity the guests read)",
1958
- artifact: {
1959
- drivers: ["virtualcpu", "virtualgpu", "virtualmemory", "nvml-shim"],
1958
+ operate: async (request) => {
1959
+ const inputs = (request.inputs ?? {}) as { vcpus?: number; cpu?: string; gpu?: string; quota?: number };
1960
+ const topology = solvectputopology(inputs.vcpus ?? 4);
1961
+ const processor = presentprocessor(inputs.cpu ?? "epyc9965");
1962
+ const bank = presentgpubank(inputs.gpu ?? "b200", 1);
1963
+ const window = mmapwindowplan(0, 65536);
1964
+ // the driver-quota gate: the nvml shim presents 1 to 16 devices.
1965
+ const quota = Math.max(1, Math.min(16, Math.round(inputs.quota ?? 4)));
1966
+ const manifest = {
1967
+ drivers: {
1968
+ virtualcpu: `${topology.sockets}x${topology.cores}x${topology.threads} (qemu ${topology.qemuflag})`,
1969
+ virtualgpu: `${bank.name} (mig ${bank.mig ? bank.migprofiles.join(", ") : "off"})`,
1970
+ virtualmemory: `${window.pages} pages, ${window.advice}`,
1971
+ "nvml-shim": processor.model,
1972
+ },
1973
+ nvmlshim: Array.from({ length: quota }, (_, index) => ({
1974
+ device: index,
1975
+ model: processor.model,
1976
+ vrammib: bank.vramgb * 1024,
1977
+ })),
1960
1978
  guestpresented: true,
1961
1979
  visitorhardware: false,
1962
- },
1963
- }),
1980
+ };
1981
+ return {
1982
+ stdout: `driver manifest: ${Object.keys(manifest.drivers).join(", ")} — the nvml shim presents ${quota} device(s) under the driver-quota gate`,
1983
+ artifact: manifest,
1984
+ };
1985
+ },
1964
1986
  }),
1965
1987
  },
1966
1988
  {
@@ -2273,17 +2295,51 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
2273
2295
  num: 16,
2274
2296
  lane: "runner",
2275
2297
  operate: async (request) => {
2298
+ // the real routing brain of the runner lane: the magic sniff answers
2299
+ // the kind, the kind answers the concrete argv and the seat of the
2300
+ // ninety that executes it — the shebang line is parsed for real.
2276
2301
  const kind = sniffpayloadmagic(request.code);
2277
- const routing: Record<string, string> = {
2278
- elf: "exec under the cgroup slice (chmod +x, binfmt_misc when the host carries it)",
2279
- exe: "wine or the binfmt msdos seat (the exe lane of the ninety)",
2280
- wasm: "the wasm seat instantiation (wasmtime/wasmedge or in-process)",
2281
- script: "the shebang interpreter the payload names (bash, sh, python...)",
2282
- text: "the text rides the bash -c seat",
2283
- };
2302
+ const cgroups = cgroupslice(BASEENVELOPE, request.profile ?? DEFAULTPROFILE, "runneruniversal");
2303
+ let seat: number;
2304
+ let argv: readonly string[];
2305
+ let interpreter: string;
2306
+ switch (kind) {
2307
+ case "elf": {
2308
+ seat = 27;
2309
+ argv = [workspacepath("runneruniversal", "payload")];
2310
+ interpreter = "the kernel exec surface (seat 27 rides the elf gate)";
2311
+ break;
2312
+ }
2313
+ case "exe": {
2314
+ seat = 26;
2315
+ argv = ["wine", workspacepath("runneruniversal", "payload.exe")];
2316
+ interpreter = "wine (seat 26 rides the mz gate)";
2317
+ break;
2318
+ }
2319
+ case "wasm": {
2320
+ seat = 22;
2321
+ argv = ["wasmtime", "--dir", "/sandbox::/sandbox", workspacepath("runneruniversal", "payload.wasm")];
2322
+ interpreter = "the wasm instantiation seat (in-process or wasmtime)";
2323
+ break;
2324
+ }
2325
+ case "script": {
2326
+ const shebang = (request.code.split("\n", 1)[0] ?? "").replace(/^#!\s*/, "");
2327
+ const [command = "/bin/sh", ...shebangargs] = shebang.split(/\s+/).filter((token) => token.length > 0);
2328
+ seat = 28;
2329
+ argv = [command, ...shebangargs, workspacepath("runneruniversal", "payload")];
2330
+ interpreter = `the shebang interpreter ${command}`;
2331
+ break;
2332
+ }
2333
+ default: {
2334
+ seat = 28;
2335
+ argv = ["bash", "-c", request.code];
2336
+ interpreter = "bash -c (the text lane)";
2337
+ break;
2338
+ }
2339
+ }
2284
2340
  return {
2285
- stdout: `universal runner: the payload sniffed ${kind} — ${routing[kind]}`,
2286
- artifact: { kind, routing: routing[kind], binfmt: "binfmt_misc registration plan stamped on the engine host" },
2341
+ stdout: `universal runner: the payload sniffed ${kind} — routing to seat ${seat} (${interpreter}), argv ${argv.join(" ")}`,
2342
+ artifact: { kind, seat, argv, interpreter, cgroups },
2287
2343
  };
2288
2344
  },
2289
2345
  }),
@@ -2337,7 +2393,9 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
2337
2393
  num: 18,
2338
2394
  lane: "runner",
2339
2395
  binary: "bun",
2340
- argv: ({ code }) => ["bun", "run", "-"],
2396
+ // the payload rides the staged program file — a "-" stdin argv would
2397
+ // wait on a pipe the spawner never writes, so the seat never builds one.
2398
+ argv: ({ file }) => ["bun", "run", file],
2341
2399
  hardening: ["package-allowlist"],
2342
2400
  }),
2343
2401
  },
@@ -2363,7 +2421,9 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
2363
2421
  num: 19,
2364
2422
  lane: "runner",
2365
2423
  binary: "deno",
2366
- argv: ({ code }) => ["deno", "run", "--allow-read=/sandbox", "-"],
2424
+ // the payload rides the staged program file — the read permission maps
2425
+ // the sandbox alone, the stdin dash never rides (no pipe is written).
2426
+ argv: ({ file }) => ["deno", "run", "--allow-read=/sandbox", file],
2367
2427
  hardening: ["permission-map"],
2368
2428
  }),
2369
2429
  },
@@ -2527,13 +2587,15 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
2527
2587
  lane: "runner",
2528
2588
  operate: async (request) => {
2529
2589
  const kind = sniffpayloadmagic(request.code);
2530
- if (kind === "wasm") {
2531
- return { stdout: await instantiatewasm(request.code), artifact: { toolchain: "wasmedge (in-process instantiation)" } };
2590
+ if (kind !== "wasm") {
2591
+ throw Object.assign(
2592
+ new Error(
2593
+ `the wasme seat requires base64 wasm module bytes in the code field (sniffed ${kind}) — the wasmedge toolchain never fakes a run on foreign bytes`,
2594
+ ),
2595
+ { code: "WASM_BYTES_ABSENT" },
2596
+ );
2532
2597
  }
2533
- return {
2534
- stdout: `wasme seat: the payload is ${kind}, not wasm bytes — the wasmedge cli plan is stamped (wasmedge --dir .:. module.wasm)`,
2535
- artifact: { toolchain: "wasmedge", plan: ["wasmedge", "--dir", ".:.", "module.wasm"] },
2536
- };
2598
+ return { stdout: await instantiatewasm(request.code), artifact: { toolchain: "wasmedge (in-process instantiation)" } };
2537
2599
  },
2538
2600
  }),
2539
2601
  },
@@ -2554,27 +2616,25 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
2554
2616
  archs: WINDOWSARCHS,
2555
2617
  osprofiles: ["windows"],
2556
2618
  resources: BASEENVELOPE,
2557
- execute: inprocseat({
2619
+ execute: hostspawnseat({
2558
2620
  slug: "runnerexe",
2559
2621
  num: 26,
2560
2622
  lane: "runner",
2561
- operate: async (request) => {
2562
- const kind = sniffpayloadmagic(request.code);
2623
+ binary: "wine",
2624
+ // the mz gate rides before the plan: the signature law refuses every
2625
+ // payload without the pe magic (the throw rides the guard seam the
2626
+ // visitor law shares — an honest coded refusal, never a faked boot).
2627
+ argv: ({ code, file }) => {
2628
+ const kind = sniffpayloadmagic(code);
2563
2629
  if (kind !== "exe") {
2564
2630
  throw Object.assign(new Error(`the exe seat refuses the payload: the mz signature is absent (sniffed ${kind})`), {
2565
2631
  code: "MZ_SIGNATURE_ABSENT",
2566
2632
  });
2567
2633
  }
2568
- return {
2569
- stdout:
2570
- "exe seat: the mz signature verified — the wine exec plan is stamped (wine /sandbox/runnerexe/payload.exe under the cgroup slice)",
2571
- artifact: {
2572
- kind,
2573
- argv: ["wine", "/sandbox/runnerexe/payload.exe"],
2574
- cgroup: cgroupslice(BASEENVELOPE, request.profile ?? DEFAULTPROFILE, "runnerexe"),
2575
- },
2576
- };
2634
+ return ["wine", file];
2577
2635
  },
2636
+ hardening: ["mz-gate", "dropped-caps"],
2637
+ probe: "the host must carry wine (the mz gate refuses every payload without the pe signature first)",
2578
2638
  }),
2579
2639
  },
2580
2640
  {
@@ -2594,27 +2654,25 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
2594
2654
  archs: ALLARCHS,
2595
2655
  osprofiles: ALLOSPROFILES,
2596
2656
  resources: BASEENVELOPE,
2597
- execute: inprocseat({
2657
+ execute: hostspawnseat({
2598
2658
  slug: "runnerbinary",
2599
2659
  num: 27,
2600
2660
  lane: "runner",
2601
- operate: async (request) => {
2602
- const kind = sniffpayloadmagic(request.code);
2661
+ binary: "the exec surface",
2662
+ // the elf gate rides before the plan: the magic law refuses every
2663
+ // payload without the elf magic, then the kernel exec surface runs the
2664
+ // staged payload under the cgroup slice (argv[0] is the payload).
2665
+ argv: ({ code, file }) => {
2666
+ const kind = sniffpayloadmagic(code);
2603
2667
  if (kind !== "elf") {
2604
2668
  throw Object.assign(new Error(`the binary seat refuses the payload: the elf magic is absent (sniffed ${kind})`), {
2605
2669
  code: "ELF_MAGIC_ABSENT",
2606
2670
  });
2607
2671
  }
2608
- return {
2609
- stdout:
2610
- "binary seat: the elf magic verified — the exec plan is stamped (chmod +x /sandbox/runnerbinary/payload && exec under the cgroup slice)",
2611
- artifact: {
2612
- kind,
2613
- argv: ["/sandbox/runnerbinary/payload"],
2614
- cgroup: cgroupslice(BASEENVELOPE, request.profile ?? DEFAULTPROFILE, "runnerbinary"),
2615
- },
2616
- };
2672
+ return [file];
2617
2673
  },
2674
+ hardening: ["elf-gate", "dropped-caps"],
2675
+ probe: "the host must stage the payload executable under /sandbox (the exec surface rides the elf gate first)",
2618
2676
  }),
2619
2677
  },
2620
2678
  {
@@ -2855,7 +2913,9 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
2855
2913
  num: 34,
2856
2914
  lane: "runner",
2857
2915
  binary: "go",
2858
- argv: ({ code }) => ["go", "run", "/dev/stdin"],
2916
+ // the payload rides the staged program file — /dev/stdin would wait on
2917
+ // a pipe the spawner never writes, so the seat never names it.
2918
+ argv: ({ file }) => ["go", "run", file],
2859
2919
  env: { GOPATH: "/sandbox/go", GOCACHE: "/sandbox/go/cache", GOFLAGS: "-mod=mod" },
2860
2920
  hardening: ["gopath-jail"],
2861
2921
  }),
@@ -3453,9 +3513,11 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
3453
3513
  { code: "TAG_NOT_IMMUTABLE" },
3454
3514
  );
3455
3515
  }
3516
+ const slice = cgroupslice(BASEENVELOPE, request.profile ?? DEFAULTPROFILE, "containerghcr");
3517
+ const argv = ["docker", "run", "--rm", ...dockerflags(slice), reference];
3456
3518
  return {
3457
- stdout: `ghcr seat: ${reference} passed the digest-pin gate — docker run --rm ${reference} under the cgroup slice`,
3458
- artifact: { reference, argv: ["docker", "run", "--rm", reference] },
3519
+ stdout: `ghcr seat: ${reference} passed the digest-pin gate — ${argv.join(" ")}`,
3520
+ artifact: { reference, argv, cgroup: slice },
3459
3521
  };
3460
3522
  },
3461
3523
  }),
@@ -3853,9 +3915,26 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
3853
3915
  operate: async (request) => {
3854
3916
  const inputs = (request.inputs ?? {}) as { mounts?: string[]; quota?: number };
3855
3917
  const mounts = inputs.mounts ?? ["/sandbox", "/sandbox/tmp"];
3918
+ const quotamb = Math.max(1, Math.round(inputs.quota ?? 64));
3919
+ // the real chunk-catalog composition: every mount answers its
3920
+ // page-aligned window over the payload bytes (the mmap math), and
3921
+ // the quota gate refuses a composition the ceiling cannot hold.
3922
+ const payload = new TextEncoder().encode(request.code);
3923
+ const catalog = mounts.map((mount) => {
3924
+ const window = mmapwindowplan(0, Math.max(1, payload.byteLength));
3925
+ return { mount, pages: window.pages, bytes: window.pagelength, advice: window.advice };
3926
+ });
3927
+ const composed = catalog.reduce((total, entry) => total + entry.bytes, 0);
3928
+ const pages = catalog.reduce((total, entry) => total + entry.pages, 0);
3929
+ if (composed > quotamb * 1024 * 1024) {
3930
+ throw Object.assign(
3931
+ new Error(`the vfs quota is exceeded (${composed} bytes over ${mounts.length} mounts > ${quotamb} mb)`),
3932
+ { code: "VFS_QUOTA_EXCEEDED" },
3933
+ );
3934
+ }
3856
3935
  return {
3857
- stdout: `vfs: ${mounts.length} mounts composed (${mounts.join(", ")}) under the ${inputs.quota ?? 64} mb chunk-catalog quota`,
3858
- artifact: { mounts, quota: inputs.quota ?? 64, chunked: true },
3936
+ stdout: `vfs: ${mounts.length} mounts composed (${mounts.join(", ")}) — ${composed} bytes in ${pages} chunk pages under the ${quotamb} mb quota`,
3937
+ artifact: { mounts: catalog, quota: quotamb, composed, pages, chunked: true },
3859
3938
  };
3860
3939
  },
3861
3940
  }),
@@ -3911,11 +3990,52 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
3911
3990
  slug: "deliverycdn",
3912
3991
  num: 69,
3913
3992
  lane: "sandbox",
3914
- operate: async () => ({
3915
- stdout:
3916
- "cdn mirror: the cache-control plan answers (public, max-age=31536000, immutable — the hashed asset law), the fetch rides inside the sandbox",
3917
- artifact: { cachecontrol: "public, max-age=31536000, immutable", fetchscope: "inside-sandbox" },
3918
- }),
3993
+ operate: async (request) => {
3994
+ // the real mirror planner: the code field is the manifest document
3995
+ // {"origin":"https://...","assets":["a.js",...]} — the origin-pin
3996
+ // law refuses a manifest without an origin, every asset answers its
3997
+ // sha256 content-addressed key and the etag the cdn pins (the hashed
3998
+ // asset law), and the fetch itself rides inside the sandbox (never
3999
+ // the visitor network).
4000
+ let manifest: { origin?: unknown; assets?: unknown } = {};
4001
+ try {
4002
+ manifest = JSON.parse(request.code) as { origin?: unknown; assets?: unknown };
4003
+ } catch {
4004
+ throw Object.assign(
4005
+ new Error("the cdn mirror seat requires a json manifest {origin, assets} in the code field"),
4006
+ { code: "MANIFEST_INVALID" },
4007
+ );
4008
+ }
4009
+ if (typeof manifest.origin !== "string" || manifest.origin.length === 0) {
4010
+ throw Object.assign(new Error("the cdn mirror seat requires an origin (the origin-pin law)"), {
4011
+ code: "ORIGIN_PIN_ABSENT",
4012
+ });
4013
+ }
4014
+ if (!Array.isArray(manifest.assets)) {
4015
+ throw Object.assign(new Error("the cdn mirror seat requires an assets array in the manifest"), {
4016
+ code: "MANIFEST_INVALID",
4017
+ });
4018
+ }
4019
+ const assets = manifest.assets.map((name) => (typeof name === "string" ? name : String(name)));
4020
+ const entries = await Promise.all(
4021
+ assets.map(async (name) => {
4022
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(name));
4023
+ const sha256 = Array.from(new Uint8Array(digest))
4024
+ .map((value) => value.toString(16).padStart(2, "0"))
4025
+ .join("");
4026
+ return {
4027
+ name,
4028
+ key: `assets/${sha256.slice(0, 32)}`,
4029
+ etag: `"${sha256}"`,
4030
+ cachecontrol: "public, max-age=31536000, immutable",
4031
+ };
4032
+ }),
4033
+ );
4034
+ return {
4035
+ stdout: `cdn mirror: ${entries.length} asset(s) keyed under ${manifest.origin} — the hashed asset law (etag + immutable), the fetch rides inside the sandbox`,
4036
+ artifact: { origin: manifest.origin, assets: entries, fetchscope: "inside-sandbox" },
4037
+ };
4038
+ },
3919
4039
  }),
3920
4040
  },
3921
4041
  {
@@ -4045,11 +4165,68 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
4045
4165
  slug: "storagelibsql",
4046
4166
  num: 73,
4047
4167
  lane: "sandbox",
4048
- operate: async () => ({
4049
- stdout:
4050
- "libsql vault: the connection plan answers (the turso-shaped endpoint, the auth token gate) — the wire rides when the configuration lands",
4051
- artifact: { engine: "libsql", gate: "LIBSQL_URL + LIBSQL_AUTH_TOKEN configuration keys" },
4052
- }),
4168
+ operate: async (request) => {
4169
+ // the real vault roundtrip: the @libsql/client runtime the engine
4170
+ // graph carries plus the LIBSQL_URL configuration — without either
4171
+ // the seat answers the honest coded absence, and with both it drives
4172
+ // one full roundtrip (create, insert, select, drop) on a private
4173
+ // table, the readback compared against the payload character for
4174
+ // character (the seat never fakes a database).
4175
+ const url = typeof process !== "undefined" ? process.env.LIBSQL_URL ?? "" : "";
4176
+ if (url.length === 0) {
4177
+ throw Object.assign(
4178
+ new Error(
4179
+ "the libsql vault requires the LIBSQL_URL configuration and the @libsql/client runtime on the engine host (the seat never fakes a database)",
4180
+ ),
4181
+ { code: "HOST_RUNTIME_ABSENT" },
4182
+ );
4183
+ }
4184
+ let libsql: typeof import("@libsql/client");
4185
+ try {
4186
+ libsql = (await import("@libsql/client")) as typeof import("@libsql/client");
4187
+ } catch (error) {
4188
+ throw Object.assign(
4189
+ new Error(`the @libsql/client runtime is absent from the engine module graph: ${error instanceof Error ? error.message : String(error)}`),
4190
+ { code: "HOST_RUNTIME_ABSENT" },
4191
+ );
4192
+ }
4193
+ const client = libsql.createClient({ url });
4194
+ const table = `saddle_libsql_${Date.now().toString(36)}${Math.floor(Math.random() * 1679616).toString(36)}`;
4195
+ const payload = request.code;
4196
+ let readback = "";
4197
+ try {
4198
+ await client.execute({ sql: `create table if not exists ${table} (k text primary key, v text)` });
4199
+ await client.execute({ sql: `insert or replace into ${table} (k, v) values (?, ?)`, args: ["saddle-payload", payload] });
4200
+ const selected = await client.execute({ sql: `select v from ${table} where k = ?`, args: ["saddle-payload"] });
4201
+ readback = String((selected.rows[0] as { v?: unknown } | undefined)?.v ?? "");
4202
+ } catch (error) {
4203
+ throw Object.assign(
4204
+ new Error(`the libsql endpoint refused the roundtrip: ${error instanceof Error ? error.message : String(error)}`),
4205
+ { code: "LIBSQL_ROUNDTRIP_FAILED" },
4206
+ );
4207
+ } finally {
4208
+ try {
4209
+ await client.execute({ sql: `drop table if exists ${table}` });
4210
+ } catch {
4211
+ /* the roundtrip already answered; the drop is best effort */
4212
+ }
4213
+ try {
4214
+ await client.close();
4215
+ } catch {
4216
+ /* the close is best effort */
4217
+ }
4218
+ }
4219
+ if (readback !== payload) {
4220
+ throw Object.assign(
4221
+ new Error(`the libsql roundtrip answered ${readback.length} characters for ${payload.length} written`),
4222
+ { code: "LIBSQL_ROUNDTRIP_FAILED" },
4223
+ );
4224
+ }
4225
+ return {
4226
+ stdout: `libsql vault: ${payload.length} characters roundtripped through the ${url.split(":")[0]} endpoint`,
4227
+ artifact: { engine: "libsql", url: url.split(":")[0], roundtrip: true },
4228
+ };
4229
+ },
4053
4230
  }),
4054
4231
  },
4055
4232
  {
@@ -4210,11 +4387,26 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
4210
4387
  num: 78,
4211
4388
  lane: "sandbox",
4212
4389
  operate: async (request) => {
4213
- const inputs = (request.inputs ?? {}) as { domain?: string };
4214
- const packet = builddnsquery(inputs.domain ?? "devthink.dev", "a");
4390
+ // the real rfc 8484 composition: the dns wire packet (the same
4391
+ // builder the dns seat answers) framed as one application/dns-message
4392
+ // post against the resolver endpoint — the request document answers
4393
+ // the bytes and the url, the https ride stays inside the sandbox.
4394
+ const inputs = (request.inputs ?? {}) as { domain?: string; qtype?: string; resolver?: string };
4395
+ const domain = inputs.domain ?? "devthink.dev";
4396
+ const qtype = inputs.qtype ?? "a";
4397
+ const resolver =
4398
+ typeof inputs.resolver === "string" && /^https:\/\//.test(inputs.resolver) ? inputs.resolver : "https://dns.google/dns-query";
4399
+ const packet = builddnsquery(domain, qtype);
4400
+ const url = `${resolver}?name=${encodeURIComponent(domain)}&type=${encodeURIComponent(qtype)}`;
4215
4401
  return {
4216
- stdout: `doh: the application/dns-message post answers for ${inputs.domain ?? "devthink.dev"} (the rfc 8484 wire rides https)`,
4217
- artifact: { packet, mediatype: "application/dns-message", method: "POST" },
4402
+ stdout: `doh: the ${qtype} query for ${domain} framed as a ${packet.length / 2}-byte wire packet — post ${url} (application/dns-message, the rfc 8484 ride stays inside the sandbox)`,
4403
+ artifact: {
4404
+ url,
4405
+ method: "POST",
4406
+ mediatype: "application/dns-message",
4407
+ packet,
4408
+ body: packet,
4409
+ },
4218
4410
  };
4219
4411
  },
4220
4412
  }),
@@ -4530,11 +4722,32 @@ export const MODALITYENGINE: readonly ModalitySpec[] = [
4530
4722
  slug: "mobiletermux",
4531
4723
  num: 89,
4532
4724
  lane: "sandbox",
4533
- operate: async () => ({
4534
- stdout:
4535
- "termux: the android sandbox plan answers (the termux property composition, the emulated device the lane mounts on the edge)",
4536
- artifact: { platform: "android", device: "emulated", execscope: "edge-host" },
4537
- }),
4725
+ operate: async (request) => {
4726
+ // the real termux composition: the prefix property plan (the default
4727
+ // prefix the termux device hosts carry), the path and home the
4728
+ // emulated device mounts, the pkg install plan and the exec argv
4729
+ // through the prefix shell — all derived from the request.
4730
+ const inputs = (request.inputs ?? {}) as { prefix?: string; packages?: string[] };
4731
+ const prefix =
4732
+ typeof inputs.prefix === "string" && inputs.prefix.length > 0 ? inputs.prefix : "/data/data/com.termux/files/usr";
4733
+ const packages = Array.isArray(inputs.packages) ? inputs.packages.map((name) => String(name)) : [];
4734
+ const plan = {
4735
+ platform: "android",
4736
+ device: "emulated",
4737
+ execscope: "edge-host",
4738
+ prefix,
4739
+ home: "/data/data/com.termux/files/home",
4740
+ path: `${prefix}/bin:/usr/bin:/bin`,
4741
+ shell: `${prefix}/bin/sh`,
4742
+ pkg: packages.length > 0 ? ["pkg", "install", "-y", ...packages] : ["pkg", "install", "-y", "bootstrap"],
4743
+ exec: [`${prefix}/bin/sh`, workspacepath("mobiletermux", "payload")],
4744
+ cgroup: cgroupslice(INPROCENVELOPE, request.profile ?? DEFAULTPROFILE, "mobiletermux"),
4745
+ };
4746
+ return {
4747
+ stdout: `termux: the android sandbox plan answers (prefix ${prefix}, the ${packages.length > 0 ? `${packages.length}-package` : "bootstrap"} install plan, the exec rides ${plan.exec.join(" ")}) — the emulated device mounts on the edge host, never the visitor machine`,
4748
+ artifact: plan,
4749
+ };
4750
+ },
4538
4751
  }),
4539
4752
  },
4540
4753
  {