Skip to content

fix(execution): only attribute timeout when elapsed reached the configured limit - #2752

Merged
vybe merged 2 commits into
Abilityai:devfrom
louisss1016:feature/2106-timeout-attribution
Sep 14, 2026
Merged

vybe merged 2 commits into
Abilityai:devfrom
louisss1016:feature/2106-timeout-attribution

Conversation

@louisss1016

Copy link
Copy Markdown
Contributor

Fixes #2106

Problem

execute_task labelled every httpx.TimeoutException as Task execution timed out after N seconds regardless of elapsed time. Per the issue evidence, 16 of 30 timeout-labelled executions ran nowhere near the configured limit (9 ran ~305s against 2700/3600/2400s limits). The label misdirects operators (raising timeouts that were never hit) and corrupts aggregate failure analysis.

Change

  • New module-level _classify_timeout_failure(elapsed_s, timeout_seconds, *, exc) in src/backend/services/task_execution_service.py.
  • Timeout is attributed only when elapsed_s >= timeout_seconds - 30 (30s grace, matching the issue's "within 30s" definition). Otherwise the failure is recorded as Task execution aborted after {elapsed}s of {limit} allowed with a NETWORK error code and the real exception class name — the configured limit stays as context, not as cause.
  • error_code now flows from the classifier into the returned TaskExecutionResult.

Tests

tests/unit/test_2106_timeout_attribution.py — 7 tests: classifier unit tests (including the issue's headline case: 305s elapsed vs 2700s limit → NOT a timeout) plus 2 execute_task branch tests driving both sides of the new branch.

Verification

  • New tests: 7 passed.
  • Regression across all 69 test files referencing the module (4 files requiring tests/testkit, unavailable in a shallow clone, excluded): 1909 passed, 5 skipped, 0 failures.
  • Baseline full unit suite (Windows): 207 failed / 11709 passed / 31 skipped — all 207 failures are pre-existing Windows platform differences; none in affected files.
  • CI lints (lint_sys_modules.py, lint_root_test_placement.py): pass.

Command (Windows, Python 3.12):
python -m pytest tests/unit/test_2106_timeout_attribution.py --confcutdir=tests/unit -q -p no:cacheprovider

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

merge-train: batch validated on train/20260914-0901 (train PR #2765, full suite green)

@vybe
vybe merged commit f36e88b into Abilityai:dev Sep 14, 2026
25 checks passed
vybe pushed a commit that referenced this pull request Sep 14, 2026
…e is refused (#2767) (#2769)

`issue-status-on-merge.yml` ran on `pull_request`, where a PR opened from a
FORK gets a read-only `GITHUB_TOKEN`. Every label write was refused with
"Resource not accessible by integration", the issue stranded in
`status-in-progress` with its fix already on `dev` — and the run reported
SUCCESS, because the refusal was a `core.warning`. It only ever bit external
contributors, i.e. exactly the PRs nobody is watching the label on (observed
2026-09-14: #2752 merged, #2106 relabelled by hand).

Two changes.

**`pull_request_target`**, which runs in the base repo's context and so carries
the write token the `permissions:` block already asks for. That trigger is the
standard privilege-escalation footgun, so the reasoning is written next to it
rather than left implicit: the escalation always takes the form "check out the
stranger's code, then execute it", and this workflow does neither — no
`actions/checkout`, no `run:` steps, and the only untrusted values
(`pull_request.title` / `.body`) reach exactly one regex that extracts `\d+`.
The residual capability is bounded to what the feature does anyway — a MERGED
PR names which issue numbers get relabelled — and `pull_request_target` runs
the base branch's copy of the workflow, so a fork cannot edit this file to
widen that.

**A refused write now fails the job.** Failures are collected rather than
thrown at the first miss, so one unlabelable issue cannot strand the others,
and `core.setFailed` runs after the loop naming every issue that still needs a
manual fix. A `removeLabel` 404 stays a non-failure — an issue that was never
picked up simply has no label to remove.

`tests/unit/test_2767_issue_status_fork_prs.py` guards both safety properties
in the shape of `test_1896_integration_nightly_workflow.py`. Mutation-tested,
each caught: reverting the trigger, adding an `actions/checkout`, adding a
`run:` step, and downgrading `setFailed` back to `warning`.

Note for reviewers of the test: the guards strip comment lines before
asserting. Without that, a comment saying "there is NO actions/checkout"
satisfies the checkout check and "collected, not thrown" satisfies the throw
check — the guard would pass because of the sentence claiming the property
instead of the property. Both bit me while writing it.

Fixes #2767


Claude-Session: https://claude.ai/code/session_01Q19uRCksdn4DiRAJ55rfpZ

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

3 participants