Skip to content

feat(forge): notify router + snapshot apply (RIG-2732) - #676

Open
rigel-mintaka wants to merge 2 commits into
compass-forge/rig-2732-t2-ingressfrom
compass-forge/rig-2732-t4-router
Open

feat(forge): notify router + snapshot apply (RIG-2732)#676
rigel-mintaka wants to merge 2 commits into
compass-forge/rig-2732-t2-ingressfrom
compass-forge/rig-2732-t4-router

Conversation

@rigel-mintaka

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

Copy link
Copy Markdown
Contributor

This PR is part of a stack containing 4 PRs:

  1. main
  2. feat(forge): container-scope subscriptions, notification kinds, forge ack frame (RIG-2732) #674
  3. feat(forge): webhook ingress + event normalize (RIG-2732) #675
  4. "feat(forge): notify router + snapshot apply (RIG-2732)" (this PR)
  5. feat(forge): reconcile sweep + conditional reads (RIG-2732) #677

T4: the ForgeEvent hot path — NotifyRouter.Route + pure ApplyEvent/SnapshotRevision.

  • notify_router.go: package-local structural seams (NotifyStore, NotifyDispatcher, ChecksRoller) + NotifyRouter. Route runs the frozen algorithm (design.md:841-872): load prior snapshot -> resolve CHECKS roll-up before apply -> ApplyEvent -> upsert cursor BEFORE notify -> resolve subs (OPENED=container/project-matched, per-artifact=exact coordinate) -> dispatch a ForgeNotification carrying revision. Never advances delivered_revision (W3, ack-driven).
  • notify_detect.go: ArtifactSnapshot canonical form + pure ApplyEvent + SnapshotRevision (sha256 of canonical JSON, sorted checks, map-keyed comments) — the cross-producer meeting-point contract shared with T5.
  • Red-first unit tests with fakes for both seams, incl. the meeting-point invariant.

Reconciled seams (single-admissible readings, not open forks): NotifyStore gained LoadArtifactCursor (the frozen 3-method block omits the point read the algorithm's step 1 needs); ChecksRoller returns a placeholder ChecksResult in this commit, collapsed into the real forge.ConditionalResult[forge.Checks] by T5 stacked above; UPDATE/REVIEW are snapshot-neutral and labels are excluded from the digest (the ForgeEvent currency carries no title/body/labels, so the canonicalization invariant holds trivially).

Refs RIG-2732

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

@linear-code

linear-code Bot commented Aug 27, 2026

Copy link
Copy Markdown

RIG-2732

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

Compass engineering docs preview: https://compass-forge-rig-2732-t4-ro.compass-eng-docs.pages.dev

Deployed from compass-forge/rig-2732-t4-router at 5ac4f40.

rigel-mintaka and others added 2 commits August 27, 2026 04:44
T4: the `ForgeEvent` hot path — `NotifyRouter.Route` + pure `ApplyEvent`/`SnapshotRevision`.

- `notify_router.go`: package-local structural seams (`NotifyStore`, `NotifyDispatcher`, `ChecksRoller`) + `NotifyRouter`. `Route` runs the frozen algorithm (design.md:841-872): load prior snapshot -> resolve CHECKS roll-up before apply -> `ApplyEvent` -> upsert cursor BEFORE notify -> resolve subs (OPENED=container/project-matched, per-artifact=exact coordinate) -> dispatch a `ForgeNotification` carrying revision. Never advances `delivered_revision` (W3, ack-driven).
- `notify_detect.go`: `ArtifactSnapshot` canonical form + pure `ApplyEvent` + `SnapshotRevision` (sha256 of canonical JSON, sorted checks, map-keyed comments) — the cross-producer meeting-point contract shared with T5.
- Red-first unit tests with fakes for both seams, incl. the meeting-point invariant.

Reconciled seams (single-admissible readings, not open forks): `NotifyStore` gained `LoadArtifactCursor` (the frozen 3-method block omits the point read the algorithm's step 1 needs); `ChecksRoller` returns a placeholder `ChecksResult` in this commit, collapsed into the real `forge.ConditionalResult[forge.Checks]` by T5 stacked above; UPDATE/REVIEW are snapshot-neutral and labels are excluded from the digest (the `ForgeEvent` currency carries no title/body/labels, so the canonicalization invariant holds trivially).

Refs RIG-2732

Co-authored-by: Matt Wilkinson <matt@rigel.build>
…-2732)

Review fixes for the notify router slice (PR #676):

- Extend `Route`'s coordinate guard to reject `ev.Number == 0`, not just zero provider/kind. The frozen Global Constraint makes a zero number a caller bug for every event kind (ForgeEvent.Number is always set; on OPENED it is the new artifact's number), so a zero-number event must be `ErrInvalidArgument`, never a bogus number-0 cursor write. OPENED is unaffected (it carries the new artifact's number).
- Add router error-path tests: a `LoadArtifactCursor` error aborts before upsert/dispatch; a `ChecksRoller` error on a CHECKS event aborts before apply; an `UpsertArtifactCursor` error surfaces and dispatches nothing (proving upsert-before-notify ordering under failure). These fakes exposed the error fields but no test set them.

Refs RIG-2732

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@rigel-mintaka
rigel-mintaka force-pushed the compass-forge/rig-2732-t2-ingress branch from e8f7a9f to 4e56465 Compare August 27, 2026 08:51
@rigel-mintaka
rigel-mintaka force-pushed the compass-forge/rig-2732-t4-router branch from 0732b93 to 5ac4f40 Compare August 27, 2026 08:52
@rigel-mintaka
rigel-mintaka marked this pull request as ready for review August 27, 2026 09:05
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