trusty-mpm 1.8.2

trusty-mpm: unified multi-agent orchestration platform (core, daemon, CLI, TUI, Telegram)
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.

pub mod agent;
pub mod agent_builder;
pub mod agent_cost;
pub mod agent_deployer;
// #7727: every deploy shape resolves `{{TM_SKILLS}}` to files that exist.
pub mod agent_manifest;
pub mod agent_metadata;
pub mod agent_reset;
pub mod agent_reset_workspace;
pub mod agent_skill_codeploy;
#[cfg(test)]
mod skill_root_deploy_tests;
// #4840: bundled agent assets reached `$CLAUDE_CONFIG_DIR/agents/` only via a
// manual `tm install`; this module makes the refresh+deploy automatic.
pub mod agent_source;
// #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.
pub mod alt_screen;
// #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).
pub mod ancestor_claude_md;
pub mod ancestor_claude_md_repair;
pub mod artifact;
// #6807: the attribution footer is one constant, shared by the settings seed
// and the `tm pr open` body validator.
pub mod attribution;
pub mod auto_resume;
// #5069: the base checkout behind a worktree owns the embedding lane that
// `worktree_index` deliberately skips; this module is what creates it.
pub mod base_facet_index;
pub mod binary_provenance;
// #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.
pub mod bounded_proc;
pub mod budget;
// #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.
pub mod build_env;
pub mod build_env_repair;
// #8261 increment two: the build-command lease — a machine-wide flock slot per
// heavy build, admitted against memory pressure, load and the process census.
pub mod build_lease;
// #8297 (absorbed into #8261): what is actually compiling on this host — the
// process-table census that counts builds holding no lease.
pub mod build_probe;
// #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.
pub mod build_identity;
pub mod bundle;
// 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.
pub mod bundled_pm_package;
// #6649: one asset name claimed by two entries inside ONE tier — the collision
// every tier-vs-tier probe is structurally unable to see.
pub mod asset_duplicates;
// #4442/#4448: the ONE bundled-agent name roster, shared by `tm doctor`'s
// asset_tier probe (which reports) and the quarantine (which moves).
pub mod bundled_roster;
// DOC-28 cutover bridge: incremental catch-up runtime — CUTOVER BRIDGE — remove post-migration (#1762)
pub mod catchup;
pub mod circuit;
pub mod claude_config;
// 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.
pub mod claude_env_scrub;
// #7673: the three-outcome downward scan for child git repositories — found,
// clear, or could not finish — behind the workspace-parent seed refusal.
pub mod child_repo_scan;
// 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`.
pub mod claude_md_excludes;
pub mod claude_md_sections;
// #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.
pub mod claude_md_seed;
// #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.
pub mod claude_md_seed_git;
// 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.
pub mod claude_md_writer;
// Issue #4072: one process-wide lock every `~/.claude.json` read-modify-write
// seeder holds, so concurrent daemon provisioning cannot lose a trust entry.
pub mod claude_json_guard;
// DOC-28 cutover bridge: cross-format session discovery — CUTOVER BRIDGE — remove post-migration (#1762)
pub mod claude_mpm_registry;
pub mod claude_mpm_session;

// #6892: the machine-wide builder-slot cap — the `[builders]` config section,
// the memory-tier default table, and the one host-root resolution site.
pub mod builders;

// #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.
pub mod builder_slot_pool;

