Skip to content

Add fingerprint caching to archdocs and audit commands#70

Merged
greynewell merged 1 commit intomainfrom
fix/audit-archdocs-caching
Apr 8, 2026
Merged

Add fingerprint caching to archdocs and audit commands#70
greynewell merged 1 commit intomainfrom
fix/audit-archdocs-caching

Conversation

@greynewell
Copy link
Copy Markdown
Contributor

@greynewell greynewell commented Apr 8, 2026

Summary

Both commands were re-uploading the repo zip on every invocation — no fingerprint cache check.

  • archdocs: caches the raw API response by git fingerprint; skips upload on subsequent calls when the repo is unchanged; uses --force to bypass
  • audit: caches both the domain analysis (audit-domains key) and impact results (impact key) by fingerprint; the impact cache key is shared with the standalone blast-radius command; also deduplicated config.Load() and context creation (previously called once per API call)

Test plan

  • go build ./... passes
  • go test ./... passes
  • go vet ./... passes
  • Manual: supermodel docs twice — second call prints "Using cached analysis" and skips upload
  • Manual: supermodel audit twice — second call returns from cache without re-uploading

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Audit analysis now implements intelligent caching to speed up repeated operations on unchanged repositories.
    • Archive documentation analysis now implements intelligent caching to speed up repeated operations on unchanged repositories.
    • Audit command enforces API key requirement and adds a 10-minute timeout for long-running analyses.

Both commands were re-uploading the repo on every invocation with no
cache check. This adds the same fingerprint-based fast path used by
`analyze`, `dead-code`, and `blast-radius`.

- archdocs: cache raw API response by git fingerprint; skip upload
  on subsequent calls with an unchanged repo
- audit: cache both the domain analysis and impact results by
  fingerprint; also deduplicate config.Load() and share the context
  across both API calls (no behavioural change — cosmetic cleanup)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e14f3a80-220d-4d7c-a249-c8133a3f893a

📥 Commits

Reviewing files that changed from the base of the PR and between e6e4961 and 0051368.

📒 Files selected for processing (2)
  • cmd/audit.go
  • internal/archdocs/handler.go

Walkthrough

The changes implement fingerprint-based analysis caching in two files: cmd/audit.go and internal/archdocs/handler.go. Both refactor their main analysis flows to compute a repository fingerprint, check a cache before performing expensive analysis, and conditionally store results back to cache keyed by fingerprint and analysis type.

Changes

Cohort / File(s) Summary
Audit Command Caching
cmd/audit.go
Refactored runAudit to load config upfront, create a shared 10-minute timeout context, compute repository fingerprint, and pass these to downstream analysis functions. Both auditAnalyze and runImpactForAudit now accept context, config, and fingerprint parameters, implement best-effort cache lookups keyed by (fingerprint, analysis_type, build.Version), and return cached results when available; otherwise they analyze fresh and write results to cache.
Architecture Docs Caching
internal/archdocs/handler.go
Extracted repository analysis logic into new analyzeOrCachedRaw helper that implements fingerprint-based caching. When force is false, it computes repository fingerprint, derives cache key, and returns cached results if available; on miss, creates archive, uploads/analyzes, then stores results back to cache. Added imports for encoding/json and github.com/supermodeltools/cli/internal/build.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Analysis Client
    participant Cache as Fingerprint Cache
    participant API as API Service

    Client->>Client: Compute repo fingerprint
    Client->>Cache: Check cache<br/>(fingerprint, type, version)
    alt Cache Hit
        Cache-->>Client: Return cached result
    else Cache Miss
        Client->>API: Upload repo & analyze<br/>(with idempotency key)
        API-->>Client: Return analysis result
        Client->>Cache: Store result<br/>(best-effort write)
        Cache-->>Client: Write complete
    end
    Client-->>Client: Return result to caller
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • jonathanpopham

Poem

🔐 A fingerprint unlocks the cache,
No need to analyze so fast,
Results are stored for next time 'round,
Where speedy answers will be found! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/audit-archdocs-caching

Comment @coderabbitai help to get the list of available commands and usage tips.

@greynewell greynewell merged commit 47c8f36 into main Apr 8, 2026
6 of 7 checks passed
@greynewell greynewell deleted the fix/audit-archdocs-caching branch April 8, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant