Skip to content

perf(runtime): simplify SQL persistence for conversational turns - #1127

Merged
XuPeng-SH merged 58 commits into
matrixorigin:mainfrom
XuPeng-SH:perf/issue-1124-chat-sql-simplification
Oct 26, 2026
Merged

XuPeng-SH merged 58 commits into
matrixorigin:mainfrom
XuPeng-SH:perf/issue-1124-chat-sql-simplification

Conversation

@XuPeng-SH

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

Copy link
Copy Markdown
Collaborator

Capability assessment: Updated: Ordinary Server conversation uses Run authority, canonical Context and durable effect custody while retiring redundant persistence, distributed weighted reservations, automatic memory processing and implicit history tools. Update authentication, runtime lifecycle, data/storage, model routing/tool guidance, memory and multi-session design contracts; preserve the pinned MOI gate.

Summary

A short conversation should not create a separate persistence protocol at every model or tool boundary. This change concentrates execution authority in Run, continuation in canonical Context, and uncertain external effects in the existing invocation ledger.

The public /chat/stream scripted-provider fixture measures 15 SQL statements for empty Context and 17 with retained Context, in two transactions, including BEGIN/COMMIT and complete post-stream drain. One→three readonly discovery/agent-list rounds add zero framework SQL; an observed control-watcher poll adds one statement. These are fixture counts, not arbitrary-tool or production-latency guarantees.

  • Admit one immutable Run opening containing original input and execution facts. Atomically commit final Context, raw conversation, terminal receipt, qualified usage and exact owner retirement. Remove duplicate admission transcripts and per-model settlement protocols while preserving durable effect custody and generation/Session fences.

  • Store immutable Context content inline with its manifest node. Retire separate segment/reference staging, provider WAL/checkpoint mirrors, Run display mirrors/repair, weighted reservation/slot tables and write-only output projections. Keep exact fork bounds, historical ACK verification and resource-failure disposition at their canonical owners.

  • Bound authentication/model observations and model fill coordination. A successful auth snapshot can authenticate an overlapping request while invalidation prevents stale retention; absolute expiry is checked after awaits. Cold authentication uses one statement and warm authentication none. Ordinary turns consume shared control observations and lazily resolve Work/skills/messaging only when needed.

  • Read selected Web history through one bounded Session snapshot combining immutable openings, root status and committed root/runless rows. Enforce the 256 KiB historical-opening/detail budget before body transfer/decoding, preserve selected exact input under the existing 8 MiB opening limit and retain independent raw cursors. A reusable same-root stream omits history; a successor returns bounded history in the same query.

  • Project failure from the existing terminal receipt onto its exact final assistant answer. Preserve completed intermediate replies; represent a missing visible final answer with a stable failure notice without a raw sequence. Web retains failed partial output through idle refresh, process-state loss and successor Runs.

  • Unify Web JSON and SSE under the existing message/parser/writer owner. Stop, deletion, successor selection and Session rebinding fence stale writers/read responses and late ACKs. Metadata writes commit against the current matching shell, preserving deferred input and exact stream continuations.

  • Deliver fitting child results automatically through the existing completion barrier and aggregate budget, retaining explicit result-owner references for oversized output. Default agent exposes ordinary delegation; explicit current-run wait remains available through canonical tool_search/invoke_tool, without a child target. Preserve exact model/Offering selection and compact task-label meaning without aliases, fallback or relaxed validation.

  • Settle exhausted provider recovery as Failed through the canonical C0 boundary, retaining real partial text and qualified usage. Keep genuine input/approval/debugger waits and checkpoint resume authority separate. Unknown effects never become successful receipts because a Run ended.

  • Make native collaborator preparation opt-in (ASTRA_NATIVE_COLLABORATORS=true or 1). Ordinary CLI/TUI turns avoid eager native discovery, Session creation and WebSocket attachment. Explicitly selected capacity must be ready before admission; preparation failure retains unsubmitted input and joins cleanup.

  • Make optional diagnostics/Explain use the existing bounded asynchronous ingestion/drain. Retire automatic per-turn memory processing and unused global history tools; explicit close/finalize and memory/skills/Work operations retain their owners. The harness reads complete invocation-scoped execution traces rather than removed per-tool SQL mirrors; missing/conflicting ownership, full documents or dispositions still fail closed.

  • Preserve producer-owned reasoning/model/Work guidance through resident schemas and provider requests. Reject malformed calls before execution with bounded leaf diagnostics and producer-owned usage guidance. The Work harness distinguishes historical execution from retirement, fences accepted cancellations before the next full board, and proves board-first delivery against assigned execution evidence; explicit never-started scenarios retain strict controls. No new SQL, persistent state or validation/execution owner is added.

  • Preserve source error classification independently of the domain code in the canonical terminal receipt. Live streams and terminal-only replay retain valid partial output; absent kinds stay absent, genuine protocol failures remain strict, and accepted cancellation clears failure classification. Exact terminal retries compare the classification without extra SQL.

  • Deliver the applicable complete action/child evidence to external-command judges and apply their existing 64 KiB envelope limit to every request before spawning, including text-only judgments.

