@yaks/cli 0.0.0-stage → 0.2.36

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 (331) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +1059 -2
  3. package/_dist/account-forward.d.ts +12 -0
  4. package/_dist/account-forward.d.ts.map +1 -0
  5. package/_dist/accounts.d.ts +23 -0
  6. package/_dist/accounts.d.ts.map +1 -0
  7. package/_dist/answer.d.ts +88 -0
  8. package/_dist/answer.d.ts.map +1 -0
  9. package/_dist/apply.d.ts +17 -0
  10. package/_dist/apply.d.ts.map +1 -0
  11. package/_dist/args.d.ts +86 -0
  12. package/_dist/args.d.ts.map +1 -0
  13. package/_dist/commands.d.ts +15 -0
  14. package/_dist/commands.d.ts.map +1 -0
  15. package/_dist/complete.d.ts +15 -0
  16. package/_dist/complete.d.ts.map +1 -0
  17. package/_dist/config.d.ts +37 -0
  18. package/_dist/config.d.ts.map +1 -0
  19. package/_dist/dependencies.d.ts +6 -0
  20. package/_dist/dependencies.d.ts.map +1 -0
  21. package/_dist/facets.d.ts +71 -0
  22. package/_dist/facets.d.ts.map +1 -0
  23. package/_dist/grammar.d.ts +5 -0
  24. package/_dist/grammar.d.ts.map +1 -0
  25. package/_dist/host.d.ts +164 -0
  26. package/_dist/host.d.ts.map +1 -0
  27. package/_dist/install.d.ts +43 -0
  28. package/_dist/install.d.ts.map +1 -0
  29. package/_dist/main.d.ts +16 -0
  30. package/_dist/main.d.ts.map +1 -0
  31. package/_dist/memo.d.ts +60 -0
  32. package/_dist/memo.d.ts.map +1 -0
  33. package/_dist/mod.d.ts +46 -0
  34. package/_dist/mod.d.ts.map +1 -0
  35. package/_dist/page.d.ts +73 -0
  36. package/_dist/page.d.ts.map +1 -0
  37. package/_dist/platform.d.ts +27 -0
  38. package/_dist/platform.d.ts.map +1 -0
  39. package/_dist/reader.d.ts +10 -0
  40. package/_dist/reader.d.ts.map +1 -0
  41. package/_dist/release.d.ts +48 -0
  42. package/_dist/release.d.ts.map +1 -0
  43. package/_dist/remote.d.ts +13 -0
  44. package/_dist/remote.d.ts.map +1 -0
  45. package/_dist/reported.d.ts +11 -0
  46. package/_dist/reported.d.ts.map +1 -0
  47. package/_dist/roles.d.ts +2 -0
  48. package/_dist/roles.d.ts.map +1 -0
  49. package/_dist/roster.d.ts +41 -0
  50. package/_dist/roster.d.ts.map +1 -0
  51. package/_dist/rpc.d.ts +29 -0
  52. package/_dist/rpc.d.ts.map +1 -0
  53. package/_dist/run.d.ts +164 -0
  54. package/_dist/run.d.ts.map +1 -0
  55. package/_dist/runtime.d.ts +4 -0
  56. package/_dist/runtime.d.ts.map +1 -0
  57. package/_dist/searching.d.ts +7 -0
  58. package/_dist/searching.d.ts.map +1 -0
  59. package/_dist/show.d.ts +22 -0
  60. package/_dist/show.d.ts.map +1 -0
  61. package/_dist/store.d.ts +25 -0
  62. package/_dist/store.d.ts.map +1 -0
  63. package/_dist/terminal.d.ts +17 -0
  64. package/_dist/terminal.d.ts.map +1 -0
  65. package/_dist/tool.d.ts +55 -0
  66. package/_dist/tool.d.ts.map +1 -0
  67. package/_dist/tty.d.ts +3 -0
  68. package/_dist/tty.d.ts.map +1 -0
  69. package/_dist/vault.d.ts +9 -0
  70. package/_dist/vault.d.ts.map +1 -0
  71. package/_dist/words.d.ts +11 -0
  72. package/_dist/words.d.ts.map +1 -0
  73. package/_dist/yak.d.ts +10 -0
  74. package/_dist/yak.d.ts.map +1 -0
  75. package/account-forward.js +40 -0
  76. package/account-forward.js.map +1 -0
  77. package/account-forward.ts +50 -0
  78. package/accounts.js +162 -0
  79. package/accounts.js.map +1 -0
  80. package/accounts.ts +228 -0
  81. package/answer.js +394 -0
  82. package/answer.js.map +1 -0
  83. package/answer.ts +569 -0
  84. package/apply.js +49 -0
  85. package/apply.js.map +1 -0
  86. package/apply.ts +54 -0
  87. package/args.js +420 -0
  88. package/args.js.map +1 -0
  89. package/args.ts +494 -0
  90. package/code.js +209 -0
  91. package/code.js.map +1 -0
  92. package/code.ts +227 -0
  93. package/commands.js +131 -0
  94. package/commands.js.map +1 -0
  95. package/commands.ts +142 -0
  96. package/complete.js +104 -0
  97. package/complete.js.map +1 -0
  98. package/complete.ts +152 -0
  99. package/config.js +125 -0
  100. package/config.js.map +1 -0
  101. package/config.ts +180 -0
  102. package/declarations.js +67 -0
  103. package/declarations.js.map +1 -0
  104. package/declarations.ts +84 -0
  105. package/deno.json +1 -0
  106. package/dependencies.js +126 -0
  107. package/dependencies.js.map +1 -0
  108. package/dependencies.ts +141 -0
  109. package/derive.js +102 -0
  110. package/derive.js.map +1 -0
  111. package/derive.ts +125 -0
  112. package/drain.js +83 -0
  113. package/drain.js.map +1 -0
  114. package/drain.ts +115 -0
  115. package/duties.ts +17 -0
  116. package/exports.json +1486 -0
  117. package/external.js +373 -0
  118. package/external.js.map +1 -0
  119. package/external.ts +435 -0
  120. package/facets.js +214 -0
  121. package/facets.js.map +1 -0
  122. package/facets.ts +232 -0
  123. package/feedback.js +54 -0
  124. package/feedback.js.map +1 -0
  125. package/feedback.ts +57 -0
  126. package/files.js +84 -0
  127. package/files.js.map +1 -0
  128. package/files.ts +112 -0
  129. package/get_starts.js +31 -0
  130. package/get_starts.js.map +1 -0
  131. package/get_starts.ts +34 -0
  132. package/git-credential.js +79 -0
  133. package/git-credential.js.map +1 -0
  134. package/git-credential.ts +77 -0
  135. package/grammar.js +4 -0
  136. package/grammar.js.map +1 -0
  137. package/grammar.ts +5 -0
  138. package/held.js +51 -0
  139. package/held.js.map +1 -0
  140. package/held.ts +66 -0
  141. package/host.js +1174 -0
  142. package/host.js.map +1 -0
  143. package/host.ts +1343 -0
  144. package/init.js +138 -0
  145. package/init.js.map +1 -0
  146. package/init.ts +139 -0
  147. package/install.js +216 -0
  148. package/install.js.map +1 -0
  149. package/install.ts +223 -0
  150. package/lifetime.js +56 -0
  151. package/lifetime.js.map +1 -0
  152. package/lifetime.ts +66 -0
  153. package/local-page.ts +114 -0
  154. package/local.js +417 -0
  155. package/local.js.map +1 -0
  156. package/local.ts +537 -0
  157. package/lockfile.js +20 -0
  158. package/lockfile.js.map +1 -0
  159. package/lockfile.ts +32 -0
  160. package/machines.js +33 -0
  161. package/machines.js.map +1 -0
  162. package/machines.ts +51 -0
  163. package/made/4f855610bdabcd736100d34e4e467ea5.json +1 -0
  164. package/main.js +534 -0
  165. package/main.js.map +1 -0
  166. package/main.ts +547 -0
  167. package/mcp.js +108 -0
  168. package/mcp.js.map +1 -0
  169. package/mcp.ts +113 -0
  170. package/member.js +103 -0
  171. package/member.js.map +1 -0
  172. package/member.ts +133 -0
  173. package/memo.js +503 -0
  174. package/memo.js.map +1 -0
  175. package/memo.ts +634 -0
  176. package/mod.js +46 -0
  177. package/mod.js.map +1 -0
  178. package/mod.ts +99 -0
  179. package/operations.js +53 -0
  180. package/operations.js.map +1 -0
  181. package/operations.ts +68 -0
  182. package/package.json +115 -4
  183. package/page.js +211 -0
  184. package/page.js.map +1 -0
  185. package/page.ts +308 -0
  186. package/parser.js +45 -0
  187. package/parser.js.map +1 -0
  188. package/parser.ts +77 -0
  189. package/people-search.js +112 -0
  190. package/people-search.js.map +1 -0
  191. package/people-search.ts +162 -0
  192. package/platform.js +184 -0
  193. package/platform.js.map +1 -0
  194. package/platform.ts +224 -0
  195. package/platform_effects.js +5 -0
  196. package/platform_effects.js.map +1 -0
  197. package/platform_effects.ts +13 -0
  198. package/prepare.js +40 -0
  199. package/prepare.js.map +1 -0
  200. package/prepare.ts +46 -0
  201. package/read_activity.js +54 -0
  202. package/read_activity.js.map +1 -0
  203. package/read_activity.ts +61 -0
  204. package/read_thread.js +387 -0
  205. package/read_thread.js.map +1 -0
  206. package/read_thread.ts +506 -0
  207. package/read_worker.ts +164 -0
  208. package/reader.js +48 -0
  209. package/reader.js.map +1 -0
  210. package/reader.ts +57 -0
  211. package/release.js +82 -0
  212. package/release.js.map +1 -0
  213. package/release.json +127 -0
  214. package/release.ts +98 -0
  215. package/remote-page.ts +70 -0
  216. package/remote.js +96 -0
  217. package/remote.js.map +1 -0
  218. package/remote.ts +153 -0
  219. package/report.js +83 -0
  220. package/report.js.map +1 -0
  221. package/report.ts +101 -0
  222. package/reported.js +32 -0
  223. package/reported.js.map +1 -0
  224. package/reported.ts +38 -0
  225. package/restart.js +349 -0
  226. package/restart.js.map +1 -0
  227. package/restart.ts +478 -0
  228. package/restore.js +32 -0
  229. package/restore.js.map +1 -0
  230. package/restore.ts +38 -0
  231. package/roles.js +32 -0
  232. package/roles.js.map +1 -0
  233. package/roles.ts +49 -0
  234. package/roster.js +65 -0
  235. package/roster.js.map +1 -0
  236. package/roster.ts +84 -0
  237. package/rpc.js +113 -0
  238. package/rpc.js.map +1 -0
  239. package/rpc.ts +159 -0
  240. package/run.js +533 -0
  241. package/run.js.map +1 -0
  242. package/run.ts +741 -0
  243. package/runtime.js +381 -0
  244. package/runtime.js.map +1 -0
  245. package/runtime.ts +433 -0
  246. package/sandboxes.js +26 -0
  247. package/sandboxes.js.map +1 -0
  248. package/sandboxes.ts +30 -0
  249. package/searching.js +33 -0
  250. package/searching.js.map +1 -0
  251. package/searching.ts +50 -0
  252. package/show.js +109 -0
  253. package/show.js.map +1 -0
  254. package/show.ts +144 -0
  255. package/shown.js +13 -0
  256. package/shown.js.map +1 -0
  257. package/shown.ts +44 -0
  258. package/stall.js +90 -0
  259. package/stall.js.map +1 -0
  260. package/stall.ts +156 -0
  261. package/stall_profile.js +113 -0
  262. package/stall_profile.js.map +1 -0
  263. package/stall_profile.ts +142 -0
  264. package/stall_wait.js +183 -0
  265. package/stall_wait.js.map +1 -0
  266. package/stall_wait.ts +249 -0
  267. package/stall_wait_worker.ts +11 -0
  268. package/start.js +349 -0
  269. package/start.js.map +1 -0
  270. package/start.ts +343 -0
  271. package/starvation.js +147 -0
  272. package/starvation.js.map +1 -0
  273. package/starvation.ts +224 -0
  274. package/store.js +118 -0
  275. package/store.js.map +1 -0
  276. package/store.ts +193 -0
  277. package/subcommands.js +62 -0
  278. package/subcommands.js.map +1 -0
  279. package/subcommands.ts +77 -0
  280. package/terminal.js +93 -0
  281. package/terminal.js.map +1 -0
  282. package/terminal.ts +128 -0
  283. package/text.js +20 -0
  284. package/text.js.map +1 -0
  285. package/text.ts +37 -0
  286. package/tool.js +76 -0
  287. package/tool.js.map +1 -0
  288. package/tool.ts +157 -0
  289. package/trace_control.js +231 -0
  290. package/trace_control.js.map +1 -0
  291. package/trace_control.ts +233 -0
  292. package/traces.js +138 -0
  293. package/traces.js.map +1 -0
  294. package/traces.ts +160 -0
  295. package/tracker.js +22 -0
  296. package/tracker.js.map +1 -0
  297. package/tracker.ts +27 -0
  298. package/tty.js +82 -0
  299. package/tty.js.map +1 -0
  300. package/tty.ts +142 -0
  301. package/unit_failure.js +178 -0
  302. package/unit_failure.js.map +1 -0
  303. package/unit_failure.ts +191 -0
  304. package/upkeep_thread.js +32 -0
  305. package/upkeep_thread.js.map +1 -0
  306. package/upkeep_thread.ts +35 -0
  307. package/upkeep_worker.ts +27 -0
  308. package/vault.js +186 -0
  309. package/vault.js.map +1 -0
  310. package/vault.ts +220 -0
  311. package/vocab-ids.js +63 -0
  312. package/vocab-ids.js.map +1 -0
  313. package/vocab-ids.ts +62 -0
  314. package/vocab.json +35 -0
  315. package/warm.js +138 -0
  316. package/warm.js.map +1 -0
  317. package/warm.ts +171 -0
  318. package/watch_revision.js +25 -0
  319. package/watch_revision.js.map +1 -0
  320. package/watch_revision.ts +30 -0
  321. package/words.js +29 -0
  322. package/words.js.map +1 -0
  323. package/words.ts +41 -0
  324. package/workspaces.js +40 -0
  325. package/workspaces.js.map +1 -0
  326. package/workspaces.ts +58 -0
  327. package/yak-unit-failure.conf +6 -0
  328. package/yak-unit-handoff.conf +2 -0
  329. package/yak.js +123 -0
  330. package/yak.js.map +1 -0
  331. package/yak.ts +136 -0
