feat(store): recency-guard write-path threading for forge_updated_at (RIG-2883) - #710
Open
rigel-mintaka wants to merge 1 commit into
Open
Conversation
|
Compass engineering docs preview: https://compass-forge-rig-2883-t4a-r.compass-eng-docs.pages.dev Deployed from |
…(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
force-pushed
the
compass-forge/rig-2883-t4a-recency
branch
from
August 28, 2026 05:02
374648c to
19ebe53
Compare
rigel-mintaka
marked this pull request as ready for review
August 28, 2026 05:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is part of a stack containing 2 PRs:
mainThread the forge
updated_atrecency 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 inertissues.forge_updated_atcolumn; 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 = 19to the canonicalIssuemessage (next free field number) and regenerate the Go and TS clients.TranslateIssuemaps it fromforge.Issue.UpdatedAt(zero time to nil),protoToForgeFieldscarries it intoIssueForgeFields.ForgeUpdatedAt, andUpsertIssueForgeFieldswritesforge_updated_at(zero time to SQL NULL) with a conditionalON 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 thatPublishIssueUpdatedepends on.Refs RIG-2883
Co-authored-by: Matt Wilkinson matt@rigel.build