Related issue

Refs #1124. Remaining MatrixOne index selection is tracked in matrixorigin/matrixone#31046. Prepared unpartitioned SUM-window failure is reported with an independently executed reproducer in matrixorigin/matrixone#31089; the owner/Session-partitioned equivalent avoids it without changing the budget or parameter binding.

Change type

  • Refactor or performance improvement
  • Bug fix
  • Documentation
  • Test

User and compatibility impact

  • The default agent surface now uses the existing runtime completion barrier for ordinary child results. Explicit current-run wait/timeout_ms remains available through typed tool_search/invoke_tool selection of the unchanged canonical contract; it accepts no child ID. Preserve the short task-label meaning of description in compact schemas. No REST/MOI contract, executor, validation bypass, alias, state machine, SQL or model fallback is added.

This is a fresh-schema change, without historical migration, backfill or old-layout fallback. Existing incompatible schema markers fail startup explicitly.

External native collaborator discovery is now opt-in in the CLI process (ASTRA_NATIVE_COLLABORATORS=true or 1; default off). Ordinary Server-model conversations and local workspace tools retain their existing route. Explicitly selected native capacity that is unavailable or times out returns a preparation error before chat admission; it no longer silently proceeds after failed installation. Invocation permissions, sandbox and attachment authority remain enforced.

Ordinary turns no longer perform automatic memory extraction/implicit memory recall, eager skill/Work discovery, or global session-history tools. Explicit memory/skills/Work operations and local CLI journal remain. Proven builtin readonly observations may execute again and see current data; they do not promise exact read replay. Real external effects retain durable prepare/dispatch/outcome custody. Default diagnostic ingestion is omitted; explicit Explain still records diagnostics.

Cross-process ordinary JWT revocation can take up to the fixed 30-second cache window; sensitive identity/credential operations resolve fresh authority, and local mutations invalidate the cache. Capacity is bounded per process rather than by a globally precise weighted reservation. Qualified execution usage remains on Run; the daily token mirror is no longer an ordinary-Run admission gate. Session-creation limits retain their contract.

Run display GET reads canonical facts and may advance between queries; its old repair endpoint is retired. Live cross-server tool presentation is best effort; cold replay does not promise generic tool cards. Canonical results and uncertainty remain in the invocation ledger and Context. The standalone segment-upload transport and optional legacy fallback paths are retired; pinned MOI APIs remain unchanged.

The new conversation projection supports optional reuse_run_id / reuse_terminal and explicit history_loaded; an omitted view has null raw cursor/truncation fields. Existing raw transcript scopes and the frozen MOI API contract are unchanged.

Resident tools advertise usable reasoning and fixed-model selector forms, including Work assignment/evidence chronology. Short-circuit trace rows now retain complete redacted arguments and the actual returned response without claiming execution. Semantic judgments share the existing authorized, invocation-scoped complete documents; obsolete stderr/tool packing and ordered-exchange truncation are removed. Child adoption retains its stronger Server/custody checks. Native requests use existing Server admission; external command requests reject a complete envelope above 64 KiB. Recursive schema reconstruction and variant-selection rendering are removed; rejection feedback reuses bounded leaf facts, labels unmatched-union uncertainty and inherits the nearest producer-owned compact guidance. Human-readable rejection feedback improves; validation decisions and the sanitized diagnostic codes/paths remain unchanged. The generic Work harness permits pre-retirement execution history, while explicit cancel-before-start and board-first contracts are checked separately. These prospective oracle corrections do not regrade historical runs.

