Skip to content

test: add sidecar differential foundation - #26660

Merged
mergify[bot] merged 27 commits into
matrixorigin:mainfrom
aunjgr:agent/26159-offload-test-foundation
Aug 7, 2026
Merged

mergify[bot] merged 27 commits into
matrixorigin:mainfrom
aunjgr:agent/26159-offload-test-foundation

Conversation

@aunjgr

@aunjgr aunjgr commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #26159

What this PR does / why we need it:

Adds the reusable MatrixOne side of the MO/Sirius differential-test foundation.

  • defines a runner contract with query-scoped execution evidence, explicit native/offloaded expectations, terminal outcomes, and fallback state
  • compares driver-visible schema before byte-exact typed rows, preserving NULL/text/binary distinctions and duplicate multiplicity in ordered or unordered mode
  • compares SQL failures by stable code, SQLSTATE, and class instead of unstable message text
  • fails matching result rows when the expected Sirius GPU backend did not actually execute
  • writes deterministic, permission-restricted failure artifacts with redacted diagnostics, row fingerprints, and raw plan bytes only for explicitly synthetic plans
  • keeps exact unordered comparison linear-time and uses constant-memory unordered fingerprints on the failure path

Validation:

  • GOWORK=off go list -mod=readonly ./pkg/tests/sidecar
  • GOWORK=off go build -mod=readonly ./pkg/tests/sidecar
  • GOWORK=off go vet -mod=readonly ./pkg/tests/sidecar
  • GOWORK=off go test -mod=readonly -count=1 -cover ./pkg/tests/sidecar (85.2%)
  • exact concurrency test under -race -count=100
  • full package under -race -count=1

@aunjgr
aunjgr requested a review from XuPeng-SH as a code owner August 3, 2026 18:00
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed exact head cf3c7163cbff27825fd3e3ad1dd12c60bfcf8637.

The previous partial-terminal-result blocker is fixed: schema and rows are now compared before the terminal error identity, and the focused FAILED/CANCELLED controls cover ordinary started executions. One blocking state-model gap remains at the intersection of that change and the earlier pre-start support.

Backend is documented as the engine that actually started executing the request, and BackendUnknown is accepted only as a pre-start FAILED/CANCELLED state. Such an observation cannot have delivered result rows. However, validateObservation only validates row width/cells; it does not reject rows when Evidence.Backend == BackendUnknown. If both adapters return the same impossible evidence and rows, the row comparison succeeds and Compare returns nil, so the differential oracle certifies a report whose backend proof is internally contradictory.

I reproduced this through the exported Compare API by taking matching failed observations, setting both expectations and both evidence values to {Backend: BackendUnknown, Outcome: OutcomeFailed}, and assigning the same valid non-empty row to both observations. Compare returned nil. The same state is accepted for OutcomeCancelled.

Please reject non-empty Rows for BackendUnknown observations and add focused FAILED and CANCELLED regressions (schema can remain allowed if it may be known before execution). This preserves valid partial delivery after a backend has started while closing the impossible pre-start combination.

Validation on the exact head: full pkg/tests/sidecar tests, full package under -race, go vet, and clean worktree all pass. The independent pre-start-with-rows counterexample fails as described.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed exact head b68773deaccc4b691d931aa36ef6e17a5c63417e. The previous pre-start-row state contradiction is fixed, and the full package passes under -race plus go vet. One blocking unhappy-path gap remains in the failure-artifact contract.

WriteFailureArtifact cannot persist a failure when the comparison failed because an adapter produced an invalid cell. makeArtifactObservation calls fingerprintRows, which reuses encodeRow; encodeRow calls validateCell and returns the same semantic error that Compare just reported. Concrete exact-head reproduction: set one offloaded cell to Cell{Kind: CellInvalid, Data: []byte("adapter-bug")}. Compare correctly returns a mismatch, but WriteFailureArtifact(root, report, failure) returns encode offloaded failure artifact: row 0: column 0 has invalid cell kind 0, and no failure.json is written. CellNull with unexpected data follows the same path. These malformed adapter observations are precisely a class for which the parent issue requires retained SQL/seed/evidence diagnostics.

