Add execution ownership leases with epoch fencing and persistent run commands (U5) #151

Merged
weichen merged 2 commits from feature/collab-storage-u5-ownership into main 2026-10-11 12:26:35 +00:00
Owner

Plan U5 slice (KTD4/KTD5): conversation_executions lease (epoch+1 on takeover, monotonic fencing) + run_commands inbox; fenced settle in-transaction (stale owners cannot commit); cross-instance cancel/HITL via owner-routed command consumption with explicit stale-gate rejection; server 202 fallback enqueue; instance identity wiring. Green on SQLite and real PG 18.6 (lease + multi-instance suites). Refs: plan U5, R4/R10.

Plan U5 slice (KTD4/KTD5): conversation_executions lease (epoch+1 on takeover, monotonic fencing) + run_commands inbox; fenced settle in-transaction (stale owners cannot commit); cross-instance cancel/HITL via owner-routed command consumption with explicit stale-gate rejection; server 202 fallback enqueue; instance identity wiring. Green on SQLite and real PG 18.6 (lease + multi-instance suites). Refs: plan U5, R4/R10.
weichen added 1 commit 2026-10-11 12:25:32 +00:00
Why: plan U5/KTD4+KTD5 - before a second instance may serve writes, conversation execution must have a single valid owner (DB lease, epoch increments on takeover), stale owners must not settle (in-transaction fence check), and cancel/HITL must reach the executing instance via a persistent command inbox.

Evidence: full suite green twice-relevant on SQLite and real PostgreSQL 18.6 (35 packages each tier) - lease tests (claim/contention/re-claim/renew fencing/expiry takeover/monotonic epoch, command inbox idempotent enqueue, atomic concurrent claim) and multi-instance tests (same-conversation contention rejected, stale-owner settle fenced with run unchanged, cross-instance cancel consumed exactly once by the owner instance, non-owner does not consume).

Impact: v23 migration (conversation_executions + run_commands); ClaimConversation stacks a DB lease on PG tiers (15min, release on conversation release); settle path fenced (fenced runs emit run.fenced, no terminal write); StartCommandConsumer polls the inbox for commands on locally-owned executions (cancel routes to local cascade or DB-level close-out; HITL revalidates gate and rejects expired explicitly); server cancel/HITL fall back to command enqueue with 202 when the run is not local; app wires instance identity (host:addr on PG tiers) and starts the consumer.

Refs: proposals/2026-10-11-collaboration-storage-and-distribution.md U5 KTD4/KTD5; R4/R10.
weichen added 1 commit 2026-10-11 12:26:25 +00:00
Merge authoritative main into the task branch
ci / vet-and-test (pull_request) Failing after 1m11s
9422bf9c28
weichen merged commit 840757240b into main 2026-10-11 12:26:35 +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#151