Architecture and complexity delta

  • Canonical owners: Run opening/control/terminal, immutable Context/head, existing effect ledger, existing async diagnostic ingestion/drain and process-local capacity.
  • Search and update lifecycle/recovery, storage/cleanup, public clients, harness callers and contract tests together. Remove obsolete tables, allocators, projection hashes, repair methods and tests dedicated to retired behavior.
  • No replacement slot state machine, observation replay cache, background authority writer or compatibility migration is introduced. Inline Context replaces separate storage ownership rather than adding another projection.
  • Remaining limitation: admission still reads real Run/owner/custody facts, and raw transcript sequencing still uses its existing Session MAX. MatrixOne may scan history despite tenant predicates/index hints. A generated-key experiment failed an interleaved-history control and is excluded. This PR does not claim every remaining query has history-independent cost or that remote-effect tools add no SQL.

Verification

Current CI correction — 637d27135d9be94e04785d565c0bafc2f30ba724

The online Runtime and integration lanes failed the same fixture: it compared newly committed control notifications with an idempotent terminal confirmation. The fixture now checks the actual contracts separately: identical completion, unchanged durable event list/allocation, exactly one returned-intent fact before completion, cursor replay, and no fabricated model application. Same-attempt unknown-ACK handling and durable reconnect already preserve the control facts; runtime settlement stays with its existing owner.

The child-question verifier had an independent false-negative path: questions excluded affirmative non-execution, but answer request-ID collection and answer uniqueness still counted rejected attempts. All three stages now share the existing canonical execution fact. Only NotExecuted is excluded; unknown, failed/executed and genuinely duplicated answers retain the strict receipt, identity, delivery and completed-child checks. Regression controls cover rejected attempts before/after success, wrong recipients, missing to with extraneous agent_id, and a separate question referenced only by a rejected answer. Prompts and case oracles are unchanged. No production SQL, table or state machine was added.

Current correction check Result
Old-code regression One executed criterion regression fails on unchanged 885 logic; the real-DB LateGuidance failure also reproduces locally.
Complete native Harness 627 passed, 1 existing opt-in ignored.
Instrumented-stdlib TSan 662 passed: all 627 Harness tests plus all 35 Runtime persistence tests, including 16 real MatrixOne opt-ins. No suppressions or race reports; test DB dropped.
Static analysis Runtime and Harness, all targets with e2e-hooks, Clippy -D warnings; formatting and diff checks passed.
Required model gates gpt-6.1-sol / xhigh design, overall source review and final validation acceptance; same recorded review session.
Fresh candidate live case 1/1 PASS: unchanged flash_child_question_parent_answer with fresh clean candidate CLI/Server/Harness binaries and DeepSeek v4.1 Flash. Three executed/successful calls, no rejected attempts; the repaired branch is covered by deterministic RED/green controls, not this smoke. Fresh Server exited 0 and DB was dropped.

Before this correction, 885 CI was 103/104 in Runtime and 294/295 in integration, with the same LateGuidance fixture failure and a failed aggregate. Live regression was 17/18, failing flash_child_question_parent_answer as QuestionUnanswered; its safe artifact records a rejected non-executed call and successful answer, but does not retain their correlation IDs. One separate unchanged-885 direct-provider diagnostic passed with four successful executed calls and no rejected attempt, so it did not exercise the repaired branch or prove the original CI trigger. These original results are not rescored. New candidate CI remains pending.

Prior terminal correction validation at 8855283b4 — reused where unchanged

The following records predate this CI correction. Affected Harness behavior and the complete Runtime persistence fixture have been revalidated above; other unchanged inputs retain their recorded evidence.

Previous terminal candidate 8855283b43a36b884577894acf0d44c446b46208, based on 54e49ec3e1753d0661ba48ccda35225eb85d41b1. The complete PR change map reconciles prior evidence with the current delta; unchanged owning paths reuse their exact file/input evidence.

