Skip to content

fix(runtime): activate new runs from committed owner leases - #1105

Merged
mergify[bot] merged 3 commits into
matrixorigin:mainfrom
gouhongshen:codex/fix-run-start-authority-19270
Oct 21, 2026
Merged

mergify[bot] merged 3 commits into
matrixorigin:mainfrom
gouhongshen:codex/fix-run-start-authority-19270

Conversation

@gouhongshen

@gouhongshen gouhongshen commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Capability assessment: Unchanged: Agent chat remains Beta, and Durable Work and Checkpoints and recovery remain Partial in the existing CLI/Server/Web profiles. This fixes initial run activation without adding a capability, expanding a profile, or claiming new live-database qualification.

Summary

A newly created run could return 409 execution_authority_not_current before any model or tool execution even though its creation transaction had committed. Startup immediately renewed the new owner's lease through another pooled connection; a different MatrixOne CN snapshot can lag that commit. A later diagnostic read does not establish which predicate rejected the earlier UPDATE.

  • Return the committed initial owner generation and a conservative monotonic lease bound from the canonical run store. Normal creation anchors the bound before INSERT; timeout reconciliation retains the earlier admission bound. A delayed acknowledgement never restarts the lease clock.

  • Activate fresh root and child runs from that receipt, start the existing heartbeat, and check the same live local authority before root execution. Exact retries return the existing run without fresh authority. Preclaimed and recovered children retain durable authority confirmation.

  • Preserve existing periodic renewal, provider/tool database authorization, generation fencing, cancellation, and expiry checks. Preparation that loses its lease cannot terminalize the run or remove the workspace needed by recovery.

  • Add entrypoint and lease-boundary regressions, an opt-in MatrixOne creation/replay test, English rationale comments, and the durable-run contract update.

  • Unblock the required security audit with a Cargo-generated lockfile-only patch: rustls-webpki 0.103.16 and webpki-roots/webpki-root-certs 1.0.10 fix RUSTSEC-2026-0381/0382/0383. This matches the dependency update in fix(deps): update webpki crates for RustSec advisories #1104; no audit exceptions or gate changes are added.

  • Retain safe grading-time evidence for the live cache-scope CI investigation. The aggregate intentionally drops physical execution captures; the existing progress observer could therefore publish neither the observed post-cold cache reads nor which execution capture was missing, pending, unverified, or conflicted. Publish only typed states, identity-match flags, scope counts, and numeric cache counters through the existing progress/summary chain. Acceptance predicates, assertions, thresholds, models, timeouts, workflow selection, and audit policy remain unchanged.

Related issue

Fixes matrixorigin/matrixflow#19270

Related security update: #1104.

Change type

  • Feature
  • Bug fix
  • Documentation
  • Refactor or performance improvement
  • Test
  • Build, CI, or maintenance

User and compatibility impact

Fresh run creation no longer depends on a second connection immediately recognizing the lease just committed by creation. Exhausted or cancelled startup authority still cannot execute, and exact replays do not launch another executor.

HTTP/SDK wire formats, database schema, SQL statements, lease durations, renewal budgets, and migrations are unchanged. The Rust store contract changes: insert_run and insert_run_with_deadline return DurableRunStartAuthority, and DurableRunStartClaim::Started carries that receipt. Repository implementations and callers are updated. No MOI code is changed. The compatible TLS security patches reject distrusted certificate paths and remove the affected trust root.

Architecture and complexity delta

  • Canonical owner changed or extended: RunStateStore/DatabaseRunStateStore return evidence of their own creation transaction; RunEngine validates its original safety window and installs the existing owner heartbeat.
  • Existing implementations and callers searched: in-memory and database stores, both runtime test stores, root create/stream/idempotent admission, collaborator-stage admission, child execution, replay, recovery, heartbeat and provider-boundary authorization.
  • Superseded code, states, tables, shims, or self-only tests removed: redundant post-create activation renewals and the optional generation state in the fresh root path. No new table, persisted receipt, retry policy, compatibility shim, or fallback.
  • If parallel implementations remain, their boundary and retirement condition: fresh creation consumes its process-local transaction receipt; preclaimed/recovered execution must prove current durable authority. Both paths use the same heartbeat, exact-generation ownership, and execution boundaries.

