Skip to content
Edit this page

Implementation and evaluation

The Git model defines what the tool does. This page describes the boundaries that make those semantics enforceable.

Layers

Dependencies point inward:

commands/                 arguments, terminal presentation, JSON reports
ops/                      command orchestration and resolution
render.rs, eval.rs        tree rendering and expression evaluation
template/, context.rs     manifest types and shared evaluation values
git/                      GitBackend and its isolated implementation
data/                     structured data acquisition

src/cli.rs contains argument types; src/report.rs owns machine-readable envelopes. src/commands/ has one module per subcommand. src/ops/mod.rs holds operations small enough to remain individual functions, with larger orchestration in files such as backport.rs, testing.rs, and switch.rs. resolve.rs resolves template revisions; extends.rs merges inherited manifests; compose.rs renders selected modules in private answer namespaces. hunks.rs and unsubstitute.rs are internal backport mechanisms, not commands or independent diagnostic areas.

Neither manifest types nor rendering know about the CLI. Typed errors originate where a failure has meaning; the command edge presents them with stable diagnostic codes.

Resolution and evaluation

Resolution produces a concrete template revision, inherited manifest, and source tree. The dependency graph statically analyzes expression references to order questions and reject cycles before prompting. That graph describes dependencies, not permission to eagerly acquire every declared source.

The evaluation session resolves computed values and data on actual expression access. This includes dependencies reached through conditions and short-circuiting; rendering can demand values that no question needed, while unused values stay unresolved. A conditional expression that does not read a source does not acquire it. Questions, files, and context assertions share the session so an acquired value and its provenance remain consistent. See ADR-007 and ADR-047.

flowchart TD
    accTitle: One context for prompting and rendering
    accDescr: Questions, paths and file bodies demand values through one shared evaluation session.
    questions("Question expressions and prompting") --> session("Shared demand-driven evaluation")
    paths("Templated paths") --> session
    bodies("File bodies") --> session
    session --> answers("Answers")
    session --> computed("Computed values and their accessed dependencies")
    session --> data("Declared data acquired on access")

Prompt-only machine seeds are collected outside deterministic rendering. A seed becomes a rendering input only after the person accepts it as an answer. User preferences, clocks, and environment values are not runtime template context.

Tree rendering and retained state

Rendering writes into a TreeBuilder, not rendered files in the project's worktree. An update appends a commit to refs/tpl/<id> with the previous tip as parent. The previous rendered tree and cumulative capture trailers retain one-shot entries; the user's current worktree is never a rendering baseline.

Equal inputs and retained baseline produce an identical tree. No semantic configuration change means no configuration write, even when the rendered output changes. Changed answers or composed-child locks are saved unstaged. See determinism and ADR-053.

Explicit integration is a separate command-layer phase. merge, pull, update --merge, and switch --merge use native Git with its configured hooks, drivers, and signing; these capabilities are unavailable to rendering and init. See ADR-052.

Capability boundaries

git2 appears only in src/git/libgit2.rs. The GitBackend trait exposes project-owned types; new Git capabilities extend that trait. This also confines git-backed network access to the backend implementation.

HTTP data-source access belongs to src/data/. Trust authorizes a template's declared network capability before acquisition; pinning and content digests independently determine whether acquired inputs are reproducible. See the data-source reference and practical reproducibility guide.

Templates cannot execute processes during rendering or init. The explicit test harness may run case commands in its sandbox. Completed diff presentation, explicit integration, and merge-abort recovery have separate native-Git capabilities. Hooks and real-Git integration tests enforce these boundaries; they are not conventions callers may bypass.