Skip to content

feat(store): status board tables, patch merge and board reads (RIG-5170) - #2212

Open
rigel-mintaka wants to merge 1 commit into
mainfrom
compass-server/rig-5170-board-store
Open

rigel-mintaka wants to merge 1 commit into
mainfrom
compass-server/rig-5170-board-store

Conversation

@rigel-mintaka

@rigel-mintaka rigel-mintaka commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

This PR is part of a stack containing 5 PRs:

  1. main
  2. "feat(store): status board tables, patch merge and board reads (RIG-5170)" (this PR)
  3. feat(comms): carry an optional issue or PR ref on asks (RIG-5173) #2228
  4. feat(board): derive board refs, PR gates and stacks from stored rows (RIG-5171) #2231
  5. feat(mirror): mirror asks and topics to forge issues and PRs (RIG-5181) #2275
  6. feat(board): agent board RPCs, roster summary and board events (RIG-5172) #2285

Summary

Status board store layer (task T2 of the agent status record). It adds tables, patch merge, and board, search and ask reads. It has no RPC; ListAgentBoards and the relay arms are T4/T5.

  • Schema (0001_init.sql): agent_boards and agent_board_tasks (tenant-scoped, RLS forced), plus messages_topic_at_idx (tenant_id, topic_id, at_unix_ms), which bounds the answered-ask window.
  • ApplyBoardPatch:
    • Merges upserts, removes, focus and halt in one transaction under a FOR NO KEY UPDATE agent lock.
    • Enforces caps (tasks, refs, waiting, subagents, field lengths). Validation errors write nothing.
    • Drops the oldest settled subagent at capacity. Settled means ended_at is set, or the status is completed, failed or aborted.
    • Rejects a waiting.on that is missing, numeric or unknown.
  • AgentBoards: board and task rows come from one REPEATABLE READ, read-only snapshot.
  • SearchAgentBoards: full-text title and primary-ref match, plus state, waiting and ref filters. It caps distinct agents in SQL (default 20, max 100) and returns each agent's matching task keys.
  • AsksByAuthor: pending asks first, then asks answered inside the window. The answer time is the answer message's timestamp, and channels the viewer can't see are clipped.
  • PR/issue coordinate reads and open authored refs: GitHub repos are matched on the normalized (lowercase) coordinate.
  • Ask.Ref was added to the stored ask block.

Tests

pgtest (-tags=pgtest, container):

  • Patch: merge and defaults, focus clear, unknown focus, replace at capacity, cap breach keeps the board, validation writes nothing (13 subtests, including waiting on missing, numeric and unknown), settled-subagent eviction (including aborted), automatic patch freshness.
  • Reads: the one-snapshot test (a test seam commits a patch between the two reads; red-checked against reading outside the tx), tenant isolation.
  • Search: combined filters with a state decoy, title and primary ref, clamp to 100 agents with 3 keys each (red-checked against a task-row LIMIT), zero limit defaults to 20.
  • Asks: an old pending ask outranks 19 answered asks, answer-timestamp window, invisible-channel clipping.
  • Coordinates: mixed-case GitHub repo matches (red-checked).
  • TestRLSCatalogEnabledAndForced, the cross-tenant RLS suite and all TestAnswerAsk* pass.

Gates: sqlc-drift, sqlc-vet (db-prepare skipped locally with no DSN), sql-migration-gate, inline-sql-gate, golangci-lint (with and without the pgtest tag), and the moon ci pre-push gate.

Refs RIG-5170

Ledger-impact: none

@trunk-io

trunk-io Bot commented Oct 12, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@linear-code

linear-code Bot commented Oct 12, 2026

Copy link
Copy Markdown

RIG-5170

@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

Review result: head 4d8ea6f

Review-lead fan-out (correctness, security, design, style).

Round High Medium Low Outcome
R1 1 5 some fixed
R2 0 4 some fixed (PostedAt is the ask time; settled definition)
R3 0 some some fixed (aborted terminal, SQL agent cap, decoys, ordering)
R4 1 4 1 fixed (pending-first, answer pre-filter, snapshot tx, cap and state decoy tests)
R5 0 4 2 fixed (topic/time index, direct repo match, waiting.on validation, NO KEY UPDATE, xmin assertion dropped). Style findings on files outside this diff came from a stale review base and were voided after a rebase
R6 0 1 1 fixed (deterministic snapshot test, zero-limit default test)
R7 0 0 1 fixed (blank line)

Dismissed with reasons: viewer-visibility capping belongs to the T4 service boundary; stopword-only search; cancelled/error statuses (the SDK emits only started, completed, failed and aborted); positional sqlc params.

After R7, the pre-push inline-sql-gate flagged the agent lock query. It moved verbatim to the sqlc LockBoardAgent query; patch tests re-run green.

No open findings.

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Compass engineering docs preview: https://compass-server-rig-5170-boar.compass-eng-docs.pages.dev

Deployed from compass-server/rig-5170-board-store at 4d7c165.

@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

Rebase note: rebased onto main (#2210 also edited 0001_init.sql). Interdiff from reviewed head 4d8ea6fa to 51287001: only the sqlc-regenerated go/internal/store/db/querier.go (ListOpenPullRequests/PullRequestLinks ordering after sqlc generate). No hand edits. Re-checked: sqlc-drift, sql-migration-gate, inline-sql-gate, store/board unit tests, board pgtests (33 PASS), golangci-lint plain and pgtest (0 issues).

Adds agent_boards and agent_board_tasks to 0001_init.sql, with tenant RLS and
updated_at triggers. ApplyBoardPatch merges a presence-aware patch in one
transaction: it enforces the caps, defaults a new task to ACTIVE, clears focus
when the focused task is removed, merges subagents by id (dropping the oldest
settled one past the cap), and leaves freshness alone for automatic patches.

Board reads, task search, viewer-clipped asks by author, open authored refs, and
coordinate lookups for pull requests and issues serve the later board derivation.
Ask gains a stored Ref.

Ledger-impact: none

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@rigel-mintaka
rigel-mintaka force-pushed the compass-server/rig-5170-board-store branch from 5128700 to 4d7c165 Compare October 13, 2026 08:43
@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

Rebase note: rebased onto main (b1e8515) after RIG-5326 and RIG-5324 landed. Interdiff from approved head 51287001 to 4d7c1659 is empty.

This branch has not been deployed

No deployments
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.

2 participants