Skip to content

Fix #616: Refresh Review inbox relearn cache from tj optimize - #701

Merged
anshss merged 2 commits into
Metabuilder-Labs:mainfrom
Axiya3749:fix/616-refresh-relearn-store
Aug 9, 2026
Merged

anshss merged 2 commits into
Metabuilder-Labs:mainfrom
Axiya3749:fix/616-refresh-relearn-store

Conversation

@Axiya3749

Copy link
Copy Markdown
Contributor

tj optimize computed and displayed a fresh relearn finding locally, but never persisted that finding to the Review inbox cache. This allowed the CLI and inbox to report different cluster counts until the daemon independently recomputed the cache.

Summary

  • Persist the exact relearn finding computed by direct tj optimize runs.
  • Cover both bare tj optimize and tj optimize relearn.
  • Leave the daemon-backed path read-only because it consumes an already-stored report rather than computing a new finding.
  • Preserve the previous relearn result when an optimize subset does not run the relearn analyzer.

Related issue

Closes #616

Tests / Verification

  • env -u FORCE_COLOR .venv/bin/python -m pytest tests/integration/test_cli.py -k 'optimize and not validate' -q
    • 19 passed
  • .venv/bin/ruff check tokenjam/cli/cmd_optimize.py tests/integration/test_cli.py
  • .venv/bin/mypy tokenjam/cli/cmd_optimize.py
  • git diff --check

What's NOT in this PR

  • This does not make daemon-backed tj optimize perform an inline recompute. The daemon continues to own its scheduled and explicit Rescan workflow.
  • No architecture or configuration changes were required.

Checklist

  • Full test suite passes
  • Changed files pass Ruff
  • Changed production file passes Mypy
  • CLAUDE.md update not required; architecture is unchanged
  • Test spans use tests/factories.py
  • Requested @anilmurty as reviewer

@anilmurty

@Axiya3749
Axiya3749 requested a review from anilmurty as a code owner August 6, 2026 11:49
@greptile-apps

greptile-apps Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR persists relearn findings computed by direct tj optimize invocations so the Review inbox can consume the same result.

  • Writes a locally computed relearn finding to the existing cache before rendering.
  • Leaves daemon-backed and non-relearn analyzer paths unchanged.
  • Adds integration coverage for full and relearn-only optimize invocations.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure eligible for this follow-up review remains.

No blocking failure remains.

Important Files Changed

Filename Overview
tokenjam/cli/cmd_optimize.py Persists a direct-mode relearn finding to the Review inbox cache while leaving daemon and omitted-analyzer paths untouched.
tests/integration/test_cli.py Verifies that full and relearn-only direct optimize runs replace a stale cached finding with the newly computed result.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as tj optimize
    participant Analyzer as build_report
    participant Cache as relearn_store
    participant Inbox as Review inbox
    User->>CLI: Run direct optimize
    CLI->>Analyzer: Compute requested findings
    Analyzer-->>CLI: OptimizeReport
    alt Relearn finding present
        CLI->>Cache: write_cache(finding)
    end
    CLI-->>User: Render report
    Inbox->>Cache: Read persisted finding
    Cache-->>Inbox: Relearn clusters
Loading

Reviews (4): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

@Axiya3749
Axiya3749 force-pushed the fix/616-refresh-relearn-store branch from 4a33e8b to da2dc19 Compare August 6, 2026 12:23
@Axiya3749
Axiya3749 force-pushed the fix/616-refresh-relearn-store branch from da2dc19 to 13657ed Compare August 6, 2026 12:42
@anshss

anshss commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

@Axiya3749 thanks for pr! lgtm!

@anshss
anshss merged commit 3950047 into Metabuilder-Labs:main Aug 9, 2026
6 checks passed
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.

Review inbox's relearn finding is refreshed only by the daemon recompute, so tj optimize leaves it stale

2 participants