Scope Result
Current owning functional tests 3 terminal-service + 29 Runtime producer/consumer native tests passed. Current complete Harness and directly affected lifecycle/SSE unit tests pass under TSan below, including actual external-judge subprocess input, oversize rejection before launch, partial output and terminal-only replay. Unchanged a27 evidence retains 62 schema + 27 discovery, 110 tool-pipeline and 22 journal tests plus two real recorded 14-call judge-input replays.
Incremental SCA cargo clippy --locked -p astra-runtime -p astra-services -p astra-turn-core -p astra-test-harness --all-targets --features e2e-hooks -- -D warnings: passed (305.5 s). cargo fmt --all -- --check and git diff --check: passed.
Incremental UT with race detection 934 affected unit tests passed for the previous terminal candidate under TSan with instrumented standard library: 3 services, 76 Runtime, 228 shared SSE/stream tests and all 627 Harness tests. Four binary hashes/__tsan_init definitions and 40 standard-library instrumentation symbols verified; no suppressions. The old 2 MiB pipe fixture was corrected to an admissible 32 KiB request after unconditional envelope enforcement; its original timeout/output/descendant assertions and separate oversized/no-spawn control pass in this final scope. Prior unchanged journal/pipeline/schema/discovery race evidence remains separate. This is not an all-integration TSan pass.
Terminal database boundaries Five isolated real MatrixOne checks passed, covering failed commit/replay, accepted cancellation from a proposed failure, exact request/receipt/ACK classification identity, normal success and rollback. All five databases dropped. Later wire-omission and external-judge corrections do not change these storage/claim/transaction inputs.
Work public boundary Existing delayed cancel/add/commit-window recovery fixture passed against a fresh real MatrixOne database; exact assignment/retirement/recovery receipts verified and database dropped. Work authority and effect custody remain unchanged by these corrections.
Reused auth/history/Web boundaries Unchanged owning paths retain 108 auth + 57 Runtime native tests, four isolated fresh-database boundary checks (all dropped), 873 Web and 449 SDK passed / 13 opt-in skips, typechecks/build/changed-file lint. Auth interleaving, bounded history/cursors and HTTP partial/no-answer terminal projection remain covered.
Required model gates Passed. gpt-6.1-sol / xhigh design and overall review/correction loop, session 01a177a5-ae85-7443-89c9-f1b25f442c76. The review reconciles the complete PR, closes the previously unavailable a27 trace/evidence review, and resolves all three follow-up source findings. Prior accepted designs and b8f review remain reconciled; CI and historical runtime-quality/sanitizer limitations below are not waived.

Prior a27 targeted live verification

The b8f365f fresh eight-case sample remains 4 passed / 4 failed. Its parallel task completed but two suppressed lookup records lacked full documents; both news tasks passed functional controls but lossy judge input produced UNKNOWN. Both producer/input causes are corrected and replay-tested. The Work board-first model violation remains a separate failed outcome. Scores from different revisions are not combined.

4/4 passed, one serial execution per case at the candidate revision, 6 min 19 s total:

Case Result
multi_turn_local_followup_focus (existing CI failure) PASS; initial and follow-up semantic judgments both accepted.
parallel_historical_review_medium PASS; both children, complete trace/custody, and semantic synthesis accepted; 42 complete tool documents.
work_news_deferred_replacement_journey PASS; functional retirement/Work controls and semantic judgment accepted; 14 complete documents.
work_news_implicit_replacement_journey PASS; functional history/retirement controls and semantic judgment accepted; 24 complete documents.

All five required judgments accepted. Owned Server exited 0 and the temporary database was dropped. Case hashes, all three clean binary hashes/build identities and Server health match the candidate. The current parallel sample had no suppressed calls: the repaired suppressed producer path is covered by actual-emitter unit tests and serialization controls, rather than being claimed exercised by this live sample. The two historical 14-call news captures separately pass exact complete-document replay into the actual typed judge request; their old scores remain unchanged.

Soft targets remain unmet: historical review used 42 tools / 13 rounds against advisory 18 / 12 limits; implicit news used 24 tools against advisory 20. The previously observed natural Work board-first model violation remains a separate recorded failure, not rerun or waived. This four-case sample does not establish an all-inventory pass or replace historical results.

Fresh production Server/CLI/harness binaries are bound to the clean candidate revision and build nonce, individually hashed, checked against owned Server health, and exercised in one new workspace/database. Case copies are hashed. Execution and judgment both use DeepSeek v4.1 Flash, as requested. Historical full-inventory judgment used GLM-5.3, so this targeted sample is not a directly comparable replacement score; no source/model/case-specific branch, substitution, raised deadline, argument autofill or retry-to-green policy. The private bounded wire observer is preflighted for original status/bytes/streaming and downstream cancellation before/after headers. Owned services and database are cleaned up.

