oficina / equipo Public

push/server

Native slice 2, server: push registrations, push outbox, rules, sender, set aside

Plan: docs/superpowers/plans/2026-11-20-equipo-native-slice-2.md (branch native/slice-2-plan), approved by Paul 2026-11-20 with every recommendation; Luna's verdicts are the copy review.

Review: Claude Fable 5.2, CHANGES REQUESTED on 2ea81007; fixed in 18eee15f.

Paul's rulings (2026-11-20)

"Coordinator replied" stays. A step stopped awaiting Retry keeps the Live Activity running (amber). The Luna acceptance markers are confirmed under his ruling (kept). The per-process stream check is accepted.

Review fixes, with evidence

Mutation evidence: each guard was broken in a scratch copy, the test named was run, and the copy restored. All 58 mutations fail their test (no survivors, skips or build breaks); the list is below the findings.

  1. (High) One APNs token, one credential. push.Register and push.RegisterActivity take the token or start token from any other credential in the same transaction: that credential's registration, its waiting rows and its activity tokens holding it go (takeTokens; tokens compared opened in Go, never in SQL; one that will not open stops nothing). Tests: TestPushTokenMovesToNewCredential (A on the phone, B pairs: A's card never reaches B, A's waiting rows dropped, B's card alerts B), TestRegisterTakesTokens.
  2. (High) Set aside never alerts; the alert mark is durable. setCardAside writes its card event with no push rule (cardEventPush(c, false)). Once-only pushes (card, reply, outcome) are decided once per person in push_once, which is never pruned, and a card's alert is decided even with no device registered. Migration 0095 marks cards already open or asking. Tests: TestSetAsideKeepsNeedsYou (a card with no alert decided, set aside: no alert, no badge), TestPushCardOpensOnce (still no alert after the outbox rows are pruned; a card older than the person's first device never alerts), TestEnqueueCoalesceAndOnce, TestPushMigrationMarksOpenCards.
  3. (Medium-high) Activity tokens after the end, and updates with no token. Once a task ended, RegisterActivity takes the token while a push for that task still waits for the device; the waiting end then goes at once (push.Hurry). Otherwise it answers 409 task_ended. Before the end, a token's arrival sends the task's whole state (push.CatchUp, priority 10). An update with no activity token is never written, and an activity line that went nowhere is not remembered as told. Tests: TestPushActivityTokenAfterEnd, TestRegisterPushAuthority, TestPushActivityLineOnceAMinute, TestPushTaskLifecycle.
  4. (Medium) No token or payload text in SQL or logs. Registration tokens, start tokens, activity tokens and outbox payloads are sealed at rest with the instance key (push.Box = Authority.Seal/Open, domains push.token/push.payload). The sender scrubs any token out of a transport's error and Apple's reason before they are logged or stored. The logged transport no longer logs a token digest (the CARLOS design forbids anything derived from a token). Tests: TestTokensNeverSQLText (captures every statement at GORM Info level through register, activity, enqueue and send), TestPushRegistrationLifetime (real wiring: no token in the table), TestSenderTimeoutAndScrub, TestLoggedTransportKeepsTokensOut.
  5. (Medium) apns-id is a UUID. Row IDs are random version-4 UUIDs, canonical and lowercase (push.NewID), sent as apns-id. Test: TestRowIDIsAnAPNsID, plus the shape check in TestSenderSendsOnceAndRecordsApple.
  6. (Medium-low) First device. Registration (with the outbox on) remembers what the person's open tasks show now and sends the device its badge. Test: TestPushFirstDeviceHearsOutcomes (a task waiting before the first registration gets badge 1 at registration, then Done and badge 0 at merge).
  7. (Low) Only gone forgets. The device check answers push.ErrGone (revoked, never exchanged, another person or instance, signed out everywhere, person removed), push.ErrNotCurrent (token expired: the row is dropped and the registration kept) or a lookup error (the row stays and is retried). personapi.DeviceStore.PushState replaces VerifyAt for pushes. Tests: TestSenderCheckOutcomes, TestPushRegistrationLifetime (expired is not current but stays registered; revoked and removed are ErrGone).
  8. Smaller. - A 4 KB guard (push.MaxPayload) in Render, Enqueue and the sender (TestSenderExpiredAndOversized). - Push bookkeeping never fails the engine's write. Decided and documented in chat/push.go: each change's push work runs in a savepoint (pushSafe); on failure only it is rolled back and logged, and the change commits without its pushes (TestPushNeverFailsTheWrite: a task write, a reply with no message, and a card whose once-mark was written before the outbox failed). - One sound on needs-you: the Live Activity update stays urgent (10) with no alert, so the card's alert is the one sound. push.activity.needs_you was removed (TestRuleTaskLifecycle, TestPushTaskLifecycle, golden activity-needs.json). - Room is made for a start only when a device can take it (TestPushStartsOnlyWhereItCan). - EQUIPOALLOWLOGGEDPUSH together with CARLOSPUSH refuses boot (copyPushBoth, TestPusherRefusesBoth). - The sender gives each send a 30 s deadline (Sender.Timeout, TestSenderTimeoutAndScrub).

