Skip to content

Check the tasks under a stopped task, and a non-owner's ready and status - #26

Open
rogers-andrew wants to merge 4 commits into
cppalliance:masterfrom
rogers-andrew:tasks-unchecked-statements
Open

rogers-andrew wants to merge 4 commits into
cppalliance:masterfrom
rogers-andrew:tasks-unchecked-statements

Conversation

@rogers-andrew

@rogers-andrew rogers-andrew commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Four statements about Lua's tasks table each had a part that no test checked: with the code broken there, all 4,052 tests still passed. This PR adds the checks to three existing tests. It adds no test and changes no production code.

Plan: plan/2026-11-18-1-tasks-unchecked-statements.plan.md

What was unchecked

Statement The part with no check
tasks.cancel(task) stops a task and every task it owns. "and every task it owns"
Only the owner may wait on, check, send to, or cancel a task. "check": tasks.ready and tasks.status called by a task that is not the owner
A task still live when its owner ends is abandoned, with every task under it. "with every task under it"
Each task that starts reports one TaskStarted event and exactly one terminal event. The terminal of a task whose owner was stopped

The code is correct today. These are missing checks, not bugs.

The proof

Each break below is one small change under crates/runvil-internal/runtime/src/execute/scheduler/. Before this PR every test passed with the break applied. Now each one fails a test.

Break Where Now fails
A stopped chain's own tasks are left running chain.rs, abort_subtree a_returning_owner_abandons_its_running_task_as_owner_returned, cancel_ends_a_parked_task_idempotently_and_reports_task_canceled_once
Their terminal event is dropped task_end.rs, abandon_owned_tasks the same two
Their reason is OwnerReturned, not OwnerAborted chain.rs, abort_subtree the same two
tasks.ready answers any caller waits.rs, dispatch_ready a_non_owner_is_refused_with_task_not_owned
tasks.status answers any caller waits.rs, task_status a_non_owner_is_refused_with_task_not_owned

What changed in the tests

All three are in crates/runvil-internal/runtime/src/execute/tests/.

  • a_returning_owner_abandons_its_running_task_as_owner_returned (tasks-chain-end.rs) and cancel_ends_a_parked_task_idempotently_and_reports_task_canceled_once (waits.rs): the task that is abandoned or canceled now owns a task that has started. That inner task must end Abandoned, report one start and one terminal, name OwnerAborted as the reason, and report before its owner does.
  • a_non_owner_is_refused_with_task_not_owned (waits.rs): the caller gains a sibling. Its tasks.ready on itself and on the sibling, and its tasks.status on the sibling, must each raise task_not_owned.
  • One helper is new, TaskRecorder::assert_aborted_with_its_owner in tasks.rs. Both stopped-owner tests use it. Without it the cancel test was 107 lines, over the limit of 100 on a function.
  • In the cancel test, the assertion that no task reports another terminal became the exact list of the canceled task's observations: one start and one TaskCanceled.

For review

  • OwnerAborted was the one abandon reason of the five that no test named.
  • aborting_a_chain_abandons_the_tasks_it_owns passes even when the abort leaves owned tasks running, because the end of the run marks every leftover task abandoned. I left it as it is. The two stopped-owner tests now prove what its name says.
  • This replaces Add 30 golden tests of tasks #25, which I closed. Its 30 new tests repeated checks that existing tests already made for 25 of the 29 statements on the list I was working from. These four are the rest.

Verification

  • cargo nextest run --locked --workspace --all-features: 4,049 passed, the same count as before.
  • cargo clippy --workspace --all-targets --all-features with CARGO_BUILD_WARNINGS=deny, cargo fmt --all --check, both cargo doc commands with RUSTDOCFLAGS="-D warnings", cargo +nightly-2026-09-05 xtask api --check, cargo test -p build-xtask, and node --test tools/docs-claims.mjs: all pass.
  • cargo dylint did not run, because it is not installed on the machine that built this.
  • vibelight on the two changed test files gives the same two leads for each as before the change, all on code that was already there.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of task cancellation and ownership, including tasks with their own running or waiting work.
  • Tests
    • Expanded checks for cancellation outcomes, task ownership restrictions, and the order in which tasks finish.

rogers-andrew and others added 3 commits November 18, 2026 14:06
Four of the 29 statements about Lua's `tasks` table have a part that no test checks: the code can be broken there and every test still passes. The plan adds the checks to three existing tests and lists the five breaks that must each fail a test afterwards.

