Expand description
~/.mecha/work/<producer>/ — where a run’s generated output goes.
Two directories, and they mean opposite things:
~/.mecha/work/<producer>/ generated · mutable · disposable · cleanable
~/.mecha/bundles/<id>/<ver>/ published · immutable · versioned · never deletedA producer is whatever made the output: a trigger’s name, or chat, or a
session id. The directory is stable across runs of the same producer,
which is the whole point — yesterday’s briefing is an ordinary file in
today’s run rather than something that has to be fetched back from
somewhere. It is also the run’s workspace, and that fixes three things at
once:
- The jail default. A trigger with no explicit workspace fell through to
std::env::current_dir(), and the daemon’s unit setsWorkingDirectory=%h. So an unattended run with filesystem tools was path-jailed to$HOME, which contains~/.mecha/— the mail OAuth tokens, every session transcript, the learning store. Rooting it here roots it somewhere holding nothing sensitive. (The interactive half of that hazard isensure_outside_mecha_home.) - Cross-run read-back, as above.
notify. The shipped morning trigger ended withmkdir -p ~/.mecha/briefings && cat > …— a shell redirect into a directory it created on the way past, outside every path jail, so no later run could read it. That existed only because there was no designated place to write.
Retention is a policy, not an intention. Anything without one becomes a
pile nobody opens, so clean keeps the last N entries per producer and
says what it removed. One hard rule: it never removes anything a published
bundle names as a source, because “regenerate last week’s report” must not
silently lose its input.
Structs§
- Clean
Report - What a
cleandid, or would do. - Entry
- One top-level entry in a producer’s directory. A run’s output may be a file or a directory (a rendered bundle is a directory), so retention counts entries rather than files.
- Producer
- One producer’s directory, as
listreports it.
Constants§
- DEFAULT_
KEEP - How many entries per producer survive a
cleanthat does not say.
Functions§
- bundles_
root ~/.mecha/bundles— the published mirror. Written by the publisher, read here only to find out whatcleanmust not remove.- clean
- Keep the
keepmost recent entries in each producer’s directory and remove the rest. - ensure
- The directory for one producer, created if absent.
- ensure_
outside_ mecha_ home - Refuse a workspace that contains the mecha home.
- list
- Every producer with a directory, alphabetically.
- mecha_
home ~/.mecha, or$MECHA_HOME.- producer_
dir - The directory for one producer, without creating it.
- protected_
sources - Paths a published bundle names as its source, which
cleanmust never remove. - root
~/.mecha/work.- valid_
producer - A producer name is a directory name, a CLI argument and a log line. Keep it to what is unambiguous in all three — the same rule trigger names follow, because a trigger name is a producer name.