Skip to content

fix(cli): bind root archive consumers to verified cache bytes #40

Description

@TheHalfMoon

Finding

A post-CF-13 cache-integrity audit found additional verify-then-reopen paths in the shared CLI root-package consumers on canonical main eeecb0bc03c7040bb18b70bce8b69d618384f783.

Affected visible paths in crates/commandf-cli/src/main.rs include:

  • inspect: cache.verify(...) followed by independent fs::read(cache/sha256/<digest>.tgz);
  • shared build_diff_report, therefore diff, classify, and check: verify before/after, then independently raw-read both archives;
  • build_terminology_report: verify before/after root packages, then independently raw-read through read_locked_archive before CF-07 processing.

This is the same integrity invariant family as #35/#36: a local mutation after digest verification but before the independent read can rebind analysis to bytes that were never verified.

Required repair

  • replace verify-then-reopen in these root-package paths with PackageCache::read_verified or a common verified-byte helper;
  • reuse the exact returned bytes throughout the command invocation;
  • do not weaken package/lock identity or existing fail-closed behavior;
  • remove redundant verify calls where the verified read itself is authoritative;
  • audit the final CLI source for any remaining cache-object fs::read after a separate verification step.

Tests

  • deterministic regressions for inspect and shared diff-family verified-byte consumption;
  • terminology root path uses verified bytes without a second raw cache read;
  • corrupted-cache failures remain fail closed;
  • no semantic JSON/SARIF output changes for valid unchanged inputs;
  • all existing determinism/proof tests remain green.

Boundaries

No CF-06 production oracle identity change, no CF-10 corpus change, and no semantic reinterpretation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions