Skip to content

Pin the server-recorded cancel_remaining failure transaction - #440

Merged
rmcdaniel merged 2 commits into
mainfrom
general/232-cancel-remaining-vectors
Nov 26, 2026
Merged

rmcdaniel merged 2 commits into
mainfrom
general/232-cancel-remaining-vectors

Conversation

@rmcdaniel

Copy link
Copy Markdown
Member

Conformance step for the cancel_remaining decision on #232: (a), Server-recorded. This PR changes only the contract and its vectors. No runtime or binding change.

Contract changes (conformance/parallel-groups/README.md)

  • The failure transaction. It records, in order: the failing member's terminal event, a cancellation for each unfinished sibling in member order, then one workflow wake.
  • Finished siblings. A sibling that already has an outcome is never cancelled. A retrying activity has none yet, so its pending retry is cancelled.
  • Mapping to existing events. Activities (default or try_cancel) get ActivityCancelled. Timers get TimerCancelled. A condition wait gets ConditionWaitCancelled, then TimerCancelled for its timeout timer. A child gets ChildCancellationRequested on the parent plus a cooperative request on the child run. abandon activities keep running.
  • Cause object. Each recorded cancellation carries the member's group fields and parallel_group_cancellation (schema, policy, failure_event_sequence, failed_member_index). This follows the cancellation_scope cause convention.
  • Late results. Cancellation stays cooperative. A child's later close, or an abandoned activity's result, is a late sibling result: no wake, no outcome, no clock. Consumers replay recorded cancellations and send no cancellation commands for them.
  • Waiting members. A wait_cancellation_completed member is refused at cancel_remaining admission until waiting composition is qualified.

Vector changes (fixtures-v1.json)

  • Updated case. cancel-remaining-targets-open-sibling now includes the recorded ActivityCancelled in the failure's transaction. Before, its history ended at the failure. Only the server's copy of this fixture references the case, and it does not read case histories.
  • New cases.
    • member order around a middle failure
    • a finished sibling that is not cancelled, and a retrying sibling that is
    • timer and condition-wait members (condition before its timeout timer)
    • a child cancellation request with the child's later ChildRunCancelled as a late sibling result
    • an abandoned activity left running
  • New expected fields. producer_cancellations, transaction_event_sequences, parent_wakes, consumer_cancellation_commands, uncancelled_member_indexes, late_sibling_event_sequences.
  • New refusal vector. cancel-remaining-wait-cancellation-member.

Choices for review

  • The cause object's name and fields.
  • Refusing wait_cancellation_completed members for now, rather than waking only after the worker acknowledges.
  • Using ChildCancellationRequested (with request_outcome, as native records it) for children instead of a terminal child event.

After this merges, Server pins its copy of the fixture to the new SHA and implements the transaction. The policy stays unadvertised until that path is qualified.

🤖 Generated with Claude Code

.github#232 decided that the producer records cancel_remaining sibling
cancellations itself (decision (a)). The contract only named the
cancellation targets.

The README now defines the failure transaction: the failing member's
terminal event, a cancellation for each unfinished sibling in member
order, then one workflow wake. It maps each member kind to an existing
history event and names the parallel_group_cancellation cause each
cancellation carries. Members that already have an outcome are never
cancelled, abandon activities keep running, and
wait_cancellation_completed members are refused for now.

The fixture's cancel_remaining case now includes the recorded
cancellation. New vectors cover member order around the failing
member, a finished and a retrying sibling, timer and condition-wait
members, a child cancellation request with its late close, and an
abandoned activity, plus a refusal vector for wait members.

Refs #232

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rmcdaniel rmcdaniel added the agent:general Pull request opened by General agent label Nov 26, 2026
@rmcdaniel

Copy link
Copy Markdown
Member Author

Independent review: CHANGES REQUESTED at head 2164867

The transaction shape is sound: the failing member's terminal event, then cancellations in member order, then one wake. These parts are right:

  • the clock stays on the initiating failure, not on the last cancellation;
  • members that already finished are skipped, and a pending retry is cancelled;
  • the cause object is used on every recorded cancellation;
  • consumers send no cancellation commands on replay;
  • wait_cancellation_completed is refused instead of composing a wait.

Registration and claim vectors and the other cases are unchanged. The file is canonical json.dumps(indent=2) plus a trailing newline. The two new Avro blobs decode to the prefixed done and abandoned strings. Two contract gaps need fixing before Server implements against this, because Server will be checked against the vector exactly.

