[P0] Make pending approval execution handoff cancellation-linearizable #63
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nsaspy/prolog-rlm#63
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
PR #62 currently has a narrow but real scheduling race between host approval and owner cancellation.
Current shape in
rlm_authority:rlm_approve/2moves a record frompendingtoapprovedunderrlm_authoritymutex.rlm_async_submit/3for the trusted continuation.executing.During the interval between (1) and (3),
rlm_pending_cancel_owner/2can observe anapprovedrecord whose control entry still hasExecutionFuture = none. The currentcancel_owned/2branch performs no cancellation in that state. A scheduler worker can therefore cross into the trusted continuation after the owner was cancelled.This was discovered during the #53/#54 core-hardening audit. Do not paper over it with sleeps or a weaker cancellation test.
Required invariant
Cancellation and the authoritative execution claim must have an explicit linearization point:
Human approval must still never occupy an
rlm_asyncworker while waiting.Acceptance
Constraints
Preserve the canonical direction:
Do not add an authority UI/TUI and do not create a second confirmation subsystem.
Implemented on PR #62, exact final head
1dddd22e0d4bdd8c862cc06c6a3d609c26c96094.The approval handoff now uses a private short-lived execution gate. The execution Future is attached to authority control state before the gate is armed; after arming, owner cancellation and execution race a single mutex-protected authoritative execution claim. Cancellation that wins before the claim terminalizes the operation and prevents the trusted continuation from crossing the side-effect boundary. Cancellation after the claim has documented best-effort interruption semantics without pretending to roll back already-performed host effects.
Adversarial coverage includes scheduler saturation with all 8 workers occupied, queued approved execution cancelled before claim with zero later mutation after worker release, and repeated concurrent approve/cancel races with exactly-once terminal resolution / at-most-once mutation. Runtime/agent teardown uses the same owner-cancellation path.
Exact-head validation is green: full deterministic CI, benchmark/conformance, deep-recursion experiment, CLI/trace, fresh-process graph restart, durable artifact handoff, whitespace, and the complete configured REAL OpenRouter suite all passed.