Historical complete local inventory — unchanged result

At 54a776447529f7046112d2da0873a4503d1ade3d: 82 inventoried; 79 executed; 74 passed / 5 failed; 3 exact-model unavailable cases separately excluded. One serial execution each, no retries/source/oracle/binary changes. Supplementary GLM-5.2 was available; two DeepSeek-v4-flash-required cases and one Qwen3.7-max case were unavailable after normal probes. All 79 rows reached terminal results, three clean binaries/case hashes matched, owned Server exited 0 and fresh database was dropped. This is an Astra live inventory, not a Terminal-Bench score.

Original failure Root-cause evidence and disposition
flash_child_question_parent_answer Malformed fixed selectors caused schema/source-discovery detours; child subsequently completed. Root later produced two clean-decoded non-actionable completions. Operative selector guidance and bounded correction feedback are fixed; the original empty-completion transport/model cause remains unproven without its raw stream.
flash_reasoning_correction reasoning.mode=medium was rejected; Bash/source grep violated the no-tool contract. Preserve the actual adaptive/effort and enabled/budget forms in producer/resident/wire guidance; admission remains strict.
parallel_historical_review_medium Child inference failed after roughly139s, then exhausted bounded recovery; custody contradicted and hard judge was not run. No evidence attributes this to SQL/locks. Original raw stream cause remains unresolved; deadlines/retries are unchanged.
work_natural_dynamic_board_journey Unbound pre-reads preceded Work; evidence guard correctly rejected the first premature settlement, followed by two recorded deliveries. New functional oracle proves board-first execution/assigned evidence/exact deliveries and still rejects that workflow; it does not merely raise a call-count ceiling.
work_news_implicit_replacement_journey NetEase execution under task2revision1 preceded cancellation at a later revision. The user requested cancellation during the process, not never-started cancellation. Generic retirement now preserves valid history while forbidding retired authority; explicit strict scenarios retain cancel-before-execution checks.

Ten historical cases also missed non-hard efficiency/cache targets; hard passes do not imply those targets passed. The older 64/79 inventory and earlier focused trials remain historical evidence, not rescored or replaced by the targeted run.

Existing CI observation

At published a27bbbb, all other CI checks passed, including the frozen MOI gate; regression/harness finished 17/18, with agent_workspace_evidence_chain failing at exit 3 and missing final text. One separate diagnostic on that exact revision, using its attested binaries and a fresh workspace/database, reproduced the failure: the child completed its required workspace read and returned a visible answer, then two complete parent provider streams ended with stop/[DONE], no visible content and no tool call, exhausting the existing recovery. The diagnostic used DeepSeek v4.1 Flash; the owned Server exited cleanly and its database was dropped.

This proves the local provider-output omission, not the reason for that omission or identical raw behavior in the original CI run. It is not a retry-to-green result or a rescore. These serialization/judge-envelope fixes do not claim to solve the omission; no hidden reasoning is promoted to an answer, oracle weakened or deadline increased. New candidate CI remains pending.

Test contract changes

Tests for retired automatic capture, memory/history tools and stored projection repair follow the supported product contracts. Fanout completion checks actual child adoption, fixed slots/results and inherited model identity rather than treating an immutable launch receipt as final status. Cache cases hard-require independently observed positive warm reads; exact read-share remains diagnostic. Sequence evidence requires distinct witnessed provider rounds, not order within a parallel batch.

Two catalog absence/uniqueness cases and the unsupported Bash-to-opaque-Session-artifact case were retired, which reduces that live coverage; exact-selector negative, impossible-model, saved-output and artifact-authorization controls remain. The compact-JSON case drops two undeclared hard discovery bans while retaining exact child/hash/JSON/IO checks and soft efficiency targets. Budget exhaustion verifies canonical Failed facts, partial output, request counts and quiescence. These changes are disclosed product/test-contract changes, not a claim that the entire PR kept every historical oracle unchanged.

