Repository navigation
perf(storage): shrink Run writes and retire redundant products - #1187
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewer verdict: Request changes. GitHub rejected the REQUEST_CHANGES event because the connected account is the PR author; this COMMENT records the verdict and findings without claiming a formal blocking review state.
Request changes on ad0d963ee321ede077317cd03165d0533b090004.
The overall ownership direction is sound: one mutable Run control owner, immutable opening storage, checkpoint-body ownership in run_checkpoints, and retirement of the redundant products rather than compatibility shims. Owner/CAS/transaction boundaries and the qualified performance claims are substantially better than the former duplicated state.
Two P2 gaps remain: checkpoint persistence still hydrates a cold opening it does not use, and new reference/opening decode errors can bypass the sanitized public resume boundary. Two P3 cleanup/documentation issues are also annotated. These are separate implementation, test-quality and documentation findings; the deletion count is not used as evidence of correctness.
Validation: read the exact-head production diff and directly affected consumers/contracts; executed bounded local MatrixOne probes through the public Run store for the large-opening checkpoint path and malformed-reference rejection (both completed successfully as diagnostic tests). Probes and databases were removed; no product fixes or source commits were made. Existing matching-head functional/static/concurrency evidence was reused rather than rerunning the whole suite. The two missed foreground arrivals and the unproven 1,000-Session capacity matrix remain declared limits, not a newly proven regression and not a reason to relax the benchmark.
At review start, GitHub had no prior comments, review submissions or inline threads, so there are no historical review threads to mark resolved. No subagents were used. Please resolve the findings and add the targeted behavior coverage before re-review.
Keep cold opening and checkpoint bodies out of mutable Run control. Preserve exact checkpoint custody, bounded reconciliation and owned transactional lifecycle semantics while removing five redundant product and persistence paths with their schema, endpoints and configuration. Refs matrixorigin#1186
ad0d963 to
0b3c5b2
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewer verdict: Request changes. GitHub rejected the REQUEST_CHANGES event because the connected account is this PR's author; this COMMENT records the same verdict.
Request changes on 0b3c5b2: one confirmed P2 remains in the public read-error boundary.
The four historical patches are present, including the sanitized resume preflight. However, the new checkpoint-reference decoder still leaks its internal diagnostics through the Run list and Session Run tree. The inline finding includes an executed authenticated HTTP reproduction and passing controls. Keep the storage validation fail-closed; finish the presentation-layer fix across these callers and cover the actual read routes.
I reviewed the storage/control ownership, current-reference versus history semantics, transaction/cancellation paths, bounded reconciliation and harness reuse, retirement closure, tests and documentation. No other material finding is asserted. Existing exact-content validation was reused; the new DB-backed probe exercised six HTTP requests and left durable controls unchanged. Its synthetic database and temporary test target were removed. No subagents or product edits.
Validation limits remain explicit: the earlier full normal run had 7,314 passes and one timing failure, followed by a separately passing CA-configured control; CI is not claimed green, and 1,000-Session/mixed capacity remains unproven.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewer verdict: APPROVE. GitHub rejected the formal APPROVE event because the connected account is the PR author; this COMMENT records the same code-review conclusion and does not satisfy a separate reviewer's branch-protection approval.
Approve on 8660c66: no new actionable material finding.
All five historical review items are implemented and covered. In particular, load, list and Session Run-tree reads now share the existing lifecycle presentation owner; strict checkpoint validation remains in storage. The final correction adds no SQL, lock path, mutable state or compatibility layer. The metadata-versus-full-opening boundary and authentication/ownership owners remain intact.
The existing DB fixture now exercises actual authenticated list/tree requests concurrently, with healthy, malformed-reference, missing-opening and foreign-user filtering controls, resume behavior, unchanged durable-state assertions and canonical cleanup. The permissive Session stub qualification is documented; it does not redefine the production foreign-Session404 contract. Test and documentation changes are proportionate to the behavior fixed.
I reconciled this delta with the previously reviewed storage/reference, recovery/cancellation, bounded reconciliation/index, harness enforcement and retired-chain design. Exact-content validation is reusable: runtime all-target Clippy,11 phase1 DB cases,19 contracts and formatting passed; unaffected package/race evidence remains valid. No subagents or product edits; no duplicate unchanged test runs.
Qualifications remain: the earlier full normal run had7,314 passes and one timing failure, with a separately passing165ms CA-configured case; its exact environmental cause is not proven. CI on this head is not claimed green, TSan is unsupported on the recorded stablemacOS setup, and broader1,000-Session/mixed capacity remains unproven (#1186). This approval is a code-review verdict, not a claim that pending merge gates or capacity acceptance have passed.
Capability assessment: Updated: retire legacy Context/Decision CRUD, Server harness snapshot history/SSE/admin controls, and personal-skill self-report evaluation; retain canonical Context/Run custody, decision trace, reflection, skill activation, harness enforcement and CLI inspection. Update API/configuration, storage contracts and system capability coverage for all supported profiles.
Summary
Frequent Run frontier and lease writes currently carry opening and checkpoint bodies through the mutable control row. This change moves immutable opening data to one owned row per Run and makes
run_checkpointsthe sole checkpoint-body owner, with an exact current ID/version/digest reference onagent_runs. Summary/control readers avoid loading cold bodies. Opening admission, checkpoint updates, Context work, fences and rollback stay within their existing transaction owners.Remove five complete redundant persistence/product chains: generic Context snapshots, legacy Decision audits and their aggregation, durable Server harness snapshots and live snapshot APIs, duplicate skill-activation state events, and skill self-report evaluation. Remove their handlers, configuration, clients, readers, cleanup, fixtures and documentation together. Canonical activity, Context, policy, model usage, skill activation and harness verifier enforcement remain exercised through retained product paths.
Also remove three unused secondary indexes after actual query-plan controls, eliminate redundant guarded-action and guidance reads, and batch two existing commit-reconciliation loops with positional identity/byte bounds. The main append preflight was already batched; this does not claim to remove an N+1 there. Recovery keeps per-row locks because multi-row locking semantics were not sufficiently proven.
Related issue
Refs #1186. The issue remains open for the broader sustained-capacity matrix; this PR does not mark that acceptance complete.
Change type
User and compatibility impact
Requires a fresh database. No migration, backfill, old-format reader or compatibility branch is provided. The schema marker stays at v116; startup requires the new shape and rejects the former shape even with the same marker.
Retired HTTP products return 404. Normal reports remove the retired fields/source rather than presenting empty counts or internal implementation warnings. Resume and conversation failures retain their status/code contracts and provide actionable messages; technical detail stays in logs. An unreadable saved checkpoint cannot execute or masquerade as a recoverable concurrent change.
Architecture and complexity delta
agent_runsremains mutable control;agent_run_openingsowns opening bodies;run_checkpointsowns checkpoint bodies. A nullable triple represents the exact current reference. Full-reader validation and explicit unloaded opening state remain distinct from absence.Verification
cargo fmt --all -- --check,git diff --check; schema inventory's 45 tests; affected eight-package all-target Clippy with warnings denied. 16,448 offline tests passed without retries under the repository's strict profile; subsequent review corrections receive the scoped normal/database checks recorded below.Prior-head review and performance evidence
Prior-head source corrections: 70 scoped offline handoff/resume/harness cases passed. Four owning database cases passed, including exact-current corruption classification and concurrent resume/rollback. The new child-sink case separately passed through the actual database-backed lifecycle, invocation ledger and localhost provider; it also exercised canonical Session deletion cleanup. Prior-head services/runtime all-target Clippy passed with warnings denied; the other six package checks remain valid. The prior-head independent source review found no material source blocker; current repair validation is reported separately below.
Instrumented 100-Session comparison used fresh MatrixOne 4.2.6 instances with the same image, deterministic fixture seed, 4 vCPU / 2 GiB limit, 1536 MiB Go memory limit, 32 connections and unchanged timeouts/rates/assertions. Each case attempted 60 seconds warmup plus 600 seconds measurement on a shared 16 GiB host.
This provides a bounded diagnostic observation, not a passing capacity gate or a comparable before/after latency speedup. The broader 1,000-Session, mixed-size, hot-owner, repeated-rate and sustained scripted-provider capacity matrix remains unproven and #1186 stays open. No production capacity, cross-process fairness, failover, physical disk-amplification or deterministic OOM-fix claim is made. Neither the benchmark assertions nor production limits/timeouts were loosened.
Rebase and review fixes
Rebased onto
2edb4566132cb69ef227fd0d6ef8affa3700aaee(main, scoped MOI forks). The new fork admission reads the explicitly loaded opening through its existing fail-closed accessor; provider authorization remains with the existing coordinator.Current-revision checks:
make test-contract: 11 admin + 6 HTTP + 2 settings passed, with six pre-existing opt-in admin cases ignored.Explicit
gpt-6.1-terra/maxdesign and overall source review completed with no unresolved material source finding. Stable macOS Rust lacks the requested ThreadSanitizer instrumentation; the supported independent-connection database concurrency checks above passed. Historical 16,448-test results do not claim this rebased revision passed that complete suite. CI for the updated head is not claimed passed.Complete durable-read error presentation
Run lists, Session Run trees and resume preflight now share the existing lifecycle presentation owner: internal diagnostics are logged, while the established neutral 503/absent-code response reaches the client. No storage validation, ownership predicate, SQL statement or lock path changed.
The existing corruption fixture now exercises concurrent authenticated list/tree requests alongside resume, including healthy, malformed-reference, missing-opening and foreign-user controls and unchanged durable-state snapshots. Its permissive Session stub deliberately tests store-level filtering; production rejects a foreign Session before the Run reader. On this correction, all 11 phase-1 DB cases, 19 contracts, runtime all-target Clippy and formatting passed. Explicit Terra/max design and overall review found no material source blocker. Existing timing/capacity/TSan qualifications remain unchanged; CI is not claimed passed.
Final checklist