1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
//! # trusty-mpm-core
//!
//! Why: Shared types used by every trusty-mpm crate (daemon, CLI, TUI, Telegram).
//! Centralizing them prevents protocol drift between the daemon and its clients.
//!
//! What: Defines the artifact model (agents, skills, hooks), session state types,
//! and the IPC protocol envelope exchanged over the daemon's local socket / HTTP API.
//!
//! Test: `cargo test -p trusty-mpm-core` exercises serde round-trips and the
//! claude-mpm frontmatter parser against fixture files.
// #7727: every deploy shape resolves `{{TM_SKILLS}}` to files that exist.
// #4840: bundled agent assets reached `$CLAUDE_CONFIG_DIR/agents/` only via a
// manual `tm install`; this module makes the refresh+deploy automatic.
// #6495: the classic-renderer default every managed launch carries. Claude
// Code's fullscreen renderer captures the mouse wheel, costing the pane both
// native and tmux scrollback.
// #7673: memory files ABOVE the project root — the scan, the launch WARN, and
// the two `tm doctor --fix` repairs (rename a seed aside, exclude a real one).
// #6807: the attribution footer is one constant, shared by the settings seed
// and the `tm pr open` body validator.
// #5069: the base checkout behind a worktree owns the embedding lane that
// `worktree_index` deliberately skips; this module is what creates it.
// #7965: the one kill-on-timeout subprocess runner every background sweep uses,
// so a wedged `git`/`gh` child can never pin a blocking-pool thread for the life
// of the daemon.
// #7956: `pub` rather than `pub(crate)` — the `tm` binary is its own
// compilation unit, and `tm wait --for check` needs the same one runner so a
// wedged `gh` cannot carry an invocation past its slice into a SIGKILL.
// #6868: the machine-level `build:` section — the shared cargo target
// directory, the job count, and the sccache posture the `rust_build_env` doctor
// row reports and its `--fix` arm seeds.
// #8261 increment two: the build-command lease — a machine-wide flock slot per
// heavy build, admitted against memory pressure, load and the process census.
// #8297 (absorbed into #8261): what is actually compiling on this host — the
// process-table census that counts builds holding no lease.
// #7822: the build fingerprint `tm doctor` compares when two semvers agree —
// a same-version daemon started before the installed binary was written is
// still stale, and semver alone cannot say so.
// Epic #4183: the DEFAULT (bundled-fallback) PM prompt, re-sourced through
// `instruction_package`. Byte-identical to the legacy assembly it replaces; the
// override configurations stay on that legacy path by design.
// #6649: one asset name claimed by two entries inside ONE tier — the collision
// every tier-vs-tier probe is structurally unable to see.
// #4442/#4448: the ONE bundled-agent name roster, shared by `tm doctor`'s
// asset_tier probe (which reports) and the quarantine (which moves).
// DOC-28 cutover bridge: incremental catch-up runtime — CUTOVER BRIDGE — remove post-migration (#1762)
// Issue #4467: the shared set of Claude Code process-local session markers every
// managed spawn must scrub. An inherited `CLAUDE_CODE_CHILD_SESSION` makes
// Claude Code disable transcript saving, costing the session native
// `--resume`/`--continue`/`/rewind` recovery.
// #7673: the three-outcome downward scan for child git repositories — found,
// clear, or could not finish — behind the workspace-parent seed refusal.
// Epic #4183 / #4286: the READER for `CLAUDE.md` named-section instruction
// overrides. Ships before the floor text that advertises the mechanism —
// advertising an override no code reads is issue #381 verbatim.
// #7673: Claude Code's `claudeMdExcludes` key — read across layers, extended by
// `tm doctor --fix`.
// #7673: is a CLAUDE.md tm's own seed template, and may tm seed one here? The
// root-cause guard for the $HOME seed-template incident.
// #7673 round 3: the git-init-offer half of the seed-site guard, split out so
// `claude_md_seed.rs` stays a focused shape/site pair under the SLOC cap.
// Issue #4754: the WRITER counterpart to `claude_md_sections` — the single
// owner of `CLAUDE.md` section-override edits. Idempotent by construction, and
// it borrows the reader's grammar rather than spelling a second one.
// Issue #4072: one process-wide lock every `~/.claude.json` read-modify-write
// seeder holds, so concurrent daemon provisioning cannot lose a trust entry.
// DOC-28 cutover bridge: cross-format session discovery — CUTOVER BRIDGE — remove post-migration (#1762)
// #6892: the machine-wide builder-slot cap — the `[builders]` config section,
// the memory-tier default table, and the one host-root resolution site.
// #8261: the pool of persistent per-slot `CARGO_TARGET_DIR` directories a
// leased builder compiles into, so concurrent builds stop serialising on one
// shared cargo build-directory lock.
// #7123: the component labels an issue audit ACCEPTS — the seed table plus the
// repository's own crate labels. Distinct from `policy_labels`, which answers
// which labels the harness CREATES.
/// Unrecognised-key reporting for the host-level config files (#5207).
// #9011: the agent roster and harness docs resolve from content here.
// #9012: skills, instructions, output styles and SM instructions from content.
/// The `disk.max_usage_pct` gate every worktree-creation path consults (#7497).
/// Working-tree isolation policy for native Agent-tool dispatches (#4480).
// #7678: `tm doctor --fix`'s session-scope arm — re-applies the plugin and MCP
// scope writes to a live project through the launch path's own writers.
// #8510: the gh config dirs an account-only pin may ask for a candidate token.
pub
// #8510: proves a candidate token is the pinned account's with `GET /user`.
pub
// #5850: the ProjectRegistry half of `gh_account`, read synchronously for a
// daemon-side checkout. `pub(crate)` throughout — nothing outside this crate
// resolves a pin from a bare directory.
pub
// #9091: asks gh about a login in the daemon's env and in tm's account dirs.
pub
// #9091: `[accounts]` org → gh account map and the one account resolver.
// #8914: `--account` sessions run gh and HTTPS git as the account named.
// #7059: the in-process stand-in for the scoped `gh` subprocesses — a test
// seam, compiled out of every `--release` build (see the module docs).
// #8511: keep the harness's own files out of every registered project's `git status`.
pub
// #8545: a test binary's fence around the operator's home config paths.
// #8407: classifies a pane's input box as empty, suggestion, or typed.
// Issue #7616: the compose-time fold — the one transformation between the
// authored section corpus and the bytes delivered to the PM.
// Issue #4184 / epic #4183: the sectioned-JSON instruction package schema. Types
// + validation only; `bundled_pm_package` is its first composing call site.
// Issue #8533: the one enumeration of the prompt content no project override
// can remove.
// Epic #4183: committed snapshots of the fully composed PM prompt. The
// delivered-prompt diff a content change produces is the review artifact.
// #7097: `tm issue audit` — the mechanical read-back of the #7067 ticketing
// standard. `issue_audit` is the pure evaluation, `issue_audit_gh` the `gh`
// reads that feed it; both live here rather than in `bin/tm` because the
// `issue_audit_recent` doctor check runs from the library.
// ADR-0055 / #6000: the local-path `repo_url` rule and its typed refusal,
// shared by every `session_new` entry point.
// #4181: per-project MCP pins now travel as spawn environment variables, not as
// arguments injected into a workspace `.mcp.json` (ADR-0042).
// #7685: `tm memory import-auto-memory` — the migration that makes zeroing
// Claude Code's `MEMORY.md` safe.
// #7685: auto memory is a FALLBACK — every write site that turns it off asks
// this module whether trusty-memory is available first.
// #8352: `tm memory recall|remember|note` — palace access over the daemon
// socket, so a dead MCP connection does not cut the session off from memory.
// #9340: `tm memory forget` — the forget-specific half of `memory_verbs`.
// #9544: `tm memory rename` — trusty-memory's `palace_rename` over the socket.
// DOC-28 cutover bridge: unified session finder — CUTOVER BRIDGE — remove post-migration (#1762)
// #4058: single canonical source for the crate's own `[[bin]]` names, so
// discovery/hooks/statusline/daemon-PID lists can't drift out of sync again.
// The labels trusty-mpm applies by policy, shared by session launch and
// `tm issue seed-labels` (#6914). Doc lives in the module's own `//!` header —
// an outer `///` here would resolve its intra-doc links in THIS scope and break
// them (`check_rustdoc_links.sh`).
// #7275: deterministic post-merge cleanup — the executor behind
// `tm pr cleanup <n>`, shared by `tm pr merge`'s final step and the
// supervisor's periodic merged-PR sweep.
/// The committed, project-level `.trusty-mpm.toml` config surface (#5207).
// #7892: `.mcp.json` follows Claude Code's own approval flow, so tm reports
// that state rather than deciding it.
// #4880: the project skill tier redeploys on project-manifest change.
// #6649: `tm doctor --fix-agents` sweeps bundled AGENT copies stranded at the
// project tier — the ledger-proven mirror of `project_tier_strays`.
// #6586: `tm doctor --fix-skills` sweeps bundled copies stranded at the project
// tier by a pre-#6602 deploy.
// #7688: the captured `## Prompt feedback` ledger — extract, append, read back.
// #7688: the `prompt-self-improvement` flag and the two addenda it injects.
// #7171: idempotently disables git's own background maintenance/gc on a
// managed checkout, so an OPERATOR running git directly inside one of its
// worktrees (outside anything that routes through `trusty_common::git`)
// still gets the quieted repo.
// `tm reinstall`: the two-hop asset redeploy across every deploy destination,
// and the install-provenance route its `--binary` flag takes.
// #4462: whether a `--path` install source is behind `origin/main` — the one
// global `tm` binary regresses every session at once when it is.
// #7748: whether the local `origin/<base>` a three-dot diff is taken against is
// the remote's tip — the pre-push credential scan's base, fail-closed.
// #8934: the one "has an origin remote / local-only" predicate and the no-gh pin.
// #9124: the one helper that strips `user:token@` from a URL before it reaches
// a log line or an error message.
// #6958: the per-session token-savings ledger every producer appends to, and
// the instruction/language-compression producer that writes the first row.
// The `tm compress` tool-output producer, the ledger's third row source — what
// makes the 💸 segment include bash and gate output, not just prompts and reads.
// #6959: the bulk-read diversion producer, the ledger's second row source.
// #7569: the one-shot repair that quarantines the ledger rows #7514's resolver
// bug let unit tests write into the operator's own ledger.
// #7245: the side files that carry an instruction-compression row from the
// compiling process to the hook that learns the session id, and that keep the
// "nothing folded" decline to one warning per project.
// #7422: default-deny MCP scoping — a session loads the trusty-* builtins, the
// project's own `.mcp.json`, and only the shared servers the project opts into.
// #6972: which model the parent session runs, remembered by the statusline hook
// so the divert producer prices its rows at the parent's real rate.
// #8453: the PM or supervisor instruction profile a session runs.
// #7282: a pause snapshot reaches `origin/main` through its own branch and PR,
// never as a commit on whatever branch the main checkout happens to be on.
// #7830 / ADR-0062: session history is an orphan, append-only commit chain in
// `refs/tm/sessions/<user>/<key>` — never a commit on a code branch.
// #7422: the plugin half of the same default-deny decision — written into the
// project's `.claude/settings.json`, because Claude Code has no plugin flag.
// #7678: what a project's `.claude/settings.json` still owes that plugin write —
// the one comparison the doctor check, the preview and the writer all read.
// #7617: which Claude session ids share a managed session, so a restart does not
// read as a savings disappearance.
// #7762: the one cross-process critical section and `.bak`-free atomic publish
// every `settings.json` writer in this crate goes through.
pub
// #7751: the stack-to-skill-family table behind the project-tier skillOverrides.
// #7424: the turn-1 startup-context reading, its store, and the doctor verdict.
// #6556: a `SubagentStop` the hook could not deliver, parked on disk where the
// daemon's reap loop replays it — instead of the record sitting Running for the
// six hours of `RUNNING_STALE_AFTER_SECS`.
// #7617: the one seed-or-repair rule for the `statusLine` settings entry, which
// every tier's writer and `tm doctor --fix` go through.
// #6542: each test binary's private default tmux server; test support only.
// #8878: the supervisor-twin identity (D1) and its arming record.
// #8878 ruling A: the Architect is bound to the `claude` tm launched for it.
// #8878 R1: the Architect's tmux session name, recorded at launch.
// #8981: the Architect's conversation id, resumed by the next `tm fleet init`.
// #8942 ruling 2: `tm fleet init` prunes a sidecar only for a proven-dead launch.
// #8572: dirty-tree probe for the main-checkout HEAD-switch guard.
// #7889: route (c) of the landing admission — HEAD inside a merged PR's history.
// #7889: the landed-content admission both reclaim ladders share.
// #8633: the merge-into-base question, including a base that moved on.
// #8994: the machine-wide append-only worktree ledger.
// See ADR-0057 — the facts the pm-guard's removal re-checks ask git and GitHub.
pub use ;
pub use ;
pub use ;