CARLOS verb alignment (design/platform-push-submission §4, awaiting Paul; not built)

The seam stays: CARLOS_PUSH=submit refuses boot until rastrillo's push client exists. The contract is in place behind it:

  • push.CarlosRequestOf(m) builds the body: {device_token, topic, push_type, priority, collapse_id?, expiration? (Unix s), apns_id (the row UUID), environment, payload (compact object)}. The payload is at most 4096 bytes compacted and the body at most 8 KiB.
  • push.CarlosResult(status, Retry-After, body) reads the answer: a 200 is Apple's {status, apns_id, reason?, timestamp (ms)?}; anything else is the platform's {code} and Retry-After.
  • push.Judge decides, and the sender acts. Tests: TestJudge, TestSenderCarlosOutcomes, TestCarlosRequest, TestCarlosResult, all through a fake transport. What the sender does: - 429 PAUSED/RATE and 503 PUSHERUNAVAILABLE/APNSUNAVAILABLE: wait for Retry-After without spending an attempt, and end the pass. - 400 BADREQUEST/PAYLOADTOOLARGE, 401, 403 TOPICNOTALLOWED/ENVIRONMENTNOT_ARMED: fail the row, no retry. - Apple 410 Unregistered/ExpiredToken and 400 BadDeviceToken/DeviceTokenNotForTopic: delete the token, unless the registration is newer than a 410's timestamp. - Apple 429: back off that device's rows. - Apple 5xx: retry after 15 minutes, then doubling. - Any other Apple 4xx: fail. - A row past its expiration is dropped unsent.

Device contract (OpenAPI + TestPersonAPIDeviceContract + wireschema.Ops)

  • POST /api/v1/push-registrations (device bearer only; a session gets 401): {"token":hex,"environment":"production|development","platform":"ios|macos","start_token"?:hex} (starttoken on iOS only) returns 200 `PushRegistration {environment, platform, liveactivities, updated_at}. - Tokens are never echoed and are sealed at rest. - One per device credential, and one credential per token: registering takes the token from any other credential. - Deleted on device revocation, on roster removal, and when Apple reports Unregistered, ExpiredToken, BadDeviceToken or DeviceTokenNotForTopic. - With the outbox on, the device gets its badge at once. - Audited as push.register <credential>`, with no token.
  • POST /api/v1/push-registrations/activities: {"task_id","token"} returns 204. Only the person's own task (else 404). - The activity then gets the task's whole current state. - Once the task ended, the token is taken only while the activity's end waits (which then goes at once); otherwise 409 task_ended.
  • POST /api/v1/cards/{id}/visibility (D5): {"aside":bool,"revision":n} returns 200 Card; stale or no longer waiting returns 409 CardConflict card_stale with the card. It never pushes.
  • Payloads (goldens in internal/equipo/push/testdata/): - Alerts carry equipo: {kind: card|reply|task|badge, card_id?, task_id?, turn_id?}. - Card alerts have category needs_you; the collapse ID is the card ID. - Task alerts are interruption-level: passive, collapsed by task:<id>. - The badge is {"aps":{"badge":N}}, coalescing. - Live Activity: topic works.oficina.equipo.push-type.liveactivity, attributes-type EquipoTaskAttributes, attributes {task_id}, content state wire.LiveActivityState.

Rules (internal/equipo/push/rules.go, one table, evaluated in the engine transaction)

  • card_opens: once per card per person, ever.
  • reply_unseen: no /events stream open in this process.
  • task_ends: passive, once.
  • task_fails: needs_you becomes retry; passive.
  • badge: sent when needs_you changes, and at registration.
  • activity_start: only where a device can start an activity.
  • activity_update: priority 10 and silent when the task starts needing the person, else 5; only to a device with the activity's token.
  • activity_line: at most once a minute, remembered only when sent.
  • activity_end.
  • Cap: a fourth start ends the oldest (replaced).

Migration

0095_push.sql (additive): pushregistrations, pushactivities, pushoutbox, pushtasks, push_once. Cards open at migration are marked alerted.

Local gates

  • Pass: runner-dead-references, lanes-check, fmt-check, budget (chat, equipo and plan3test exemptions raised to the measured lines), migration-check, copy-release-check, staticcheck on the changed packages.
  • Packages passing: equipo, chat, push, setup, personapi, wire, wireschema, thintest.
  • Pre-existing local-only failures, the same on origin/main on this Mac: plan3test TestCoordinatorAcceptance3B, team TestPublishCoreAuthorizationContract.

