Repository navigation
fix: adversarial review P0/P1 hardening - #34
Merged
Merged
Conversation
Validate Hub client_message_id fail-closed (charset/length/path escapes) while still accepting UUID, msg_*, and agent-result:* ids. Daemon no longer uses raw origin as a path component (sha256 hex), asserts writes stay under .attachments, allowlists download hosts to configured backend origin, and streams downloads with size cap + timeout.
P0-2: fail closed when durable delivery cannot keep order. Server: - Revoke connections on catch-up barrier overflow and try_send backpressure instead of dropping frames while still acking outbox publish paths. - Claim outbox rows ordered by (topic, topic_seq) via durable_event_log join. - Same-batch dispatch remains serial; full monotonic outbox_id migration deferred. Clients: - Desktop tryAdvanceTopicCursor refuses silent gaps and triggers SnapshotRequired. - Mobile tracks pending Dart holds, blocks AdvanceNow across holds, detects holes, and serializes inbox/conversation apply+ack chains. Document the ordered no-drop + hole-detection contract in architecture-messaging.md §4.1.
P0-3: stop full host-topic replay from re-executing history after restart. - Add host_command_ledger + host_topic_cursors (migration 0002), mirroring bot_delivery_ledger restart-safe exactly-once semantics. - Hydrate host Subscribe resume cursor from SQLite; persist on durable apply. - SnapshotRequired advances resume to retention_floor (not 0) and re-subscribes so catch-up cannot loop. - Retention reclaim: dead-letter outbox rows no longer pin durable_event_log forever (ack_at_ms NULL + dead_at_ms set). Deferred: pruning old completed ledger rows / cross-process inflight fencing.
P0-4: background jobs must not die permanently after a short DB outage. - JobSupervisor enters extended respawn backoff after consecutive fatals instead of exiting the task forever. - Approval timeout poller always sleeps after due-deadline ticks; skip undecodable rows; force-timeout pending approvals with NULL host so they cannot pin next_pending_deadline forever. - Expose JobHealthRegistry on AppContext and include job snapshots in GET /health/jobs.
P1 Desktop: - Proactive JWT refresh before expiry; shared ensureFreshCloudAccessToken single-flight for HTTP 401 → refresh → one retry in minos-cloud. - Outbox classifies unauthorized/401 as transient (refreshable), not permanent. - Timeline clears focusedConversationId on unmount; Hub mark-read waits for auth hydrate + observed message_seq so cold-start open commits read watermark.
P1 Mobile: - FRB ui/social event forwarders continue after broadcast Lagged instead of breaking the stream for the process lifetime. - ConversationsController rebinds socialEvents on every build so invalidate after reconnect cannot leave a dead subscription. - im_outbox gains account_id (db v8); drain filters by current account; logout clears social_cache.db (outbox + conversations + messages). - Enlarge mobile social/ui broadcast buffers to reduce lag under catch-up.
Spawn BotInboxDelivery off the dispatch loop so inject cannot self-deadlock on the uplink drain. Bound AppendBotMessage sends instead of silent try_send drops after accept. Reap Claude turns via process-group SIGTERM/SIGKILL on shutdown, and use char-boundary-safe UTF-8 prefixes to stop panics taking run_dispatch offline.
Require owning host_installation_id on host-command ack/finish (H4). Renew mailbox leases on host Ping and delivery activity so long turns keep the 2-minute lease alive (H5). Persist provider_token alongside token_hash so APNs/FCM have send material (H6). Treat user_online, quiet_hours, and cooldown as deferred requeues that do not burn dead-letter attempts (H7/H8).
Apply cargo fmt across prior P0/P1 edits and resolve clippy -D warnings (single_match / collapsible_else_if on mobile hole detection; Box::pin large BotInboxDelivery future on daemon dispatch).
Keep CI dart format --set-exit-if-changed green after social apply-chain fixes.
Replace device_installations / host_installation_tokens with devices / host_tokens and rename the wire fields to device_id / host_device_id. Desktop login now issues a host_token bound to (account_id, DeviceId). The realtime registry keys by (rail, DeviceId) so Account IM and Host runtime can share one Mac without kicking each other. Native /ws/client accepts Authorization: Bearer; host WS has no ticket.
Own DeviceId, refresh, and host_token in Keychain (AfterFirstUnlock). Login/refresh/sign-out and Account IM now run in the Tauri host with native Bearer /ws/client — no ticket. The webview only projects UI state and forwards frames.
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
Addresses the consolidated adversarial review findings (main @
47f5dbc) across Hub, daemon, Desktop, and Mobile. Commits are split by concern.P0
client_message_idvalidation; daemon hashes origin for attachment dirs + canonicalize containment; download host allowlist, no redirects, streamed size cap + timeoutP1
Residual / follow-ups
outbox_idmigration yet (in-batch serial claim + no-drop fanout landed)provider_tokenplaintext alongside hash PK; pre-migration rows need re-register; APNs/FCM still NotWired where previously soTest plan
cargo xtask check-rust(fmt/clippy/schema-parity/workspace tests)check/test/ biome / file-sizes / px-text (CIcheck:allscripts)pub get,build_runner,dart format,dart analyze --fatal-warnings,flutter test --exclude-tags ffi(79), FRB driftclient_message_idcannot write outsideworkspace/.minos/attachments