notifications (2/5): notification_history keyset listing#453
notifications (2/5): notification_history keyset listing#453illegalprime wants to merge 3 commits into
Conversation
🔐 Codex Security Review
Review SummaryOverall Risk: MEDIUM Findings[MEDIUM] Notification History Page Size Is Not Capped
[LOW] Migration Recovery Instructions Use The Wrong Version
NotesNo changed hunk introduced raw SQL interpolation, shell execution, auth/session handling, plugin trust-boundary changes, frontend rendering changes, pool/wallet configuration changes, or protobuf wire-format changes. The new query is sqlc-parameterized and scoped by Generated by Codex Security Review | |
c64a5c2 to
d032a2d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 923f5e3745
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| @@ -0,0 +1,4 @@ | |||
| -- Index matching the ListNotifications keyset pattern (org_id, id DESC); existing indexes are on received_at and can't serve it. | |||
|
|
|||
| CREATE INDEX idx_notification_history_org_id | |||
There was a problem hiding this comment.
Use the next sequential migration number
This tree jumps from 000086 directly to 000088 (I checked server/migrations, and no 000087 exists), even though the repo's migration workflow is sequential. Once a database runs this file, golang-migrate records version 88, so any follow-up stack that later adds the missing 000087 migration will be skipped on already-deployed environments. Rename this migration to the next unused version, or include the missing 87 before this one.
Useful? React with 👍 / 👎.
| CREATE INDEX idx_notification_history_org_id | ||
| ON notification_history (organization_id, id DESC); |
There was a problem hiding this comment.
Build the history index concurrently
In deployed environments with existing notification_history rows and incoming alertmanager webhooks, this plain CREATE INDEX holds a write-blocking lock on the table for the duration of the build, so InsertNotificationHistory calls can stall during deploy. This table is already populated by the webhook path, and the repo uses CREATE INDEX CONCURRENTLY for similar high-row-count list indexes under the same migration runner; use the concurrent form here as well.
Useful? React with 👍 / 👎.
CREATE INDEX took ACCESS EXCLUSIVE on the live notification_history table, blocking webhook-driven inserts for the duration of the build. Switch to CREATE INDEX CONCURRENTLY (and a matching DROP INDEX CONCURRENTLY in the down migration) so the build runs online, matching the convention established in 000074. golang-migrate's postgres driver runs statements without an implicit transaction, so CONCURRENTLY is safe. Addresses Codex security review finding (LOW) on #453. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Codex findings on this PR:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d9857a968f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| EndsAt sql.NullTime | ||
| } | ||
|
|
||
| // One page of an organization's notifications, newest first. Keyset |
There was a problem hiding this comment.
Regenerate sqlc output from the committed query
This generated comment doesn't match the committed query source (server/sqlc/queries/notification_history.sql now has only the one-line comment on ListNotificationHistory), which means this sqlc file was produced from an earlier version. The generated-code workflow runs just gen and then git diff --quiet (.github/workflows/generated-code-check.yml), so CI will leave the tree dirty until the sqlc artifacts are regenerated from the current SQL.
Useful? React with 👍 / 👎.
CREATE INDEX took ACCESS EXCLUSIVE on the live notification_history table, blocking webhook-driven inserts for the duration of the build. Switch to CREATE INDEX CONCURRENTLY (and a matching DROP INDEX CONCURRENTLY in the down migration) so the build runs online, matching the convention established in 000074. golang-migrate's postgres driver runs statements without an implicit transaction, so CONCURRENTLY is safe. Addresses Codex security review finding (LOW) on #453. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
d9857a9 to
c49d919
Compare
Two review fixes: - The keyset-index migration was numbered 000088 while the permission-seed migration in the next stack PR is 000087. Since this PR merges first, deploying it would advance schema_migrations to 88 and golang-migrate would then skip the lower-numbered 000087 seed on already-upgraded DBs. Renumber the index to 000087 (this PR merges first); the seed becomes 000088 in the authz PR so the numeric order matches the merge order. - Regenerate sqlc: the committed ListNotificationHistory query comment had been shortened but generated/sqlc was stale, so 'just gen' + the generated-code CI check would have failed on a dirty tree. Addresses Codex connector findings (P1/P2) on #453. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…to the mount PR Two review fixes: - Renumber the permission-seed migration 000087 -> 000088 so it sits above the keyset-index migration (now 000087) that merges first in the stack, keeping numeric order aligned with merge order (see #453). - Move the notification entries out of registeredServices (the RBAC contract fixture): TestRPCContract_RegisteredServicesMatchMainMux compares it against the handlers mounted in main.go, and the mounts land in the next stack PR, so listing them here failed the test standalone. The ProcedurePermissions policy map (and its catalog keys) stay here; only the mount-coupled registration moves to the server PR. Addresses Codex connector findings (P1/P2) on #454. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
codex-connector triage (all fixed):
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 607669536a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| -- leaves schema_migrations.dirty=true at version 88 and may leave an INVALID | ||
| -- index in pg_indexes; recovery is to DROP the INVALID index and | ||
| -- `migrate force 87` before re-deploying. |
There was a problem hiding this comment.
Correct the failed-migration recovery version
If this 000087 concurrent index build fails, golang-migrate leaves the database dirty at version 87, not 88; the documented migrate force 87 is unsafe because Force sets the stored migration version and resets dirty to false (pkg.go.dev/github.com/golang-migrate/migrate/v4#Migrate.Force), so the next up treats 000087 as already applied and skips rebuilding the missing index. The recovery text should force the previous version (86) before redeploying.
Useful? React with 👍 / 👎.
d032a2d to
7a2ceb2
Compare
CREATE INDEX took ACCESS EXCLUSIVE on the live notification_history table, blocking webhook-driven inserts for the duration of the build. Switch to CREATE INDEX CONCURRENTLY (and a matching DROP INDEX CONCURRENTLY in the down migration) so the build runs online, matching the convention established in 000074. golang-migrate's postgres driver runs statements without an implicit transaction, so CONCURRENTLY is safe. Addresses Codex security review finding (LOW) on #453. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two review fixes: - The keyset-index migration was numbered 000088 while the permission-seed migration in the next stack PR is 000087. Since this PR merges first, deploying it would advance schema_migrations to 88 and golang-migrate would then skip the lower-numbered 000087 seed on already-upgraded DBs. Renumber the index to 000087 (this PR merges first); the seed becomes 000088 in the authz PR so the numeric order matches the merge order. - Regenerate sqlc: the committed ListNotificationHistory query comment had been shortened but generated/sqlc was stale, so 'just gen' + the generated-code CI check would have failed on a dirty tree. Addresses Codex connector findings (P1/P2) on #453. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6076695 to
03bb87c
Compare
…to the mount PR Two review fixes: - Renumber the permission-seed migration 000087 -> 000088 so it sits above the keyset-index migration (now 000087) that merges first in the stack, keeping numeric order aligned with merge order (see #453). - Move the notification entries out of registeredServices (the RBAC contract fixture): TestRPCContract_RegisteredServicesMatchMainMux compares it against the handlers mounted in main.go, and the mounts land in the next stack PR, so listing them here failed the test standalone. The ProcedurePermissions policy map (and its catalog keys) stay here; only the mount-coupled registration moves to the server PR. Addresses Codex connector findings (P1/P2) on #454. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds the ListNotifications sqlc query and a keyset index on notification_history(id) for stable id-based pagination, plus the Lister interface and StoredNotification read-back type. Builds on the existing webhook-driven history persistence already on main. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
CREATE INDEX took ACCESS EXCLUSIVE on the live notification_history table, blocking webhook-driven inserts for the duration of the build. Switch to CREATE INDEX CONCURRENTLY (and a matching DROP INDEX CONCURRENTLY in the down migration) so the build runs online, matching the convention established in 000074. golang-migrate's postgres driver runs statements without an implicit transaction, so CONCURRENTLY is safe. Addresses Codex security review finding (LOW) on #453. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two review fixes: - The keyset-index migration was numbered 000088 while the permission-seed migration in the next stack PR is 000087. Since this PR merges first, deploying it would advance schema_migrations to 88 and golang-migrate would then skip the lower-numbered 000087 seed on already-upgraded DBs. Renumber the index to 000087 (this PR merges first); the seed becomes 000088 in the authz PR so the numeric order matches the merge order. - Regenerate sqlc: the committed ListNotificationHistory query comment had been shortened but generated/sqlc was stale, so 'just gen' + the generated-code CI check would have failed on a dirty tree. Addresses Codex connector findings (P1/P2) on #453. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
7a2ceb2 to
cd175c1
Compare
03bb87c to
b89405f
Compare
…to the mount PR Two review fixes: - Renumber the permission-seed migration 000087 -> 000088 so it sits above the keyset-index migration (now 000087) that merges first in the stack, keeping numeric order aligned with merge order (see #453). - Move the notification entries out of registeredServices (the RBAC contract fixture): TestRPCContract_RegisteredServicesMatchMainMux compares it against the handlers mounted in main.go, and the mounts land in the next stack PR, so listing them here failed the test standalone. The ProcedurePermissions policy map (and its catalog keys) stay here; only the mount-coupled registration moves to the server PR. Addresses Codex connector findings (P1/P2) on #454. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Stack 2/5 — base: `eden/notifications-1-proto`
Adds the read/list side of notification history on top of the webhook-driven persistence already on `main`.
Stack
🤖 Generated with Claude Code