Repository navigation
test: add sidecar differential foundation - #26660
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
Merge Queue Status
This pull request spent 4 hours 47 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonThe 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:
These checks were still running:
HintA 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 Requeued — the merge queue status continues in this comment ↓. |
There was a problem hiding this comment.
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]bytefromsha256.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 breakWriteFailureArtifactwhen rewritingfailure.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
Merge Queue Status
This pull request spent 37 seconds in the queue, including 3 seconds running CI. Required conditions to merge
|
What type of PR is this?
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.
Validation:
GOWORK=off go list -mod=readonly ./pkg/tests/sidecarGOWORK=off go build -mod=readonly ./pkg/tests/sidecarGOWORK=off go vet -mod=readonly ./pkg/tests/sidecarGOWORK=off go test -mod=readonly -count=1 -cover ./pkg/tests/sidecar(85.2%)-race -count=100-race -count=1