Close request atomicity: locked message append, card versions, atomic rate limit, recovery holds (U3 slice 1) #140

Merged
weichen merged 1 commits from feature/collab-storage-u3-atomicity into main 2026-10-11 04:38:02 +00:00
Owner

Plan U3 slice 1 (KTD3/KTD7/KTD10 + minimal recovery isolation):

  • message append allocates seq under the conversation advisory lock in one transaction (retry loop becomes a backstop);
  • activity_cards version column (v19) with optimistic SaveCardVersioned; user-facing card mutations map to 409, system mirrors keep blind writes;
  • recovery_holds (v20): persistent hold, fail-closed resume skip (run or conversation scope), idempotent release, admin list/release endpoints;
  • Redis limiter: single Lua INCR+PEXPIRE script (no orphan keys), per-instance conservative fallback with observable Degraded counter when Redis is unreachable.

Evidence: full suite green against real PostgreSQL 18.6 and Redis (isolated instance) and on SQLite. Refs: plan section 5 U3, R3/R6/R7/R8.

Plan U3 slice 1 (KTD3/KTD7/KTD10 + minimal recovery isolation): - message append allocates seq under the conversation advisory lock in one transaction (retry loop becomes a backstop); - activity_cards version column (v19) with optimistic SaveCardVersioned; user-facing card mutations map to 409, system mirrors keep blind writes; - recovery_holds (v20): persistent hold, fail-closed resume skip (run or conversation scope), idempotent release, admin list/release endpoints; - Redis limiter: single Lua INCR+PEXPIRE script (no orphan keys), per-instance conservative fallback with observable Degraded counter when Redis is unreachable. Evidence: full suite green against real PostgreSQL 18.6 and Redis (isolated instance) and on SQLite. Refs: plan section 5 U3, R3/R6/R7/R8.
weichen added 1 commit 2026-10-11 04:38:02 +00:00
Why: the approved plan U3 (KTD3/KTD7/KTD10 plus minimal recovery isolation) requires concurrent submits to not silently overwrite, unknown-side-effect runs to never auto-resume, and the shared rate limiter to degrade conservatively instead of failing open.

Evidence: full backend suite green twice-relevant paths against real PostgreSQL 18.6 and Redis (isolated instance) and on SQLite; new tests - card_version_test (concurrent single winner), recovery_hold_test + recovery_holds_test (skip/release/fail-closed CRUD), ratelimit atomic-window and degraded-fallback tests.

Impact: AppendMessageWithRequest now allocates seq under the conversation advisory lock in one transaction; activity_cards gain version (v19) with SaveCardVersioned/GetCardVersion/CardVersion and cardsvc user mutations (status/pin/action/resolve-by-ref) return 409-mapped conflicts while system mirrors keep blind writes; recovery_holds (v20) with admin list/release endpoints and fail-closed resume skip; Redis limiter uses one Lua INCR+PEXPIRE script and falls back to a per-instance limit with a Degraded counter.

Refs: proposals/2026-10-11-collaboration-storage-and-distribution.md U3 KTD3/KTD7/KTD10; R3/R6/R7/R8.
weichen merged commit 3def525902 into main 2026-10-11 04:38:02 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-System-Backend#140