Skip to content

fix: supervise headless sessions with operation leases and retain Codex errors - #5248

Merged
Trecek merged 37 commits into
developfrom
impl-codex-operation-leases-20261004
Oct 6, 2026
Merged

Trecek merged 37 commits into
developfrom
impl-codex-operation-leases-20261004

Conversation

@Trecek

@Trecek Trecek commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

When a Codex L2 session waits for an in-flight MCP call without stdout, the idle watchdog can kill it despite active work. Operation leases now carry that activity across both backends and every supervisor watcher, deadline extension, and termination drain. Each physical attempt gets its own channel, and the L2 idle floor is at least run_skill.timeout while L1 idle settings remain separate.

This implements the combined Parts A–E plan for #4640:

  • Add typed lease records, heartbeat and deadline handling, in-flight accounting, MCP middleware production, and run-skill deadline narrowing.
  • Consume leases consistently and retire command-spec idle overrides, dispatch-marker watchdog inputs, and network-derived liveness. Preserve CPU/output/pending-work limits, fleet heartbeat and log paths, and caller/resume identity. The run-skill marker remains the fabricated-completion attestation.
  • Recognize Codex error items as nonterminal diagnostics. Retain ordered messages in normal and killed results, bound them to the first five messages of 500 characters each, and persist session_errors in summary.json and sessions.jsonl with session-index schema 16.

The lease primitive uses existing core/plugins/ capacity and the canonical ContextVar in core/pipeline/_step_context.py. Per-attempt channel creation and spec injection live in _managed/_attempt.py to preserve the launch module's file budget. No import, complexity, file-size, or acceptance-policy limit was waived.

Validation:

  • Each part independently passed the configured task test-local-gate through MCP test_check; final run: 50,760 passed, 620 skipped, 29 xfailed.
  • All-files pre-commit and staged checks passed, including Ruff, mypy, lock/stub checks, architecture/policy checks, and secret scanning.
  • Coverage includes real silent-process lease protection, both backend launch paths, expired/mismatched/stale lease negatives, marker/network retirement, preserved attestation, all recognized Codex item types, and incident/timeout diagnostics in both persisted projections.
  • Historical L1 log review found no dependence observed on the removed marker; idle defaults were not raised.

Closes #4640.

Trecek added 29 commits October 5, 2026 17:32
@Trecek
Trecek force-pushed the impl-codex-operation-leases-20261004 branch from 8496e05 to ebc767d Compare October 6, 2026 00:38
@Trecek
Trecek added this pull request to the merge queue Oct 6, 2026
Merged via the queue into develop with commit cd27b70 Oct 6, 2026
11 checks passed
@Trecek
Trecek deleted the impl-codex-operation-leases-20261004 branch October 6, 2026 01:16
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.

1 participant