Skip to content

Module contracts (//! docs)

Status: Open — Phase 1, no confirmation needed

About 46% of source files (53 of 116) have //! orientation docs. The remaining 54% (63 files) give AI agents and contributors no orientation when they open the file — purpose, scope, and key invariants must be reverse-engineered from the code. This has barely improved since the original analysis.

Priority files (current largest / most central undocumented modules)

Section titled “Priority files (current largest / most central undocumented modules)”
FileCurrent LOC (May 2026)Original LOCGrowthWhy urgent
src/runtime/launch.rs7575~5494+38%Largest undocumented production file, jackin load critical path
src/app/mod.rs2767~1243+123%CLI dispatch entry point — more than doubled
src/app/context.rs1466~1022+43%Target resolution and workspace/agent context helpers
src/instance/auth.rs2607~2401+9%Credential forwarding and auth provisioning logic
src/isolation/materialize.rs2392~2392Central mount-materialization flow with many invariants
src/isolation/finalize.rs1819~1819Foreground-session cleanup / preservation policy
src/config/mod.rs1407~1254+12%Main config schema and auth/source policy
src/workspace/mod.rs1056~905+17%Core workspace types and validation rules
src/runtime/cleanup.rs687~637+8%Container/class cleanup semantics
src/derived_image.rs983~989Dockerfile generation, UID/GID remapping

Notable new entries not in original list:

FileCurrent LOCWhy urgent
src/console/manager/state.rs2477Central state machine for the entire console — enums, modal definitions, workspace state. No //!.
src/console/manager/input/save.rs2734Save flow, validation, commit planning. Grew from zero to 2734L. No //!.
src/console/manager/input/global_mounts.rs1984Global mounts editor input handling. Grew from ~344L to 1984L. No //!.
src/manifest/validate.rs1222Role manifest validation logic. No //!.
  1. For each file, read the first 50 lines and the public item list.
  2. Write a //! block at the top: purpose, scope claim, key invariants, what callers can assume.
  3. Model on src/env_model.rs (the 3-element exemplar: purpose + scope + history).
  4. Do not add /// item-level docs in this pass — only //! module-level.
  • Purpose: What does this module do?
  • Scope: What is it NOT responsible for? (crucial for AI agents to know where not to look)
  • Key invariants: What must always be true when this module’s public functions return?

Purely additive — no behavior change, no CI risk. Do before the behavioral specs since the spec presupposes the module has a stated contract.