Performance and validation limits

  • The public scripted-provider fixture measures 15 fresh / 17 retained-Context SQL statements in two transactions, including BEGIN/COMMIT and the complete post-stream drain. One→three readonly discovery/agent-list rounds add zero framework SQL; a deliberately observed watcher poll adds one statement. These are fixture counts, not production latency or arbitrary-tool guarantees. The auth correction preserves one cold / zero warm authentication statements; conversation failure presentation adds no statement or write.
  • On MatrixOne 4.2.5 / 1a44f3db3056e32975fde86ca0ab69a094996a3f, the earlier bounded-history measurement reduced opening-body transfer 2,622,360→131,118 bytes (~95%), with zero opening-body bytes for a matching warm continuation. The final read also budgets bounded failure detail. These bounds cover returned payload work and do not establish history-independent scanning or a controlled multi-server performance improvement. Remaining index selection is tracked in MatrixOne #31046; partitioned prepared SUM avoids the independently reproduced issue in MatrixOne #31089.
  • Broader sanitizer evidence remains unresolved. The public long-result integration reported 24 Tokio I/O races and a provider-entry timeout; a prior-production/original-short-result control reported 26 in the same two families with the same timeout before the changed delivery branch. A broader Tools run also reported 1007 passed / 1 failed / 16 ignored in an unchanged-main I/O test. Neither baseline similarity nor a related upstream discussion proves a false positive. No suppression, changed scheduler/dependency/deadline or unchanged-source retry erased those results. Scoped passing UT/race checks are not an all-integration TSan pass.
  • The frozen MOI API, pins and required gate are unchanged. Existing green checks are historical evidence; candidate CI is pending, not claimed passed.

Final checklist

  • Tests exercise canonical public behavior, rollback, cancellation, ownership and resource failures.
  • Design/public documentation records changed contracts and remaining historical-read limits.
  • Checked the delta for credentials, populated environments, private endpoints and raw traces.
  • Conventional Commit title; delivery through a fork feature branch targeting main.

Cache reuse evidence correction

A real four-turn ACK diagnostic returned no cache field on its cold request, followed by explicit positive cache reads of 4,864, 7,936 and 8,064 tokens. Explain preserved those values, but the reuse gate rejected the entire conversation before examining warm reads because cold usage was unknown.

The reuse gate now validates all canonical execution identities, lifecycle boundaries and ordering while retaining unknown counters separately. Known post-cold reads can establish a reuse witness; their sum is explicitly a lower bound. Unknown/zero reads alone still cannot pass. Exact totals, ratios and per-warm-turn requirements retain complete measurement. No production SQL, storage or runtime dispatch changes.

Validation: 904 package unit tests passed (1 ignored), including missing-cold/known-warm, cold-only-hit, zero, incomplete-capture and exact-total controls; all-target Clippy passed with warnings denied. A fresh Server/CLI/Harness build at479d1c4a2 passed the unchanged real DeepSeek-v4.1-flash matrix case. That fresh run reported every cache field, so the missing-cold branch is covered by deterministic regression, not claimed as newly reached live. The same 904 tests passed under ThreadSanitizer with instrumented standard library and no suppressions (1 ignored); no races reported.

Original broad live-run failures remain recorded independently; this correction does not claim that the other cache assertions or provider failures are resolved.

The cache correction was self-reviewed; earlier independent review evidence applies to the preceding revision.

@XuPeng-SH
XuPeng-SH marked this pull request as ready for review October 23, 2026 15:40
XuPeng-SH added a commit to XuPeng-SH/Astra that referenced this pull request Oct 23, 2026
Checkpoint the issue matrixorigin#1124 SQL reduction work. Cache ordinary authenticated
principals, reuse bounded model admission, remove distributed weighted
admission and write-only tool output projections, and keep readonly Server
observations outside the durable effect ledger and generic replay cache.

Retain explicit memory operations while removing automatic per-turn recall.
Add a public HTTP SQL budget gate and align schema inventory and ownership
documentation with the removed storage paths.

This is an intermediate checkpoint for PR matrixorigin#1127. The last measured public
SQL counts are 132/150/185 for zero/one/three readonly tool calls, exceeding
the <=20 and zero-slope targets. Context/Run transaction simplification,
remaining outdated receipt/cache fixture corrections, current-source race
checks, overall review, and a fresh live harness are still pending.
Pin sqlx-core to upstream's TCP_NODELAY fix so MySQL protocol packets
avoid Nagle/delayed-ACK stalls, including statement-cache eviction.
Keep the existing connection, TLS and persistence owners.