1. Child cancellation ignores the child's own cancellation policy. conformance/parallel-groups/README.md:127; fixture case cancel-remaining-requests-child-cancellation (fixtures-v1.json:1105).
The activity rows distinguish try_cancel from abandon, but the child row requests cancellation unconditionally. Native children also carry cancellation_policy (try_cancel, wait_cancellation_completed, abandon). In the existing cascade, Server asks a child to cancel only for try_cancel and wait_cancellation_completed (server rust/src/runtime/child_cancellation.rs:1-5). The README says the policy "preserves operation ownership". An abandon child would still get a ChildCancellationRequested, which breaks that rule. The refusal at :145 says "a member" but doesn't say whether it covers children.
Suggested fix:

  • Split the child row into try_cancel (request) and abandon (none, left running, its close is a late sibling result).
  • Say that the wait_cancellation_completed refusal applies to activity and child members alike.
  • Add a child-abandon history case, and a child variant of cancel-remaining-wait-cancellation-member (fixtures-v1.json:2221) or a member_kind field on it.
  • Also state what a rejected child request records. Native writes request_outcome: "rejected" with rejection_reason, for example when the child is already closing. Say whether that is still recorded as the member's cancellation and that it doesn't change the failure outcome.

2. open_member_indexes treats a cancellation request as proof the child closed. README (the new vector-field paragraph); cases cancel-remaining-requests-child-cancellation and cancel-remaining-leaves-abandoned-activity-running (fixtures-v1.json:1287).
The two cases are inconsistent:

  • In the abandon case, the member with no recorded cancellation is listed open ([0]) even though its late result is in the history.
  • In the child case, open_member_indexes is []. But the child run is still running after the transaction. It closes only at the late ChildRunCancelled (sequence 6).

The accepted requirement on #232 says cancellation is cooperative and must not be described as immediate proof of termination. An ActivityCancelled really does close the execution durably. A ChildCancellationRequested does not close the child.
Suggested fix:

  • Define open_member_indexes in the README, for example "members whose operation is still open after the failure transaction".
  • Set the child case to [0].
  • Or, if the intent is "members with neither an outcome nor a recorded cancellation", name the field for that. Either way, keep the "running until its own close" meaning visible for children.

Choices you asked about

  • Cause object: the parallel_group_cancellation name and its fields (schema, policy, failure_event_sequence, failed_member_index) are adequate and versioned. Consider recording failed_member_index against the innermost group only and saying so explicitly, since a member can sit in nested frames.
  • Refusing wait_cancellation_completed: correct for now. It is safe and consistent with refusing anything that isn't yet qualified. Extend it explicitly to children, as in finding 1.
  • Child cancellation as a request: correct, and it matches native's existing event. The vector needs the two fixes above to describe it accurately.

CI at review time: 7 pass, 2 pending ("Shared contract tests", "SonarQube analysis"). Not merged.

Review of the cancel_remaining vectors found that the child row ignored
the child's own cancellation policy and that open_member_indexes was
undefined and inconsistent for a child that was only asked to cancel.

Children now follow their recorded policy as activities do: try_cancel
gets ChildCancellationRequested, abandon gets nothing and keeps running,
and wait_cancellation_completed is refused for children as well. The
README states each kind's default, what a rejected child request
records, and that a request does not close the child.
open_member_indexes now means members with no terminal outcome at the
failure boundary, so the child cases list the child as open.

New vectors cover an abandoned child, a rejected child request and the
child refusal variant.

Refs #232

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@rmcdaniel

Copy link
Copy Markdown
Member Author

Independent review: PASS at head d42cb56

Both findings from my earlier review are fixed.

  1. Child policies.
    • The table now splits children into try_cancel (a request) and abandon (none, left running). The README states each kind's default.
    • I checked the defaults against native: activities default to try_cancel, and children default to abandon (server children.rs:292).
    • The wait_cancellation_completed refusal now names activity and child members. Both refusal vectors carry member_kind.
    • New cases:
      • cancel-remaining-leaves-abandoned-child-running: no cancellation, and the child's close is a late sibling result.
      • cancel-remaining-records-rejected-child-request: request_outcome: rejected with cancellation_root_conflict, which is a real native rejection reason (server child_cancellation.rs:524). The child's later completion is a late result.
    • The accepted child case records cancellation_policy: try_cancel on its openings.
  2. open_member_indexes. The README now defines it as members with no terminal outcome event after the failure transaction. A recorded cancellation event closes its member. A ChildCancellationRequested does not. All three child cases and the abandoned activity list [0]. The cases with cancellation events list []. This is consistent with how the existing propagate cases use the field.

Unchanged from my first pass, and still correct:

  • the transaction order is failing member's terminal event, then cancellations in member order, then one wake;
  • the clock stays on the initiating failure;
  • finished siblings are skipped, and a pending retry is cancelled;
  • the cause object is versioned, and consumers send no cancellation commands on replay.

The registration and claim vectors are unchanged. The fixture is canonical json.dumps(indent=2) plus a trailing newline. The new late-child blob decodes correctly. CI is fully green: 10 of 10 checks pass, including Shared contract tests.

@rmcdaniel
rmcdaniel merged commit 3837cac into main Nov 26, 2026
10 checks passed
@rmcdaniel
rmcdaniel deleted the general/232-cancel-remaining-vectors branch November 26, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:general Pull request opened by General agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant