Expand description
Materialize the embedded agent roster to <project>/.trusty-code/agents/
with a manifest and recorded provenance (#2074, epic #2892).
Why: before this, crate::assets::DEFAULT_AGENTS existed only in memory.
An operator could not read the prompt an agent actually runs, diff it, or
edit it, and nothing on disk recorded which files Trusty Code wrote versus
which the project owns. #2074 requires source provenance for every shipped
role, and provenance needs a file and a ledger to attach to.
What: ensure_roster_deployed stages the compiled-in agent sources into a
throwaway directory and hands that directory to
trusty_agents_common::agents::deployer::deploy_agents_filtered — the same
writer trusty-mpm’s ~/.claude/agents/ deploy uses, unchanged. That
deployer already takes source_dir/target_dir as plain parameters, so
reusing it needed no shared-library change. It brings the strict-YAML
validation of every composed agent, the per-agent compose-failure isolation,
the .trusty-mpm-manifest.json ledger with a recorded checksum and
Origin, and the refusal to proceed on a corrupt ledger.
§Three policies this module adds on top of the shared deployer
A compatibility root that currently wins is never shadowed. .claude/
and .open-mpm/ remain readable discovery INPUTS (#5426), and
crate::paths::agents_dir prefers .trusty-code/agents over both. Writing
the roster into .trusty-code/agents while a project’s .claude/agents/
holds its real catalog would silently demote that catalog, so the deploy is
skipped in that case — SkipReason::CompatRootWins.
A hand-edited deployed file is authoritative. The shared deployer treats
a checksum mismatch on an Origin::Bundled entry as corruption and repairs
it (#4408) — correct for trusty-mpm’s machine-global ~/.claude/agents/,
wrong for a project-local directory whose whole contract is
load_all_agents’ “disk wins, never merged”. This module therefore selects
against the ledger before deploying: a tracked file whose on-disk content no
longer matches its recorded checksum is deselected, so the deployer never
composes or writes it. Pristine files still refresh, and an UNTRACKED file is
left to the deployer’s own adopt-or-skip branch. No deployer change was
needed for either policy. Since #7779 the policy covers REAL files only: a
symlinked entry in the agents directory refuses the deploy instead of being
read through, because the pinned handle opens every entry O_NOFOLLOW (the
write_dir module header states why that is uniform rather than per-tree).
Every write reaches the project through a pinned directory handle. The
shared deployer writes through plain paths — correct for trusty-mpm’s
machine-global ~/.claude/agents/, where a symlinked ~/.claude is a
legitimate setup, and wrong for a project directory a racing writer can swap
(#7779). It therefore runs against a private scratch copy, and the ledger and
the files it produced are published back openat-relative to
crate::paths::write_dir::NativeWriteDir. The project’s own ledger lock is
taken through that same handle, so cross-process serialisation is unchanged.
Test: agents::deploy::deploy_tests::*,
tests/roster_deploy_e2e.rs.
Enums§
- Manifest
Status - What the deployed-agent ledger looks like right now.
- Roster
Deploy - What one
ensure_roster_deployedcall did. - Roster
Deploy Error - Why a roster deploy could not run.
- Skip
Reason - Why a deploy was skipped rather than attempted.
Constants§
- AGENTS_
DIRNAME - The
agentssubdirectory name, shared by every configuration root.
Functions§
- deploy_
and_ log - Run
ensure_roster_deployedfor a bound project and log what happened. - ensure_
roster_ deployed - Materialize the embedded roster into
<project>/.trusty-code/agents/. - roster_
manifest_ status - The ledger path and its current state for a project.
- roster_
target <project>/.trusty-code/agents— the only directory this module writes.