Add an offline regression that inspects real SQLx TCP sockets before
handshake and document the transport contract. The regression fails
with registry SQLx 0.9.0 and passes with the pinned fix.

Related: matrixorigin#1124
Remove per-turn memory snapshots and the separate post-loop settlement worker. Explicit session finalization reconstructs input through the existing Context coordinator; align health checks and retire obsolete metrics.
Checkpoint the issue matrixorigin#1124 SQL reduction work. Cache ordinary authenticated
principals, reuse bounded model admission, remove distributed weighted
admission and write-only tool output projections, and keep readonly Server
observations outside the durable effect ledger and generic replay cache.

Retain explicit memory operations while removing automatic per-turn recall.
Add a public HTTP SQL budget gate and align schema inventory and ownership
documentation with the removed storage paths.

This is an intermediate checkpoint for PR matrixorigin#1127. The last measured public
SQL counts are 132/150/185 for zero/one/three readonly tool calls, exceeding
the <=20 and zero-slope targets. Context/Run transaction simplification,
remaining outdated receipt/cache fixture corrections, current-source race
checks, overall review, and a fresh live harness are still pending.
@XuPeng-SH
XuPeng-SH force-pushed the perf/issue-1124-chat-sql-simplification branch from 3f34c34 to c70c68b Compare October 24, 2026 14:00

@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.

Two inline review findings: a reproducible Web cold-resume gap for Runs whose opening is persisted before any transcript row, and design docs that still describe removed execution-slot, writer-reservation, and distributed-capacity contracts.

Comment thread crates/runtime/src/server/run/lifecycle/mod.rs
Comment thread docs/design/runtime-lifecycle.md Outdated

@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.

Two new P2 findings from a counterexample pass at 7928342. The two earlier public comments are addressed, and the canonical Run/Context/effect ownership direction remains coherent. The latest Web projection still has an idle-history regression and unbounded repeated input transport. Existing 14 cold-recovery tests pass alongside the two new failing counterexamples; the history counterexample passes with the previous 26d6a44 Web-store implementation under the same fixture. Changes recommended before merge. No production code was changed in this review.

Comment thread web/lib/api/web-store.ts Outdated
Comment thread web/lib/api/web-store.ts Outdated

@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.

Post-publication review and correction completed at 4fb538e39dfa6dbb0459038ad5b0c8b48cde03a0.

The existing four inline findings are resolved: opening-only recovery, obsolete ownership documentation, stale completed successors, and unbounded selected-input transfer. The independent gpt-6.1-sol / xhigh review also exposed Web ownership and recovery races; the final correction:

  • Uses the existing message/parser/writer owner for JSON messages and SSE; removes the separate synchronous parsing path. Concurrent detail reads retain input and results; stale aliases and superseded writers cannot overwrite them.
  • Retires stopped terminal continuations independently of marker expiry. A completed writer awaiting artifact enrichment no longer blocks the next turn.
  • Separates request deadlines from writer ownership. Known admission failures settle the local message; an acknowledged Run remains resumable after observation loss or a late ACK.
  • Preserves waiting/blocked continuations through terminal polling and resumes the exact cursor. A paused parser that cannot auto-attach receives the committed terminal answer on the first detail refresh.

Validation: 422/422 affected Web tests, typecheck and changed-file ESLint passed, including actual public JSON/SSE routes and delayed interleavings. Unchanged Rust 63 native + 63 ThreadSanitizer, SDK 448 passed / 13 opt-in skips, and real-database snapshot/prepared-query/cost evidence remain applicable. Earlier broad/live limitations remain recorded in the PR description.

No persistent state, schema or write SQL was added. The bounded selected-Session read replaces owner-wide enumeration; it is not universally cheaper: one-Run warm refresh is 2→3 reads, while the measured 1000-Run case is 6→3 reads, 16.82→5.09 MB DB wire bytes. No constant-scan or complete browser-latency claim.

Actual-model final published-SHA verdict: PASS — no unresolved material blocker, session 01a171e1-d062-7f23-a87a-7afe103ef6f3. New-head CI: PR Title passed; Static Checks and Test Suite are in progress.

@XuPeng-SH
XuPeng-SH merged commit 864a753 into matrixorigin:main Oct 26, 2026
41 of 42 checks passed
@XuPeng-SH
XuPeng-SH deleted the perf/issue-1124-chat-sql-simplification branch October 26, 2026 15:28
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