@nac3/forge-cli 1.25.0 → 1.27.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 (121) hide show
  1. package/dist/chat/cache_ttl.d.ts +143 -0
  2. package/dist/chat/cache_ttl.d.ts.map +1 -0
  3. package/dist/chat/cache_ttl.js +165 -0
  4. package/dist/chat/cache_ttl.js.map +1 -0
  5. package/dist/chat/claude.d.ts +1 -0
  6. package/dist/chat/claude.d.ts.map +1 -1
  7. package/dist/chat/claude.js +47 -5
  8. package/dist/chat/claude.js.map +1 -1
  9. package/dist/chat/claude_cli.d.ts +24 -0
  10. package/dist/chat/claude_cli.d.ts.map +1 -1
  11. package/dist/chat/claude_cli.js +76 -10
  12. package/dist/chat/claude_cli.js.map +1 -1
  13. package/dist/chat/panel.d.ts.map +1 -1
  14. package/dist/chat/panel.js +128 -17
  15. package/dist/chat/panel.js.map +1 -1
  16. package/dist/chat/server.d.ts.map +1 -1
  17. package/dist/chat/server.js +13 -1
  18. package/dist/chat/server.js.map +1 -1
  19. package/dist/chat/tools/evidence.d.ts +15 -0
  20. package/dist/chat/tools/evidence.d.ts.map +1 -1
  21. package/dist/chat/tools/evidence.js +16 -0
  22. package/dist/chat/tools/evidence.js.map +1 -1
  23. package/dist/chat/tools/reader.d.ts.map +1 -1
  24. package/dist/chat/tools/reader.js +24 -4
  25. package/dist/chat/tools/reader.js.map +1 -1
  26. package/dist/chat/tools/session_verbs.d.ts +3 -1
  27. package/dist/chat/tools/session_verbs.d.ts.map +1 -1
  28. package/dist/chat/tools/session_verbs.js +65 -2
  29. package/dist/chat/tools/session_verbs.js.map +1 -1
  30. package/dist/chat/tools/shell.d.ts +11 -0
  31. package/dist/chat/tools/shell.d.ts.map +1 -1
  32. package/dist/chat/tools/shell.js +46 -1
  33. package/dist/chat/tools/shell.js.map +1 -1
  34. package/dist/commands/chat.d.ts +6 -0
  35. package/dist/commands/chat.d.ts.map +1 -1
  36. package/dist/commands/chat.js +25 -0
  37. package/dist/commands/chat.js.map +1 -1
  38. package/dist/commands/limits.d.ts.map +1 -1
  39. package/dist/commands/limits.js +77 -6
  40. package/dist/commands/limits.js.map +1 -1
  41. package/dist/commands/operate.d.ts.map +1 -1
  42. package/dist/commands/operate.js +42 -0
  43. package/dist/commands/operate.js.map +1 -1
  44. package/dist/commands/urazuke.d.ts.map +1 -1
  45. package/dist/commands/urazuke.js +189 -9
  46. package/dist/commands/urazuke.js.map +1 -1
  47. package/dist/core/brain_pin.d.ts +74 -0
  48. package/dist/core/brain_pin.d.ts.map +1 -0
  49. package/dist/core/brain_pin.js +113 -0
  50. package/dist/core/brain_pin.js.map +1 -0
  51. package/dist/core/cost_router.d.ts.map +1 -1
  52. package/dist/core/cost_router.js +56 -0
  53. package/dist/core/cost_router.js.map +1 -1
  54. package/dist/core/limits_config.d.ts +19 -0
  55. package/dist/core/limits_config.d.ts.map +1 -1
  56. package/dist/core/limits_config.js +38 -0
  57. package/dist/core/limits_config.js.map +1 -1
  58. package/dist/core/machine_files.d.ts +27 -0
  59. package/dist/core/machine_files.d.ts.map +1 -0
  60. package/dist/core/machine_files.js +97 -0
  61. package/dist/core/machine_files.js.map +1 -0
  62. package/dist/docs/doctrine/session-orchestration.md +109 -91
  63. package/dist/docs/doctrine/urazuke.md +221 -221
  64. package/dist/llm/sse_stream.d.ts +2 -0
  65. package/dist/llm/sse_stream.d.ts.map +1 -1
  66. package/dist/llm/sse_stream.js +10 -1
  67. package/dist/llm/sse_stream.js.map +1 -1
  68. package/dist/nac3/dispatch_log.d.ts +16 -1
  69. package/dist/nac3/dispatch_log.d.ts.map +1 -1
  70. package/dist/nac3/dispatch_log.js +29 -10
  71. package/dist/nac3/dispatch_log.js.map +1 -1
  72. package/dist/nac3/internal_manifest.d.ts.map +1 -1
  73. package/dist/nac3/internal_manifest.js +2 -0
  74. package/dist/nac3/internal_manifest.js.map +1 -1
  75. package/dist/telemetry/battery_events.d.ts +91 -0
  76. package/dist/telemetry/battery_events.d.ts.map +1 -0
  77. package/dist/telemetry/battery_events.js +84 -0
  78. package/dist/telemetry/battery_events.js.map +1 -0
  79. package/dist/telemetry/usage.d.ts +107 -0
  80. package/dist/telemetry/usage.d.ts.map +1 -1
  81. package/dist/telemetry/usage.js +172 -13
  82. package/dist/telemetry/usage.js.map +1 -1
  83. package/dist/urazuke/evidence.d.ts +5 -0
  84. package/dist/urazuke/evidence.d.ts.map +1 -1
  85. package/dist/urazuke/evidence.js +2 -0
  86. package/dist/urazuke/evidence.js.map +1 -1
  87. package/dist/urazuke/freeze.d.ts.map +1 -1
  88. package/dist/urazuke/freeze.js +82 -16
  89. package/dist/urazuke/freeze.js.map +1 -1
  90. package/dist/urazuke/gates_data.d.ts +4 -1
  91. package/dist/urazuke/gates_data.d.ts.map +1 -1
  92. package/dist/urazuke/gates_data.js +7 -1
  93. package/dist/urazuke/gates_data.js.map +1 -1
  94. package/dist/urazuke/gates_ledger.d.ts +25 -1
  95. package/dist/urazuke/gates_ledger.d.ts.map +1 -1
  96. package/dist/urazuke/gates_ledger.js +30 -6
  97. package/dist/urazuke/gates_ledger.js.map +1 -1
  98. package/dist/urazuke/method_config.d.ts +116 -0
  99. package/dist/urazuke/method_config.d.ts.map +1 -0
  100. package/dist/urazuke/method_config.js +328 -0
  101. package/dist/urazuke/method_config.js.map +1 -0
  102. package/dist/urazuke/prompts_client.d.ts +42 -12
  103. package/dist/urazuke/prompts_client.d.ts.map +1 -1
  104. package/dist/urazuke/prompts_client.js +120 -16
  105. package/dist/urazuke/prompts_client.js.map +1 -1
  106. package/dist/urazuke/prompts_freeze.d.ts +186 -0
  107. package/dist/urazuke/prompts_freeze.d.ts.map +1 -0
  108. package/dist/urazuke/prompts_freeze.js +498 -0
  109. package/dist/urazuke/prompts_freeze.js.map +1 -0
  110. package/dist/urazuke/receipts.d.ts +28 -1
  111. package/dist/urazuke/receipts.d.ts.map +1 -1
  112. package/dist/urazuke/receipts.js +59 -6
  113. package/dist/urazuke/receipts.js.map +1 -1
  114. package/dist/urazuke/start.d.ts.map +1 -1
  115. package/dist/urazuke/start.js +42 -2
  116. package/dist/urazuke/start.js.map +1 -1
  117. package/dist/version.d.ts +1 -1
  118. package/dist/version.js +1 -1
  119. package/docs/doctrine/session-orchestration.md +109 -91
  120. package/docs/doctrine/urazuke.md +221 -221
  121. package/package.json +124 -124