Verification

  • Runtime commands and results (from the Astra repository root, at 81fa532b0 before the security-only lockfile update):

    • Before the implementation change, cargo test --locked -p astra-runtime --lib fresh_run_uses_committed_lease_before_preparation -- --nocapture reproduced the unwanted 409 and failed.
    • cargo test --locked -p astra-runtime --lib server::run:: -- --test-threads=1 --nocapture: 846 passed, 0 failed, 62 ignored.
    • cargo test --locked -p astra-services --lib runs::tests -- --nocapture: 194 passed, 0 failed, 71 ignored.
    • cargo clippy --locked -p astra-runtime -p astra-services --all-targets -- -D warnings: passed.
    • cargo fmt --all -- --check: passed.
    • git diff --check: passed.
    • Initial parallel execution exposed timing-sensitive failures under concurrent compilation; final runtime verification ran serially without concurrent Cargo compilation. Test deadlines and production budgets were not increased.
  • Public entrypoint exercised: create_run and stream_chat, including idempotent stream replay, through the production lifecycle with a fault-injected store.

  • Unhappy paths exercised: delayed acknowledgement with no lease extension, expired receipt, cancellation, wrong generation, missing/dropped heartbeat, lease loss during preparation, replay without a new executor, and existing preclaimed-child cancellation/fencing paths.

  • Database verification: schema and SQL are unchanged. The new MatrixOne creation/replay test was not run locally, but passed in the CI online services lane on 81fa532b0: 503 passed, including database_creation_returns_initial_lease_without_granting_it_to_replays. The complete Test Suite, online integration, and MOI compatibility lanes also passed on that head. This does not establish real multi-CN qualification. No local MOI tests or QA operations were performed.

  • Security follow-up: required Static Checks on 81fa532b0 passed Clippy and formatting, then failed cargo-audit on three newly published certificate advisories affecting the unchanged upstream lockfile. Cargo regenerated only the three compatible package versions, their checksums, and version-qualified references (+10/-10); the result is byte-identical to fix(deps): update webpki crates for RustSec advisories #1104's lockfile. cargo audit --json, the exact CI entrypoint make audit, cargo metadata --locked --offline --no-deps --format-version 1, cargo check --locked -p astra-core, make format-check, and git diff --check passed. Audit scanned the current advisory database and found no unignored vulnerabilities; existing audit policy is unchanged. The security-fix head 57279d39e subsequently passed Static Checks, including the audit and required aggregate, and the complete Test Suite, including all selected online and MOI compatibility lanes.

  • Live-model follow-up on head 57279d39e: attempt 1 completed 17/18; the remaining task_agent_profile_callable case was interrupted after its child completed. One unchanged diagnostic rerun, attempt 2, also completed 17/18. The task-profile case and all three failures from the original head passed in attempt 2. Its sole failure was instead cache_provider_matrix_regression: the initial request and all three follow-up steps completed with exit 0; the explicit alert/ratio composite passed, while the additional hard prompt_cache_reuse_scope check failed. That check requires ordered canonical per-execution explain coverage and positive cache reads after the cold turn; aggregate reported cache reads alone cannot establish it. Public artifacts omit the criterion detail and per-turn explain capture, so they cannot distinguish unavailable/conflicting scope evidence from absent post-cold reuse. The precise cause remains unestablished; neither classifier labels nor the changed failing case prove provider randomness or a regression from this PR. No further blind rerun, assertion/timeout/model change, CI exemption, or production fallback was applied. That attempt remained red; its omitted per-turn scope/capture diagnostics prevent establishing the historical failure cause. The current-head result is recorded below.

  • Cache-scope diagnostic follow-up (Astra only):

    • Before the change, the Rust grader-to-progress regression failed because the diagnostic was null, and the real Python summary-entrypoint regression failed with invalid_progress for the missing diagnostic type.
    • cargo test --locked -p astra-test-harness --lib -- --test-threads=1: 620 passed. The unchanged acceptance coverage includes cold/warm reuse, unknown creation counters, missing evidence, ordering, and replay boundaries. The new checks retain a warm read witness and distinguish a pending snapshot without certifying it as cache reuse.
    • python3 -m unittest discover -s scripts/ci -p 'test_manual_harness_progress.py': 15 tests, OK (3 existing platform skips), including the real summary subprocess, preserved failing verdict, and rejection of private/malformed fields.
    • cargo clippy --locked -p astra-test-harness --all-targets -- -D warnings: passed.
    • cargo fmt --all -- --check, git diff --check, and scripts/ci/validate_repository.py with the bundled Python runtime: passed. The system Python lacks tomllib; the repository script itself is unchanged.
    • An initial parallel Rust package run had two subprocess timeout failures (618 passed); the full serial run passed under the original deadlines. No deadline or assertion was changed.
    • Current head 0558d9a0f passed Static Checks, the complete Test Suite including online integration and MOI compatibility, and live regression, 18/18. The cache case retained four verified execution captures, matching run/session bindings, one scope per execution, and 27,448 post-cold cache-read tokens; its unchanged hard scope check passed. This verifies the safe diagnostic path and this execution of the regression; the previous intermittent failure cause remains unestablished, and the diagnostic-only change is not presented as a production cache fix. No QA access or local MOI tests.

