gleamunison/cli_lifecycle
Where a store lives, whether a run trusts it, and which branch it reads.
Three decisions belong here rather than scattered across commands: the store directory (an override for tests, CI, and running an artifact from anywhere), whether unverified content may execute, and which branch a session or command is bound to. All three are resolved through the live configuration layer and passed in as data.
Types
pub type StoreContext {
StoreContext(
store_path: String,
manifest_path: String,
root_dir: String,
)
}
Constructors
-
StoreContext( store_path: String, manifest_path: String, root_dir: String, )
Values
pub const default_branch: String
The branch a store-scoped command runs against when --branch is absent.
The commands that peel --store/--branch take their default from here
instead of declaring their own “main”, so the default cannot drift between
them.
Two look-alikes deliberately stay where they are: cli_publish.publish_branch
is where publish records its entries — a decision of its own that happens to
share the name — and run_ref.default_branch is public surface the
branch-scope tests read.
pub fn default_store_dir() -> String
pub fn manifest_path(context: StoreContext) -> String
pub fn missing_branch_value(usage: String) -> #(Int, String)
--branch given with no name after it. Same two commands, same exceptions.
pub fn missing_store_value(usage: String) -> #(Int, String)
--store given with no path after it. purge and unpublish refuse with
exactly these bytes and this exit code, so the wording lives here rather
than in two files that could drift apart.
The other three store-scoped commands keep their own: run prefixes “run: “
and reports a bare String, sync omits the usage block, and pkg has no
missing-value arm at all — its --branch must follow the manifest hash, so
it refuses with “–branch needs the manifest hash first”. Folding those in
would mean parameterising the message, the error type and the precedence:
more machinery than the four lines it would save.
pub fn resolve_allow_unverified() -> Result(Bool, String)
The escape hatch: GLEAMUNISON_STORE_ALLOW_UNVERIFIED=1 lets a run execute
content whose evidence does not verify. Absent means verify; a malformed
configuration is an error rather than a silent default.
pub fn resolve_branch() -> Result(String, String)
The branch a session or command is bound to: GLEAMUNISON_BRANCH through
the CLI > TOML > env precedence, else default_branch. This lived in
mcp_session, which made the refresh path and the hand-written HTTP routes
depend on a 443-line session module for a pure configuration decision.
pub fn resolve_context(
store_override: option.Option(String),
) -> Result(StoreContext, String)
Resolve all sibling paths from one selected store file. Commands with a
--store flag pass that path here; other commands pass None and use the
configured/default directory. The context keeps DETS, manifests, and logs
on one boundary instead of letting each command choose a root independently.
pub fn resolve_store_dir() -> Result(String, String)
The store directory: GLEAMUNISON_STORE_DIR when set, else .gleamunison.
A relative override is refused rather than guessed at — a store resolved
against the wrong working directory looks empty, and an empty store reads
as “your definition was never published”.
pub fn resolve_store_path() -> Result(String, String)
The store file inside the environment-resolved directory.
pub fn root_dir(context: StoreContext) -> String
pub fn store_path(context: StoreContext) -> String