Open
Conversation
…lignment + 422 on missing email)
…+ collapse migrations)
…ncy + push tests)
…tion-notifications
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Reviewed by gpt-5.5-2026-04-23 · 1,513,245 tokens |
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.
Summary
Add a notification framework for the scheduled action feature so admins can let users know ahead of time when an instance is going to restart or change version. Three channels:
getStatus.scheduledActionPlumbing
A new
kiloclaw_scheduled_action_notificationstable holds one row per target, kind, and channel.kindis eithernotice(the heads up that fires before the action) orcancelled(the follow up after an admin cancels an action whose notice already went out).statuswalkspending,sending, thensentorfailed.A cron in the kiloclaw worker fires every minute. It recovers any rows left in
sendingfrom a crashed prior tick, selects rows whose lead window has opened (and whose parent target is still pending fornoticerows), claims each row atomically with a CAS that revalidates parent state, dispatches the channel side effect, and marks the row sent or failed. A timeout bounds each email post so a slow upstream cannot stall the workers in a batch.Email dispatch goes through a new internal route at
/api/internal/kiloclaw/scheduled-action-side-effectsso the email rendering and Mailgun send stays where it already lives. The authentication header is compared with HMAC thentimingSafeEqualso the compare runs on fixed length buffers regardless of input.Mobile push goes directly through the NOTIFICATIONS service binding. The mobile app notification parser was extended to recognize the new payload so the app suppresses the alert when the user is already in that chat, and routes to the chat when the user taps the notification.
The webapp banner is a no op dispatch. The row exists, the workspace renders the banner from
getStatus.scheduledAction. The banner query joins the webapp notice row so the banner stays hidden when an admin opted out of notify or dropped webapp from the channel set, and the banner waits until the lead window opens.Cancellation
When an admin cancels a scheduled action (whole or per instance), pending notice rows transition to
failedwith reasonaction cancelled before notice was dispatched, so the sweep will not deliver a stale notice. For channels that already received a sent notice, a matchingcancelledrow is queued so the user sees the follow up.Admin UI
The Change Version dialog on the instance detail page and the Scheduler tab forms (Schedule Restart and Schedule Version Change) expose notify (on by default), lead hours, subject and body, and channel selection, so an admin can narrow or silence the notification per schedule. The Scheduler tab also adds a Run Notice Sweep Now button that drives the sweep on demand for verifying notice copy.
Storage
One migration adds the notifications table, a unique index on (target, kind, channel), and a partial index on
target_id WHERE status = 'pending'for the sweep lookup.Verification
failedand no notice is delivered.cancelledrow is queued for the channels that already received the notice and the user sees the cancellation.Visual Changes
N/A
Reviewer Notes
cancelledrows skip the parent gate since they announce the cancellation regardless of where the parent ended up.kilocode_usersrather than an inner join, anddispatchOneshort circuits with a clear error when the joined user record is missing. An inner join would silently drop the row and leave it pending forever. Today the GDPR flow only anonymizes the row, so this is defense against a future path that hard deletes a user.