Architecture for Contributors
The library crate owns the core staged pipeline. The binary entrypoint delegates to command-family modules under src/commands/, while presentation lives under src/output/. Reusable planning, prepare, render, tracking, cache, context, and template logic stay in the library modules.
Module map
spec: parse, interpolate, and validate the supported Compose subsetplanner: normalize the parsed spec into a deterministic planlint: run opinionated static checks over validated planscontext: resolve.hpc-compose/settings.toml, profiles, env files, interpolation variables, and binary overridescluster: generate and apply best-effort cluster capability profiles fromdoctor cluster-reportpreflight: check login-node prerequisites and cluster policy issuesprepare: import base images and rebuild prepared runtime artifactsrender: generate the finalsbatchscript and service launch commandsjob: track submissions, logs, metrics, replay, status, and artifact exporttracked_paths: centralize the.hpc-compose/layout used by render and job trackingcache: persist cache manifests for imported and prepared imagesinit: expose the shipped example templates forhpc-compose newplus the legacyinitaliasschemaandmanpages: expose the checked-in JSON Schema and generated section-1 manpage flowcommands/spec: static authoring commands such asplan,validate,lint,render,config,inspect,prepare, andpreflightcommands/runtime: submission, tracked-run, and local-development commands such asup,when,run,alloc,debug,status,ps,watch,replay,stats,logs,artifacts,down,cancel,clean,dev,tmux, andtestcommands/cache: cache inspection and pruningcommands/doctor,commands/evolve,commands/examples,commands/weather: thedoctor,evolve,examples, andweathercommand familiescommands/init:new/init,setup,context, andcompletionscommands(mod.rs): parses the CLI and routes every command to its handler modulewatch_ui: terminal UI controller and renderer forup,watch, and replay playbackoutput: binary-only text, JSON, CSV, and JSONL formatting helpers
Execution flow
ComposeSpec::loadparses YAML, resolves authoringextends, validates supported keys, interpolates variables, and applies semantic validation.planner::build_planresolves paths, command shapes, dependencies, and prepare blocks into a normalized plan.prepare::build_runtime_plancomputes concrete cache artifact locations.contextand optional cluster profiles provide resolved paths, binaries, env, and compatibility warnings.preflight::runchecks cluster prerequisites before submission.prepare::prepare_runtime_planimports or rebuilds artifacts when needed.render::render_scriptemits the batch script consumed bysbatch.jobpersists tracked metadata under.hpc-compose/and powersstatus,ps,watch,replay,stats,logs,cancel, and artifact export.job::replayreconstructs a best-effort timeline from existing state, service-exit, metrics, and log artifacts while reusing the watch renderer for playback.commands/*turns CLI variants into library calls, andoutputformats the final presentation.
Tracked Runtime Layout
tracked_paths is the single source of truth for the tracked-job layout shared by render and job.
- Compose-level metadata lives under
.hpc-compose/next to the compose file. - Per-job runtime state lives under
<runtime-root>/<job-id>/, where<runtime-root>defaults to<submit-dir>/.hpc-composeand can be overridden withx-slurm.runtime_root. The renderer resolves this to an absolute path at submit time and bakes it intoJOB_ROOT, so a running job does not depend on$SLURM_SUBMIT_DIR. Records persist an explicit override so later lookups address the same directory. - Root-level
logs/,metrics/,artifacts/, andstate.jsonare the latest-view paths used by status and export commands. - Resume-aware runs still write attempt-specific state under
attempts/<attempt>/.... - The batch script updates root-level latest symlinks so contributor-facing tooling can read the most recent attempt without reconstructing shell logic independently.
Contributor commands
cargo test
cargo test --test cli_runtime
cargo test --test release_metadata
cargo doc --no-deps
mdbook build docs
cargo run --features manpage-bin --bin gen-manpages -- --check
Coverage Notes
- Treat
src/spec/mod.rsas high risk for broad refactors until parser and semantic-validation behavior has more focused coverage. Prefer adding behavior-first tests intests/cli_spec.rsor spec unit tests before moving large validation blocks. - Render changes should keep generated-script assertions close to
src/render.rs.just examples-checkshellchecks rendered batch scripts, while local launchers are produced throughup/run --local, so local launcher syntax needs focused render or local dry-run coverage. - Runtime command refactors should start with pure helpers that have deterministic unit tests and existing CLI integration filters. Submission, tracking, watching, and process orchestration should stay together until a narrower harness makes a larger move low risk.
Documentation split
- Use this mdBook for user-facing workflows, examples, and reference material.
- Use rustdoc for contributor-facing internals and the library module map.
- Keep README short and point readers into the book instead of duplicating long-form guidance.