Please decouple diagnostic fingerprinting from semantic validation. The artifact encoder should be total for every Observation representable by the model (for example, fingerprint kind + length + bytes even when the kind/payload is invalid, and optionally record the validation error), while still never emitting raw rows. Add regressions that take the actual Compare error for invalid-kind and NULL-with-data observations and verify a deterministic private artifact is still produced. The diagnostic path must not depend on the failed invariant being valid.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds the foundational pkg/tests/sidecar package for MO/Sirius differential testing, defining the typed execution/evidence contract, result/error comparison logic, and deterministic/redacted failure artifacts to support Substrait offload compatibility and lifecycle coverage.

Changes:

  • Introduces the core sidecar model types (modes, evidence/expectations, typed cells/rows, schema columns, SQL error identity, runner/report contracts).
  • Implements native-vs-offloaded comparison (evidence validation, schema/row comparison, stable error-identity comparison).
  • Adds deterministic, permission-restricted, redacted failure artifact writer plus unit tests for comparison and artifact behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/tests/sidecar/model.go Defines the sidecar runner/observation/case/report contract and typed result representations.
pkg/tests/sidecar/compare.go Implements Run and Compare with evidence-first validation, schema/row comparison, and stable error identity comparison.
pkg/tests/sidecar/compare_test.go Unit tests for comparison semantics and runner behavior (includes a concurrency test).
pkg/tests/sidecar/artifact.go Writes deterministic, redacted failure artifacts with strong permission handling and row fingerprinting.
pkg/tests/sidecar/artifact_test.go Verifies redaction, determinism, permission tightening, and synthetic plan handling.

Comment thread pkg/tests/sidecar/compare_test.go Resolved

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed exact head f81c7645417c2ec244309c62ca004618bd7a4d60.

The previous malformed-observation blocker is fixed correctly: failure fingerprinting is now total over every representable Cell, remains deterministic, does not expose raw row bytes, and keeps constant extra memory for unordered observations. The focused regressions and full package race run pass.

One blocking generation-consistency gap remains in WriteFailureArtifact. The logical artifact is a bundle — failure.json plus the optional plan.substrait.bin named and hashed by that metadata — but the implementation publishes/removes the plan first and publishes metadata through a separate rename later. Each file is atomic by itself; the bundle has no single linearization point.

This is a concrete false-evidence failure, not a theoretical filesystem concern. I ran two concurrent calls for the same case ID with different seeds and synthetic plans. The first writer published its plan and then spent longer encoding metadata; the second writer completed in between. Both calls returned nil, but the final directory contained metadata from writer 1 (seed=1, hash of slow-plan) and fast-plan from writer 2, whose SHA-256 did not match the metadata. The counterexample fails identically under -race; there is no Go data race because the broken state is the independently published filesystem generation.

The same invariant is exposed on the single-writer unhappy path: after a retained artifact exists, a successful plan replacement followed by a metadata write/rename failure or process interruption leaves the old metadata paired with the new plan (and the no-plan branch can remove the old plan before new metadata is durable).

Please give the bundle one publication boundary rather than serializing only one observed schedule. A small general design is to write plans under an immutable content-addressed/generation-specific name, include that name/hash in metadata, and atomically rename metadata last; then concurrent writers and interruption before publication cannot corrupt the previously published generation. Another design is fine if it proves the same invariant. Add a same-case/different-plan concurrent regression and an interrupted/replacement-state control.

Validation on this exact head: readonly package resolution, build, vet, full package tests, full package under -race, and both latest focused tests under -race -count=100 pass. Q1 temporary-file cleanup, Q2 Run cancellation/wait ownership, Q3 exact unordered comparison growth, evidence states, partial terminal results, redaction, stale-plan removal, and malformed observations were also rechecked; I found no second blocker.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed exact head 8a3d34d and its conflict-free merge with latest origin/main d0057b3.

The previous generation-consistency blocker is fixed at the correct publication boundary: synthetic plans are immutable and content-addressed, while failure.json is the single atomic pointer to the published generation. Same-case concurrent writers, concurrent readers, a stopped replacement, and planless replacement now expose either the prior complete generation or a complete new generation, never mixed metadata and plan bytes.

