Skip to content

fix(runtime): scope tool-call identities and report persistence failures - #1099

Merged
XuPeng-SH merged 15 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/tool-call-invocation-identity
Oct 21, 2026
Merged

XuPeng-SH merged 15 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/tool-call-invocation-identity

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Capability assessment: Unchanged: Execution profiles and User Runner boundaries remain accurate. Invocation identity, canonical outcomes and Web observation/control ownership stay within their existing Runtime and Web owners.

Summary

Repeated provider tool-call IDs could collapse execution receipts across rounds and collide during terminal persistence. Freeze invocation-scoped IDs at model acceptance, reject malformed batches before effects, and restore provider IDs only through the existing outbound history projection, including structural cache annotations. Canonical persistence failures reach existing fanout/cancellation paths while preserving partial answers.

Web now retains one genuine parser projection and one selected chat/session/root/assistant observer binding. Only explicit matching root terminal receipts establish completion; interrupted POST recovery uses bounded GET attachment without replaying the turn. Stop uses that same binding end to end: stale requests cannot cancel a successor, and delayed ACKs, refreshes, reconciliation and rollback cannot overwrite a successor or newer root facts. Resume ordering, upstream-error separation and bounded retry ownership retain their existing fixes.

The PR also removes quadratic bounded gap insertion, bounds plan-review correlation, updates TLS/SQLx contracts, and reports typed/private-safe harness failures through existing criteria/progress. Required judgment and exact execution predicates remain strict.

Related issue

Closes #1093. Related #988 remains open: its historical incident and live-cache attribution have not been established as the identity collision fixed here.

Change type

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

User and compatibility impact

Partial answers survive observation loss and canonical failure. Waiting/blocked/paused runs retain controls; terminal runs settle from Runtime receipts. No EOF-success fallback, automatic POST replay, execution alias store or alternate lifecycle path remains.

The Web Stop endpoint requires sessionId, runId and explicit nullable assistantMessageId. Missing/malformed bindings return 400; a binding changed before Runtime admission returns 409 with zero cancellation calls. Cancellation already dispatched continues against its captured root. Runtime-only roots use null assistant and cannot complete another message by fallback. All current callers are updated; no chat-ID-only compatibility overload remains.

Safe harness progress uses v5 with its strict reader updated together. Actual predicate values, unexpected JSON keys and private error text stay out of public artifacts. Deployment defaults, database schema, authentication, sandbox and User Runner boundaries do not change.

Architecture and complexity delta

  • Canonical owners remain Runtime model acceptance, provider request projection, persistence/fanout, Web parser/selection/control owners, and harness criteria/progress plus CLI judgment.
  • The existing active-run-merge module owns the shared binding comparison used by observation and controls. Stop revalidates current store authority after every relevant await and preserves later root facts and parser progress. Its browser cleanup handle owns only a control request's busy flag and timer; it adds no lifecycle generation, durable state or alternate execution path.
  • Remove guessed message creation, text-based EOF settlement, redundant browser paused/cancelled flags, unused status feedback, Stop's latest-assistant fallback, whole-transcript rollback and overlapping Stop intervals. Stop reads are single-flight, with the next timeout scheduled after settlement. Rollback restores only Stop's unchanged fields and preserves newer output, artifacts and cursor.
  • Ordered keyed recovery preserves first retention, insertion order and the 20,000-event cap while removing quadratic insertion. Previous instrumented overflow control improved from about 75 s to 0.34 s. Selection replacement cancels observer retry admission and retires Stop's local effects.
  • TLS verifier 0.103.16 / roots 1.0.10 remove forwarding roots 0.26 without new audit exceptions. SQLx 0.9 uses explicit runtime/TLS/authentication features and upstream owned SQL types; dynamic identifiers remain validated/quoted and values bound. Public-root WebSocket/proxy policy stays in astra-core::net; HTTP retains native-plus-bundled roots and normal certificate/hostname validation.
  • Predicate diagnostics expose bounded structural reason/path/type/count data without changing matching. Judge failures retain typed causes; process/quorum failures remain failures. Retained-writer DB tests retain their five-scenario matrices through two production writer entrypoints under the existing 60 s profile.

Recovery after Stop follows committed eligible selection, including reconciliation after a pending cancellation is rejected. The existing retry owner preserves its budget and latest cursor; the Stop handle retires at this one-shot handoff. Shared public controls cover stale status reads, pending running/waiting/blocked/input-queued outcomes, paused/terminal controls, exhausted budget, and subsequent ordinary observation without reentry. Cancellation status reconciliation also follows the committed owned cancelling lifecycle, including roots without an assistant message. HTTP acknowledgement latency never decides whether reconciliation starts: cancelPending describes only the bounded ACK wait. The existing operation-local timer reserves both the scheduled and physically in-flight cycle, so rerenders cannot duplicate requests. Response and error branches no longer start their own reconciliation. No additional retry state or execution path is introduced.

