Refactor architecture into eight components and consolidate reliability work
Build and publish container images / images (push) Successful in 9m34s
Release container images / release (push) Successful in 36s

Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts.

Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation.

Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
This commit is contained in:
Anya Tokugawa committed 2026-11-01 15:23:31 +09:00
1 parent 9dd425f765
commit d5d21b7841
302 files changed
+20037 -3492

No files matched your search

+34 -11
View File
@@ -8,9 +8,11 @@ import (
"errors"
"strings"
"time"
"pageswiki/internal/ordoschnellic"
)
const NotificationPushEventType = "notification.push.deliver"
const NotificationPushEventType = ordoschnellic.PushEventType
func (s *Store) ensureNotificationPushSchema() error {
_, err := s.DB.Exec(`CREATE TABLE IF NOT EXISTS notification_push_keys(id INTEGER PRIMARY KEY CHECK(id=1),private_key TEXT NOT NULL,public_key TEXT NOT NULL);
@@ -81,11 +83,7 @@ func (s *Store) DeleteNotificationPush(ctx context.Context, domain, owner, endpo
return err
}
type NotificationPushDelivery struct {
ID, Notification, Domain, Owner, Subscription string
Focused bool
Attempt int
}
type NotificationPushDelivery = ordoschnellic.PushDelivery
func (s *Store) AcknowledgeNotificationPush(ctx context.Context, domain, owner, endpoint string, ids []string) error {
if len(ids) == 0 {
@@ -104,12 +102,20 @@ func (s *Store) AcknowledgeNotificationPush(ctx context.Context, domain, owner,
return err
}
func (s *Store) DeferFocusedNotificationPush(ctx context.Context, d *NotificationPushDelivery) error {
_, err := s.DB.ExecContext(ctx, `UPDATE notification_push_queue SET attempts=attempts-1,lease_until_ms=0,next_at_ms=? WHERE subscription_id=? AND notification_uuid=? AND attempts=?`, time.Now().Add(time.Minute).UnixMilli(), d.ID, d.Notification, d.Attempt)
return s.DeferFocusedNotificationPushAt(ctx, d, time.Now())
}
func (s *Store) DeferFocusedNotificationPushAt(ctx context.Context, d *NotificationPushDelivery, at time.Time) error {
_, err := s.DB.ExecContext(ctx, `UPDATE notification_push_queue SET attempts=attempts-1,lease_until_ms=0,next_at_ms=? WHERE subscription_id=? AND notification_uuid=? AND attempts=?`, at.Add(ordoschnellic.PushFocusDelay).UnixMilli(), d.ID, d.Notification, d.Attempt)
return err
}
func (s *Store) ClaimNotificationPush(ctx context.Context) (*NotificationPushDelivery, error) {
now := time.Now().UnixMilli()
return s.ClaimNotificationPushAt(ctx, time.Now())
}
func (s *Store) ClaimNotificationPushAt(ctx context.Context, at time.Time) (*NotificationPushDelivery, error) {
now := at.UnixMilli()
tx, err := s.DB.BeginTx(ctx, nil)
if err != nil {
return nil, err
@@ -117,7 +123,7 @@ func (s *Store) ClaimNotificationPush(ctx context.Context) (*NotificationPushDel
defer tx.Rollback()
// Atomic claim across scheduler workers/processes. Outbound I/O is never inside this transaction.
var d NotificationPushDelivery
err = tx.QueryRowContext(ctx, `UPDATE notification_push_queue SET lease_until_ms=?,attempts=attempts+1 WHERE (subscription_id,notification_uuid)=(SELECT subscription_id,notification_uuid FROM notification_push_queue WHERE next_at_ms<=? AND lease_until_ms<=? ORDER BY next_at_ms LIMIT 1) RETURNING subscription_id,notification_uuid,attempts`, now+60000, now, now).Scan(&d.ID, &d.Notification, &d.Attempt)
err = tx.QueryRowContext(ctx, `UPDATE notification_push_queue SET lease_until_ms=?,attempts=attempts+1 WHERE (subscription_id,notification_uuid)=(SELECT subscription_id,notification_uuid FROM notification_push_queue WHERE next_at_ms<=? AND lease_until_ms<=? ORDER BY next_at_ms LIMIT 1) RETURNING subscription_id,notification_uuid,attempts`, at.Add(ordoschnellic.PushLeaseDuration).UnixMilli(), now, now).Scan(&d.ID, &d.Notification, &d.Attempt)
if errors.Is(err, sql.ErrNoRows) {
return nil, nil
}
@@ -141,15 +147,32 @@ func (s *Store) ClaimNotificationPush(ctx context.Context) (*NotificationPushDel
}
func (s *Store) FinishNotificationPush(ctx context.Context, d *NotificationPushDelivery, retry, expired bool) error {
return s.FinishNotificationPushAt(ctx, d, retry, expired, time.Now())
}
func (s *Store) FinishNotificationPushAt(ctx context.Context, d *NotificationPushDelivery, retry, expired bool, at time.Time) error {
if expired {
if _, err := s.DB.ExecContext(ctx, `DELETE FROM notification_push_subscriptions WHERE id=?`, d.ID); err != nil {
return err
}
}
if retry && d.Attempt < 5 {
_, err := s.DB.ExecContext(ctx, `UPDATE notification_push_queue SET next_at_ms=?,lease_until_ms=0 WHERE subscription_id=? AND notification_uuid=? AND attempts=?`, time.Now().Add(time.Duration(1<<d.Attempt)*time.Minute).UnixMilli(), d.ID, d.Notification, d.Attempt)
if next, again := ordoschnellic.RetryAt(d.Attempt, at); retry && again {
_, err := s.DB.ExecContext(ctx, `UPDATE notification_push_queue SET next_at_ms=?,lease_until_ms=0 WHERE subscription_id=? AND notification_uuid=? AND attempts=?`, next.UnixMilli(), d.ID, d.Notification, d.Attempt)
return err
}
_, err := s.DB.ExecContext(ctx, `DELETE FROM notification_push_queue WHERE subscription_id=? AND notification_uuid=? AND attempts=?`, d.ID, d.Notification, d.Attempt)
return err
}
// CleanupNotificationPush only removes bounded stale delivery state, not Inbox.
func (s *Store) CleanupNotificationPush(ctx context.Context, at time.Time) error {
if s.ReadOnly {
return ErrReadOnly
}
_, err := s.DB.ExecContext(ctx, `DELETE FROM notification_push_subscriptions WHERE id IN (SELECT id FROM notification_push_subscriptions WHERE expires_at_ms<? LIMIT 100)`, at.UnixMilli())
if err != nil {
return err
}
_, err = s.DB.ExecContext(ctx, `DELETE FROM notification_push_queue WHERE rowid IN (SELECT rowid FROM notification_push_queue WHERE created_at_ms<? LIMIT 500)`, at.Add(-ordoschnellic.PushRetention).UnixMilli())
return err
}