fix: PR #38 follow-ups — upgrade path, DeleteRun race, runquery lift - #39
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR introduces a backend-neutral read API package ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Addresses the critical review on #38: - schema.sql: add UPDATE workflow_runs SET org_id/initiated_by = NULL WHERE = '' so single-tenant rows migrated from v0.0.3 stay visible to the new read API (GetRun, ListRuns), and drop NOT NULL on initiated_by alongside org_id. Expand the upgrade-path comment to name v0.0.3 -> v0.0.4 explicitly. - DeleteRun: collapse into one atomic DELETE ... WHERE status <> 'running' RETURNING status; a post-delete probe only runs to pick between ErrRunNotFound and ErrCannotDeleteRunning for the error message, not to gate the destructive path. - experimental/worker/runquery: new stdlib-only package holding Run, RunFilter, RunCursor, ErrRunNotFound, ErrCannotDeleteRunning, and the Store interface. Postgres now aliases the runquery types and satisfies runquery.Store at compile time so dashboards can import the neutral package instead of experimental/store/postgres. - sqlite ReclaimStale: also clear started_at, matching Postgres. - sqlite store.go: document that SQLite has no schema namespacing; consumers who need coexistence should hand the library a dedicated *sql.DB. - HandlerContext/HandlerStores: doc comment clarifying only Checkpointer is lease-fenced. ProgressStore and ActivityLogger accept *Claim for symmetry and typically ignore it; SignalStore is shared across claims and intentionally lives on Config, not the factory. - Rename QueueStore.ListFailedWithCredits -> ListRefundPending in worker, memstore, postgres, sqlite, and the integration test. - Add TestStore_UpgradeFromV003: seeds a v0.0.3-shaped table with a populated row, runs Migrate, and asserts the row is still findable via the new read API. Catches the very regression the review flagged. - Add TestStore_ClaimQueuedConcurrent: 8 goroutines race to claim a 20-run queue; every run must be claimed exactly once. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…n loop - memstore.ListRefundPending: collect every match, sort by completed_at ASC NULLS LAST then ID, then apply the limit. The previous loop applied the limit while iterating an unordered map, then sorted the truncated set, so the returned page was nondeterministic. - postgres/runs.go: extract the GetRun/ListRuns column projection into a single runProjection constant kept in lock-step with scanRun. Adding or reordering a column now touches one place, not two. - postgres/integration_test.go: replace the for-range-with-blanks queue drain with an explicit "claim until empty" loop. Same effect, the intent is on the page. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reflect the changes from PRs #37-#39: richer Claim fields, HandlerContext with the only-Checkpointer-is-fenced caveat, the runquery subpackage, configurable Postgres schema via WithSchema, atomic DeleteRun, the v0.0.3 single-tenant upgrade carry-forward, and the SQLite coexistence note. Lighter tone throughout; replaced the "Going to production" section with a friendlier "Bring your own storage" framing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…40) Reflect the changes from PRs #37-#39: richer Claim fields, HandlerContext with the only-Checkpointer-is-fenced caveat, the runquery subpackage, configurable Postgres schema via WithSchema, atomic DeleteRun, the v0.0.3 single-tenant upgrade carry-forward, and the SQLite coexistence note. Lighter tone throughout; replaced the "Going to production" section with a friendlier "Bring your own storage" framing. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Addresses the critical review on #38. Stacked on top of
feat/worker-pgstore-v2so it merges once the base PR ships.Must-fix
UPDATE workflow_runs SET org_id/initiated_by = NULL WHERE = ''so pre-existing v0.0.3 single-tenant rows stay visible to the new read API afterMigrate(). Also drop NOT NULL oninitiated_by(was only dropped onorg_id), and rewrite the upgrade comment to name the v0.0.3 → v0.0.4 boundary explicitly.DELETE … WHERE status <> 'running' RETURNING status. The destructive path is now one atomic statement; a follow-up probe only fires to pick betweenErrRunNotFoundandErrCannotDeleteRunningfor the error message, never to gate the delete.Should-fix
experimental/worker/runquery(stdlib-only) holdsRun,RunFilter,RunCursor,ErrRunNotFound,ErrCannotDeleteRunning, and theStoreinterface. Postgres aliases the types and satisfiesrunquery.Storeat compile time. Dashboards can now depend onrunqueryinstead of importingexperimental/store/postgres.started_at = NULL, matching Postgres.Checkpointeris lease-fenced.ProgressStore/ActivityLoggeraccept*Claimfor API symmetry and typically ignore it;SignalStoreis shared across claims and intentionally lives onConfig, not the factory.Nice-to-have
QueueStore.ListFailedWithCredits→ListRefundPendingacross worker, memstore, postgres, sqlite, and the integration test.*sql.DB.New tests
TestStore_UpgradeFromV003— seeds a v0.0.3-shapedworkflow_runstable (org_id NOT NULL DEFAULT '', noproject_id/parent_run_id/metadata), inserts a populated row, runsMigrate, and asserts the row is still findable viaGetRun/ListRuns. This catches the exact regression the review flagged.TestStore_ClaimQueuedConcurrent— 8 goroutines race to claim a 20-run queue; every run must be claimed exactly once across all workers.Test plan
make test-allat repo root — all modules build, vet clean, existing tests passgo vetcleanly across root,experimental/worker,experimental/store/postgres,experimental/store/sqliteWORKFLOW_PG_DSN=… go test ./experimental/store/postgres/…— newTestStore_UpgradeFromV003andTestStore_ClaimQueuedConcurrentin particular🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Improvements