Copy (Luna, codex gpt-5.6-luna, house rules; marked COPY ACCEPTED BY DELEGATION (Luna, 2026-11-20))

  • First pass: push.card.title, push.card.body, push.reply.title "Coordinator replied", push.task.done, push.task.cancelled, push.task.failed, push.activity.started, copyLoggedPushPublic, copyCarlosPushUnavailable.
  • Review fixes: - copyPushBoth "Set EQUIPOALLOWLOGGEDPUSH or CARLOSPUSH, not both." (keep). - The "Receive pushes on a device" section of docs/api/equipo-v1.md (Luna revised two paragraphs; applied verbatim). - push.activity.needs_you removed.

Mutation list (58, all fail)

  • F1: register takes the token (engine and unit); activity token taken; a token that will not open stops nothing.
  • F2: visibility runs no push rule; card alert decided without a device; once-only decided once (unit and engine); the mark outlives the outbox prune; migration marks open cards.
  • F3: token taken while the end waits; 409 when nothing waits; the waiting end goes at once; catch-up on the token's arrival; no update row without a token; a line not sent is not told.
  • F4: tokens, activity tokens and payloads sealed (unit, plus tokens in the real wiring); transport error and Apple's reason scrubbed.
  • F5: UUID IDs; version bits.
  • F6: badge at registration; memory seeded at registration.
  • F7: only gone forgets; a lookup error keeps the row; expired is not gone and revoked is gone (wiring).
  • F8: Render, Enqueue and sender 4 KB guards; push never fails the write; a failed push rolls back alone; one sound (rule and engine); room only when a start is written; both transports refuse boot; a send has a deadline.
  • CARLOS: a hold ends the pass, spends no attempt, honours Retry-After; refusals never retried; Apple 429 holds the device; Apple 5xx waits 15 min; a 410 keeps a newer registration; ExpiredToken and DeviceTokenNotForTopic are gone; a platform answer is never Apple's; expired rows dropped; apns_id is the row; payload compacted before the limit; 410 timestamp in ms; Retry-After read.
  • Earlier guards in changed code: outbox in the engine transaction (an Enqueue through the store's own handle blocks on the engine's transaction, so the test times out); revoked device gets no row; reply only without a stream; logged transport keeps tokens out; the sender sends once.

For Paul

  • Needs-you states with no waiting card (fixrounds, runneroffline, machineremoved, macsandbox, branchmoved, mergeconflict, review_blocked) now make no sound: the Live Activity turns amber at priority 10 and the badge moves. retry keeps its passive alert, and merge and the other card-backed states alert through their card.
  • CARLOS push submission (D1) is still to build: the verb's design awaits approval, and rastrillo's client does not exist. This branch refuses CARLOS_PUSH=submit until then.

Review fixes on 18eee15f

Implementer: Codex GPT-6-Astra. Review: Codex GPT-6-Astra, CHANGES REQUESTED on 18eee15f; fixed in 466b6a0cf1d9448e6d750fbb92cbb4b867a90797