// #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.
pub mod commit_trailers;
pub mod component_labels;
pub mod compress;
pub mod config;
/// Unrecognised-key reporting for the host-level config files (#5207).
pub mod config_keys;
pub mod connect;
// #9011: the agent roster and harness docs resolve from content here.
pub mod content_source;
// #9012: skills, instructions, output styles and SM instructions from content.
pub mod daemon_identity;
pub mod delegation_authority;
pub mod deploy_validate;
pub mod deterministic_overseer;
pub mod discovery;
/// The `disk.max_usage_pct` gate every worktree-creation path consults (#7497).
pub mod disk_usage_guard;
/// Working-tree isolation policy for native Agent-tool dispatches (#4480).
pub mod dispatch_isolation;
pub mod doctor;
pub mod doctor_repair;
pub mod framework_content;
// #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.
pub mod doctor_repair_scope;
pub mod error;
pub mod exit_codes;
pub mod external_session;
pub mod frontmatter;
pub mod gh_account;
// #8510: the gh config dirs an account-only pin may ask for a candidate token.
pub(crate) mod gh_account_dir;
// #8510: proves a candidate token is the pinned account's with `GET /user`.
pub(crate) mod gh_account_proof;
// #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(crate) mod gh_account_registry;
pub mod gh_identity;
// #9091: asks gh about a login in the daemon's env and in tm's account dirs.
pub(crate) mod gh_login_probe;
// #9091: `[accounts]` org → gh account map and the one account resolver.
pub mod gh_org_accounts;
// #8914: `--account` sessions run gh and HTTPS git as the account named.
pub mod gh_session_account;
// #7059: the in-process stand-in for the scoped `gh` subprocesses — a test
// seam, compiled out of every `--release` build (see the module docs).
#[cfg(any(test, debug_assertions))]
pub mod gh_scoped_stub;
pub mod git_identity;
// #8511: keep the harness's own files out of every registered project's `git status`.
pub(crate) mod harness_exclude;
pub mod harness_root;
pub mod home_trust_seed;
// #8545: a test binary's fence around the operator's home config paths.
pub mod home_write_fence;
pub mod hook;
pub mod host_state_gate;
pub mod idle_nudge;
pub mod idle_parking;
// #8407: classifies a pane's input box as empty, suggestion, or typed.
pub mod input_box;
// Issue #7616: the compose-time fold — the one transformation between the
// authored section corpus and the bytes delivered to the PM.
pub mod instruction_fold;
pub mod instruction_overrides;
// Issue #4184 / epic #4183: the sectioned-JSON instruction package schema. Types
// + validation only; `bundled_pm_package` is its first composing call site.
pub mod instruction_package;
pub mod instruction_pipeline;
// Issue #8533: the one enumeration of the prompt content no project override
// can remove.
pub mod instruction_safety_core;
// Epic #4183: committed snapshots of the fully composed PM prompt. The
// delivered-prompt diff a content change produces is the review artifact.
pub mod ipc;
// #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.
pub mod issue_audit;
pub mod issue_audit_gh;
pub mod llm_overseer;
// ADR-0055 / #6000: the local-path `repo_url` rule and its typed refusal,
// shared by every `session_new` entry point.
pub mod local_repo_url;
pub mod managed_config;
pub mod manifest;
pub mod mcp_config;
pub mod mcp_provenance;
// #4181: per-project MCP pins now travel as spawn environment variables, not as
// arguments injected into a workspace `.mcp.json` (ADR-0042).
pub mod mcp_session_env;
pub mod mcp_test;
pub mod memory;
pub mod memory_import;
// #7685: `tm memory import-auto-memory` — the migration that makes zeroing
// Claude Code's `MEMORY.md` safe.
pub mod auto_memory_import;
// #7685: auto memory is a FALLBACK — every write site that turns it off asks
// this module whether trusty-memory is available first.
pub mod memory_reachable;
// #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.
pub mod memory_verbs;
// #9340: `tm memory forget` — the forget-specific half of `memory_verbs`.
pub mod memory_forget;
// #9544: `tm memory rename` — trusty-memory's `palace_rename` over the socket.
pub mod memory_rename;
pub mod model_inject;
pub mod names;
pub mod oauth_token;
#[cfg(test)]
#[path = "pm_prompt_golden_tests.rs"]
mod pm_prompt_golden_tests;
// DOC-28 cutover bridge: unified session finder — CUTOVER BRIDGE — remove post-migration (#1762)
pub mod native_session_finder;
pub mod output_style;
pub mod output_style_deployer;
pub mod output_style_tiers;
pub mod overseer;
pub mod overseer_config;
// #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.
pub mod own_binary_names;
pub mod paths;
pub mod pid_registry;
// 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`).
pub mod policy_labels;
// #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.
pub mod pr_cleanup;
pub mod process;
pub mod project;
pub mod project_aliases;
/// The committed, project-level `.trusty-mpm.toml` config surface (#5207).
pub mod project_config;
pub mod project_discovery;
// #7892: `.mcp.json` follows Claude Code's own approval flow, so tm reports
// that state rather than deciding it.
pub mod project_mcp_approval;
// #4880: the project skill tier redeploys on project-manifest change.
pub mod project_skill_tier;
// #6649: `tm doctor --fix-agents` sweeps bundled AGENT copies stranded at the
// project tier — the ledger-proven mirror of `project_tier_strays`.
pub mod project_tier_agent_strays;
// #6586: `tm doctor --fix-skills` sweeps bundled copies stranded at the project
// tier by a pre-#6602 deploy.
pub mod project_tier_strays;
pub mod project_trust;
// #7688: the captured `## Prompt feedback` ledger — extract, append, read back.
pub mod prompt_feedback;
// #7688: the `prompt-self-improvement` flag and the two addenda it injects.
pub mod prompt_self_improvement;
pub mod protected_dirs;
pub mod provisioning_stage;
pub mod push_guard;
// #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.
pub mod git_maintenance;
// `tm reinstall`: the two-hop asset redeploy across every deploy destination,
// and the install-provenance route its `--binary` flag takes.
pub mod binary_reinstall;
// #4462: whether a `--path` install source is behind `origin/main` — the one
// global `tm` binary regresses every session at once when it is.
pub mod install_freshness;
// #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.
pub mod base_ref_freshness;
pub mod reinstall;
// #8934: the one "has an origin remote / local-only" predicate and the no-gh pin.
pub mod remote_mode;
// #9124: the one helper that strips `user:token@` from a URL before it reaches
// a log line or an error message.
pub mod remote_url_redact;
// #6958: the per-session token-savings ledger every producer appends to, and
// the instruction/language-compression producer that writes the first row.
pub mod savings;
// 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.
pub mod savings_compress;
// #6959: the bulk-read diversion producer, the ledger's second row source.
pub mod savings_divert;
pub mod savings_instructions;
// #7569: the one-shot repair that quarantines the ledger rows #7514's resolver
// bug let unit tests write into the operator's own ledger.
pub mod savings_repair;
// #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.
pub mod savings_sidecar;
pub mod scaffold_gitignore;
pub mod session;
pub mod session_assets;
pub mod session_launch;
// #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.
pub mod session_mcp_scope;
// #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.
pub mod session_model;
// #8453: the PM or supervisor instruction profile a session runs.
pub mod session_profile;
// #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.
pub mod session_pause_pr;
// #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.
pub mod session_ref_publish;
// #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.
pub mod session_plugin_scope;
// #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.
pub mod session_scope_drift;
// #7617: which Claude session ids share a managed session, so a restart does not
// read as a savings disappearance.
pub mod session_links;
pub mod session_record;
pub mod session_store;
// #7762: the one cross-process critical section and `.bak`-free atomic publish
// every `settings.json` writer in this crate goes through.
pub(crate) mod settings_lock;
pub mod skill_deploy_tiers;
pub mod skill_deployer;
pub mod skill_drift;
pub mod skill_install_tiers;
pub mod skill_manifest;
// #7751: the stack-to-skill-family table behind the project-tier skillOverrides.
pub mod skill_overrides;
pub mod skill_reconcile;
pub mod skill_repair;
pub mod skill_retire;
pub mod skill_source;
pub mod skill_staleness;
pub mod skill_tiers;
pub mod skill_unmanaged;
pub mod sm;
pub mod spawn_disclaim;
pub mod stack_profile;
// #7424: the turn-1 startup-context reading, its store, and the doctor verdict.
pub mod staged_paths;
pub mod stale_skills;
pub mod standalone;
// #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`.
pub mod startup_context;
pub mod stop_spool;
// #7617: the one seed-or-repair rule for the `statusLine` settings entry, which
// every tier's writer and `tm doctor --fix` go through.
pub mod statusline_settings;
pub mod stray_mcp;
pub mod tmux;
// #6542: each test binary's private default tmux server; test support only.
#[doc(hidden)]
pub mod tmux_test_isolation;
pub mod transcript_usage;
pub mod trusty_tools_config;
// #8878: the supervisor-twin identity (D1) and its arming record.
pub mod twin_arming;
// #8878 ruling A: the Architect is bound to the `claude` tm launched for it.
pub mod architect_launch;
// #8878 R1: the Architect's tmux session name, recorded at launch.
pub mod architect_session;
// #8981: the Architect's conversation id, resumed by the next `tm fleet init`.
pub mod architect_conversation;
// #8942 ruling 2: `tm fleet init` prunes a sidecar only for a proven-dead launch.
pub mod architect_sidecar_prune;
pub mod twin_identity;
// #8572: dirty-tree probe for the main-checkout HEAD-switch guard.
pub mod uncommitted_changes;
pub mod update_check;
pub mod version_staleness;
pub mod workspace_liveness;
pub mod workspace_scan;
// #7889: route (c) of the landing admission — HEAD inside a merged PR's history.
pub mod worktree_carried_by_pr;
pub mod worktree_index;
// #7889: the landed-content admission both reclaim ladders share.
pub mod worktree_landed_content;
// #8633: the merge-into-base question, including a base that moved on.
pub mod worktree_landed_history;
// #8994: the machine-wide append-only worktree ledger.
pub mod worktree_ledger;
pub mod worktree_naming;
// See ADR-0057 — the facts the pm-guard's removal re-checks ask git and GitHub.
pub mod worktree_removal_facts;

pub use connect::{ResolveResult, SessionSummary, resolve_target};
pub use discovery::{
    DEFAULT_CONSOLE_ADDR, DEFAULT_DAEMON_ADDR, DEFAULT_DAEMON_URL, DaemonUrlError,
    EXIT_DAEMON_URL_UNREACHABLE, GATEWAY_PATH, ISOLATED_NO_DAEMON_URL, client_lock_url,
    console_addr_to_probe, default_daemon_addr, explicit_url_from_env, isolated_environment,
    lock_file_path, refuse_daemon_spawn_when_isolated, refuse_isolated_no_daemon,
    resolve_daemon_url, resolve_daemon_url_for_cli, resolve_daemon_url_probing,
    resolve_daemon_url_via_gateway, try_resolve_daemon_url,
};
pub use error::{Error, Result};