Final checklist

  • I added or updated tests at the layer that owns the behavior, or explained why no test is needed.
  • I updated public or design documentation for contract changes, or the change needs no documentation update.
  • I checked the diff for credentials, private URLs, customer data, generated files, and other sensitive information.
  • The PR title follows the repository's Conventional Commit format.

@gouhongshen gouhongshen self-assigned this Oct 21, 2026
@gouhongshen
gouhongshen marked this pull request as ready for review October 21, 2026 09:17

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed commit 0558d9a. No blocking findings.

Creation returns initial authority from the canonical transaction with its original lease bound. Delayed acknowledgements cannot extend that bound, and exact replays cannot activate another executor. Existing heartbeat renewal and durable provider/tool fencing retain their responsibilities. Cache-scope diagnostics reuse the grading/progress path without changing acceptance criteria or exposing private payloads.

Local validation passed: 846 Runtime run tests, 194 Services run tests, 621 harness tests, 15 Python progress tests, and two additional ACK/cancellation tests covering four create/stream scenarios. Formatting and diff checks passed. The current-head live harness completed 18/18.

This approves the reviewed source. Real multi-CN fault qualification was not performed, historical cache-failure attribution remains unproven, and the cancelled PR-title check still needs its normal CI disposition.

@mergify mergify Bot added the queued label Oct 21, 2026
@mergify

mergify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-21 11:50 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-10-21 11:50 UTC · at d39864bc0bf9d6c6abbe8bcd005d454d253537b3 · squash

This pull request spent 18 seconds in the queue, including 2 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Check PR title
    • check-neutral = Check PR title
    • check-skipped = Check PR title
  • any of [🛡 GitHub branch protection]:
    • check-success = check
    • check-neutral = check
    • check-skipped = check
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: core crates + bridge hooks
    • check-neutral = Test: core crates + bridge hooks
    • check-skipped = Test: core crates + bridge hooks
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-runtime
    • check-neutral = Test: astra-runtime
    • check-skipped = Test: astra-runtime
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-fs-tools)
    • check-neutral = Test: astra-cli (edge-fs-tools)
    • check-skipped = Test: astra-cli (edge-fs-tools)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-git-gix)
    • check-neutral = Test: astra-cli (edge-git-gix)
    • check-skipped = Test: astra-cli (edge-git-gix)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-rest)
    • check-neutral = Test: astra-cli (edge-rest)
    • check-skipped = Test: astra-cli (edge-rest)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-shell)
    • check-neutral = Test: astra-cli (edge-shell)
    • check-skipped = Test: astra-cli (edge-shell)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (non-edge)
    • check-neutral = Test: astra-cli (non-edge)
    • check-skipped = Test: astra-cli (non-edge)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: online (core)
    • check-neutral = Test: online (core)
    • check-skipped = Test: online (core)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: online (integration)
    • check-neutral = Test: online (integration)
    • check-skipped = Test: online (integration)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: turn-core + services + plan
    • check-neutral = Test: turn-core + services + plan
    • check-skipped = Test: turn-core + services + plan
  • any of [🛡 GitHub branch protection]:
    • check-success = web (typecheck, test, build)
    • check-neutral = web (typecheck, test, build)
    • check-skipped = web (typecheck, test, build)
  • any of [🛡 GitHub branch protection]:
    • check-success = Astra SDK (typecheck, test+coverage, build)
    • check-neutral = Astra SDK (typecheck, test+coverage, build)
    • check-skipped = Astra SDK (typecheck, test+coverage, build)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: macOS workspace coordination
    • check-neutral = Test: macOS workspace coordination
    • check-skipped = Test: macOS workspace coordination

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