Read the repository AGENTS.md, native slice 2 plan on origin/main, and CARLOS platform-push-submission design on origin/design/platform-push-submission. Work began clean at origin/push/server (18eee15f). No merge or default-branch push.

  1. In-flight token rotation. Before invalidating a device, start or activity token, compare the currently stored token with the sent token, opened only in Go. Every token type also keeps registrations newer than a 410 timestamp. Successful activity ends use the same token comparison for cleanup. Test: TestSenderInvalidationKeepsNewRegistration (rotation on 400/410, same-token renewal on 410, unchanged-token deletion, and rotation during a successful end). Mutations: disable token equality, disable timestamp protection, restore unconditional successful-end deletion; all three fail, including all three token types for the shared equality/timestamp guards.
  2. Unreadable rows. Quarantine token/payload decryption failures as failed with fixed reason codes, keeping opener errors out of logs. A batch of 50 unreadable rows no longer starves valid rows. Test: TestSenderQuarantinesUnreadableRows. Mutations: remove payload quarantine, remove token quarantine, return the raw token opener error; all three fail.
  3. Coalesced badge. Reload the claimed row inside the claim transaction so its current payload, priority and attempt count are used. Test: TestSenderClaimsCurrentBadge. Mutation: remove the reload; the test fails with a stale badge.
  4. Delayed activity start/end. A missing-token end stays pending until its full one-hour expiry, covering the earlier start/update lifetime. Missing tokens consume no delivery attempts; retries remain bounded and back off with row age. Existing registration acceptance while a push is pending remains intact. Token arrival hastens only activity-target rows, preserving a start's Apple retry deadline. Tests: TestSenderEndWaitsForDelayedStart, TestSenderMissingTokenWaitIsBounded, TestActivityTokenDoesNotHurryDelayedStart, TestPushDelayedStartAcceptsTokenAndEnds, and existing TestPushActivityTokenAfterEnd. Mutations: drop missing-token ends, count missing tokens as delivery attempts, bypass end expiry, hurry start rows; all four fail.
  5. Retry enforcement. Claims recheck nextat. A durable platform hold applies across drains, new rows and fresh sender instances for PAUSED, RATE, PUSHERUNAVAILABLE and APNSUNAVAILABLE. Overlapping holds keep the longest deadline, and hold lookup failures deny sending. A final failed delivery still applies Apple's device throttle before exhausting the row. Additive migration 0096pushhold.sql, model and schema snapshot added. Tests: TestSenderThrottlesAlreadyReadBatch, TestSenderPlatformHoldAcrossDrains, TestSenderPlatformHoldLookupFailsClosed, TestSenderPlatformHoldCannotBeShortened, TestSenderLastAttemptStillThrottlesBatch, plus existing CARLOS outcome tests. Mutations: remove nextat recheck, omit hold persistence, ignore held state, ignore hold lookup errors, shorten overlapping holds, skip throttle on the last attempt; all six fail.
  6. Replaced activities. A late token for a replaced activity hastens its pending end without catch-up or memory revival. The fifth task replaces only task 2, leaving exactly three live records. Test: TestPushLateTokenKeepsReplacedActivityEnded. Mutations: bypass ended memory, omit the pending-end hurry; both fail.

Verification commands and evidence

  • Before implementation: GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/push ./internal/equipo/chat -run 'TestSender(Invalidation|Quarantines|ClaimsCurrent|EndWaits|Throttles|PlatformHold)|TestPushLateToken' -count=1 failed for all six findings. The engine delayed-start test, start-deadline test, successful-end rotation case and last-attempt throttle test were also observed failing before their fixes.
  • Mutations: for each of the 19 changes above, GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/{push|chat} -run <named test> -count=1 produced an assertion failure, with no survivors or build-only failures. Each original was restored immediately afterward.
  • Full package suites and local gates: PASS: GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo/push ./internal/equipo/chat ./internal/equipo -count=1; GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/wire/... ./internal/equipo/personapi -count=1; GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/plan3test -run TestPersonAPI -count=1. PASS: PATH="$HOME/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.11.darwin-arm64/bin:$PATH" make runner-dead-references lanes-check fmt-check budget migration-check. Post-commit make runner-dead-references: 2467 tracked text files, 0 failures. All 19 mutations failed their tests, then all requested suites passed with the guards restored.
  • Budget: chat measured 31887 source / 6905 test lines, source exception raised by exactly 6 lines for the replaced-memory check and pending-end handling.
  • CI: PASSED for 466b6a0cf1d9448e6d750fbb92cbb4b867a90797, verified with AMADAN_HOME=$HOME/.amadan-claude-agent amadan ci status oficina/equipo -branch push/server. Pushed through the supplied agent helper; its temporary credential was revoked.

Main integration (a986e103)

Implementer: Codex GPT-6-Astra. Merge commit a986e1035e80965c5903bbfd3de5c8cb1a229528 brings origin/main b6c76de292c1506b03bbd5747dc9df58d5f9dcc9 into push/server, preserving 466b6a0c as the first parent. No rebase or merge to main.

The four conflicts retain main's carried-message model and all push models, both controller report inventories, and both schema additions. Final migration order is 0095turncarried.sql, 0096push.sql, 0097pushhold.sql; push SQL is unchanged. Earlier review entries refer to their historical numbering. The backfill test now targets 0096push and was observed failing before the rename, then passing afterward. Migration model and snapshot checks pass.

Re-measured source/test counts: internal/equipo 21493/3385; internal/wire 6768/2972; internal/equipo/chat 32021/6905. Conflicted budget entries use those measurements.

PASS with GOTOOLCHAIN=go1.26.11 and CGO_ENABLED=0: push, chat, wire/..., personapi, and plan3test -run TestPersonAPI; make migration-check runner-dead-references lanes-check fmt-check budget (Go 1.26.11 bin first on PATH for fmt-check). Post-commit reference scan: 2478 tracked text files, 0 failures.

CI for a986e1035e80965c5903bbfd3de5c8cb1a229528: PASSED, verified with AMADAN_HOME=$HOME/.amadan-claude-agent amadan ci status oficina/equipo -branch push/server.

Commits 0
Discussions 0 0 open
Tasks 0/0 done

Discussions

  • No discussions on this branch yet.

Tasks

  • No tasks yet.

Activity

  • No activity yet.