Skip to content

Fix retrospective cache invalidation for ORB-9 - #459

Open
thomasluizon wants to merge 3 commits into
mainfrom
fix/orb-9-retro-cache
Open

Fix retrospective cache invalidation for ORB-9#459
thomasluizon wants to merge 3 commits into
mainfrom
fix/orb-9-retro-cache

Conversation

@thomasluizon

@thomasluizon thomasluizon commented Aug 7, 2026

Copy link
Copy Markdown
Owner

DEGRADED: same-vendor review

Summary

Correct retrospective cache invalidation so habit mutations clear the same versioned, period-start keys written by retrospective reads.

Implementation

  • Added one shared retro:v2 key builder used by both reads and invalidation.
  • Resolved invalidation dates through RetrospectivePeriodRange.Resolve for every supported period and language.
  • Cleared both supported week-start variants so existing mutation call sites do not need user settings and either valid weekly key is removed.
  • Added parity and survival coverage across all periods, languages, and week starts, plus a successful log followed by a fresh retrospective read.

The invalidation helper does not receive a user's week-start setting. Clearing values 0 and 1 is the bounded interpretation chosen here. It guarantees correct invalidation without widening every habit and goal mutation command.

Verification

  • dotnet build Orbit.slnx: 0 errors
  • Focused cache, query, and log tests: 59 passed
  • dotnet test: 5,613 passed

Links

Linear: ORB-9

Fixes #413

@thomasluizon

Copy link
Copy Markdown
Owner Author

Implementation approach before code:

  1. Add src/Orbit.Application/Common/RetrospectiveCacheKey.cs as the sole formatter for retro:v2 keys.
  2. Replace the interpolated key in GetRetrospectiveQuery.cs with that builder.
  3. Update CacheInvalidationHelper.cs to enumerate supported periods and languages, resolve each period start through RetrospectivePeriodRange.Resolve, and remove keys through the same builder. For weeks it will cover both valid week-start values because the helper has no user setting.
  4. Extend CacheInvalidationHelperTests.cs, GetRetrospectiveQueryHandlerTests.cs, and LogHabitCommandHandlerTests.cs to prove parity across periods, languages, and week starts, preserve unrelated keys, and exercise the cached read after a successful log.

I am keeping period resolution outside the key formatter so the builder has one responsibility and can also support the separate recap work later. I am not adding a week-start parameter to every mutation command because that would widen many unrelated call sites; removing both valid weekly variants is complete and bounded.

@sonarqubecloud

sonarqubecloud Bot commented Aug 7, 2026

Copy link
Copy Markdown

@thomasluizon

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 6edb35bb70

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@thomasluizon

Copy link
Copy Markdown
Owner Author

DEGRADED: same-vendor review

Review verdict: clean after round 1. No Blocking or Non-blocking findings against the frozen rubric. This used a fresh Sol xhigh session; same-family bias is not eliminated and its magnitude is unmeasured.

@thomasluizon

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 6edb35bb70

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

Fix broken retrospective AI cache invalidation (stale after every log)

1 participant