Skip to content

Conversation

jakubno
Copy link
Member

@jakubno jakubno commented Sep 30, 2025

Simplify the sandbox store interface before we add redis store


Note

Reworks sandbox store to use option-based queries and atomic updates, refactoring orchestrator, handlers, metrics, analytics, and eviction to the new API.

  • Core sandbox store:
    • Introduces option-based querying via Items(options...) with ItemsFilter and helpers: WithTeamID, WithAllTeams, WithState, WithStates, WithOnlyExpired.
    • Adds atomic Update(sandboxID, updateFunc); removes ItemsByState, ItemsToEvict, ExtendEndTime from interface.
    • Adds NotFoundError.
  • Memory store:
    • Implements Items with filtering and Update; removes old state-specific listing and TTL extension.
    • Adds applyFilter and minor log tweak.
  • Orchestrator:
    • GetSandboxes now returns []sandbox.Sandbox and accepts store options.
    • Updates admin nodes/detail, analytics (long-running), status logging to use Items(WithAllTeams...) and/or state filters.
    • KeepAliveFor now performs TTL changes via sandboxStore.Update with explicit errors; updates orchestrator with new end time.
  • Evictor:
    • Scans items to evict via Items(WithAllTeams(), WithOnlyExpired(true)).
  • Handlers:
    • Update listing to new orchestrator GetSandboxes API; split running/pausing via filtering; import shared utils for filtering.
  • Metrics:
    • Team observer uses cache.Items(WithAllTeams()) for per-team counts.

Written by Cursor Bugbot for commit 9f580dc. This will update automatically on new commits. Configure here.

@jakubno jakubno self-assigned this Sep 30, 2025
@jakubno jakubno added the improvement Improvement for current functionality label Sep 30, 2025
@jakubno jakubno marked this pull request as ready for review September 30, 2025 15:27
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Comment on lines 51 to 54
func WithIsExpired(isExpired bool) ItemsOption {
return func(f *ItemsFilter) {
f.IsExpired = &isExpired
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about making this false by default?

so.registration, err = so.meter.RegisterCallback(
func(ctx context.Context, obs metric.Observer) error {
sbxs := cache.Items(nil)
sbxs := cache.Items(sandbox.WithState(sandbox.StateRunning), sandbox.WithIsExpired(false))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the WithIsExpired should be by default false

@dobrac dobrac assigned dobrac and unassigned jakubno Sep 30, 2025
cursor[bot]

This comment was marked as outdated.

@jakubno jakubno force-pushed the simplify-sandbox-store branch from 727887b to 19ddf38 Compare October 1, 2025 11:21
cursor[bot]

This comment was marked as outdated.

@jakubno jakubno requested a review from dobrac October 2, 2025 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement for current functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants