Skip to content

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

Open
XuPeng-SH wants to merge 30 commits into
matrixorigin:mainfrom
XuPeng-SH:perf/issue-1124-chat-sql-simplification
Open

XuPeng-SH wants to merge 30 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, memory and multi-session design contracts; preserve the pinned MOI gate.

Summary

Local validation is complete for bd8d3a511. New-head CI and fresh live harness are pending. The earlier c70c68b02 CI/preflight failures are historical failures, not passes for this revision.

A short conversation should not pay for a separate persistence protocol at every model or tool boundary. Concentrate execution authority in Run, continuity in Context and uncertain effects in the invocation ledger, and remove the redundant owners and writes.

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

  • Capture the immutable opening input/events once on Run and share the same authority across model rounds. Keep late binding and durable guidance/cancellation at their existing owners.
  • Store immutable Context content inline with its existing node; append and advance the head in the same terminal transaction. Remove separate segment/reference storage and staging. Preserve captured fork bounds, immutable historical ACK proofs and resource-failure answer/usage disposition.
  • Replace global diagnostic scans and per-session hydration in resumable listings with a compact directory; load selected details separately. Use existing head activity rather than a new recency writer.
  • Bound authentication/model caches and coalesce model fills. Initialize fresh-opening observers from the exact opening ACK so a quiet control poll does not manufacture permission/input reads.
  • Remove obsolete inference WAL/checkpoint mirrors, Run display projections and repair API, distributed weighted reservations, write-only output projections, automatic prompt-memory processing and unused model-facing history tools.
  • Keep actual effects, unknown delivery, approval, Runner boundaries and multi-server execution fences in their canonical owners. The pinned MOI request/rejection contract is unchanged.
  • Settle exhausted provider recovery through the existing Failed C0 transaction, retaining real partial output and observed usage. Shared clients accept the exact classified Failed root without fabricating success, a tool receipt or another provider request; malformed/conflicting evidence remains closed.
  • Fix MatrixOne model UNION NULL typing, retire tests of removed automatic capture, and validate readonly delivery against actual provider requests. Forced transfer revokes the execution owner before sealing unresolved effects; real input/approval/debugger pauses retain their owners.

Related issue

Refs #1124. Remaining MatrixOne index selection is tracked in matrixorigin/matrixone#31046.

Change type

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

User and compatibility impact

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

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.

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

  • Base 54e49ec3e; candidate bd8d3a511. Separate actual gpt-6.1-sol / xhigh design and overall reviews reconciled the complete PR, implementation/test/documentation deltas and corrections; no material code blocker remains. The frozen MOI consumer, both pins and gate workflow are unchanged.
  • Incremental SCA: all-target Clippy for Runtime, Core, CLI and ThinClient with -D warnings, plus format checks passed. Earlier unchanged Services/schema/repository-contract checks remain valid.
  • Native owning suites: Core 3399 passed / 12 ignored, Runtime 5685 / 104, Services 1761 / 96. Current final-boundary checks: 111 command-router UT, 21 actual CLI binary tests and 200 ThinClient tests passed. The binary test covers four output modes across Failed, missing terminal and missing root, with one execution POST, zero accounting GET/DELETE, exact partial/model identity/nullable usage, and no successful-turn journal.
  • Validation qualification: the broad CLI run had 5033 passes and three 30-second timeouts during measured host disk pressure. Two unchanged controls passed at the same deadline with isolated small fixtures; the new text-output case exposed a real defect, was corrected, and all affected command-router/binary checks above passed. No timeout increase, ignore or skipped-test inflation was used.
  • Real MatrixOne: 87 HTTP + 25 offline controls, 5 public SQL-budget tests, schema/Context authority, model UNION NULL/positive-cap controls, owner/ledger/Work/collaborator and isolated memory-security cases passed. The current frozen MOI historical/normal/reasoning journey passed again on a fresh disposable database. Resource controls preserve an 8MiB answer and observed usage after Context encoding fails; cancellation, guidance from another Server, immutable ACK/fork bounds, rollback and lock release before provider wait remain covered.
  • Clean attested production astra, astra-server, astra-test were built from bd8d3a511. Actual CLI/internal-JWT/fresh Server/real MatrixOne/scripted provider: healthy chat exits 0, full answer and Completed C0; malformed partial exits 3, remains Failed, preserves actual text, reports authoritative terminal, and retains Failed C0/raw history. Each chat made exactly one provider request. This is a functional diagnostic, not a scored/live-model benchmark.
  • Current incremental Rust ThreadSanitizer with instrumented stdlib: Core 261, CLI 318 + 1 MCP recheck, Runtime handler 29 passed, zero reports, no suppressions. The first MCP attempt stopped at a missing fixture; it was rebuilt from the same source/target/profile and staged for the nightly Cargo artifact layout before its successful recheck. Prior unchanged backend race evidence remains valid. A clean full-workspace TSan run is not claimed; separate broader Tokio/Crossbeam reports have independent non-Astra reproductions and are not assumed harmless.
  • Unchanged SDK 447 passed / 13 skipped plus typecheck/build, Web Node24.20.0 typecheck/52 changed-surface tests/ESLint, and Python harness contracts 90 passed remain valid.
  • Fresh CI/live harness: pending publication of this head. Historical runs 40100652501 and 40100683696 failed execution preflight on c70c68b02, with zero formal cases executed; they do not establish a pass or an infrastructure/provider root cause.

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.

@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
Preserve real provider output and qualified usage through atomic terminal
settlement and cold replay, without treating recovery hints as resume grants.
Fence forced handoffs before uncertain-effect reconciliation and retain debt.

Align online fixtures with canonical ownership and immutable Run events;
retire automatic full-capture assumptions and isolate the Memory catalog.

This branch has not been deployed

No deployments
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