@awebai/oats 0.53.0 → 0.55.0

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.
Files changed (42) hide show
  1. package/bin/oats.mjs +17 -7
  2. package/docs/design/2026-09-23-workspace-module-contracts.md +3 -0
  3. package/docs/desktop-cli-api.md +44 -12
  4. package/docs/implementation.md +12 -4
  5. package/docs/integrations.md +2 -2
  6. package/docs/knowledge.md +14 -2
  7. package/docs/official-catalog.md +5 -5
  8. package/docs/packages.md +14 -14
  9. package/docs/release-notes/v0.53.0.md +14 -0
  10. package/docs/release-notes/v0.54.0.md +142 -0
  11. package/docs/release-notes/v0.55.0.md +158 -0
  12. package/docs/servers.md +13 -3
  13. package/docs/souls-and-instances.md +2 -1
  14. package/docs/upgrading.md +14 -2
  15. package/docs/workspaces.md +122 -2
  16. package/lib/packages.mjs +5 -1
  17. package/lib/remote.mjs +255 -76
  18. package/lib/servers.mjs +82 -34
  19. package/lib/workspace.mjs +27 -9
  20. package/package-catalog.json +4 -4
  21. package/package.json +1 -1
  22. package/packages/client/cli-locator.mjs +2 -2
  23. package/packages/client/workspace-views.mjs +4 -3
  24. package/packages/record/README.md +54 -13
  25. package/packages/record/bin/capture.mjs +107 -53
  26. package/packages/record/docs/capture-service.md +193 -0
  27. package/packages/record/docs/capture-status.schema.json +100 -0
  28. package/packages/record/lib/capture-aw.mjs +96 -94
  29. package/packages/record/lib/capture-cc.mjs +109 -187
  30. package/packages/record/lib/capture-db-reader.mjs +39 -0
  31. package/packages/record/lib/capture-issues.mjs +64 -0
  32. package/packages/record/lib/capture-scratch.mjs +111 -0
  33. package/packages/record/lib/capture-state.mjs +105 -0
  34. package/packages/record/lib/derived-state.mjs +60 -0
  35. package/packages/record/lib/formats.mjs +31 -31
  36. package/packages/record/lib/index-db.mjs +74 -34
  37. package/packages/record/lib/receipt-summary.mjs +62 -0
  38. package/packages/record/lib/session-snapshot.mjs +56 -1
  39. package/packages/record/lib/sqlite-rows.mjs +14 -0
  40. package/packages/record/lib/store.mjs +122 -43
  41. package/packages/record/lib/transcript-prefix.mjs +40 -0
  42. package/skills/oats-getting-started/SKILL.md +8 -2
package/lib/servers.mjs CHANGED
@@ -16,7 +16,7 @@
16
16
  * nothing here runs Git against a remote path.
17
17
  */
18
18
 
19
- import { execFileSync, spawnSync } from "node:child_process";
19
+ import { execFile, execFileSync, spawnSync } from "node:child_process";
20
20
  import { createHash } from "node:crypto";
21
21
  import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
22
22
  import { homedir } from "node:os";
