Skip to content

CC-390: keep both Muse alerts visible + bound detector state - #462

Merged
swu-wise[bot] merged 3 commits into
mainfrom
wise/cc390-muse-alerts-detector-cap
Nov 10, 2026
Merged

swu-wise[bot] merged 3 commits into
mainfrom
wise/cc390-muse-alerts-detector-cap

Conversation

@jaywedgeworth22

@jaywedgeworth22 jaywedgeworth22 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Carries the two still-real fixes from the #390 preservation matrix (verified against main e7fca82):
Remaining tracked from #390: f6 (reparse efficiency) is carried by #464.

CC-390: keep both Muse alerts visible + bound detector state

Burn and standard-session alerts are now independent so both stay visible when both are present. MuseCodeStandardSessionDetector now tracks lastObservedAt, evicts sessions unobserved for 24 hours, and caps tracked state at 512 sessions by least-recently-observed, keeping backward compatibility for legacy persisted blobs without timestamps.

User-visible impact: Monitor page can show Burn Alert and Standard Session Alert together. Operationally, detector state is bounded and long-absent sessions refire as first-observed on return; production behavior is unverified.

Tests added (run status not reported): testBothMuseAlertsStayVisibleTogether, testSessionUnobservedPastTTLIsEvictedAndRefiresAsNew, testTrackedStateIsCappedByEvictingLeastRecentlyObserved, testLegacyPersistedStateWithoutTimestampsStillDecodes.

Unresolved review findings (medium, 3): Nil-model sessions never refresh liveness and may be TTL-evicted; empty polls skip TTL eviction and retain stale sessions; unstamped legacy sessions sort newest so live sessions may evict first.


Summary

For CC-390, keeps tracked Muse sessions alive on model-less polls while still bounding detector state. Empty polls now expire stale sessions against the wall clock. Legacy sessions without timestamps now sort oldest so cap trimming evicts them first.

Changes

  • Records lastObservedAt for every observation before the model-id guard, so presence without a model reading advances liveness and prevents refire on return.
  • Falls back to Date() when eviction has no newest observation, allowing idle periods to advance TTL expiry.
  • Changes cap-trim sort default from .distantFuture to .distantPast for unstamped entries.

Tests

Added testModelLessPollsKeepASessionAlive, testEmptyPollStillEvictsSessionsPastTTL, and testUnstampedLegacySessionsEvictBeforeStampedOnesAtCap in MuseCodeStandardSessionDetectorTests. No run results were provided in the changes, so pass status is unverified.

Open risk

Automated review flagged uncapped lastObservedAt growth for model-less sessions (Sources/QuotaCore/MuseCodeStandardSessionDetector.swift:145). This remains unresolved in the provided changes.


Summary

CC-390: Bounds MuseCodeStandardSessionDetector state for model-less sessions. Prevents orphan liveness stamps from accumulating unbounded until TTL.

Changes

  • Extended trimToCap() in MuseCodeStandardSessionDetector to cap lastObservedAt orphan entries in addition to tracked lastKnownModels. Oldest orphans are evicted first once the map exceeds maxTrackedSessions, and stamps backing a tracked session are left alone.
  • Added testModelLessOrphanStampsAreCappedToo to cover cap behavior for model-less sessions.

Impact

Operational: detector memory remains bounded at the configured cap. Model-less sessions still record no model state, and liveness eviction remains oldest-first.

Review / Testing

Automated code review completed and found no issues in the changes it reviewed. Test execution and runtime verification were not reported, so behavior beyond the added test is unverified.

@kody-ai

This comment has been minimized.

@swu-wise swu-wise Bot mentioned this pull request Nov 10, 2026
@kody-ai

kody-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Automatic approval held

Kody's assessment:

Stateful detector adds 24h TTL eviction and 512-session cap that changes alert refire semantics; production behavior unverified, test runs unreported, in historically bug-prone area.

@kody-ai

This comment has been minimized.

@kody-ai

kody-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

Automatic approval held: Stateful detector adds 24h TTL eviction and 512-session cap that changes alert refire semantics; production behavior unverified, test runs unreported, in historically bug-prone area.

@swu-wise
swu-wise Bot merged commit 1e2ccf4 into main Nov 10, 2026
12 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.

1 participant