@@ -0,0 +1,97 @@
1
+ /**
2
+ * LOS ARCHIVOS DE LA MAQUINA, Y LA UNICA PUERTA POR DONDE LA BATERIA NO
3
+ * ENTRA.
4
+ *
5
+ * Esto no es una abstraccion por prolijidad: es una familia de defectos
6
+ * MEDIDA tres veces en el mismo archivo de configuracion del dueno.
7
+ *
8
+ * 1. 2026-10-19 -- la bateria del publish dejo entradas "test approval
9
+ * gate" y llaves de prueba en el nac3_log.jsonl del dueno. Se
10
+ * "arreglo" resolviendo el path en el momento de la llamada en vez de
11
+ * al importar el modulo (src/nac3/dispatch_log.ts).
12
+ * 2. 2026-11-03 -- la bateria llevaba meses escribiendo en el
13
+ * usage.jsonl del dueno: 8.764 de 8.821 eventos de la ventana de 30
14
+ * dias, el 99,4%, todos valuados en cero dolares. Y el archivo es la
15
+ * unica fuente del reporte de costos. Se le puso una guarda... que no
16
+ * alcanzo: la bateria completa siguio dejando cuatro. La causa real es
17
+ * una CARRERA, no un permiso (G-12 en docs/GOTCHAS.md).
18
+ * 3. 2026-11-03, mas tarde, midiendo la pregunta "escribe en algun otro
19
+ * archivo mio?" con el arbol de configuracion fotografiado antes y
20
+ * despues de la bateria completa: SI, en dos mas --
21
+ * `cache/reader_sessions.json` y, todavia, `nac3_log.jsonl`. El de
22
+ * reader fue el peor: el archivo QUEDO MAS CHICO que antes de correr,
23
+ * porque el almacen tiene tope y las sesiones de prueba desalojaron
24
+ * las del dueno. No fue contaminacion: fue perdida de datos.
25
+ *
26
+ * La forma general del defecto, que es la que esta funcion cierra:
27
+ *
28
+ * el permiso se evalua en un instante y el PATH se resuelve en otro.
29
+ *
30
+ * Mientras sean dos lecturas del entorno en dos momentos distintos, el
31
+ * `void escribir(...)` que nadie espera va a despertar despues del
32
+ * `afterEach` que borro YF_CONFIG_DIR y va a aterrizar en la carpeta de la
33
+ * maquina. Por eso la puerta devuelve el DESTINO COMPLETO resuelto, de una
34
+ * sola vez: quien la usa no vuelve a mirar el entorno en esa llamada.
35
+ *
36
+ * Y fail-closed adentro de la bateria: sin YF_CONFIG_DIR, o con uno que
37
+ * apunta a la carpeta de la maquina, se NIEGA. El peor caso pasa a ser que
38
+ * un test pierda un recibo, no que la unica medicion honesta de costo del
39
+ * experimento quede contaminada -- o que al dueno le desaparezcan sus
40
+ * sesiones del lector.
41
+ *
42
+ * Lo que esta funcion NO hace, a proposito: no mueve YF_CONFIG_DIR para
43
+ * toda la bateria. Ese es un override ANCHO y este repositorio ya tiene la
44
+ * cicatriz de uno (src/chat/instance_lock.ts: "un override angosto es el
45
+ * arreglo; uno ancho era el bug"). Hay tests que necesitan la config real
46
+ * para leer. Lo que ningun test necesita es ESCRIBIR en la del dueno.
47
+ *
48
+ * ASCII-only.
49
+ */
50
+ import os from 'node:os';
51
+ import path from 'node:path';
52
+ /** La carpeta de configuracion de la MAQUINA: la del dueno, la que ningun
53
+ * test puede tocar. Se calcula aparte del configDir() de cada modulo a
54
+ * proposito -- hace falta poder comparar el destino CONTRA ella. */
55
+ export function machineConfigDir(env = process.env) {
56
+ const home = env['USERPROFILE'] || env['HOME'] || os.homedir();
57
+ return path.join(home, '.yujin-forge');
58
+ }
59
+ export function sameDir(a, b) {
60
+ const n = (x) => path.resolve(x).replace(/[\\/]+$/, '').toLowerCase();
61
+ return n(a) === n(b);
62
+ }
63
+ /** Estamos adentro de la bateria? Vitest lo declara en el entorno. */
64
+ export function inBattery(env = process.env) {
65
+ return env['VITEST'] === 'true' || env['VITEST'] === '1';
66
+ }
67
+ /**
68
+ * EL DESTINO DE UN ARCHIVO DE ESTADO, DECIDIDO DE UNA SOLA VEZ Y SIN
69
+ * AWAITS EN EL MEDIO.
70
+ *
71
+ * `rel` es la ruta relativa dentro de la carpeta de configuracion
72
+ * ('usage.jsonl', 'nac3_log.jsonl', 'cache/reader_sessions.json'). El
73
+ * llamador escribe en `file` y crea `dir` -- y no vuelve a leer el entorno.
74
+ */
75
+ export function machineFileDestination(rel, env = process.env) {
76
+ const override = env['YF_CONFIG_DIR'] || env['YUJIN_FORGE_HOME'];
77
+ const tiene = typeof override === 'string' && override.trim() !== '';
78
+ const base = tiene ? override.trim() : machineConfigDir(env);
79
+ if (inBattery(env)) {
80
+ if (!tiene) {
81
+ return { allowed: false, why: 'bateria sin YF_CONFIG_DIR: ' + rel + ' iria al archivo del dueno' };
82
+ }
83
+ if (sameDir(base, machineConfigDir(env))) {
84
+ return {
85
+ allowed: false,
86
+ why: 'bateria con YF_CONFIG_DIR apuntando a la carpeta de la maquina (' + base + ')',
87
+ };
88
+ }
89
+ }
90
+ const file = path.join(base, ...rel.split('/'));
91
+ return { allowed: true, dir: path.dirname(file), file };
92
+ }
93
+ /** Atajo para quien solo necesita el si/no. */
94
+ export function machineWritesAllowed(rel, env = process.env) {
95
+ return machineFileDestination(rel, env).allowed;
96
+ }
97
+ //# sourceMappingURL=machine_files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"machine_files.js","sourceRoot":"","sources":["../../src/core/machine_files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;qEAEqE;AACrE,MAAM,UAAU,gBAAgB,CAAC,MAA0C,OAAO,CAAC,GAAG;IACpF,MAAM,IAAI,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IAC/D,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,CAAS,EAAE,CAAS;IAC1C,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9E,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,SAAS,CAAC,MAA0C,OAAO,CAAC,GAAG;IAC7E,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC;AAC3D,CAAC;AAWD;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CACpC,GAAW,EACX,MAA0C,OAAO,CAAC,GAAG;IAErD,MAAM,QAAQ,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACjE,MAAM,KAAK,GAAG,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;IACrE,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,QAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC9D,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,6BAA6B,GAAG,GAAG,GAAG,4BAA4B,EAAE,CAAC;QACrG,CAAC;QACD,IAAI,OAAO,CAAC,IAAI,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACzC,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,GAAG,EAAE,kEAAkE,GAAG,IAAI,GAAG,GAAG;aACrF,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAChD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;AAC1D,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,oBAAoB,CAClC,GAAW,EACX,MAA0C,OAAO,CAAC,GAAG;IAErD,OAAO,sBAAsB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC;AAClD,CAAC"}
@@ -1,91 +1,109 @@
1
- # Doctrine: session orchestration (yujin.session.*)
2
-
3
- When it is optimal, you may launch other `yf chat` instances as
4
- HEADLESS AGENT sub-sessions to do orthogonal, well-scoped work in
5
- parallel with this conversation, and collect their results over the
6
- coordination bridge. This is the `yujin.session.*` verb family.
7
-
8
- This doctrine is about WHEN to spawn and how to keep it safe and
9
- cheap. It is distinct from `agent-orchestrator` (product-side agents
10
- the generated software dispatches on the user's machine).
11
-
12
- ## Off by default
13
-
14
- The whole capability is gated by `multiagent.enabled` in the limits
15
- config (Ajustes > Limites), DEFAULT OFF. While off, the
16
- `yujin.session.*` verbs are hidden from the manifest, this doctrine is
17
- not injected, the system prompt tells you it is OFF, and the handlers
18
- refuse. So you only see + use these verbs when the user has explicitly
19
- turned multi-agent on. If the user asks for parallel sub-sessions while
20
- it is off, tell them to enable it in Ajustes > Limites.
21
-
22
- ## The verbs
23
-
24
- - `yujin.session.spawn { task, project_root?, budget_tokens?, label? }`
25
- -- launch a sub-session for one self-contained task. Returns a
26
- handle immediately (NON-blocking). The user approves each spawn
27
- (it spends BYOK tokens autonomously).
28
- - `yujin.session.collect { handle?, wait_ms? }` -- read the results
29
- sub-sessions have published. `wait_ms` blocks up to that long for
30
- at least one result; default 0 = return whatever has arrived.
31
- - `yujin.session.list` -- what you have spawned, with TWO facts that are
32
- not the same one (PND-256): `alive` is whether the process exists
33
- (asked of the OS), and `registered` is whether the child already
34
- published itself on the coordination bridge. A child can be alive and
35
- not yet registered (booting), and a dead child can linger in the
36
- roster. Reading one as the other costs either a needless relaunch or
37
- an endless wait.
38
- - `yujin.session.stop { handle }` -- terminate one.
39
-
40
- ## Spawn ONLY when it pays off
41
-
42
- A sub-session boots a whole headless server and spends tokens, so the
43
- overhead must be justified. Spawn when ALL of these hold:
44
-
45
- 1. **Orthogonal** -- the subtask is independent of the work you are
46
- doing right now; it does not need the live conversation context.
47
- (The child gets ONLY the `task` string you write -- be specific.)
48
- 2. **Parallelizable** -- it can run while you keep working, and you
49
- genuinely benefit from not blocking on it (e.g. a wide read /
50
- research / analysis sweep over a different subsystem).
51
- 3. **No write collision** -- it will not edit the same files you are
52
- editing. If both might write, scope them to different paths or do
53
- it yourself.
54
- 4. **Fits a budget** -- set `budget_tokens` to bound the spend.
55
-
56
- Do NOT spawn for:
57
-
58
- - Trivial tasks (a single read, a one-line answer) -- the overhead
59
- costs more than doing it inline.
60
- - Anything that needs the user's live judgement or the chat history.
61
- - Work you could do with one of your own verbs in this turn.
62
-
63
- Typical good uses: "map how subsystem X wires together and report the
64
- key files + entry points", "search the whole repo for every place
65
- pattern Y appears and summarise", "read these 8 docs and extract the
66
- constraints". Launch one per independent angle, then `collect`.
67
-
68
- ## The child's scope (enforced, not advisory)
69
-
70
- A sub-session runs with a RESTRICTED verb scope (enforced in
71
- `nac3_invoke` via `YF_AGENT_MODE`):
72
-
73
- - CAN: read / search / write files in its project root, run SAFE
74
- shell, query the graph / pendings / reader.
75
- - CANNOT: `git push` / `git commit`, destructive actions, `fs.move`,
76
- re-anchor the project, mutate the workflow / pending / keys, run
77
- lifecycle servers, or spawn its OWN sub-sessions (no grandchildren).
78
-
79
- So the child is a safe builder/analyst. Anything outward or
80
- irreversible stays with YOU, the parent, where the user can approve
81
- it. Have the child RETURN its deliverable; you surface it (pizarron,
82
- etc.) and you do the push/commit.
83
-
84
- ## Lifecycle
85
-
86
- Sub-sessions are one-shot: a child runs its task to completion (a
87
- `[SESSION_DONE]` marker), publishes its result, and exits. The full
88
- result is written to disk; the bridge signal carries a summary + the
89
- path. Always `collect` what you spawn -- do not leave results
90
- unread. If a child is no longer useful or is burning budget, `stop`
91
- it.
1
+ # Doctrine: session orchestration (yujin.session.*)
2
+
3
+ When it is optimal, you may launch other `yf chat` instances as
4
+ HEADLESS AGENT sub-sessions to do orthogonal, well-scoped work in
5
+ parallel with this conversation, and collect their results over the
6
+ coordination bridge. This is the `yujin.session.*` verb family.
7
+
8
+ This doctrine is about WHEN to spawn and how to keep it safe and
9
+ cheap. It is distinct from `agent-orchestrator` (product-side agents
10
+ the generated software dispatches on the user's machine).
11
+
12
+ ## Off by default
13
+
14
+ The whole capability is gated by `multiagent.enabled` in the limits
15
+ config (Ajustes > Limites), DEFAULT OFF. While off, the
16
+ `yujin.session.*` verbs are hidden from the manifest, this doctrine is
17
+ not injected, the system prompt tells you it is OFF, and the handlers
18
+ refuse. So you only see + use these verbs when the user has explicitly
19
+ turned multi-agent on. If the user asks for parallel sub-sessions while
20
+ it is off, tell them to enable it in Ajustes > Limites.
21
+
22
+ ## The verbs
23
+
24
+ - `yujin.session.spawn { task, project_root?, budget_tokens?, label?, model? }`
25
+ -- launch a sub-session for one self-contained task. Returns a
26
+ handle immediately (NON-blocking). The user approves each spawn
27
+ (it spends BYOK tokens autonomously).
28
+ `model` PINS the child brain as "provider/model" (PND-263). Without
29
+ it the child inherits the global `brain_config`, so its brain comes
30
+ out by OMISSION -- which is wrong whenever the brain is part of the
31
+ point. Measured in the Urazuke A/B experiment: the step-13 audit done
32
+ by the inherited non-frontier brain wrote FOUR of the nine findings it
33
+ announced, with a false P0; the same audit over the same commit with a
34
+ frontier brain wrote SEVENTEEN, all seventeen verified. The step asks
35
+ for a second opinion, and an inherited brain turns it into a
36
+ formality. Two rules on the pin, both deliberate: the slash is
37
+ REQUIRED (Forge never guesses the provider from the model name), and
38
+ an unknown provider -- or one whose key is not in the vault -- is
39
+ REFUSED at the door instead of silently falling back to another. A pin
40
+ also overrides the eco/frontier classifier and the escalation: it is a
41
+ request, not a preference.
42
+ - `yujin.session.collect { handle?, wait_ms? }` -- read the results
43
+ sub-sessions have published. `wait_ms` blocks up to that long for
44
+ at least one result; default 0 = return whatever has arrived.
45
+ - `yujin.session.list` -- what you have spawned, with TWO facts that are
46
+ not the same one (PND-256): `alive` is whether the process exists
47
+ (asked of the OS), and `registered` is whether the child already
48
+ published itself on the coordination bridge. A child can be alive and
49
+ not yet registered (booting), and a dead child can linger in the
50
+ roster. Reading one as the other costs either a needless relaunch or
51
+ an endless wait.
52
+ - `yujin.session.stop { handle }` -- terminate one.
53
+
54
+ ## Spawn ONLY when it pays off
55
+
56
+ A sub-session boots a whole headless server and spends tokens, so the
57
+ overhead must be justified. Spawn when ALL of these hold:
58
+
59
+ 1. **Orthogonal** -- the subtask is independent of the work you are
60
+ doing right now; it does not need the live conversation context.
61
+ (The child gets ONLY the `task` string you write -- be specific.)
62
+ 2. **Parallelizable** -- it can run while you keep working, and you
63
+ genuinely benefit from not blocking on it (e.g. a wide read /
64
+ research / analysis sweep over a different subsystem).
65
+ 3. **No write collision** -- it will not edit the same files you are
66
+ editing. If both might write, scope them to different paths or do
67
+ it yourself.
68
+ 4. **Fits a budget** -- set `budget_tokens` to bound the spend.
69
+ 5. **Brain chosen, not inherited** -- when the brain matters (an AUDIT
70
+ by another session, a review, a second opinion), pass `model`. An
71
+ auditor that comes out by omission satisfies the form of the step and
72
+ loses its point.
73
+
74
+ Do NOT spawn for:
75
+
76
+ - Trivial tasks (a single read, a one-line answer) -- the overhead
77
+ costs more than doing it inline.
78
+ - Anything that needs the user's live judgement or the chat history.
79
+ - Work you could do with one of your own verbs in this turn.
80
+
81
+ Typical good uses: "map how subsystem X wires together and report the
82
+ key files + entry points", "search the whole repo for every place
83
+ pattern Y appears and summarise", "read these 8 docs and extract the
84
+ constraints". Launch one per independent angle, then `collect`.
85
+
86
+ ## The child's scope (enforced, not advisory)
87
+
88
+ A sub-session runs with a RESTRICTED verb scope (enforced in
89
+ `nac3_invoke` via `YF_AGENT_MODE`):
90
+
91
+ - CAN: read / search / write files in its project root, run SAFE
92
+ shell, query the graph / pendings / reader.
93
+ - CANNOT: `git push` / `git commit`, destructive actions, `fs.move`,
94
+ re-anchor the project, mutate the workflow / pending / keys, run
95
+ lifecycle servers, or spawn its OWN sub-sessions (no grandchildren).
96
+
97
+ So the child is a safe builder/analyst. Anything outward or
98
+ irreversible stays with YOU, the parent, where the user can approve
99
+ it. Have the child RETURN its deliverable; you surface it (pizarron,
100
+ etc.) and you do the push/commit.
101
+
102
+ ## Lifecycle
103
+
104
+ Sub-sessions are one-shot: a child runs its task to completion (a
105
+ `[SESSION_DONE]` marker), publishes its result, and exits. The full
106
+ result is written to disk; the bridge signal carries a summary + the
107
+ path. Always `collect` what you spawn -- do not leave results
108
+ unread. If a child is no longer useful or is burning budget, `stop`
109
+ it.