Repository navigation
refactor: preserve dag-run file layout in persistence store - #2214
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughUnifies file-backed persistence behind internal/persis/file factories, renames filedagrun→dagrun, introduces proc LegacyStore and ProcLegacyStore adapter, injects DAGRunStore and snapshot/base-config factories across engine/scheduler/API/worker, and updates tests/docs. ChangesPersistence layer unification
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
✨ Finishing Touches🧪 Generate unit tests (beta)
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/persis/file/dagrun_store.go`:
- Around line 41-43: The options loop in dagrun_store.go unconditionally calls
each option callback (for _, opt := range opts { opt(&options) }), which will
panic if an element is nil; update the loop to guard against nil callbacks by
checking each opt for nil before invoking it (i.e., skip nil entries), keeping
the same variables names opts and options so the change is localized to the loop
that applies option callbacks.
In `@internal/service/worker/handler.go`:
- Around line 35-37: NewTaskHandler currently passes a nil DAG-run store into
NewTaskHandlerWithDAGRunStore which later rejects nil, causing workspace-bundle
tasks to fail; fix this by having NewTaskHandler construct or obtain a valid
DAG-run store from the provided cfg and pass that instead of nil into
NewTaskHandlerWithDAGRunStore (if a DAGRunStore factory/constructor exists, call
it here), or if intentional, update NewTaskHandlerWithDAGRunStore to accept and
initialize a nil store internally—ensure the change references NewTaskHandler
and NewTaskHandlerWithDAGRunStore so workspace-bundle task handling no longer
receives a nil DAG-run store.
In `@internal/service/worker/worker.go`:
- Around line 108-110: The loop over opts may call a nil function value and
panic; in the function that iterates opts (the slice named opts, with loop
variable opt that applies to options), add a nil-check before invoking opt
(e.g., if opt == nil { continue }) so nil entries are safely skipped (or
alternatively return an error if you prefer strictness). Update the loop that
currently reads "for _, opt := range opts { opt(&options) }" to guard against
nil opt and apply only non-nil option functions to options.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e5afb34e-5b23-41e9-bcfd-69301e704e37
📒 Files selected for processing (18)
internal/cmd/context.gointernal/cmd/process/scheduler.gointernal/cmd/worker.gointernal/core/exec/dagrun.gointernal/engine/engine.gointernal/engine/types.gointernal/engine/worker.gointernal/intg/distr/fixtures_test.gointernal/intg/queue/fixture_test.gointernal/persis/file/dagrun/query_cursor.gointernal/persis/file/dagrun_store.gointernal/service/frontend/api/v1/dagruns.gointernal/service/worker/handler.gointernal/service/worker/worker.gointernal/test/helper.gointernal/test/reschedule_inline_helpers.gointernal/test/scheduler.gorefactor_persis_layer.html
✅ Files skipped from review due to trivial changes (1)
- refactor_persis_layer.html
🚧 Files skipped from review as they are similar to previous changes (2)
- internal/persis/file/dagrun/query_cursor.go
- internal/service/frontend/api/v1/dagruns.go
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
internal/githubdispatch/tracker.go (1)
17-22: 💤 Low valueConsider adding
context.Contextto Tracker interface methods.The
Trackerinterface methods (Upsert,Delete,List) don't accept acontext.Contextparameter. For file-based implementations this may be fine, but if the tracker is later backed by a database or remote store, context propagation for cancellation and deadlines would be needed. Adding context now avoids a breaking interface change later.♻️ Suggested interface with context
// Tracker persists in-flight GitHub dispatch jobs until they are reported. type Tracker interface { - Upsert(TrackedJob) error - Delete(string) error - List() ([]TrackedJob, error) + Upsert(ctx context.Context, job TrackedJob) error + Delete(ctx context.Context, jobID string) error + List(ctx context.Context) ([]TrackedJob, error) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/githubdispatch/tracker.go` around lines 17 - 22, Tracker's methods (Upsert, Delete, List) lack a context.Context parameter which prevents cancellation/deadline propagation; update the Tracker interface to accept context.Context (e.g., Upsert(ctx context.Context, t TrackedJob) error, Delete(ctx context.Context, id string) error, List(ctx context.Context) ([]TrackedJob, error)), then update all implementations of Tracker and all call sites to pass through the incoming context; also add the context import where needed and ensure any file-based or DB-backed implementations respect context for long-running operations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/persis/file/agent_stores.go`:
- Around line 221-231: NewContextStore currently dereferences cfg and will panic
if cfg is nil; add an explicit nil check at the top of NewContextStore (checking
cfg == nil) and return a descriptive error instead of proceeding. Ensure the
guard returns (nil, error) before calling crypto.ResolveKey or
crypto.NewEncryptor, and keep the rest of the flow that calls crypto.ResolveKey,
crypto.NewEncryptor, and clicontext.NewStore unchanged so callers receive an
error rather than a panic when config.Config is nil.
In `@internal/persis/file/service_stores.go`:
- Around line 90-92: NewEventCollector currently builds a fileeventstore
collector unconditionally which will panic on cfg==nil and touch the event-store
even when disabled; update NewEventCollector to mirror NewEventStore's gating:
check cfg != nil and cfg.EventStore.Enabled (or equivalent eventStore.enabled
flag) before calling fileeventstore.NewCollector, and when the gate is off
return the "disabled" result used elsewhere in this package (e.g., the same
nil/zero-value and nil error or the disabled collector helper that NewEventStore
returns) so the caller cannot start a collector when the feature is disabled.
In `@internal/service/frontend/api/v1/api.go`:
- Around line 231-241: The API currently treats baseConfigFactory as optional
but UpdateWorkspaceBaseConfig requires it; update the API constructor (where API
is created) to either (A) install a sane default WorkspaceBaseConfigStoreFactory
when none is provided (so baseConfigFactory and baseConfigStore are always
non-nil), or (B) perform a fail-fast validation in the NewAPI/constructor that
checks a.baseConfigFactory (and/or a.baseConfigStore) and returns an error or
panics so the server cannot start without the factory; ensure you update
WithWorkspaceBaseConfigStoreFactory handling accordingly and adjust
requireBaseConfigManagement to reflect the new invariant.
---
Nitpick comments:
In `@internal/githubdispatch/tracker.go`:
- Around line 17-22: Tracker's methods (Upsert, Delete, List) lack a
context.Context parameter which prevents cancellation/deadline propagation;
update the Tracker interface to accept context.Context (e.g., Upsert(ctx
context.Context, t TrackedJob) error, Delete(ctx context.Context, id string)
error, List(ctx context.Context) ([]TrackedJob, error)), then update all
implementations of Tracker and all call sites to pass through the incoming
context; also add the context import where needed and ensure any file-based or
DB-backed implementations respect context for long-running operations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ca085f19-35d0-44ef-951f-44faf84df0c5
📒 Files selected for processing (36)
internal/agentsnapshot/dispatch.gointernal/agentsnapshot/dispatch_test.gointernal/cmd/agent.gointernal/cmd/context.gointernal/cmd/license.gointernal/cmd/process/agent_stores.gointernal/cmd/process/dag_store.gointernal/cmd/process/scheduler.gointernal/cmd/upgrade.gointernal/engine/engine.gointernal/engine/run.gointernal/githubdispatch/tracker.gointernal/persis/file/agent_stores.gointernal/persis/file/dag_store.gointernal/persis/file/dagrun_store.gointernal/persis/file/proc_store.gointernal/persis/file/service_registry.gointernal/persis/file/service_stores.gointernal/persis/filegithubdispatch/store.gointernal/service/frontend/api/v1/api.gointernal/service/frontend/api/v1/base_config.gointernal/service/frontend/api/v1/dagruns.gointernal/service/frontend/api/v1/dagruns_edit_retry.gointernal/service/frontend/api/v1/dags.gointernal/service/frontend/server.gointernal/service/scheduler/dag_executor.gointernal/service/scheduler/dag_executor_internal_test.gointernal/service/scheduler/export_test.gointernal/service/scheduler/github_dispatch.gointernal/service/scheduler/scheduler.gointernal/service/worker/remote_handler.gointernal/service/worker/remote_handler_test.gointernal/test/helper.gointernal/test/proc.gointernal/test/scheduler.gorefactor_persis_layer.html
✅ Files skipped from review due to trivial changes (1)
- refactor_persis_layer.html
🚧 Files skipped from review as they are similar to previous changes (12)
- internal/persis/file/service_registry.go
- internal/test/scheduler.go
- internal/persis/file/proc_store.go
- internal/service/worker/remote_handler_test.go
- internal/cmd/process/dag_store.go
- internal/engine/engine.go
- internal/cmd/process/agent_stores.go
- internal/persis/file/dag_store.go
- internal/service/worker/remote_handler.go
- internal/persis/file/dagrun_store.go
- internal/cmd/agent.go
- internal/test/helper.go
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
You're iterating quickly on this pull request. To help protect your rate limits, cubic has paused automatic reviews on new pushes for now—when you're ready for another review, comment |
Summary
Testing
Summary by CodeRabbit
Refactor
Bug Fixes