@@ -312,28 +312,81 @@ export function parseRemoteEnvelope(stdout) {
312
312
  export function runRemote(target, oatsArgs, io = {}) {
313
313
  const exec = io.execFileSync || execFileSync;
314
314
  const [bin, ...argv] = sshArgv(target, oatsArgs, { cwd: io.cwd, control: controlUsable(target, io) });
315
- let stdout = "";
316
- let stderr = "";
317
- let status = 0;
318
- let started = true;
319
- let timedOut = false;
315
+ const timeoutMs = io.timeoutMs || 300000;
316
+ let call = { stdout: "", stderr: "", status: 0, started: true };
320
317
  try {
321
318
  // `io.input` (a Buffer) streams to the remote command's stdin: the only
322
319
  // way bytes reach a host, as a quoted argument never could.
323
- stdout = exec(bin, argv, { encoding: "utf8", stdio: [io.input === undefined ? "ignore" : "pipe", "pipe", "pipe"], ...(io.input === undefined ? {} : { input: io.input }), maxBuffer: 16 * 1024 * 1024, timeout: io.timeoutMs || 300000 });
320
+ call.stdout = exec(bin, argv, { encoding: "utf8", stdio: [io.input === undefined ? "ignore" : "pipe", "pipe", "pipe"], ...(io.input === undefined ? {} : { input: io.input }), maxBuffer: 16 * 1024 * 1024, timeout: timeoutMs });
324
321
  } catch (e) {
325
- stdout = String(e.stdout || "");
322
+ if (e.code === "ETIMEDOUT") throw remoteTimeout(target, timeoutMs);
323
+ call = failedCall(e);
324
+ }
325
+ return remoteAnswer(target, call);
326
+ }
327
+
328
+ /** `runRemote` for calls that run side by side (the roster's probes): the same ssh argv and the same
329
+ * answer, over an asynchronous transport. `io.execFileAsync(bin, argv, options)` resolves the call's
330
+ * stdout, or rejects as execFileSync throws (with the call's stdout, stderr, status and signal); the
331
+ * default runs execFile. The deadline is this call's own: when it passes, the call is aborted through
332
+ * `options.signal` (execFile then kills ssh) and fails as timed out, whether or not the transport has
333
+ * settled. The remote command's stdin is empty. */
334
+ export async function runRemoteAsync(target, oatsArgs, io = {}) {
335
+ const exec = io.execFileAsync || execFileAsync;
336
+ const [bin, ...argv] = sshArgv(target, oatsArgs, { cwd: io.cwd, control: controlUsable(target, io) });
337
+ const timeoutMs = io.timeoutMs || 300000;
338
+ const abort = new AbortController();
339
+ let timer;
340
+ const deadline = new Promise((_, reject) => { timer = setTimeout(() => { abort.abort(); reject(remoteTimeout(target, timeoutMs)); }, timeoutMs); });
341
+ let call = { stdout: "", stderr: "", status: 0, started: true };
342
+ try {
343
+ call.stdout = await Promise.race([exec(bin, argv, { encoding: "utf8", maxBuffer: 16 * 1024 * 1024, signal: abort.signal }), deadline]);
344
+ } catch (e) {
345
+ // execFile settles an aborted call at once, before the deadline's own rejection lands.
346
+ if (abort.signal.aborted) throw remoteTimeout(target, timeoutMs);
347
+ call = failedCall(e);
348
+ } finally { clearTimeout(timer); }
349
+ return remoteAnswer(target, call);
350
+ }
351
+
352
+ /** child_process.execFile as a promise of stdout that rejects as execFileSync throws: the error carries
353
+ * the call's stdout and stderr, `status` (its exit code, null when it had none) and `signal` (what
354
+ * ended it; SIGTERM when execFile killed it itself, past maxBuffer or on abort). An ssh that never
355
+ * started (spawn failed) has no stderr: its error's message speaks for it. */
356
+ function execFileAsync(bin, argv, options) {
357
+ return new Promise((resolve, reject) => {
358
+ const child = execFile(bin, argv, options, (error, stdout, stderr) => {
359
+ if (!error) return resolve(stdout);
360
+ const ran = !String(error.syscall || "").startsWith("spawn");
361
+ const status = typeof error.code === "number" ? error.code : null;
362
+ reject(Object.assign(error, { stdout, stderr: ran ? stderr : undefined, status, signal: error.signal || (ran && status === null ? "SIGTERM" : null) }));
363
+ });
364
+ child.stdin?.end();
365
+ });
366
+ }
367
+
368
+ /** A call whose own deadline killed ssh: whatever it printed is cut short. Still ssh's failure to the
369
+ * envelope (E_SSH), in words a client reads as a timeout (it says "timed out", as ssh's own does);
370
+ * `timedOut` lets a caller tell it from a broken link. */
371
+ function remoteTimeout(target, timeoutMs) {
372
+ return Object.assign(serverError("E_SSH", `ssh to ${target.sshHost} timed out: no answer within ${Math.round(timeoutMs / 1000)} s`), { timedOut: true });
373
+ }
374
+
375
+ /** What a failed ssh call left: what it printed, its exit status, and whether ssh ever started. */
376
+ function failedCall(e) {
377
+ return {
378
+ stdout: String(e.stdout || ""),
326
379
  // The process's own stderr when it ran (possibly empty); the error's
327
380
  // message only when there was no process to speak (ssh not found).
328
- stderr = String(e.stderr ?? e.message ?? "");
329
- status = typeof e.status === "number" ? e.status : 255;
381
+ stderr: String(e.stderr ?? e.message ?? ""),
382
+ status: typeof e.status === "number" ? e.status : 255,
330
383
  // Neither an exit status nor a signal: ssh never started (not installed, not executable).
331
- started = typeof e.status === "number" || !!e.signal;
332
- timedOut = e.code === "ETIMEDOUT";
333
- }
334
- // The call's own deadline killed ssh: whatever it printed is cut short. Still ssh's failure to the
335
- // envelope (E_SSH); `timedOut` lets a caller with a budget tell it from a broken link.
336
- if (timedOut) throw Object.assign(serverError("E_SSH", `ssh to ${target.sshHost} did not finish within ${Math.round((io.timeoutMs || 300000) / 1000)} s`), { timedOut: true });
384
+ started: typeof e.status === "number" || !!e.signal,
385
+ };
386
+ }
387
+
388
+ /** The envelope of one finished ssh call, or the error it amounts to. */
389
+ function remoteAnswer(target, { stdout, stderr, status, started }) {
337
390
  if (String(stdout).trim()) {
338
391
  const envelope = parseRemoteEnvelope(stdout);
339
392
  // A bare `retire --json` answer with cleanup still owed exits 1 on the
@@ -766,10 +819,10 @@ function routeHostSurface(serverId, cmd, oatsArgs, io) {
766
819
 
767
820
  // ------------------------------------------------------------------- roster
768
821
 
769
- // The roster answers within a budget the Desktop can wait for (its adapter
770
- // allows 60 s): each target gets the smaller of its own allowance and what is
771
- // left, and targets the budget cannot reach are reported as such, never
772
- // dropped and never allowed to sink the healthy groups.
822
+ // The roster probes every target at once, each within its own deadline: the
823
+ // smaller of its per-target allowance and the answer's deadline, which the
824
+ // Desktop can wait for (its adapter allows 60 s). A target that fails or does
825
+ // not answer in time reports its own error; no other group waits for it.
773
826
  export const ROSTER_BUDGET_MS = 45000;
774
827
  export const ROSTER_PER_TARGET_TIMEOUT_MS = 20000;
775
828
 
@@ -780,7 +833,7 @@ function listSnapshotServers() {
780
833
  }
781
834
 
782
835
  /** The remote roster, grouped by server id and saved route target: one
783
- * bounded status pull per group, registrations unioned with saved routes so
836
+ * bounded status pull per group, all of them at once, registrations unioned with saved routes so
784
837
  * a removed or changed registration keeps its group (registrationPresent
785
838
  * false) and its instances from the snapshots (running null when the probe
786
839
  * fails). Remote state is pulled, never cached; the saved route stays the
@@ -820,13 +873,13 @@ export function hostFeatures(result) {
820
873
  return [...list];
821
874
  }
822
875
 
823
- export function rosterGroups({ server, io = {} } = {}) {
876
+ export async function rosterGroups({ server, io = {} } = {}) {
824
877
  const started = Date.now();
825
878
  if (server && !ID_RE.test(server)) throw serverError("E_BAD_ARGS", `server id ${JSON.stringify(server)} is not a valid id`);
826
879
  if (server && !readServers()[server] && !existsSync(join(REMOTE_SNAPSHOT_DIR(), server))) throw serverError("E_SERVER_UNKNOWN", `no server registered as ${JSON.stringify(server)} and no saved routes for it (oats server list)`);
827
880
  const perTargetTimeoutMs = io.perTargetTimeoutMs || ROSTER_PER_TARGET_TIMEOUT_MS;
828
881
  const budgetMs = io.budgetMs || ROSTER_BUDGET_MS;
829
- let skipped = 0;
882
+ const timeoutMs = Math.min(perTargetTimeoutMs, budgetMs);
830
883
  const servers = readServers();
831
884
  const groups = new Map();
832
885
  const add = (serverId, target, registrationPresent, label) => {
@@ -841,16 +894,11 @@ export function rosterGroups({ server, io = {} } = {}) {
841
894
  if (server && serverId !== server) continue;
842
895
  for (const snap of listSnapshots(serverId)) { if (!snap.target) continue; add(serverId, snap.target, false, servers[serverId]?.label)._snapshots.push(snap); }
843
896
  }
844
- for (const g of groups.values()) {
897
+ // Groups keep their registration order in the answer, whatever order their probes finish in.
898
+ await Promise.all([...groups.values()].map(async (g) => {
845
899
  let status;
846
- const remaining = budgetMs - (Date.now() - started);
847
- if (remaining < 1000) {
848
- skipped++;
849
- g.probe = { ok: false, error: { code: "E_ROSTER_BUDGET", message: `not probed: the ${budgetMs} ms roster budget was used up by earlier targets` } };
850
- } else {
851
- try { status = runRemote(g.target, ["status", "--json", "--dir", g.target.workspace], { ...io, serverId: g.server, timeoutMs: Math.min(perTargetTimeoutMs, remaining) }).envelope; }
852
- catch (e) { g.probe = { ok: false, error: { code: e.code || "E_SSH", message: e.message } }; }
853
- }
900
+ try { status = (await runRemoteAsync(g.target, ["status", "--json", "--dir", g.target.workspace], { ...io, serverId: g.server, timeoutMs })).envelope; }
901
+ catch (e) { g.probe = { ok: false, error: { code: e.code || "E_SSH", message: e.message } }; }
854
902
  if (status && !status.ok) g.probe = { ok: false, error: status.error || { code: "E_REMOTE", message: "status failed" } };
855
903
  // A saved route matches a remote row by name AND home: a same-named
856
904
  // twin under another soul on the host is observed only, never given the
@@ -898,8 +946,8 @@ export function rosterGroups({ server, io = {} } = {}) {
898
946
  g.instances.push({ server: g.server, instance: snap.instance, agent: snap.agent, home: snap.home, agentsRoot: snap.agentsRoot, harness: snap.harness || snap.runtime || null, backend: null, running: null, ...rowFacts(), retirePending: false, rollbackIncomplete: false, savedRoute: true, addressable: g.probe?.ok !== true, missingRemotely: g.probe?.ok === true });
899
947
  }
900
948
  delete g._snapshots;
901
- }
902
- return { groups: [...groups.values()], bounds: { budgetMs, perTargetTimeoutMs, elapsedMs: Date.now() - started, skipped } };
949
+ }));
950
+ return { groups: [...groups.values()], bounds: { budgetMs, perTargetTimeoutMs, elapsedMs: Date.now() - started } };
903
951
  }
904
952
 
905
953
  /** argv for an INTERACTIVE remote command (a viewer attach): ssh with a PTY,
package/lib/workspace.mjs CHANGED
@@ -197,6 +197,15 @@ function* refFields(value) {
197
197
  for (const slot of ["knowledge", "messaging", "tasks", "capabilities"]) yield* froms(d[slot], `/defaults/${slot}`);
198
198
  }
199
199
  }
200
+ /** Only schema diagnostics for repository-reference fields pass the remote renderer. Provider
201
+ * payloads and unrelated invalid values keep their original diagnostics; admission uses raw values. */
202
+ function referenceProblems(problems, refs) {
203
+ const sources = new Map(refs);
204
+ return problems.map((problem) => sources.has(problem.path)
205
+ ? { ...problem, message: defaultRemote.redactUrl(problem.message, sources.get(problem.path), { known: false }) }
206
+ : problem);
207
+ }
208
+
200
209
  function refKey(remote, ref) {
201
210
  return remote.parseRepoRef(ref).key;
202
211
  }
@@ -214,7 +223,7 @@ function keyOrProblem(remote, ref, path, problems) {
214
223
  export function validateWorkspace(value, { remote = defaultRemote } = {}) {
215
224
  const problems = validateAgainst(schemaFor("workspace"), value);
216
225
  if (!isObject(value)) return problems;
217
- if (value.schemaVersion !== 2) return problems;
226
+ if (value.schemaVersion !== 2) return referenceProblems(problems, refFields(value));
218
227
  // Absolute-path refusal applies to REF/PATH fields only (L2): never to descriptions or the provider payload.
219
228
  for (const [path, s] of refFields(value)) {
220
229
  if (ABSOLUTE_PATH.test(s)) problems.push({ path, message: `absolute paths are refused in the workspace file (${show(s)}); host paths belong in oats-local.yaml (a local remote is a repo ref: file:///… or git:/abs/bare.git@<ref>)` });
@@ -251,7 +260,7 @@ export function validateWorkspace(value, { remote = defaultRemote } = {}) {
251
260
  for (const slot of ["knowledge", "messaging", "tasks", "capabilities"]) fromProblems(remote, d[slot], `/defaults/${slot}`, problems, { here: false });
252
261
  }
253
262
  sharedLabelProblems(value, problems);
254
- return withRemovedKeys(problems, value, REMOVED_KEYS.workspace);
263
+ return referenceProblems(withRemovedKeys(problems, value, REMOVED_KEYS.workspace), refFields(value));
255
264
  }
256
265
  /** Team model 3: every label `defaultTeam` and `souls:` name is a shared team of this same file, so an
257
266
  * unknown label is refused when the file is read, never at a spawn on someone else's machine. */
@@ -272,7 +281,9 @@ export function teamLabelProblem(label) {
272
281
  const problems = validateAgainst(schemaFor("workspace").$defs.label, label);
273
282
  return problems.length ? problems.map((x) => x.message).join("; ") : null;
274
283
  }
275
- export function validateMembership(value) { return withRemovedKeys(validateAgainst(schemaFor("membership"), value), value, REMOVED_KEYS.membership); }
284
+ export function validateMembership(value) {
285
+ return referenceProblems(withRemovedKeys(validateAgainst(schemaFor("membership"), value), value, REMOVED_KEYS.membership), [["/workspace", value?.workspace]]);
286
+ }
276
287
 
277
288
  /** Keys 0.30 (team model v2) and 0.38.0 (team model 3) removed: each is a schema problem naming its replacement, in place of
278
289
  * the schema's generic "unexpected property". `at(value)` → the JSON pointers where it appears. */
@@ -308,7 +319,11 @@ export function validateSoul(value, { remote = defaultRemote } = {}) {
308
319
  fromProblems(remote, value.capabilities, "/capabilities", problems, { here: true });
309
320
  for (const slot of ["knowledge", "messaging", "tasks"]) if (isObject(value[slot])) reservedKeyProblems(value[slot], `/${slot}`, problems);
310
321
  }
311
- return problems;
322
+ const refs = [];
323
+ if (isObject(value?.capabilities)) for (const [name, choice] of Object.entries(value.capabilities)) {
324
+ if (isObject(choice) && typeof choice.from === "string") refs.push([`/capabilities/${pointerKey(name)}/from`, choice.from]);
325
+ }
326
+ return referenceProblems(problems, refs);
312
327
  }
313
328
 
314
329
  /** `byTeam` was removed in 0.30 (team model v2): a per-team payload no longer exists — a team's
@@ -349,7 +364,7 @@ export function validateLocal(value) {
349
364
  problems.push({ path: `/launch-configs/${pointerKey(name)}/runtime`, reason: "harness-conflict", message: `harness ${show(entry.harness)} and runtime ${show(entry.runtime)} disagree: \`runtime\` is the pre-0.27 name of \`harness\` — keep one` });
350
365
  }
351
366
  }
352
- return problems;
367
+ return referenceProblems(problems, [["/workspace", value?.workspace], ["/standalone", value?.standalone]]);
353
368
  }
354
369
 
355
370
  /* ───────────────────────────── file decoding ──────────────────────────── */
@@ -494,11 +509,14 @@ export async function confirmMembership(workspaceObs, memberRef, { remote: injec
494
509
  let key;
495
510
  try { key = refKey(remote, memberRef); }
496
511
  catch (e) {
497
- if (e?.code === "E_REPO_REF") return unconfirmed(typeof memberRef === "string" ? memberRef : String(memberRef), "not-listed", `${show(memberRef)} is not a repo ref: ${e.message}`);
512
+ if (e?.code === "E_REPO_REF") return unconfirmed(defaultRemote.redactUrl(typeof memberRef === "string" ? memberRef : String(memberRef), null, { reference: true }), "not-listed", `${show(defaultRemote.redactUrl(memberRef, null, { reference: true }))} is not a repo ref: ${e.message}`);
498
513
  throw e;
499
514
  }
500
515
  if (!checked.keys.has(key)) return unconfirmed(key, "not-listed", `${key} is not in members of workspace ${workspaceObs.key}`);
501
- const cannotRead = (e) => unconfirmed(key, "cannot-read", `cannot read ${e.details?.url ?? e.provenance?.url ?? memberRef}${e.details?.reason ? ` (${e.details.reason})` : ""}`, { url: e.details?.url ?? e.provenance?.url ?? null });
516
+ const cannotRead = (e) => {
517
+ const url = defaultRemote.redactUrl(e.details?.url ?? e.provenance?.url ?? null, null, { reference: true });
518
+ return unconfirmed(key, "cannot-read", `cannot read ${url ?? defaultRemote.redactUrl(memberRef, null, { reference: true })}${e.details?.reason ? ` (${e.details.reason})` : ""}`, { url });
519
+ };
502
520
  let obs;
503
521
  try { obs = await remote.observeRemote(memberRef); }
504
522
  catch (e) {
@@ -520,7 +538,7 @@ export async function confirmMembership(workspaceObs, memberRef, { remote: injec
520
538
  let backlinkKey;
521
539
  try { backlinkKey = refKey(remote, read.value.workspace); }
522
540
  catch (e) {
523
- if (e?.code === "E_REPO_REF") return unconfirmed(key, "no-backlink", `${key}@${obs.commit.slice(0, 12)} oats-membership.yaml names an unparseable workspace ${show(read.value.workspace)}`, { commit: obs.commit });
541
+ if (e?.code === "E_REPO_REF") return unconfirmed(key, "no-backlink", `${key}@${obs.commit.slice(0, 12)} oats-membership.yaml names an unparseable workspace ${show(defaultRemote.redactUrl(read.value.workspace, null, { reference: true }))}`, { commit: obs.commit });
524
542
  throw e;
525
543
  }
526
544
  if (backlinkKey !== workspaceObs.key) {
@@ -793,7 +811,7 @@ export async function discoverWorkspace(ref, { at, local, lock = null, remote: i
793
811
  const sourceRef = entry.source.slice(0, pin);
794
812
  const commit = entry.source.slice(pin + 1);
795
813
  const file = `${entry.soul.replace(/\/+$/, "")}/soul.yaml`;
796
- const pushProblem = (code, path, message) => { problems.push({ code, repoKey: null, path: `external/${index}:${path}`, message, source: entry.source }); if (!soulsUnread.external.includes(entry.source)) soulsUnread.external.push(entry.source); };
814
+ const pushProblem = (code, path, message) => { problems.push({ code, repoKey: null, path: `external/${index}:${path}`, message, source: defaultRemote.redactUrl(entry.source, null, { pinned: { ref: sourceRef, commit } }) }); if (!soulsUnread.external.includes(entry.source)) soulsUnread.external.push(entry.source); };
797
815
  let key;
798
816
  try { key = refKey(remote, sourceRef); }
799
817
  catch (e) { if (e?.code === "E_REPO_REF") { pushProblem("E_REPO_REF", "source", e.message); continue; } throw e; }
@@ -3,12 +3,12 @@
3
3
  "packages": {
4
4
  "oats.okf": {
5
5
  "url": "https://github.com/awebai/oats-okf.git",
6
- "ref": "v5.0.3",
6
+ "ref": "v5.0.5",
7
7
  "path": "oats-package"
8
8
  },
9
9
  "oats.aweb": {
10
10
  "url": "https://github.com/awebai/oats-aweb.git",
11
- "ref": "v1.27.1",
11
+ "ref": "v1.27.2",
12
12
  "path": "oats-package"
13
13
  },
14
14
  "oats.jira": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "oats.engineering": {
30
30
  "url": "https://github.com/awebai/oats-engineering.git",
31
- "ref": "v1.9.1",
31
+ "ref": "v1.10.0",
32
32
  "path": "oats-package"
33
33
  },
34
34
  "oats.cloning": {
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "oats.framework": {
45
45
  "url": "https://github.com/awebai/oats.git",
46
- "ref": "oats-framework/v1.9.4",
46
+ "ref": "oats-framework/v1.10.0",
47
47
  "path": "oats-package"
48
48
  }
49
49
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awebai/oats",
3
- "version": "0.53.0",
3
+ "version": "0.55.0",
4
4
  "description": "OATS (Open Agent Team Specification) — durable souls, disposable instances, targetable capability packages, and the runtime-neutral oats CLI/kernel.",
5
5
  "keywords": [
6
6
  "agents",
@@ -13,7 +13,7 @@
13
13
  // Every candidate is canonicalized to an absolute executable and accepted
14
14
  // ONLY if executable and `<bin> version --json` returns the v1 probe:
15
15
  // {"schemaVersion":1,"name":"@awebai/oats","version":"0.24.x","desktopApi":1}
16
- // Desktop accepts desktopApi === 1 and semver >=0.25.8 <0.54.0 (the band is
16
+ // Desktop accepts desktopApi === 1 and semver >=0.25.8 <0.56.0 (the band is
17
17
  // spelled ONCE, in ACCEPT_RANGE below — this line only paraphrases it).
18
18
  // API version — not source adjacency — is authoritative.
19
19
  //
@@ -54,7 +54,7 @@ export const DESKTOP_API = 1;
54
54
  // carry a `description` for every kind and `<kind> update <id> --description`
55
55
  // sets one (feature `automation-descriptions`, which gates the Desktop's
56
56
  // summary writes). The Desktop v1 surface is otherwise unchanged.
57
- export const ACCEPT_RANGE = { min: [0, 25, 8], maxExclusive: [0, 54, 0] };
57
+ export const ACCEPT_RANGE = { min: [0, 25, 8], maxExclusive: [0, 56, 0] };
58
58
  /** The band as humans read it — derived, never hand-spelled, so the probe
59
59
  * rejection reason, the backend's /api status and the degradation card can
60
60
  * never disagree with the numbers actually enforced above. */
@@ -60,8 +60,9 @@ const REASONS = {
60
60
  standalone: () => ({ short: 'Local teams only', detail: 'Teams are local only on this host (standalone).', fix: [] }),
61
61
  };
62
62
 
63
- /** True when a failed probe's message is ssh's own timeout: the kernel reports an ssh that timed out
64
- * as E_SSH with ssh's stderr and no code of its own, so ssh's text is the only signal (a documented limit). */
63
+ /** True when a failed probe's message is a timeout: the kernel reports an ssh that timed out as E_SSH,
64
+ * with ssh's own stderr or, when its own deadline ended the call, "timed out: no answer within N s", and
65
+ * no code of its own, so the text is the only signal (a documented limit). */
65
66
  const TIMED_OUT = /timed out|timeout/i;
66
67
 
67
68
  /** The client's own sentence for a deployment whose last read failed and whose last observation is kept. */
@@ -121,7 +122,7 @@ export function deploymentReasonParts(d, terms) {
121
122
  if (d.rosterError) return { short: 'Not reached', detail: `${machine} was not reached: ${d.rosterError}`, fix: [] };
122
123
  if (d.probe && d.probe.ok !== true) {
123
124
  const code = d.probe.error?.code, message = typeof d.probe.error?.message === 'string' ? d.probe.error.message : '';
124
- if (code === 'E_ROSTER_BUDGET' || code === 'E_CLI_TIMEOUT' || TIMED_OUT.test(message)) return { short: 'Timed out', detail: `${machine} timed out; it is tried again on the next read.`, fix: [] };
125
+ if (code === 'E_CLI_TIMEOUT' || TIMED_OUT.test(message)) return { short: 'Timed out', detail: `${machine} timed out; it is tried again on the next read.`, fix: [] };
125
126
  if (code === 'E_SSH') {
126
127
  const host = d.sshHost || machine;
127
128
  return { short: 'ssh needs a prompt', detail: `${machine} needs ssh to connect without a prompt; run \`ssh ${host}\` once in a terminal.`,
@@ -101,6 +101,32 @@ their shape, quoted or not, and replaces their command; a command it cannot
101
101
  read as its own is left alone and a new hook is added beside it.
102
102
  Stream owner: `--owner`, else `$TURN_RECORD_OWNER`, else the short hostname.
103
103
 
104
+ Transcript capture reads 64 KiB chunks and frames complete native records,
105
+ including UTF-8 characters split across chunks. It appends batches of at most
106
+ 8 MiB of source bytes plus the last record and checkpoints after each batch.
107
+ One very large native record can still require memory proportional to that
108
+ record; capture does not impose a new record-size policy.
109
+ Final, attributed and protected Pi capture stage the descriptor's snapshot on
110
+ private scratch under `<root>/.capture-tmp` before the first append, preserving
111
+ attribution and custody checks without retaining the source in process memory.
112
+ Exact `--file` capture and receipt claims databases use the same record-root
113
+ volume, which may itself be memory-backed. Ordinary success/failure cleans each
114
+ caller's allocation; lock-held cleanup reclaims only proven dead local owners.
115
+ See [scratch ownership and upgrade costs](docs/capture-service.md#resource-model)
116
+ for preserved uncertain leftovers and the unresolved synchronous first-pass cost.
117
+ Explicit final proofs may read the full snapshot; their output inventories
118
+ remain proportional to the issues and sessions the receipt must return.
119
+
120
+ The search index checkpoints byte positions and turn counts in the same
121
+ transaction as its indexed rows, at most 2,000 journal lines or 8 MiB plus
122
+ the last record per transaction. Known journal history is qualified by a
123
+ durable file-version checkpoint (device, inode, size and nanosecond modification
124
+ and change timestamps). Owner appends preserve its epoch after fsync; an
125
+ unknown write, replacement or shrink requires bounded journal validation and
126
+ invalidates dependent index cursors. Interrupted validation and indexing resume
127
+ from their last committed batch. Initial/recovery validation reads historical
128
+ content; unchanged normal passes do not.
129
+
104
130
  ## Ignoring sessions and paths (privacy)
105
131
 
106
132
  `<root>/ignore` is a plain text file of glob patterns, one per line (blank
@@ -249,19 +275,30 @@ into an orphaned inode until it restarts.
249
275
 
250
276
  ## Memory
251
277
 
252
- A capture pass runs in bounded memory, whatever the size of the record.
253
- Journals are streamed, never parsed whole: the first append to a stream
254
- validates its journal one line at a time. Comm logs are read in chunks, and
255
- the aw dedupe looks up only the changed log's own turn ids, in one streamed
256
- read of the journal. A session's new lines are walked, never collected, and
257
- appended in 8 MB batches. A lost offset is rebuilt from the journal's tail.
258
-
259
- So the heap a pass needs grows with one changed comm log's entry count, not
260
- with the record. A host job can keep a small `--max-old-space-size`;
261
- `packages/record/test/capture-bounded-memory.test.mjs` captures a record four
262
- times its 64 MB heap. One cost is not on the heap: the new bytes of one
263
- session are read as one buffer, so resident memory grows with a single
264
- session's backlog.
278
+ Content processing uses fixed read chunks, bounded batches and SQLite caches,
279
+ plus memory proportional to the largest processable native record. Journals,
280
+ transcript tails and comm logs are streamed; persistent ID lookup avoids keeping
281
+ history IDs or a changed log's candidate IDs in memory. Per-input offsets live
282
+ in derived database rows rather than a rewritten global JSON map. Initial
283
+ capture, recovery validation and explicit final proofs may read all applicable
284
+ content; ordinary unchanged and suffix-growth passes use only new content and
285
+ bounded checkpoint probes. The streaming and work-count tests pin these distinct
286
+ paths; the small-heap regression remains supplementary evidence.
287
+
288
+ Filesystem discovery is a separate cost: root/path metadata inventories may grow
289
+ with file and profile counts. Native roots and each directory retain their
290
+ existing `localeCompare` sorting and depth-first traversal, including stable ties.
291
+ Aweb account logs retain code-unit sorted basename order. Public
292
+ list APIs return full arrays. Metadata enumeration, sorting and per-input probes
293
+ still run on unchanged passes; this is not a constant-memory or new-byte-only
294
+ claim for the whole pass. Explicit receipts likewise retain the issue/session
295
+ inventories their public contract returns. Background capture suppresses those
296
+ output inventories without suppressing error counts.
297
+
298
+ Verified snapshots and prefix comparisons use private record-root scratch, which
299
+ can expand with source size; journal and derived-index disk space also grow with
300
+ captured content. Staging is cleaned on success and failure. No new heap, record
301
+ size, elapsed-time or service policy limit is imposed by these algorithms.
265
302
 
266
303
  ## Known costs, accepted for v1
267
304
 
@@ -341,3 +378,7 @@ Anything that binds nothing is an error,
341
378
  | `E_NO_TURNS` | 1 | no records: an empty file, or only blank lines |
342
379
  | `E_FORMAT` | 1 | records, but no session header of the stated format; the message names the format whose header it does carry |
343
380
  | `E_CAPTURE_FAILED` | 1 | the pass failed (`appended: null`: part of the file may be in the record) |
381
+
382
+ See [capture algorithms and recovery](docs/capture-service.md) for the shared
383
+ append-only input assumption, reset/retry commands, bounded status inventory,
384
+ resource accounting and v0.53.0 downgrade/re-upgrade contract.