package/README.md CHANGED
@@ -1,3 +1,1060 @@
1
- # Temporary Holding Version
1
+ # @yaks/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@yaks/cli` provides `yak`, a command-line client for a
4
+ [@yaks/graph](../graph/README.md), and the functions that assemble a graph from
5
+ a JSON config file. A graph stores entities. Each entity has a stable ID and
6
+ components, which are named objects containing properties. A bundle is one
7
+ entity's components represented as a JSON object; it can describe the entity's
8
+ current state or a change to it. A batch is a list of bundles applied in one
9
+ transaction.
10
+
11
+ ```sh
12
+ deno run -A jsr:@yaks/cli/install
13
+
14
+ yak init # Start this machine's own graph, with you as its person.
15
+ yak task new 'Add the sign-up page' # Open that graph, run a tool, and exit.
16
+ yak task list
17
+ yak serve # Run the graph's serve tool: HTTP.
18
+ yak --config yak.json task list # The same, on the graph another config names.
19
+ yak auth yaks.app # Sign in to yaks.app,
20
+ yak app_list # then call its tools over MCP.
21
+ ```
22
+
23
+ The [repository README](https://github.com/yak-sh/yak#start) walks a first
24
+ session.
25
+
26
+ A tool is an operation declared by a graph, with a name, an input schema, and an
27
+ implementation. `yak` turns each tool in the selected graph into a subcommand.
28
+ Its arguments and help come from the tool's input schema, so a new tool does not
29
+ require a new CLI release.
30
+
31
+ `yak` provides `help`, `init`, and `apply` itself. Its other commands come from
32
+ a configured plugin, a graph opened in the current process, or an MCP server
33
+ queried at run time. `yak serve` is a tool rather than a command of this
34
+ package: [@yaks/api](../api/README.md) declares and implements it, so a config
35
+ listing that package is a config whose graph can be served.
36
+
37
+ A composed CLI host also offers `help` and `restart` through MCP. `help` with
38
+ `{ "words": ["task", "update"] }` returns that tool's arguments; no words lists
39
+ names. `restart` with `{}` uses the same ready-first systemd handover as
40
+ `yak restart`, with the host's configured processes.
41
+
42
+ `yak mcp --host http://localhost:5173` connects a local MCP client over stdio
43
+ and forwards requests to that host. Configure an agent with `command: "yak"` and
44
+ `args: ["mcp", "--host", "http://localhost:5173"]`. This client adds
45
+ `_files: true` to opt into reading `@/absolute/path` in declared string
46
+ arguments, including nested strings. It reads on the client's machine and sends
47
+ the contents; the HTTP server receives ordinary values. Omit `_files` for
48
+ literal `@` text. CLI arguments such as `--body @note.md` always expand locally;
49
+ `--_files` also expands strings inside JSON arguments.
50
+
51
+ The package has two main responsibilities:
52
+
53
+ - [`host.ts`](./host.ts) opens the graph a config names for the roles a process
54
+ serves, importing only those roles' facets of the configured plugins. It
55
+ serves no HTTP of its own: the request handler is built by the listed plugin
56
+ that hosts routes, which is @yaks/api.
57
+ - [`platform.ts`](./platform.ts) lists and calls tools on a remote MCP server.
58
+ [`subcommands.ts`](./subcommands.ts) lists the same command interface for a
59
+ graph the current process can open, from its plugins' declarations alone, and
60
+ [`local.ts`](./local.ts) opens that graph when one of them runs.
61
+ [`member.ts`](./member.ts) makes a remote host a member of a reach
62
+ (@yaks/reach): reads are its `graph_query`, writes its `graph_apply`, and its
63
+ door carries that host's own connection token. `$YAKS_TOKEN` and `--as` reach
64
+ only the host the line aims at.
65
+
66
+ ## Running sessions on your own machine
67
+
68
+ `yak start` makes this machine run the sessions its space on yaks.app asks of
69
+ it, with your own `claude` or `codex`:
70
+
71
+ ```sh
72
+ cd ~/code/my-app
73
+ yak start
74
+ yak session spawn T-1 --provider 'claude on my-laptop'
75
+ ```
76
+
77
+ It signs you in to yaks.app if this machine has not, finds `claude` and `codex`
78
+ on the PATH, and adds yaks.app's MCP server to each as `yaks`. It registers the
79
+ machine in your space under its hostname (`--machine` names it otherwise),
80
+ lending each CLI it found as a provider, `<cli> on <machine>`
81
+ ([@yaks/spawn/machines](../spawn/README.md#a-developers-own-machine)). Then it
82
+ installs a user service that keeps the runner going: the LaunchAgent
83
+ `app.yaks.runner` on macOS, which writes to `~/Library/Logs/yak-runner.log`, and
84
+ the systemd user unit `yak-runner` on Linux. Running it again replaces the
85
+ service.
86
+
87
+ The service runs `yak start --foreground`, which is the runner itself. It dials
88
+ out to yaks.app, so there is no tunnel and no open port. Each session asked of
89
+ one of the machine's providers runs in a worktree of the checkout `yak start`
90
+ was run in (`--dir`), on a branch of its own, under the state directory's
91
+ `runs/`. The run is connected to yaks.app's MCP server with this machine's
92
+ yaks.app token, and its transcript and final report go back to the space. The
93
+ runner reads no CLI's sign-in: each CLI uses its own.
94
+
95
+ When retiring a machine, finish its work and stop its runner. Then run
96
+ `yak --host yaks.app machine remove my-laptop` with the name you registered.
97
+ This removes the registration and the CLI providers it lent to the space.
98
+
99
+ ## Roles
100
+
101
+ A plugin says what it contributes, one facet per subpath, and never where it
102
+ runs. A process serves roles, and imports only the facets of the roles it
103
+ serves:
104
+
105
+ | Role | Facets | What the process does |
106
+ | --------------- | ------------------------------- | ---------------------------------------------- |
107
+ | `graph` | `./vocab`, `./graph`, `./tools` | opens the file, admits writes, runs tool calls |
108
+ | `web` | `./routes` | answers HTTP with the routes @yaks/api hosts |
109
+ | `effects` | `./effects` | claims and runs what commits owe, in a pool |
110
+ | a plugin's name | that plugin's `./service` | keeps that plugin's timer or poll running |
111
+
112
+ The `yak` command serves commands and rendering itself. It reads the plugins'
113
+ `./vocab` for tools and optional `./cli` facets for terminal controls, so the
114
+ usage page opens no graph. A `./cli` command runs directly in the terminal
115
+ process and is not a stored tool call: input such as an OAuth return URL cannot
116
+ be replayed by another process. Running one opens the graph for that command's
117
+ roles: the graph and the roles it declares (`serve` declares `web`). The duty
118
+ roles, the effect pool and each plugin's service, run in independent processes
119
+ for `serve` where no live process serves them (see Duties). The rendering role
120
+ imports `./views`, and `./tui` under `--tui`.
121
+
122
+ ## Where a command runs
123
+
124
+ A [host](../host/README.md) composes a graph and lends capabilities to its
125
+ plugins. The CLI is the box's concrete host. A config file describes a local
126
+ graph: its SQLite database, plugins, and host settings. A command that selects a
127
+ config asks the `yak serve` running over that graph to run its tool, at the
128
+ address the config says it listens on, through the same `/mcp` an agent's MCP
129
+ tools use ([`warm.ts`](./warm.ts)). That server holds the graph's code loaded,
130
+ so the command loads none of it. Where no server answers for that graph file,
131
+ the command opens the graph in its own process, runs the tool, and exits, so it
132
+ does not require `yak serve`. SQLite uses WAL mode for file-backed graphs,
133
+ allowing separate CLI and server processes to share the database.
134
+
135
+ A command stays in its own process when the server could not run it the same
136
+ way: a tool that declares a role beyond the graph (`serve`), an answer held in
137
+ the terminal (`--tui`), a plugin's terminal control, and a write typed at a
138
+ keyboard with no session, which this process signs as the config's person. Every
139
+ request names the graph file it means (`x-yak-db`, @yaks/api/address); the
140
+ server serving that file says it back, and one serving another answers 421 and
141
+ runs nothing, so a copy whose config names the same port never writes to the
142
+ graph it was copied from.
143
+
144
+ `--host` has a different meaning on the command line: it selects a remote
145
+ hostname or origin whose MCP endpoint is `/mcp`. A bare hostname uses HTTPS.
146
+ `--host` and `--config` cannot be used together because they select different
147
+ graphs.
148
+
149
+ The CLI chooses its target in this order:
150
+
151
+ | Input | Target |
152
+ | ----------------- | ---------------------------------------------------- |
153
+ | `--config <path>` | The local graph described by that config |
154
+ | `--host <host>` | The remote MCP server at `<host>/mcp` |
155
+ | `$YAKS_HOST` | The remote MCP server named by the variable |
156
+ | `$YAK_CONFIG` | The local graph described by the variable |
157
+ | `~/.yak/yak.json` | The local graph described by this file, if it exists |
158
+ | None of the above | `https://yaks.app/mcp` |
159
+
160
+ A config named on the line is the one place that line means. A config found
161
+ through `$YAK_CONFIG` or at `~/.yak/yak.json` is only first in the order: a
162
+ command its graph does not have is asked of the host next, so `yak app_list`
163
+ reaches yaks.app from a machine that keeps a graph of its own.
164
+
165
+ Local and remote tool invocations both create a call entity and run it through
166
+ `@yaks/tools`. Tool calls made by people and agents therefore use the same
167
+ validation, rules, effects, attribution, and stored record. Their answers are
168
+ shown the same way too: through the views of the packages that declared the
169
+ components, where this machine has them. A remote server's vocabulary, and the
170
+ package behind each component, come from its `graph_schema`, asked once and
171
+ cached beside its tool list; a reply that carries no entities prints as its
172
+ text. Terminal controls from a plugin's `./cli` facet, such as the harness's
173
+ `connection authorize`, run in that terminal process and use their own command
174
+ implementations, as do `help`, `init`, and `apply`.
175
+
176
+ ## The config
177
+
178
+ `yak init` starts a machine's own graph: it writes `~/.yak/yak.json` (or the
179
+ path `--config` names) with the plugins a graph, its tasks, sessions,
180
+ connections, `/mcp` and the web canvas need, and makes you the graph's `person`.
181
+ It asks for no name: it names you from git's `user.name`, or else your login,
182
+ and the graph's first task, T-1, filed to you, is confirming it, which any agent
183
+ that connects finds and asks you about. `yak name <your name>` renames you. It
184
+ never replaces a config that is already there. Its connections are where
185
+ `yak auth yaks.app` keeps your sign-in.
186
+
187
+ A config is plain JSON, so a plugin is one more line. Pass another with
188
+ `--config`, or set `$YAK_CONFIG`. This one adds @yaks/mail, with its options:
189
+
190
+ ```json
191
+ {
192
+ "db": "graph.db",
193
+ "plugins": [
194
+ "@yaks/kernel",
195
+ "@yaks/provenance",
196
+ "@yaks/id",
197
+ "@yaks/secrets",
198
+ "@yaks/doc",
199
+ "@yaks/effects",
200
+ "@yaks/tools",
201
+ "@yaks/task",
202
+ "@yaks/api",
203
+ {
204
+ "use": "@yaks/mail",
205
+ "with": {
206
+ "domain": "books.example",
207
+ "sender": {
208
+ "via": "cloudflare",
209
+ "account": "a1b2",
210
+ "token": { "secret": "CF_EMAIL_TOKEN" }
211
+ }
212
+ }
213
+ }
214
+ ],
215
+ "numbers": true,
216
+ "port": 8787
217
+ }
218
+ ```
219
+
220
+ Relative database paths and plugin specifiers are resolved relative to the
221
+ config file.
222
+
223
+ | Field | Meaning |
224
+ | ---------- | ------------------------------------------------------------------------------------------------- |
225
+ | `db` | SQLite path or `:memory:`. Required unless `$DB_PATH` is set. |
226
+ | `plugins` | Package specifiers, optionally paired with plugin-specific options. |
227
+ | `port` | Port the `serve` tool listens on; defaults to `@yaks/api`'s `PORT`. |
228
+ | `hostname` | Network interface used by `serve`; defaults to `@yaks/api`'s `HOSTNAME`, `127.0.0.1`. |
229
+ | `numbers` | Enables short entity numbers, one series per prefix a component declares (@yaks/id). |
230
+ | `name` | MCP server name; defaults to `yak`. |
231
+ | `person` | Who works at this machine, as any id the graph resolves; a command typed at a terminal is theirs. |
232
+ | `lease` | Duty lease and effect-run claim duration in milliseconds; defaults to `30000` and `60000`. |
233
+ | `duties` | Whether this process runs its duties; defaults to `true`. |
234
+
235
+ With `numbers: true`, an entity is numbered once, in the series of the prefix
236
+ its component declares (@yaks/id), and each prefix counts on its own: the person
237
+ `yak init` makes is U-1 and the first task is still T-1. An entity whose
238
+ components declare no prefix (an edge, an effect, an archetype descriptor) is
239
+ not numbered and shows @yaks/id's short handle (`#` plus ten eid characters),
240
+ accepted by `graph show`, `session peek` and the web view. Existing numbers stay
241
+ valid addresses.
242
+
243
+ There is no default database path. `compose` throws unless `db` or `$DB_PATH` is
244
+ present.
245
+
246
+ ### What a config passes to one plugin
247
+
248
+ A plugin entry is either a package specifier or an object with `use` and `with`
249
+ fields. Each exported plugin factory receives `(host, options)`. The host
250
+ contains the config, vocabulary, database connection, secrets vault, blob store,
251
+ store, graph, request handler, tool runner, duties, process entity, request
252
+ authentication function, and shutdown signal. An entry without `with` receives
253
+ an empty object. Option keys belong to the plugin.
254
+
255
+ The vault is where [@yaks/secrets](../secrets) keeps what is written through the
256
+ graph: one private file per secret in a `secrets` directory beside the database
257
+ (`~/.yak/secrets` for `~/.yak/yak.db`), or memory for a graph in memory. Removed
258
+ and replaced file values are retained in the private `secrets/trash/` directory.
259
+ Active reads exclude trash; `vault.trash()` lists archive metadata and
260
+ `vault.restore(id)` recovers a saved version, retaining any displaced value. No
261
+ background job purges this trash. `fileVault` and `vaultOf`
262
+ ([vault.ts](./vault.ts)) are exported for code that opens a graph without
263
+ `compose`.
264
+
265
+ At any depth in `with`, an object containing only `{ "secret": "NAME" }` reads
266
+ that secret when the property is accessed: the local value in the vault, or else
267
+ the environment variable `NAME`. Runtime reads never invoke 1Password. This
268
+ keeps secrets out of the JSON file and lets a long-running plugin observe a
269
+ value supplied after startup. A secret nobody supplied produces `undefined`; the
270
+ plugin decides how to handle it.
271
+
272
+ Plugin factories may omit functionality when configuration is unavailable. Any
273
+ diagnostic behavior, including a `check` tool, belongs to the plugin; the CLI
274
+ does not impose a startup policy for missing plugin options.
275
+
276
+ ## A plugin is a package, and each part of it is a subpath export
277
+
278
+ A facet is a sub-module export: one optional plugin subpath that supplies a
279
+ specific part of the running graph. `compose(config, roles)` imports, from each
280
+ configured package, the facets of the roles the process serves and no others. An
281
+ unexported facet is skipped; an exported facet that fails to import causes
282
+ composition to fail. A package that exports none of a process's facets
283
+ contributes nothing to that process.
284
+
285
+ ```json
286
+ {
287
+ "name": "@yaks/mail",
288
+ "exports": {
289
+ ".": "./mod.ts",
290
+ "./vocab": "./vocab.ts",
291
+ "./graph": "./graph.ts",
292
+ "./effects": "./effects.ts",
293
+ "./routes": "./routes.ts"
294
+ }
295
+ }
296
+ ```
297
+
298
+ | Subpath | Role | Expected exports |
299
+ | ----------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------- |
300
+ | `./vocab` | `graph` | `docs?`, `keywords?`, `derived?` and `backed?` declarations, and `description?` from package.json |
301
+ | `./graph` | `graph` | `schema?`, `plugins?: (host, options) => Plugin[]`, `extend?`, `reply?`, `meaning?`, `feed?`, and at most one `authenticate?` |
302
+ | `./tools` | `graph` | `runs?: (host, options) => Runs`, keyed by declared tool name |
303
+ | `./cli` | `yak` | `commands?: CliCommand[]`, direct terminal controls with a composed host |
304
+ | `./effects` | `effects` | `effects?: (host, options) => Handlers`, keyed by declared effect name |
305
+ | `./routes` | `web` | `routes?: (host, options) => Route[]`, `filter?`, and at most one `handler?` |
306
+ | `./service` | its plugin | `service?: (host, options, signal)` for a duty |
307
+ | `.` | | Public types and library functions; not loaded by `compose` |
308
+
309
+ The web UI separately imports `./vocab` and `./views`, and `yak` imports
310
+ `./views` to show a tool's answer. Those modules must work in a browser and must
311
+ not import SQL, storage drivers, or server-only APIs. `deno task check:types`
312
+ verifies this constraint. `compose` does not load `./views`: drawing is the
313
+ rendering role, which needs no graph open. Nor does it load `./web` or `./mail`:
314
+ @yaks/web finds an application's page in its `./web` facet, and @yaks/mail asks
315
+ each configured plugin's `./mail` facet (`reading?: (options) => Reading`) what
316
+ a letter that arrived means.
317
+
318
+ `@yaks/mail`, as `compose` reads it:
319
+
320
+ ```ts
321
+ import { docs } from '@yaks/mail/vocab'
322
+ import { plugins } from '@yaks/mail/graph'
323
+ import { runs } from '@yaks/mail/tools'
324
+ import { loadVocab } from '@yaks/vocab'
325
+
326
+ // Its options are its entry in yak.json.
327
+ let options = { domain: 'books.example' }
328
+ docs // [mailDoc]
329
+ // The host's vocab says whether the store speaks the letter's words.
330
+ plugins({ vocab: loadVocab(docs) }, options) // [mailbox(...), recipients()]
331
+ Object.keys(runs({}, options)) // the tools it runs, by name
332
+ ```
333
+
334
+ ### Workspace execution and sandbox defaults
335
+
336
+ The CLI connects existing workspaces through `workspaces.connectors`; a missing
337
+ placement never selects the CLI's own directory. `sandboxes.providers`
338
+ configures sandbox adapters separately, and `sandboxes.defaultProvider` selects
339
+ the adapter for an omitted session workspace. No configured default means
340
+ refusal, not a process-directory sandbox.
341
+
342
+ ```json
343
+ {
344
+ "db": "./graph.db",
345
+ "plugins": [
346
+ "@yaks/kernel",
347
+ "@yaks/provenance",
348
+ "@yaks/machine",
349
+ "@yaks/sandbox",
350
+ "@yaks/harness"
351
+ ],
352
+ "sandboxes": {
353
+ "defaultProvider": "coder",
354
+ "providers": {
355
+ "coder": {
356
+ "use": "@yaks/sandbox/docker",
357
+ "machine": "sandbox-computer",
358
+ "with": { "state": "/var/lib/yak/sandboxes" }
359
+ }
360
+ }
361
+ }
362
+ }
363
+ ```
364
+
365
+ The named computer must already be recorded with a configured connection
366
+ address. An omitted workspace requests a sandbox intention on the first file or
367
+ command call; the sandbox effect provisions it. See
368
+ [sandbox configuration](../sandbox/README.md) and
369
+ [workspace tools](../machine/README.md#workspace-tools-and-session-defaults).
370
+
371
+ ### A tool that acts on the machine
372
+
373
+ Some tools change the machine running them instead of only changing the graph.
374
+ For example, `land` updates a checkout, `hooks install` writes a settings file,
375
+ and `serve` binds a TCP port. The call such a tool is handed carries
376
+ `process{pid, command, cwd}` (@yaks/process), the program that executes the
377
+ call, and `cwd` is its working directory. A locally opened graph uses the
378
+ directory where the user ran `yak`; a remote call uses the server process's
379
+ directory. A tool accepting a `cwd` argument receives the CLI's current
380
+ directory when the flag is omitted. `land` requires that argument over MCP,
381
+ where a shared connection cannot identify a sub-agent's working directory.
382
+
383
+ A tool that declines a call throws `CallError`. The runner records the refusal,
384
+ and `yak` returns exit code `1`.
385
+
386
+ Factories receive the [portable host interface](../host/README.md), with no SQL
387
+ driver or state directory. They can retain `host.storage`, `host.graph`,
388
+ `host.handler`, `host.runner`, and `host.duties`, but must not access them
389
+ before initialization. Storage capabilities are available to `extend` from
390
+ `./graph`; graph reads wait until composition has bound all extensions. A route
391
+ is an `@yaks/api` `Route` with `method`, `path`, and a `(Request) => Response`
392
+ handler. Paths are exact unless they end in `*`; `*` also matches any method.
393
+
394
+ A process serving `web` answers requests only where a listed plugin exports
395
+ `handler` from `./routes`. @yaks/api is that plugin: it is handed the host once
396
+ `host.routes` holds every listed plugin's routes, and returns them in front of
397
+ `/apply`, `/query` and `/ws`, which answer whatever no route claimed. A config
398
+ that does not list it composes a host with no `handler`, no `serve` tool, and no
399
+ call to any plugin's `routes` factory — the routes are ignored rather than built
400
+ for a listener that does not exist. `/mcp` is the same arrangement one level
401
+ down: @yaks/mcp contributes it as a route, so a config that wants an agent's
402
+ door lists that package too.
403
+
404
+ Routes that write should use `host.who(request)` and `signed` from `@yaks/api`
405
+ to attribute their changes. `authenticate` belongs to `./graph`, because every
406
+ door asks it, a command line naming its session as much as an HTTP request, and
407
+ at most one plugin may export it. Without an authenticated caller, writes are
408
+ attributed to the host process.
409
+
410
+ ## Who a process writes as, and what starting up IS
411
+
412
+ Every command, server, or TUI that opens a graph, and every thread of one that
413
+ does, creates its own process entity:
414
+
415
+ ```text
416
+ process{pid, command, cwd, roles} ...and exit{code} when it closes
417
+ ```
418
+
419
+ Writes without an explicit actor are attributed to that process. Authenticated
420
+ requests are attributed to the authenticated identity. On shutdown, `close()`
421
+ records the exit and releases the process's leases in one transaction.
422
+
423
+ Start-up work is an effect declared `start: true` (@yaks/effects): a process
424
+ that starts working the pool owes itself a run of it, and a command passing
425
+ through, which serves no `effects` role, owes none; there is no separate
426
+ `./boot` facet. Start-up work that must run in the process that started holds a
427
+ lease instead.
428
+
429
+ ## What `compose` does
430
+
431
+ [`compose(config, roles)`](./host.ts) opens the box's resources and calls
432
+ [@yaks/host's assembly](../host/README.md#assembly). It performs these steps:
433
+
434
+ 1. Imports, from each configured plugin, the facets of the roles given. Every
435
+ process serves `graph`.
436
+ 2. Combines vocabulary documents and keywords, rejecting duplicate component
437
+ declarations.
438
+ 3. Opens the SQLite graph, checks migration control, and binds storage with
439
+ derived columns, backings of computed components, query extensions, optional
440
+ entity numbers, and the full-text indexes. A host that may write brings the
441
+ file to its composed schema first (below).
442
+ 4. Builds the graph from plugins and the effect registry. Every process writes
443
+ down the runs its commits owe, whatever roles it serves. An effect's `option`
444
+ names the declaring plugin's boolean option, which must be `true` before any
445
+ process owes that effect a run.
446
+ 5. Joins tool declarations to their `runs` implementations; a declared tool
447
+ without an implementation is an error. Serving `effects`, it handles each
448
+ declared effect with the one plugin `./effects` that gives it code, usually
449
+ the declaring plugin's own (a declared effect the config gives no code owes
450
+ no run, and two plugins handling one is an error), and the tool runner's two
451
+ effects for calls another process wrote.
452
+ 6. Serving `web`, asks the plugin that hosts routes, if the config listed one,
453
+ for the one handler this host answers with.
454
+ 7. Creates the current process entity after registrations are ready, except for
455
+ a read-only host (`readOnly: true`) or one composed with `process: false`. A
456
+ write storage refuses as retryable is tried again with backoff, waited out on
457
+ the `clock` option (an @yaks/fp `Clock`, the runtime's by default), which the
458
+ host's graph and tool runner keep too.
459
+
460
+ **The schema follows the vocabulary** (D-366). Everything a graph's file needs
461
+ is one composed schema: migration control, blob storage, the store's component
462
+ tables and archetypes, each graph facet's `schema(host, options)` statements and
463
+ the full-text indexes. It has one print, and every host that may write compares
464
+ it with the prints the file has recorded (@yaks/sqlite `follow`). A recorded
465
+ print opens with no DDL and no write lock. A missing one adds what is missing
466
+ (tables, the columns a standing table lacks, indexes, full-text tables, filled),
467
+ records the print, and goes on. There is no installing step: a landing that
468
+ grows the vocabulary is on the file the first time a writer with the new code
469
+ opens it, `yak init`'s included. A pass only adds, so a process still running
470
+ the older code keeps its own print and finds nothing to change.
471
+
472
+ A local read-only command opens SQLite with `readOnly: true`, records no
473
+ process, tool, call, claim or result, and invokes no write reply. Failed reads
474
+ return fault bundles without persisting them or writing telemetry to the graph.
475
+ It retains every configured graph facet and its addressing, scope and read
476
+ hooks. Attempts to apply, rehearse or admit a write refuse before writer hooks
477
+ can prepare external work. Read factories load before synchronous assembly
478
+ binding. Its connection can load native extensions to read installed indexes;
479
+ SQLite refuses any metadata writes. Semantic ranking uses the installed vector
480
+ index and scores vectors changed since its build beside its candidates. SQLite
481
+ still coordinates concurrent WAL readers through its shared-memory index; this
482
+ is not a database or WAL row write.
483
+
484
+ It returns a `Served` object: the `Host` fields — which include `roles`,
485
+ `tools`, `routes`, `handler`, `runner`, and `duties` — plus `fx` and `close`.
486
+ Nothing here binds a port. The `serve` tool does that, reading the handler off
487
+ the host it was composed into, reconciling interrupted calls, and taking over
488
+ the duties for as long as it listens. `words(config)` ([`words.ts`](./words.ts))
489
+ reads the plugins' `./vocab` alone: the vocabulary and the tools it declares,
490
+ with nothing opened and none of the code that opens a graph loaded.
491
+
492
+ Selected file-backed facets are loaded together as one module graph, so the
493
+ runtime traverses their shared dependencies once rather than once per dynamic
494
+ import. This happens for vocabulary discovery, composition, command discovery,
495
+ and portable views. It imports only the selected subpaths; tools stay lazy.
496
+ Unmapped packages use the ordinary JSR loader. An absent optional facet remains
497
+ absent; an exported facet that fails still fails the load.
498
+
499
+ A **runtime snapshot** is an immutable source tree a CLI command runs from. From
500
+ a Git checkout, every `yak` command runs in a runtime snapshot containing the
501
+ commit, tracked edits and untracked files, read while holding the checkout's
502
+ land lock shared (`@yaks/git/land`), so a launch never captures a landing half
503
+ done and never takes the index from one. The command runs in the process that
504
+ took the snapshot: that process loads only the land lock and the launcher from
505
+ the checkout, then imports the snapshot's own `yak.ts`, and Deno resolves the
506
+ snapshot's workspace through the snapshot's own `node_modules`. Deferred tool
507
+ imports read the snapshot too. A landing can add an export, change a tool or
508
+ remove a dependency while the running command keeps its own code. The next
509
+ launch uses the checkout's current code. Deno reads the checkout's `deno.json`
510
+ as the process starts, before the land lock; when a landing has written it
511
+ since, the command starts afresh from its snapshot in a process of its own. JSR
512
+ releases already have immutable sources.
513
+
514
+ Runtime snapshots live in numbered slots under `$XDG_CACHE_HOME/yak/runtime`
515
+ (otherwise `$HOME/.cache/yak/runtime`); `YAK_RUNTIME_CACHE` selects another
516
+ directory. A launch whose sources a slot already holds shares it. Otherwise it
517
+ rewrites the lowest slot no running process runs from, so a slot never changes
518
+ under a process, and its paths repeat: Deno's compiled modules and the CLI's
519
+ memo stay valid for every file the landing left alone. A command holds its
520
+ slot's `.live` lock while it runs, and a process started from a slot's `yak.ts`,
521
+ such as a duty worker, names the slot on its command line. Slots no process runs
522
+ from are removed at the next launch, so the cache holds one tree per running
523
+ version. Launchers take the cache's lock until their command holds its slot. A
524
+ detached duty worker starts from its web's snapshot and can outlive the web
525
+ command. The graph config, database and working directory retain their caller's
526
+ paths; file plugins and machine providers inside the source checkout follow the
527
+ runtime snapshot.
528
+
529
+ `@yaks/cli/memo` exports `remember(inputs, roots, make, options)` for derived
530
+ JSON data. A hit validates the source files before reusing the value; failed
531
+ derivations are never saved. `options.imports` can supply an explicit dependency
532
+ scanner when a caller already enumerates every source. `options.valid(value)`
533
+ can reject a cached value whose generated outputs were lost or changed.
534
+
535
+ Command declarations and vocabulary documents are data. The CLI derives them
536
+ once and keeps an internal memo under `$XDG_CACHE_HOME/yak/cli` (otherwise
537
+ `$HOME/.cache/yak/cli`). Each command checks the configured plugins and the
538
+ contents of their facets, static dependencies and resolution config before
539
+ reusing it. Changing those inputs rebuilds the memo automatically; a missing,
540
+ damaged or unwritable memo uses ordinary discovery. A memo nothing has read for
541
+ a day, such as a deleted worktree's or a probe config's, goes at the next miss.
542
+ Nothing needs building or running beforehand. Vocabulary factories, selected
543
+ terminal controls and the facets for the process's roles still load their code
544
+ at runtime. A command imports its runtime, selected implementation and those
545
+ facets together; views join that import when the command will draw an answer.
546
+ Literal imports used to derive metadata are tracked too. Imports inside `run`
547
+ callbacks belong to invocation: the memo excludes those callbacks, and the
548
+ selected command loads their current code when it runs.
549
+
550
+ ```ts
551
+ import { subpaths } from './config.ts'
552
+ import { equal } from '@yaks/testing'
553
+
554
+ let [words, absent] = await subpaths([
555
+ ['@yaks/doc', 'vocab'],
556
+ ['@yaks/doc', 'routes'],
557
+ ])
558
+ equal(typeof words, 'object')
559
+ equal(absent, null)
560
+ ```
561
+
562
+ ## Duties: the work nobody is asking for
563
+
564
+ Working the effect pool and each plugin's `./service` export are duties: the
565
+ pool is the `effects` role's, and a service is the role named by its plugin. Any
566
+ number of processes work the pool at once, each claiming a run before it runs
567
+ it. Each service runs under a lease named for its owning package, so only one
568
+ process over a graph runs it at a time, and a process takes only the leases of
569
+ the roles it serves.
570
+
571
+ File hosts answer committed reads in read workers, including preflight, address
572
+ resolution, revision checks and journal polling. A first read starts its worker
573
+ and waits asynchronously. Writes and their transaction reads stay on the owning
574
+ connection; lock acquisition waits between attempts on timers. The schema duty
575
+ runs file upkeep, including planner statistics and index maintenance, on a
576
+ separate thread and connection. Shutdown drains its current window before ending
577
+ that thread.
578
+
579
+ ```ts ignore
580
+ await host.duties() // Run until the host shuts down.
581
+ await host.duties(AbortSignal.abort()) // Run one pass, then release leases.
582
+ ```
583
+
584
+ `yak serve` serves web without a duty thread in its process. It checks live
585
+ process roles and starts an independent `yak work --roles <missing>` for any
586
+ missing duties, using the current executable and module, detached, with null
587
+ output. Service leases remain singleton; duplicate effect workers are allowed. A
588
+ successfully started fallback worker drains when its requesting web process ends
589
+ (`work --tethered`): the web holds the worker's stdin open and never writes it,
590
+ so its close is the web's end on any platform, with no process table read.
591
+ Explicit `yak work` processes, including managed workers, are independent of web
592
+ shutdown. `yak work` composes the graph and duty roles directly; it drains when
593
+ interrupted, when its tether closes, or when its database file is removed or
594
+ replaced. It checks file identity every second. Its `--ready` file announces
595
+ that handlers and graph are assembled, not that an old service has surrendered
596
+ its lease. Other command hosts can still use a duty thread through
597
+ [@yaks/threads](../threads/README.md); [`duties.ts`](./duties.ts) only opens the
598
+ box graph for the roles it is handed. The same package works the pool and leased
599
+ services for independent `yak work` processes.
600
+
601
+ A web checks coverage, including with `--no-duties`: it reads the unexited
602
+ processes once, then follows the process rows its feed hears (what it hears
603
+ while that read is under way is folded into what the read found, since the read
604
+ may have looked first), and every second asks whether the pids of the processes
605
+ known to serve a duty still live; a store with no feed is read whole each
606
+ second. What is uncovered when the web starts, it starts at once, and the web
607
+ listens without waiting for those workers. A duty role lost after that has 30
608
+ seconds (`GRACE`) to be taken up again, as it is when systemd restarts a worker
609
+ in place; one still unserved then reports to the tracker's durable spool, before
610
+ an independent replacement is started. A replacement started sooner would race
611
+ the restarting worker for its service leases and hold them, on the web's code,
612
+ until the web ends. Failed launches are reported and retried; a draining process
613
+ withdraws its duties before its in-flight work ends. Config `duties: false`
614
+ disables this too, for deliberately inert hosts. Readiness names the worker's
615
+ own process.
616
+
617
+ A **process layout** is the config's `processes` list of systemd unit templates.
618
+ `yak work --process <unit>` selects that entry's `roles` (or all duties when
619
+ omitted), minus `except`. An explicit `--roles` selects duties instead, still
620
+ respecting the entry's exclusions. With no `--process`, work serves its given
621
+ roles or all duties. For example:
622
+
623
+ ```json
624
+ {
625
+ "processes": [
626
+ { "unit": "yak-work", "except": ["@yaks/mail"] },
627
+ { "unit": "yak-mail", "roles": ["@yaks/mail"] },
628
+ { "unit": "yak-web" },
629
+ { "unit": "yak-tracker", "optional": true },
630
+ { "unit": "yak-tracker-web", "optional": true }
631
+ ]
632
+ }
633
+ ```
634
+
635
+ The worker templates run `yak work --process yak-work` and
636
+ `yak work --process yak-mail` over the same config, each with its own
637
+ `--ready %t/<unit>-%i.ready`. Web templates run
638
+ `serve --no-duties --share --ready <file>`. A separate tracker template may use
639
+ its own config. `yak restart --config <path>` rolls exactly that config's
640
+ process layout; entries marked `optional` roll only when active. Without a
641
+ process layout it rolls the primary worker and web and active tracker units.
642
+ `yak restart` queues a supervised ready-first handover and returns in seconds.
643
+ `yak restart --config /path/to/yak.json` selects its process layout. Its
644
+ `yak-restart-<uuid>.service` job warms one replacement at a time in the
645
+ background to limit CPU contention. It starts each replacement from its unit
646
+ template, waits for its readiness file, and queues the old units' stops before
647
+ starting the next role. Its journal says which units it started, how long each
648
+ took and which it is stopping.
649
+
650
+ A role whose running units already run what a replacement would is left running,
651
+ so a landing that touched one package interrupts only the processes that load
652
+ it. A process given `--ready` keeps a code record beside its ready file
653
+ (`<unit>-<instance>.code`, ./code.ts): the tree it runs from, the modules it
654
+ imported by a computed specifier (a plugin's facets, the bundler and the browser
655
+ modules it bundled), the files it read in that tree, and its config's digest.
656
+ Once its imports have been quiet for ten seconds, the process computes its own
657
+ module graph by `deno info` in its tree and keeps the files it reaches in the
658
+ record too; its tree never changes, so the graph holds while it runs. The
659
+ handover proves the record against its own tree as the test runner proves a
660
+ pass: the module graph of the record's roots, literal dynamic imports included,
661
+ taken from the record and computed only for the roots it does not cover, with
662
+ every file it reaches, the `deno.json` and `package.json` over each, the lock
663
+ and every file read, compared byte for byte. A unit with no record, or one that
664
+ cannot be proved, is replaced, and its journal line says why each old unit went.
665
+
666
+ A worker is ready once its pool and graph are assembled; the old worker drains
667
+ its steps in flight. A web listens on the old web's shared port before that web
668
+ stops taking requests ([@yaks/api](../api/README.md)). Inactive optional units
669
+ stay untouched. A second restart waits for the running handover, then coalesces
670
+ into a later one that began after it was called, or else rolls again, so it
671
+ always ends with code at least as new as its caller's. Each replacement has two
672
+ minutes to become ready. If a replacement fails to become ready, its
673
+ predecessors keep serving and the handover cleans up that candidate. The job
674
+ reports failures through the ordinary `unit failure` tracker spool. The report
675
+ captures the candidate's systemd state before cleanup unloads its instance.
676
+ Nobody waits on that job before finishing a landing.
677
+
678
+ `yak --no-duties` turns inline duties off for a host that stays up: it takes no
679
+ lease, works no effects, and runs neither the services nor the start-up passes
680
+ `@yaks/session` and `@yaks/spawn` hold a lease for; what it commits is left
681
+ written down for another host. `yak --no-duties serve` answers requests while
682
+ independent workers do the duties; its monitor starts one if needed. Config
683
+ `duties: false` disables inline duties and external recovery for an inert host.
684
+
685
+ `stop()` winds a host down with the graph still open: it aborts `host.stopping`,
686
+ so the duties stop, a server takes no new request and a transcript starts no new
687
+ step, and it leaves the pool, claiming no new run. `close()` does the same,
688
+ closes the duty thread, waits for every effect the host started to finish, and
689
+ after thirty seconds says in the log which ones it is waiting on, repeating
690
+ every thirty seconds ([`drain.ts`](./drain.ts)); then it ends every call its
691
+ runner is still running as `interrupted{code}`, releases leases, records the
692
+ process exit, and closes SQLite. A graph-only CLI writer neither starts nor
693
+ drains an effects pool; it records owed effects for a worker. A prompt drain
694
+ prints nothing. What a run left owed is the next worker's. Plugin timers and
695
+ loops should listen to `host.stopping` or the signal passed to `service`.
696
+
697
+ An interrupt winds a command down (`@yaks/process/wind`, wired in
698
+ [`yak.ts`](./yak.ts)): a SIGTERM, SIGINT or SIGHUP, or Ctrl-C in a terminal app.
699
+ The first stops every graph the command opened, so `yak serve` stops taking
700
+ requests, answers the ones in flight and returns, and the command closes the way
701
+ it always does once its effects have finished. Nothing here puts a deadline on
702
+ that for interactive commands. A second interrupt ends their duty thread where
703
+ it stands, closes with the interrupt's code (143, 130, 129) and exits.
704
+
705
+ `yak work` gives in-flight session steps ten seconds to finish after shutdown
706
+ starts. A step still waiting hands its admitted request back with its recorded
707
+ output. After 55 seconds the worker fences any remaining effect claims and hands
708
+ them back for recovery at the 60-second deadline. It exits with a failure if the
709
+ drain reaches that point, even if the handoff write is blocked. The replacement
710
+ can recover the durable claims when their leases expire.
711
+
712
+ ## Shared command grammar
713
+
714
+ Import `@yaks/cli/grammar` for command parsing and completion in a browser or
715
+ another host that does not need the CLI runtime. Both functions read the same
716
+ `Grammar` descriptors: command names, `inputSchema`, optional `positional`, and
717
+ `short` on input properties. A final positional suffixed `...` takes every
718
+ remaining bare word. A browser caller does not need a separate argument parser.
719
+
720
+ ```ts
721
+ import { argsFor, complete, type Grammar } from '@yaks/cli/grammar'
722
+
723
+ let greet: Grammar = {
724
+ name: 'greet',
725
+ inputSchema: {
726
+ type: 'object',
727
+ properties: { name: { type: 'string', enum: ['Ada', 'Lin'] } },
728
+ required: ['name'],
729
+ },
730
+ }
731
+
732
+ await argsFor(greet, ['--name=Ada']) // { name: 'Ada' }
733
+ await argsFor(greet, ['--name', 'Ada']) // { name: 'Ada' }
734
+ await complete([greet], 'greet --name A') // ['Ada']
735
+ ```
736
+
737
+ `argsFor(tool, argv, reads?)` returns a promise of the typed, validated argument
738
+ object, including schema defaults. It accepts `name=value`, `--name=value` and
739
+ `--name value`, declared short options, boolean flags, positional arguments, and
740
+ repeated list options; `--` ends option parsing. Invalid input throws `Usage`.
741
+ File and stdin expansion (`@path`, `-`, `@-`) happens only when the host
742
+ supplies `Reads{file, stdin}`; without it, those words stay literal.
743
+
744
+ `complete(tools, line, look?)` returns a promise of whole replacement words, not
745
+ suffixes. `line` may be a string or a words array. It offers commands, options
746
+ and schema values (enums, booleans and examples), recognizing both option-value
747
+ forms. Optional `Lookup{ids, hits}` callbacks supply entity IDs and full-text
748
+ matches without putting graph IO in the grammar.
749
+
750
+ ## The command line
751
+
752
+ `cli(commands, opts)` parses and runs one command and returns an exit code:
753
+
754
+ | Code | Meaning |
755
+ | ---- | ---------------------------------------------- |
756
+ | `0` | Success |
757
+ | `1` | A tool or server refused or failed the request |
758
+ | `2` | Invalid command-line usage |
759
+
760
+ A program with commands of its own runs
761
+ `Deno.exitCode = await cli([helpTool(opts), ...commands], opts)`.
762
+
763
+ Commands earlier in the array take precedence. A graph's tools become commands
764
+ unless their `surfaces` leaves out `cli`. Tools with a noun and verb can be
765
+ written in either order, such as `yak task list` or `yak list task`. The usage
766
+ page groups verbs under their noun. `yak graph`, `yak graph --help`, and
767
+ `yak help graph` print the commands in the `graph` group.
768
+
769
+ | Global flag | Meaning |
770
+ | ----------------- | ------------------------------------------------------------------------ |
771
+ | `--config <path>` | Open the graph described by a local config. |
772
+ | `--host <host>` | Call a remote MCP server. |
773
+ | `--json` | Print structured results as JSON. |
774
+ | `--tui` | Hold the answer in the terminal until Ctrl-C, drawn by plugins' `./tui`. |
775
+ | `--timing` | Print response timing to stderr. `$YAKS_TIMING=1` enables it globally. |
776
+ | `--no-duties` | No inline duties; serve still monitors and restores independent workers. |
777
+ | `--help`, `-h` | Print general or command-specific help. |
778
+
779
+ An argument value written as `@path` is read from that file; `-` reads from
780
+ stdin. Strings stay literal: `--body null` writes the word `null`, as does a
781
+ file containing that word. For a nullable input, `--clear <field>` supplies JSON
782
+ `null`; repeat it to clear several fields:
783
+
784
+ ```sh
785
+ yak task update T-42 --clear blocked --clear priority
786
+ ```
787
+
788
+ `yak apply` accepts a JSON array or newline-delimited JSON. For streamed input,
789
+ it groups bundles into batches of 50; `--dry-run` validates and reports the
790
+ result while rolling back the transaction.
791
+
792
+ `yak graph apply --restore` accepts supplied server-owned values, including
793
+ historical `at`, `by` and `via`, in the local graph a config names. Admission,
794
+ guards, rules, stamps, indexes and journaling still run; the current caller
795
+ writes the journal entry. `--check` rehearses the restoration and rolls it back.
796
+ The flag is refused when the command names a remote MCP server.
797
+
798
+ ```sh
799
+ yak graph apply --config ./yak.json --bundles @history.json --restore --check
800
+ yak graph apply --config ./yak.json --bundles @history.json --restore
801
+ ```
802
+
803
+ For a repair that must preserve provenance, `--restore --stamp=false` accepts
804
+ the supplied stamps without generating new ones. Guards, rules, reference
805
+ admission and journaling still run, and the journal records the current writer.
806
+
807
+ Remote authentication uses `$YAKS_TOKEN` when set. Otherwise,
808
+ `yak auth yaks.app` signs in through OAuth. The sign-in is a connection in the
809
+ configured graph, which needs @yaks/connections among its plugins; `yak init`'s
810
+ config has it. A machine with no graph creates a small personal graph in its CLI
811
+ state directory on its first `yak auth`.
812
+
813
+ `--as <account>` is optional on commands that reach yaks.app. An agent session
814
+ on the shared box defaults to `checks@bot.yak.sh`. Select `--as admin` for
815
+ platform operations. For other CLI calls, the connection whose account matches
816
+ the configured person's own address wins, with the oldest connection as
817
+ fallback. `YAKS_TOKEN` still supplies a sandbox bearer without opening a graph.
818
+
819
+ Global flags stay separate from tool arguments. For a tool property with the
820
+ same name, use `name=value`. This selects the installer's account and names the
821
+ copy `my-books`:
822
+
823
+ ```sh
824
+ yak app_install --name reading-list as=my-books --as installer
825
+ ```
826
+
827
+ Omit `as=my-books` to let `app_install` choose the copy's address.
828
+
829
+ A local plugin can explicitly bind a global flag to one of its tool inputs by
830
+ exporting `globals` from its `./cli` facet, keyed by tool name. For example,
831
+ `export let globals = { admin_fee: ['as'] }` supplies the selected account to
832
+ `admin_fee`'s `as` input. Commands passed directly to `cli` declare the same
833
+ binding on `Command.globals`.
834
+
835
+ A local plugin's `./cli` facet can also export `tools`, keyed by an existing
836
+ tool name. Each callback receives validated arguments and the CLI context,
837
+ without opening a graph. Returning an exit code finishes the invocation;
838
+ returning `undefined` delegates to the ordinary tool runner. Remote calls always
839
+ use the graph tool. For example, `@yaks/session` answers prompt timing from the
840
+ local transcript and delegates session creation to the graph:
841
+
842
+ ```sh
843
+ echo '{"hook_event_name":"UserPromptSubmit"}' | yak session context --hook -
844
+ ```
845
+
846
+ | File | Contents |
847
+ | ------------------------------ | ----------------------------------------------------------------------- |
848
+ | `accounts.json`, `accounts.db` | The personal account graph on a machine with no configured graph |
849
+ | `secrets/` | Private vault beside the account graph; no token in graph text |
850
+ | `tools.json` | Per-host tool schemas, protocol version, roster version, and vocabulary |
851
+
852
+ The tool cache avoids an MCP round trip for ordinary calls. A server response
853
+ that reports a changed roster invalidates the cache, and an `about` naming a
854
+ version the cache is not stamped with lists the tools again and stamps them with
855
+ it. A command line the cached schema refuses, such as an argument a release
856
+ added, is read against a fresh list once before it is refused.
857
+
858
+ The package exports eight entry points:
859
+
860
+ - `@yaks/cli` exports command parsing, schema conversion, display and completion
861
+ helpers, MCP transport, token and roster storage, config reading, remote tool
862
+ listing and app-command adapters. It is what the command is built from, not
863
+ the command: importing it starts nothing. Browser callers use the IO-free
864
+ `@yaks/cli/grammar` entry point rather than the CLI runtime.
865
+ - `@yaks/cli/grammar` is the browser-safe command grammar and completion entry
866
+ point, with no runtime IO: `argsFor`, `complete`, command lookup and token
867
+ helpers, and the `Grammar`, `Reads`, `Lookup`, `Prop` and `Schema` types.
868
+ - `@yaks/cli/yak` is the command: the executable `main`, its built-in commands,
869
+ and the `YAK`, `TOOLS` and `HOST` defaults it runs with. Run it directly or
870
+ pass additional commands to `main(argv, extra)`.
871
+ - `@yaks/cli/config` reads a config file: where its graph is, the plugins it
872
+ names, and the release a plugin named without a version comes from. It imports
873
+ no plugin, for a command that only needs to know where the graph is.
874
+ - `@yaks/cli/host` exports the facet loader, `compose`, and re-exports portable
875
+ host types from `@yaks/host`, and the box's `CliCommand`, `person`, `read` and
876
+ `dbOf`. Portable facet contracts and graph assembly belong to `@yaks/host`.
877
+ - `@yaks/cli/install` is the installer: run it and `yak` is on PATH at the
878
+ installer's own release, under a config that lets Deno resolve that release
879
+ the day it publishes.
880
+ - `@yaks/cli/release` exports that config (`released`), for anything else that
881
+ resolves a release from JSR, as `@yaks/cli/page`'s bundler does.
882
+ - `@yaks/cli/page` is what a plugin's `./routes` serve a page with: `kept`
883
+ answers an address with a body made once and kept for the process, bounded,
884
+ healed on its next request after a failure, and ended as its host closes;
885
+ `bundle(entry, signal)` makes a page's script and everything it imports into
886
+ one browser module with esbuild and Deno’s module resolver, from a file or
887
+ from an entry written for the host (`Written`: its code, and where its imports
888
+ resolve from). `split(entries, signal)` makes several of a checkout's page
889
+ scripts in one build, what they share in chunks they import from the site's
890
+ `/_yak/` (`imports` reads which). It loads esbuild only when it makes a body,
891
+ so a host that serves only bodies a release made ahead downloads none.
892
+ @yaks/web serves the application its plugin config chooses through a
893
+ contributed `./web` facet, such as @yaks/browse.
894
+
895
+ Application commands use `yak command <name> [arguments] --app <app>`, or the
896
+ short form `yak <app> <name> [arguments]`, as the selected yaks.app connection.
897
+ The command's `vocab.json` declares `positional` beside `input`, with a final
898
+ `...` suffix for every remaining bare word, and `short` on the input property it
899
+ shortens. Without `positional`, it takes only named arguments (`name=value` or
900
+ `--name value`). Its input schema decides each value's type; `@path` reads a
901
+ file and `-` reads stdin. `--app` selects an app when several share a command
902
+ name. A graph tool with the same command name takes precedence.
903
+
904
+ The same optional `--as` selects an account for connector tools and app
905
+ commands; no separate admin forwarding command is needed.
906
+
907
+ ```sh
908
+ yak where matt
909
+ yak app_list --space checks --as checks
910
+ yak app_errors --space checks --app vale --as checks
911
+ ```
912
+
913
+ ### Reporting outside the watched graph
914
+
915
+ `tracker: {spool: "tracker-spool"}` names the file spool relative to the config
916
+ file. Hosts report unexpected tool, effect, request and duty failures there,
917
+ tagged with their handler and target. Reports contain no letter or tool
918
+ arguments and open no tracker database. The separate @yaks/tracker role imports
919
+ the spool using its own config and database. Its configured remote tracker
920
+ receives failures through signed intake before the spool is acknowledged, so an
921
+ outage leaves failures ready for retry. The task graph keeps no tracker error
922
+ rows. Console telemetry remains enabled.
923
+
924
+ The daily `bin/backup` uses this same reporter for nonzero exits, including its
925
+ hard timeout. Its supervisor stays outside the bounded backup child, forwards
926
+ stdout and stderr to the cron log, and retains only the last 8 KiB of stderr in
927
+ the error. The report has `during.kind=backup` and `job`/`exit_code` tags;
928
+ intake groups it into a bug like other box errors. A successful backup writes no
929
+ report. Reporting failure never changes the backup's exit code. A restore
930
+ (`bin/backup restore`) is a person's: it runs unbounded and reports nothing. The
931
+ newest seven completed nights stay in `snapshots/`; older and incomplete nights
932
+ move to `trash/snapshots/`, which is never automatically purged.
933
+ `bin/backup restore <new dir> trash/<night>` restores a completed trashed night.
934
+ Failed and interrupted local snapshot work moves into private
935
+ `~/.yak/trash/backups/` records with its original path, time and bytes. The
936
+ filesystem `restore(record)` operation recovers it. Interrupted runs discard raw
937
+ database copies when the retained compressed copy decodes to the same bytes.
938
+ Unique local snapshots are kept.
939
+
940
+ Before copying databases, the nightly job trims local filesystem trash to 8 GiB,
941
+ process output trash to 2 GiB, and the selected build and download caches to 8
942
+ GiB combined. It evicts older entries first and preserves entries modified
943
+ within the last day.
944
+
945
+ The existing cron command invoking `bin/backup` needs no change. It reads the
946
+ box config (`$YAK_CONFIG`, otherwise `$HOME/.yak/yak.json`) only for reporting,
947
+ and the vault beside the data dir only for the R2 key pair; it opens no graph.
948
+ To use another spool, set `YAK_CONFIG=/path/to/yak.json` on that cron command.
949
+ Keep its existing `>> ~/.tasks-backup.log 2>&1` redirection. `YAK_BACKUP_BOUND`
950
+ is internal to the supervised child, not a cron setting.
951
+
952
+ ### Box request traces
953
+
954
+ Every box host records request, effect and apply span trees in memory. HTTP
955
+ `/query`, `/apply`, the web UI's applies, socket messages (`ws subscribe`,
956
+ `ws unsubscribe`, `ws relay`, `ws message`) and subscription refreshes
957
+ (`ws
958
+ refresh`) retain phase, plugin and SQL ancestry. A reader thread returns
959
+ its query/SQL tree and counts to the requesting server; it does not send a
960
+ duplicate trace. A streamed import has an independent `http stream apply` root
961
+ lasting through the whole import rather than only the HTTP response head.
962
+
963
+ Only selected completed roots go to `tracker.spool`: work strictly over 10,000
964
+ rows read or written, an armed capture, or an ordinary random sample. Automatic
965
+ traces are admitted once per operation and code name per rolling hour in a host;
966
+ suppressed repeats accompany the next admitted trace as root `repeats{n}`.
967
+ Captures and samples bypass that automatic quota. Sampling defaults to zero.
968
+ Unselected trees stay in memory only: no extra SQL, projection or delivery. A
969
+ tree is held until its root ends, so one whose root outlives its work (an effect
970
+ that watches for the life of the process) is cut back past `4 × TRACE_MAX_SPANS`
971
+ spans to the ones `@yaks/timing`'s `held` names. There are no per-minute timing
972
+ rows. Traces use `@yaks/timing`'s span entities and independent metric
973
+ components, not JSON trees in the watched store.
974
+
975
+ Arm the next operations without opening the database:
976
+
977
+ ```sh
978
+ yak trace --config /path/to/yak.json --next 3
979
+ yak trace --config /path/to/yak.json --rate 0.01
980
+ # Only the already-running web server consumes this capture:
981
+ yak trace --config /path/to/yak.json --process <serve-pid> --next 3
982
+ # Disable ordinary sampling for that process:
983
+ yak trace --config /path/to/yak.json --process <serve-pid> --rate 0
984
+ ```
985
+
986
+ `--next` replaces the remaining capture count; omitted settings are unchanged.
987
+ `--rate` is a probability from zero to one. Without `--process`, next captures
988
+ are shared across processes over that database. A PID-specific rate overrides
989
+ the shared rate; PID-specific pending captures are consumed before shared ones.
990
+ The controls are persisted in `<db>.trace.json`, with advisory locking for
991
+ capture consumption and a 250 ms unref poll updating each host's cache. Idle
992
+ requests consult memory only. The command can arm an absent database and never
993
+ opens or creates it; the sidecar directory must be writable. Controls do not
994
+ require a service restart. To target the web server, use its `yak serve` PID,
995
+ not a `yak work` PID.
996
+
997
+ The separate tracker config must compose `@yaks/timing` beside `@yaks/tracker`
998
+ and its browser/inspect plugins. Both the watched config's `tracker.spool` and
999
+ the tracker service's `with.spool` name the same spool directory. Browse
1000
+ `/?.trace` on the tracker for grouped traces and each trace's flamegraph and
1001
+ places list.
1002
+
1003
+ ### Reporting systemd unit failures
1004
+
1005
+ `yak unit failure <unit> --config <config>` is an `ExecStopPost` command. It
1006
+ reads systemd's `SERVICE_RESULT`, `EXIT_CODE`, `EXIT_STATUS` and `INVOCATION_ID`
1007
+ and writes a failed unit to the config's tracker spool without opening its
1008
+ graph. This includes failures that the unit's main process cannot report itself,
1009
+ such as a stop timeout or SIGKILL. A successful stop reports only when it leaves
1010
+ its template with no other active instance ready (its
1011
+ `$XDG_RUNTIME_DIR/<template>-<instance>.ready` file). Restarting or stopping the
1012
+ only web in place with `systemctl` is that: every connection is refused until
1013
+ another listens. A `yak restart` handover stops old units only once their
1014
+ replacements are ready, and a user manager that is stopping stops everything, so
1015
+ neither reports. `yak restart` keeps a role whose units already run its code;
1016
+ `yak restart --replace yak-work` hands that role over anyway, the ready-first
1017
+ way to restart one role.
1018
+
1019
+ Install `yak-unit-handoff.conf` in `yak-work@.service.d` to cover direct systemd
1020
+ stops and in-place restarts of the worker. Its `ExecStop` hook starts a peer and
1021
+ waits for it to be ready before the last ready worker drains. After an in-place
1022
+ restart, the peer drains once the restarted worker is ready. The hook skips
1023
+ replacement when the user manager is shutting down.
1024
+
1025
+ Install `yak-unit-failure.conf` as `tracker.conf` in each user unit template's
1026
+ drop-in directory (`yak-web@.service.d`, `yak-work@.service.d`,
1027
+ `yak-tracker@.service.d`, and `yak-tracker-web@.service.d`). The report runs
1028
+ after the template's own `ExecStopPost` lines, and systemd skips it when one of
1029
+ them fails, so each carries `-` (`ExecStopPost=-/usr/bin/rm -f …`). The config
1030
+ must name the spool consumed by tracker intake. Reload the user manager after
1031
+ installing the drop-ins; use `yak restart` for a ready-first handover.
1032
+
1033
+ `bin/limits` runs the servers in `yak.slice`, gives them the CPU before anything
1034
+ else on the box, keeps them an 8 GB floor of memory for the yak.db pages they
1035
+ read, and caps the memory and disk for everything else, so neither sessions'
1036
+ tests nor bulk work can slow their reads. On the host it limits how much each
1037
+ process may leave dirty, by its memory, so a capped job's queue cannot hold the
1038
+ shared ext4 journal and a server waits only on its own writes. Each session gets
1039
+ 6 GB and all of them together 16 GB; a session over its cap loses its largest
1040
+ process.
1041
+
1042
+ ```sh
1043
+ # Inside a systemd service's [Service] section:
1044
+ ExecStopPost=%h/.deno/bin/yak unit failure %n --config %h/.yak/yak.json
1045
+ ```
1046
+
1047
+ ### Worker inspection and unit failures
1048
+
1049
+ `YAK_WORK_INSPECT=0 yak work --config /path/to/yak.json` starts a loopback
1050
+ inspector on an automatically assigned port, printed by Deno. A fixed port
1051
+ (`YAK_WORK_INSPECT=9237`) is for a single worker only: overlapping workers
1052
+ during a ready-first handover cannot share it. Set profiling configuration only
1053
+ on the worker being inspected, and remove it after profiling.
1054
+
1055
+ `yak unit failure <unit> --config /path/to/yak.json` is the ExecStopPost door.
1056
+ It includes the last 40 journal lines (at most 8192 characters) from the failed
1057
+ invocation as the `stderr` report tag. These units merge stdout and stderr in
1058
+ the journal, so this includes both. If the user's journal has no output, it
1059
+ tries `sudo -n journalctl` with the same unit, invocation and uid filters;
1060
+ unavailable journal access never suppresses the exit metadata report.