pub struct Charter { /* private fields */ }Expand description
The owner’s charter, in file order.
Order is rank. See the module doc — there is no field for it because
a second statement of priority disagrees with the first the moment either
is edited, the same rule TASK-AGENT-DESIGN.md R1 gives task urgency.
Implementations§
Source§impl Charter
impl Charter
Sourcepub fn default_path() -> Result<PathBuf>
pub fn default_path() -> Result<PathBuf>
~/.mecha/charter.toml — the only path there is. See the module doc:
this is deliberately not a Config field, because a configurable path
is a path a project layer could set.
Sourcepub fn load(path: &Path) -> Result<Charter>
pub fn load(path: &Path) -> Result<Charter>
Read and validate path. A missing file is an empty charter, not
an error — a machine nobody has written one for yet must still start,
on crate::skill::SkillStore::load’s rule for a missing directory.
Sourcepub fn parse(text: &str) -> Result<Charter>
pub fn parse(text: &str) -> Result<Charter>
Parse and validate charter TOML that has not been written anywhere
yet. The seam a surface that accepts an edit needs — the web
settings page validates a proposed charter with exactly the reader
every run will load it through, and refuses the save on an error,
so a file that reaches disk is one that will load. load goes
through here so the two can never diverge on what “valid” means.
pub fn lines(&self) -> &[CharterLine]
Sourcepub fn char_count(&self) -> usize
pub fn char_count(&self) -> usize
How many characters the charter actually costs when rendered into the
system prompt — prompt_block’s own length, not just the authored
id/text content. The header and the per-line "N. id — "
formatting ride in the cached prefix too, so measuring only the
authored text would under-report the true cost by a few hundred
characters of fixed overhead. What Charter::over_budget checks
against CHARTER_CHAR_BUDGET, and the same number every message
that quotes “characters” beside “the prompt” means.
Sourcepub fn over_budget(&self) -> bool
pub fn over_budget(&self) -> bool
Costs more of the cached prefix than CHARTER_CHAR_BUDGET argues
for. Not refused by Charter::load — see its doc comment — so a
caller that cares (today: mecha doctor) checks this after loading.