Skip to content

feat(store): recency-guard write-path threading for forge_updated_at (RIG-2883) - #710

Open
rigel-mintaka wants to merge 1 commit into
compass-forge/rig-2883-t4-storefrom
compass-forge/rig-2883-t4a-recency
Open

feat(store): recency-guard write-path threading for forge_updated_at (RIG-2883)#710
rigel-mintaka wants to merge 1 commit into
compass-forge/rig-2883-t4-storefrom
compass-forge/rig-2883-t4a-recency

Conversation

@rigel-mintaka

@rigel-mintaka rigel-mintaka commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

This PR is part of a stack containing 2 PRs:

  1. main
  2. feat(store): watermark persistence + enabled-repo enumeration (RIG-2883 T4) #705
  3. "feat(store): recency-guard write-path threading for forge_updated_at (RIG-2883)" (this PR)

Thread the forge updated_at recency guard (OQ-6 ruled option (a), DL-129 precedent) end-to-end so the board sink is order-independent: a stale or out-of-order re-sink never overwrites a fresher row. T4 added the inert issues.forge_updated_at column; this slice populates it and makes the UPSERT conditional. The five-step chain lands together, since the guard cannot fire until all of it is present.

Add google.protobuf.Timestamp updated_at = 19 to the canonical Issue message (next free field number) and regenerate the Go and TS clients. TranslateIssue maps it from forge.Issue.UpdatedAt (zero time to nil), protoToForgeFields carries it into IssueForgeFields.ForgeUpdatedAt, and UpsertIssueForgeFields writes forge_updated_at (zero time to SQL NULL) with a conditional ON CONFLICT DO UPDATE ... WHERE issues.forge_updated_at IS NULL OR EXCLUDED.forge_updated_at IS NULL OR EXCLUDED.forge_updated_at >= issues.forge_updated_at.

The guard is additive: the two NULL arms let any writer that does not set a timestamp (rows written before threading, any not-yet-threaded writer) still upsert; only when both sides carry a timestamp does the >= comparison gate the write (inclusive, so an equal-timestamp re-sink still applies at second granularity). A guard-skipped write is not an error — the upsert is wrapped in a CTE whose fallback SELECT returns the existing id, preserving the "returns the stable id across polls" contract that PublishIssueUpdate depends on.

Refs RIG-2883
Co-authored-by: Matt Wilkinson matt@rigel.build

@linear-code

linear-code Bot commented Aug 28, 2026

Copy link
Copy Markdown

RIG-2883

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

Compass engineering docs preview: https://compass-forge-rig-2883-t4a-r.compass-eng-docs.pages.dev

Deployed from compass-forge/rig-2883-t4a-recency at 19ebe53.

…(RIG-2883)

Thread the forge `updated_at` recency guard (OQ-6 ruled option (a), DL-129 precedent) end-to-end so the board sink is order-independent: a stale or out-of-order re-sink never overwrites a fresher row. T4 added the inert `issues.forge_updated_at` column; this slice populates it and makes the UPSERT conditional. The five-step chain lands together, since the guard cannot fire until all of it is present.

Add `google.protobuf.Timestamp updated_at = 19` to the canonical `Issue` message (next free field number) and regenerate the Go and TS clients. `TranslateIssue` maps it from `forge.Issue.UpdatedAt` (zero time to nil), `protoToForgeFields` carries it into `IssueForgeFields.ForgeUpdatedAt`, and `UpsertIssueForgeFields` writes `forge_updated_at` (zero time to SQL NULL) with a conditional `ON CONFLICT DO UPDATE ... WHERE issues.forge_updated_at IS NULL OR EXCLUDED.forge_updated_at IS NULL OR EXCLUDED.forge_updated_at >= issues.forge_updated_at`.

The guard is additive: the two NULL arms let any writer that does not set a timestamp (rows written before threading, any not-yet-threaded writer) still upsert; only when both sides carry a timestamp does the `>=` comparison gate the write (inclusive, so an equal-timestamp re-sink still applies at second granularity). A guard-skipped write is not an error — the upsert is wrapped in a CTE whose fallback SELECT returns the existing id, preserving the "returns the stable id across polls" contract that `PublishIssueUpdate` depends on.

Refs RIG-2883
Co-authored-by: Matt Wilkinson <matt@rigel.build>
@rigel-mintaka
rigel-mintaka force-pushed the compass-forge/rig-2883-t4a-recency branch from 374648c to 19ebe53 Compare August 28, 2026 05:02
@rigel-mintaka
rigel-mintaka marked this pull request as ready for review August 28, 2026 05:41
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.

1 participant