Skip to content

07 — Caching, incremental analysis & the CLI gates in CI #16

Description

@rahlk

Part of #9. Phase 1 — level 1.

Learning goals

Integration testing a binary (TRPL Writing Automated Tests + the assert_cmd/predicates
crates), filesystem hygiene (tempfile), serde round-trips as a cache format, GitHub Actions for
Rust (dtolnay/rust-toolchain, Swatinem/rust-cache — already in your release.yml, reuse them).

Task

  • Per-run output cache: write analysis_cache.json under -c after every successful run;
    on a lazy re-run, reuse per-file RustModules whose hash/mtime/size are unchanged and rebuild
    only what changed. --eager forces a clean rebuild and rewrites the cache.
  • Flag validation everywhere: --format msgpack (until implemented) and any unknown --emit
    exit non-zero with a clear message — asserted by an integration test, not a promise.
  • stdout contract: no -o → compact JSON on stdout, logs on stderr only (pipe-clean at -vv).
  • CI: a test.yml running fmt + clippy -D warnings + the full test suite on push/PR, so every
    later issue's gate is un-regressable.

Teacher's notes

  • The four caching behaviors to assert (from the skill's testing reference): CacheFileWritten,
    CacheContentsRoundTrip, SecondRunReuses, EagerForcesRebuild (sleep ≥1s so mtime can advance).
  • assert_cmd drives the real binary — this is where the stdout/stderr split gets honest.

Gate

  • All four caching tests + both flag-validation tests green, in CI.
  • A -vv run piped to jq . parses — logs never contaminate stdout.

Metadata

Metadata

Assignees

Labels

learning-ladderThe escalating-complexity curriculum issueslevel-1Symbol table + resolver call graph

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions