Skip to content

refactor(store): wave B.15 — action_set repo (#273)#274

Merged
PaulDotterer merged 1 commit into
mainfrom
feat/273-actionset-repo
May 15, 2026
Merged

refactor(store): wave B.15 — action_set repo (#273)#274
PaulDotterer merged 1 commit into
mainfrom
feat/273-actionset-repo

Conversation

@PaulDotterer

@PaulDotterer PaulDotterer commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

`ActionSetRepo` — read side of `action_sets_projection` + `action_set_members_projection`. Branches off main directly.

Methods

  • `Get(id)` / `List(filter)` / `Count(unassignedOnly)`
  • `ListMembers(setID)` — hydrated with action_name + action_type
  • `ListInDefinition(definitionID)` — sets belonging to a definition

`Schedule` stays as `json.RawMessage` at the boundary.

Call sites migrated (~20)

  • `action_set_handler.go` — full CRUD + `actionSetToProto` signature
  • `assignment_handler.go` — source validation for ActionSet
  • `user_selection_handler.go` — ActionSet source enrichment
  • `search/index.go` — set reindex sweep, member-list, definition-set membership

Non-goals

  • Definition / Execution / Assignment — subsequent sub-waves.
  • Write-side projector queries — stay on `Queries()`.

Acceptance

  • Build / vet / staticcheck / gofmt: clean.
  • Tests pass: api (34s).

Part of #242. Closes #273.

Summary by CodeRabbit

  • Refactor
    • Consolidated action-set data access behind a repository layer for consistent read handling.
    • Added persistent action-set storage and membership support plus repository wiring to the backend.
    • Updated indexing and dispatch flows to use the new action-set repository, improving reliability and maintainability without changing user-facing behavior.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2cd938bb-6beb-4d07-96d4-7fcac98f6d92

📥 Commits

Reviewing files that changed from the base of the PR and between 0af1f39 and 6dbf590.

📒 Files selected for processing (10)
  • internal/api/action_dispatch.go
  • internal/api/action_set_handler.go
  • internal/api/assignment_handler.go
  • internal/api/definition_handler.go
  • internal/api/user_selection_handler.go
  • internal/search/index.go
  • internal/store/action_set.go
  • internal/store/postgres/action_set.go
  • internal/store/postgres/wire.go
  • internal/store/repos.go
🚧 Files skipped from review as they are similar to previous changes (10)
  • internal/store/postgres/wire.go
  • internal/api/action_dispatch.go
  • internal/store/action_set.go
  • internal/api/user_selection_handler.go
  • internal/store/repos.go
  • internal/api/assignment_handler.go
  • internal/api/definition_handler.go
  • internal/search/index.go
  • internal/store/postgres/action_set.go
  • internal/api/action_set_handler.go

📝 Walkthrough

Walkthrough

Adds a read-side ActionSetRepo: domain projections and interface, Postgres implementation, repo wiring in NewRepos, and migrates action-set read call sites across handlers and the search index from query-layer sqlc calls to the new repository methods.

Changes

ActionSetRepo Read-Side Repository

Layer / File(s) Summary
Store contracts and domain types
internal/store/action_set.go
New ActionSet, ActionSetMember, ListActionSetsFilter types and ActionSetRepo interface with Get, List, Count, ListMembers, ListInDefinition.
Postgres repository implementation
internal/store/postgres/action_set.go
Postgres-backed repo implementing Get/List/Count/ListMembers/ListInDefinition, mapping sqlc projections to store.ActionSet/store.ActionSetMember, passing Schedule as json.RawMessage, and wrapping errors.
Dependency injection wiring
internal/store/repos.go, internal/store/postgres/wire.go
Add ActionSet ActionSetRepo to Repos and initialize it with NewActionSet(q) in NewRepos.
Action set CRUD handlers
internal/api/action_set_handler.go
Switch handler reads from h.store.Queries() to h.store.Repos().ActionSet for create/get/list/rename/update and member operations; update actionSetToProto to accept store.ActionSet.
Cross-handler migrations
internal/api/assignment_handler.go, internal/api/definition_handler.go, internal/api/user_selection_handler.go, internal/api/action_dispatch.go, internal/search/index.go
Migrate assignment validation, definition membership, user-selection enrichment, dispatch listing, and search-index warming to use h.store.Repos().ActionSet methods while preserving existing control flow and error handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

"I'm a rabbit in the code, quick and spry,
ActionSets now read from repos nearby.
Projections hop in, Postgres gives a grin,
Twenty spots migrated—let the tests begin! 🐇"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor(store): wave B.15 — action_set repo (#273)' clearly and specifically describes the main change: implementing the ActionSetRepo as a refactoring effort.
Linked Issues check ✅ Passed The PR implements all required ActionSetRepo methods (Get, List, Count, ListMembers, ListInDefinition), maintains Schedule as json.RawMessage, and successfully migrates ~20 call sites across action_set_handler, assignment_handler, user_selection_handler, and search/index as specified [#273].
Out of Scope Changes check ✅ Passed All changes are directly related to implementing ActionSetRepo and migrating call sites to use it; no Definition, Execution, or Assignment repos are included per stated non-goals [#273].

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/273-actionset-repo

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/api/assignment_handler.go`:
- Around line 340-343: The code in assignment_handler.go silently ignores errors
from h.store.Repos().ActionSet.Get (and the similar call around lines 356-359)
by using continue; change these branches to log the error before continuing:
capture the returned err from h.store.Repos().ActionSet.Get(ctx, id) and call
the appropriate logger (e.g., h.logger or h.store logger) with a clear message
including the action set id and err, then continue; do the same for the second
occurrence so partial failures are visible in logs while preserving the existing
control flow.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 15f5d63c-8faa-4764-83a0-0c63feb30536

📥 Commits

Reviewing files that changed from the base of the PR and between 8e6bf70 and 0af1f39.

📒 Files selected for processing (10)
  • internal/api/action_dispatch.go
  • internal/api/action_set_handler.go
  • internal/api/assignment_handler.go
  • internal/api/definition_handler.go
  • internal/api/user_selection_handler.go
  • internal/search/index.go
  • internal/store/action_set.go
  • internal/store/postgres/action_set.go
  • internal/store/postgres/wire.go
  • internal/store/repos.go

Comment on lines +340 to 343
set, err := h.store.Repos().ActionSet.Get(ctx, id)
if err != nil {
continue
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Log enrichment failures before continuing.

Line 341 and Line 357 swallow repo errors with continue, which hides partial response failures.

🔧 Suggested fix
 		set, err := h.store.Repos().ActionSet.Get(ctx, id)
 		if err != nil {
+			logEnrichmentErr("ActionSet.Get", "action_set_id", id, err)
 			continue
 		}
@@
 		members, err := h.store.Repos().ActionSet.ListMembers(ctx, id)
 		if err != nil {
+			logEnrichmentErr("ActionSet.ListMembers", "action_set_id", id, err)
 			continue
 		}

As per coding guidelines, "Never silently ignore errors."

Also applies to: 356-359

🤖 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/api/assignment_handler.go` around lines 340 - 343, The code in
assignment_handler.go silently ignores errors from h.store.Repos().ActionSet.Get
(and the similar call around lines 356-359) by using continue; change these
branches to log the error before continuing: capture the returned err from
h.store.Repos().ActionSet.Get(ctx, id) and call the appropriate logger (e.g.,
h.logger or h.store logger) with a clear message including the action set id and
err, then continue; do the same for the second occurrence so partial failures
are visible in logs while preserving the existing control flow.

ActionSetRepo continues the action-chain migration started in #271:

  Get / List(filter) / Count(unassignedOnly) / ListMembers /
  ListInDefinition

ActionSetMember rows are hydrated with action_name + action_type for
display. Schedule stays as json.RawMessage at the boundary per the
JSONB normalize plan.

Call sites migrated (~20):
- action_set_handler.go (full CRUD + actionSetToProto signature)
- assignment_handler.go (source validation for ActionSet)
- user_selection_handler.go (ActionSet source enrichment)
- search/index.go (set reindex sweep + member-list enrichment +
  definition-set membership)

Non-goals:
- Definition / Execution / Assignment — subsequent sub-waves.
- Write-side projector queries — stay on Queries() per pattern.

Closes #273.
@PaulDotterer PaulDotterer force-pushed the feat/273-actionset-repo branch from 0af1f39 to 6dbf590 Compare May 15, 2026 22:46
@PaulDotterer PaulDotterer merged commit 84f2769 into main May 15, 2026
5 checks passed
@PaulDotterer PaulDotterer deleted the feat/273-actionset-repo branch May 15, 2026 23:03
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.

wave B.15: action_set repo

1 participant