Verification

Final correction: 1af249616a11, based on rebased 7784e70c21 and frozen main@b232c4a570. The requested rebase was verified already up to date. Rust/SDK/dependency/configuration inputs are unchanged by the Stop correction.

  • Current Web: 817/817 tests, full TypeScript check, configured incremental ESLint over all changed TypeScript implementation/test files with zero warnings, and production Next build passed. The final cancellation-lifecycle correction passed renewed full tests/typecheck, affected-file ESLint and production build for exact patch 4026692a8dcf.
  • Public QA uses real ChatView, stream POST/GET, Stop route and store entrypoints with controlled Runtime responses. Controls cover stale incoming targets, replacement before/after admission, delayed ACK/failure refresh, same root with different session/message, malformed payload, null assistant, late success/failure, status-read replacement, single-flight polling, unmount, successor busy flags, newer terminal/root facts, field rollback genuine cursor preservation, and live GET reattachment after failed Stop with either refresh outcome. Shared controls also cover both successful ACK flags across all recovery states, direct terminal ACKs without polling, runtime-only roots preserving unrelated messages, transient status-read failure followed by convergence, and rerenders during an in-flight read with one next cycle. Public HTTP/store tests prove that fast ACK plus unsettled execution or unavailable immediate status legitimately returns a retained cancelling lifecycle. Previously failing counterexamples now pass alongside unchanged-binding controls.
  • Reused exact-source rebase gates: locked all-target/all-feature Core/Services/Runtime/CLI/harness Clippy with -D warnings, format/repository checks, 152/152 Python contracts, native 1698/1698 units + 9/9 real-MatrixOne groups, and actual instrumented-std TSan 1698/1698 units + 9/9 DB groups. Strict existing 30 s/60 s profiles, zero retries, no suppressions or application deadline/thread changes. No applicable JavaScript event-loop race detector exists; deterministic asynchronous interleavings validate the changed Web paths, and Rust TSan is not represented as JavaScript race coverage.
  • Reused configured-policy dependency audit passed against RustSec revision 4b587f00996ebe5c05a73eaef105ef241e876414, with three existing allowed warnings and no new ignore. Applicable unchanged SDK 34, TLS/SQLx/MOI and other source-bound evidence remains valid.

Actual gpt-6.1-sol / xhigh produced the design and admission amendment and performed the final overall review of design, implementation, tests and docs. No unresolved material source/design/test/documentation blocker remains after the completed correction and re-review. This is ordinary feature-branch delivery approval, not a claim of overall live readiness.

Remaining live evidence

The latest completed live evidence is from predecessor c6cdf6cff683: 18/18 passed, exit 0, termination finished, with exact artifact commit verified. Completed live job. The final Web-only correction does not change Runtime, SDK, harness, dependencies or criteria. No new live run or CI wait is claimed for the final commit. This passing run does not establish the cause of earlier Work failures or historical cache attribution; #988 remains open.

Final checklist

  • Tests cover owning public entrypoints and unhappy paths.
  • Updated canonical observation/control contracts.
  • Checked the diff for credentials, private endpoints, generated data and unsanitized logs.
  • Conventional Commit-style title.

@XuPeng-SH
XuPeng-SH force-pushed the fix/tool-call-invocation-identity branch from e1d3ce7 to 7784e70 Compare October 21, 2026 14:45

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Commit review for 1af249616a11128ffadc6c919f84abf01b6b63e6 (relative to c6cdf6cff683f96149c6184357ed3e22ec4bad66): no actionable findings. The committed cancelling lifecycle now owns reconciliation independently of ACK latency; scheduled and in-flight reads share one operation slot, and stale responses remain fenced by binding and snapshot checks. The added cases cover fast ACK, terminal ACK, missing assistant message, transient status-read failure, and overlapping Stop operations. Exact-source local evidence: 817 Web tests, typecheck, affected-file lint, production build, and two additional deterministic Stop interleavings passed. No full-CI completion is claimed here.

@XuPeng-SH
XuPeng-SH merged commit af74eb0 into matrixorigin:main Oct 21, 2026
@XuPeng-SH
XuPeng-SH deleted the fix/tool-call-invocation-identity branch October 21, 2026 23:26
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.

[Bug]: Reused tool-call IDs collide during terminal settlement and close streams without run_finished

1 participant