Plan: /plan/2026-11-18-1-tasks-unchecked-statements.plan.md

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…status`

Four statements about Lua's `tasks` table had a part that no test checked: with the code broken there, every test still passed. Three existing tests now check those parts. No test is added, and no production code changes.

- `a_returning_owner_abandons_its_running_task_as_owner_returned` and `cancel_ends_a_parked_task_idempotently_and_reports_task_canceled_once`: the task that is abandoned or canceled now owns a task that has started. That inner task must end `Abandoned`, report one start and one terminal, name `OwnerAborted` as the reason, and report before its owner does. `OwnerAborted` was the one abandon reason no test named. Both tests make the checks through one new helper, `TaskRecorder::assert_aborted_with_its_owner`.
- `a_non_owner_is_refused_with_task_not_owned`: the caller gains a sibling, and its `tasks.ready` on itself and on the sibling and its `tasks.status` on the sibling must each raise `task_not_owned`.
- Each of five breaks of the scheduler, which all passed before, now fails one of these tests: a stopped chain's tasks left running, their terminal event dropped, their reason changed, and `ready` and `status` answering any caller.

Plan: /plan/2026-11-18-1-tasks-unchecked-statements.plan.md

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Each of the five breaks now fails a test, and the workspace keeps its 4,049 tests. The plan also records the one helper the two stopped-owner tests share and why it exists.

Plan: /plan/2026-11-18-1-tasks-unchecked-statements.plan.md

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 18, 2026 22:13

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

The pull request is cppalliance#26.

Plan: /plan/2026-11-18-1-tasks-unchecked-statements.plan.md

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The task tests now cover sibling ownership checks and child-grandchild termination when an owner is canceled or returns with a live child. A shared recorder assertion checks the grandchild’s owner-aborted terminal and its order relative to the owner terminal.

Changes: Task Ownership and Termination

Layer / File(s) Summary
Ownership checks and terminal assertions
crates/runvil-internal/runtime/src/execute/tests/tasks.rs, crates/runvil-internal/runtime/src/execute/tests/waits.rs, plan/2026-11-18-1-tasks-unchecked-statements.plan.md
The ownership test checks that a task cannot call ready or status on a sibling. TaskRecorder gains an assertion for an OwnerAborted terminal recorded before the owner terminal. The plan documents the test scope and checks.
Cancellation of a child and grandchild
crates/runvil-internal/runtime/src/execute/tests/waits.rs, plan/2026-11-18-1-tasks-unchecked-statements.plan.md
The cancellation test holds writes from a child and grandchild. It checks that both writes are withdrawn, the child is canceled, and the grandchild is abandoned with its abort attributed to the child’s cancellation. The plan records verification details.
Termination after owner returns
crates/runvil-internal/runtime/src/execute/tests/tasks-chain-end.rs
The test checks that a live child and its started grandchild are abandoned when the owner returns. It retains the TasksLive assertion for task 0.0 and checks terminal-event order.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Suggested reviewers: vinniefalco

Merge Risk: Minimal · up to f8e0b

This change only strengthens test coverage for task ownership and termination behavior and does not alter runtime behavior. No actionable merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names two things the PR touches: checking tasks under a stopped task, and a non-owner's ready and status. The changeset does add owner-abandonment assertions for a stopped owner's child …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names two things the PR touches: checking tasks under a stopped task, and a non-owner's ready and status. The changeset does add owner-abandonment assertions for a stopped owner's child and grandchild, and ready/status non-owner checks on a caller or sibling. The title is specific and accurate, though it lists two aspects rather than one main change, and it uses a somewhat terse phrasing.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: db7cf20d-567f-4ac3-9ce4-fb0f1ca1f42e
Commits

Reviewing files that changed from the base of the PR and between ee199e3 and f8e0bf0.

Files selected for processing: 4

  • crates/runvil-internal/runtime/src/execute/tests/tasks-chain-end.rs
  • crates/runvil-internal/runtime/src/execute/tests/tasks.rs
  • crates/runvil-internal/runtime/src/execute/tests/waits.rs
  • plan/2026-11-18-1-tasks-unchecked-statements.plan.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the test-only changes strengthening task ownership and descendant-cleanup coverage.

No open issues 🎉

What changed in this PR

Strengthens three existing Engine tests for Lua’s tasks API, covering ownership checks and task cleanup when an owner stops. No production code or new test functions are added.

Changes:

  • Checks that tasks.ready and tasks.status reject non-owner callers.
  • Verifies that started descendants of canceled or abandoned tasks end as Abandoned, with exactly one terminal event naming OwnerAborted, before their owner’s terminal event.
  • Adds a shared assertion helper and records the regression checks and verification results.
File Description
plan/​2026-11-18-1-tasks-unchecked-statements.plan.md Documents coverage gaps, planned assertions, and verification results.
crates/​runvil-internal/​runtime/​src/​execute/​tests/​waits.rs Extends non-owner checks and cancellation coverage to a started grandchild.
crates/​runvil-internal/​runtime/​src/​execute/​tests/​tasks.rs Adds a shared helper for descendant abandonment events and ordering.
crates/​runvil-internal/​runtime/​src/​execute/​tests/​tasks-chain-end.rs Checks descendant abandonment when a returning owner leaves a live task.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants