Skip to main content

trusty_code/prompt/
mod.rs

1//! System-prompt assembly layer (parity-spec — `docs/trusty-code/parity-spec.md`).
2//!
3//! Why: The model-comparison harness must drive the *same* system instruction
4//! surface through every model so a comparison measures the model, not the
5//! scaffolding (parity-spec §1). This module owns that surface: the
6//! byte-identical BASE preamble, its version token, and the fixed-order
7//! assembler that merges the BASE preamble with the per-agent prompt, project
8//! `CLAUDE.md` context, and the optional per-tier fallback guidance.
9//! #4602: every section that INSTRUCTS the model to call a named tool — file
10//! discovery, batch writes, code discovery — left that byte-identical floor and
11//! is gated on the run's tool registry, so an agent is never instructed to call
12//! a tool it was not given. `BASE_PREAMBLE` still MENTIONS `write_file`,
13//! `read_file` and `bash` inside the tool-use protocol, as `e.g.` illustrations
14//! of what batching means; those are not instructions and are not gated.
15//! What: Re-exports [`BASE_PREAMBLE`], [`BASE_PREAMBLE_VERSION`],
16//! [`PromptAssembler`], [`assemble_system_prompt`], and (#2059)
17//! [`assemble_system_prompt_for_mode`] — the `HarnessMode`-branching entry
18//! point `task::executor`/`runner::in_process` call. Its `skills_catalog`
19//! parameter (#2069) is P1B's first token-efficiency layer to actually land:
20//! `DailyDriver` appends the cheap, always-cached skill metadata catalog
21//! (`crate::skills::format_skill_catalog`); `Parity` ignores it.
22//! Test: `prompt::tests::*` (via `assembler.rs`'s inline test include).
23//!
24//! [`BASE_PREAMBLE`]: crate::prompt::BASE_PREAMBLE
25//! [`BASE_PREAMBLE_VERSION`]: crate::prompt::BASE_PREAMBLE_VERSION
26//! [`PromptAssembler`]: crate::prompt::PromptAssembler
27//! [`assemble_system_prompt`]: crate::prompt::assemble_system_prompt
28//! [`assemble_system_prompt_for_mode`]: crate::prompt::assemble_system_prompt_for_mode
29
30mod assembler;
31mod preamble;
32mod version;
33
34pub use assembler::{
35    BATCH_WRITE_TOOLS, DISCOVERY_GUIDANCE, DISCOVERY_GUIDANCE_TOOLS, FILE_DISCOVERY_TOOLS,
36    GATED_SECTIONS, PromptAssembler, assemble_system_prompt, assemble_system_prompt_for_mode,
37};
38pub use preamble::{BASE_PREAMBLE, BATCH_WRITE_GUIDANCE, FILE_DISCOVERY_GUIDANCE};
39pub use version::BASE_PREAMBLE_VERSION;