I also rechecked the full comparison state model: backend/fallback proof, pre-start failure and cancellation, partial terminal rows/schema, stable SQL error identity, malformed adapter observations, artifact redaction and permissions, exact ordered/multiset comparison, and failure-path memory behavior. No blocking correctness, lifecycle, performance, or compatibility finding remains.

Fresh validation: readonly package resolution, build, vet, full package tests, full package under race, focused concurrency tests under race count=100, an independent concurrent reader/writer bundle stress test, diff check, and the latest-main merge-state package race test all pass. CI is green on this head.

@mergify

mergify Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-06 17:45 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ❌ Checks timed out · in-place
  • 🚫 Left the queue — 2026-08-06 21:46 UTC · at 7d6c0032deb885d0c173c33391dca75be53eb920

This pull request spent 4 hours 47 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

The merge conditions cannot be satisfied: the checks did not pass within the checks timeout of 4 hours

These checks never reported on this pull request:

  • Configuration changed

These checks were still running:

  • Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • Matrixone CI / UT Test on Ubuntu/x86
  • Matrixone CI / SCA Test on Linux/arm64
  • Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • Matrixone Utils CI / Coverage
  • Matrixone UT Coverage / UT Coverage on Ubuntu/x86

Hint

A check that never reports can never satisfy its merge condition. Check that the check names in your merge conditions match what your CI publishes.

If you want to requeue this pull request, you can post a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (3)

pkg/tests/sidecar/compare.go:234

  • In unordered mode, using string(encoded) as the map key retains a full copy of each encoded row (including full cell payloads) in memory, which can become very large for big result sets and can significantly increase GC pressure. Consider keying the multiset by a fixed-size digest (e.g., [32]byte from sha256.Sum256(encoded)) instead of the full encoded row bytes; this keeps memory bounded while preserving multiplicity counting.
	counts := make(map[string]int, len(native))
	for i, row := range native {
		encoded, err := encodeRow(row)
		if err != nil {
			return mismatch("native rows", "row %d: %v", i, err)
		}
		counts[string(encoded)]++
	}
	for i, row := range offloaded {
		encoded, err := encodeRow(row)
		if err != nil {
			return mismatch("offloaded rows", "row %d: %v", i, err)
		}
		key := string(encoded)
		count := counts[key]
		if count == 0 {
			return mismatch("row data", "offloaded row %d has no native multiset match", i)
		}
		if count == 1 {
			delete(counts, key)
		} else {
			counts[key] = count - 1
		}
	}

pkg/tests/sidecar/artifact.go:91

  • The comment says “Plan files are immutable”, but the implementation intentionally overwrites an existing plan path via writePrivateFile (and there’s a test asserting stale plan content gets replaced). Either adjust the comment to reflect the actual behavior (e.g., ‘content-addressed plan files are never deleted; they may be rewritten to correct stale/tampered content and to tighten perms’) or change the implementation to enforce immutability (create-if-missing + verify existing content matches digest).
// writeFailureArtifact accepts the metadata publisher separately so tests can
// stop a replacement at the publication boundary. Plan files are immutable and
// failure.json is the only pointer to the currently published generation.

pkg/tests/sidecar/artifact.go:196

  • os.Rename(temp, path) does not reliably replace an existing destination file on all platforms (notably Windows), which can break WriteFailureArtifact when rewriting failure.json/plan files (your tests explicitly exercise rewrite). If this code is expected to run in Windows CI or on developer machines, add a fallback strategy for ‘destination exists’ (e.g., attempt rename, and on failure remove the destination then rename, or use a platform-specific atomic replace implementation). If Windows is out of scope, it would be helpful to document the supported platforms/assumptions.
	if err = os.Rename(temporaryPath, path); err != nil {
		return err
	}
	return nil

@mergify

mergify Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-07 14:33 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-08-07 14:34 UTC · at bcd59481d4bb12b2b69040bb0895e080dc74b619 · squash

This pull request spent 37 seconds in the queue, including 3 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 = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/test-ci size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants