Skip to content

ci: preserve test variants in affected SCA selection - #32666

Closed
XuPeng-SH wants to merge 1 commit into
mainfrom
codex/sca-variant-closure-main-20261113
Closed

XuPeng-SH wants to merge 1 commit into
mainfrom
codex/sca-variant-closure-main-20261113

Conversation

@XuPeng-SH

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:

Fixes #32664
Related to #32654 (4.2-dev counterpart)

What this PR does / why we need it:

The affected-SCA selector folds Go test variants into package owners before reverse traversal. When B's tests import A, a production edit in A can therefore expand through B's unchanged production consumers and trigger an unnecessary full scan.

Traverse the resolved go list -deps -test variant Imports graph and seed every active variant of a changed production owner. Collapse variants into owning packages only for analyzer arguments. Remove the redundant TestImports/XTestImports discovery and dependency representation. Preserve test-only owner selection, unknown-input fallbacks, the full-scan threshold, graph/analyzer failure propagation, and the existing analyzer/Make recipes.

Validation on 57 with Go 1.26.4:

  • All 51 CI contract tests passed without skips (node --test .github/ci/*.test.cjs). The existing eight-package Go/Make fixture now covers internal/external test edges followed by unchanged production consumers; no extra repository or service fixture was added. Focused checks also cover changed production variants retargeted into another owner's tests.
  • Both new regression checks fail against the old shared selector and pass after the fix. The pre-fix selection function is identical on main and the 4.2 backport; the corrected discovery/selection core is identical on both branches.
  • On the actual main graph (510 owners / 1604 variants), queryservice selects 170 packages and protoc selects 21. Hashmap's genuine 314-package closure still triggers the full-scan threshold. All three results match Go's independently computed transitive Deps, rather than an oracle repeating the selector's BFS.
  • A real clean-Git base/head and CLI counterexample selects only A/B after the fix. Go compilation still detects A's changed API breaking B's tests, while unrelated production consumers C/D compile successfully. This check passed on both branches.
  • The same correction is validated with pinned real analyzers on the 4.2 counterpart. Its paired x86 golangci run takes 86.9s for 39 packages versus 155.2s for the previous full 466-package selection, with warmed Go export cache, separate empty lint caches, two workers, GOFLAGS=-p=2 and GOMAXPROCS=4. Both exit zero. This is one 4.2 x86 pair; no main or ARM timing improvement is claimed.

No Go product, Python SDK, workflow or analyzer configuration files change. New-head CI is pending publication/execution.

@XuPeng-SH
XuPeng-SH requested a review from fengttt as a code owner November 13, 2026 03:42
@XuPeng-SH XuPeng-SH self-assigned this Nov 13, 2026
@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 →

@mergify

mergify Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is closed, so it cannot be queued. Reopen it to get the box back.

@XuPeng-SH

XuPeng-SH commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: f2b839e484a1eaab20f836bbce68cd779856fce0

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

mo-bot review · mo-bot-local · review

Commit: f2b839e484a1eaab20f836bbce68cd779856fce0

Assessment: approve

Variant-preserving traversal fixes test-only dependency expansion while retaining all changed-production variants and conservative fallbacks. Reusing Go's resolved Imports removes redundant dependency representations. No actionable findings remain.

Model: gpt-6.1-sol / max

Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0

Validation:

  • Reviewed the complete two-file delta, baseline selector, Go discovery and Make/analyzer consumers, all discussion entries and linked issue #32664.

  • Preflight and syntax checks passed. All seven focused contract tests passed with Go 1.27.1, real Go/Make discovery and mocked analyzers; no skips or failures.

  • An independent forward all-pairs oracle passed 2,176 variant-graph cases. The retained baseline control reproduced the unnecessary full scan.

  • Frozen-head CI contract checks succeeded; source fingerprints, command receipts and retained logs were reconciled.

Limitations:

  • Local analyzer commands were mocked. Full-main-graph and real-analyzer timing results remain author-reported; no main or ARM speedup is claimed.

  • Broader CI remained in progress.

XuPeng-SH added a commit that referenced this pull request Nov 13, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to #28100
Related to #32664 (test-variant closure; main counterpart #32666)
Related to #32652 (separate pre-existing molint exit-status defect)

## What this PR does / why we need it:

The 4.2-dev SCA analysis target scans every Go package for every PR.
Backport affected-package selection and correct the main selector's
over-expansion of test dependencies. Both existing analyzers receive one
shared package list from Go's resolved production/test variant graph. A
changed production file seeds every active variant of its owner; reverse
traversal preserves variant identity until results are grouped into
owning packages. Test-only edits select their owner. Remove the
redundant TestImports/XTestImports graph representation.

Unknown or unverified inputs, unsupported changes, broad affected
closures and explicit full scans retain complete analysis. Discovery
errors and analyzer failures remain fatal. The explicit full
`static-check` target and existing license checks are preserved. The
selector's contract tests run for CI changes.

Validation on 57 (Go 1.26.4):

- All six selector/Make contract tests passed without skips. The
existing eight-package real Go/Make fixture covers internal and external
test imports, unaffected production consumers, shared analyzer
arguments, full overrides, dirty/ignored files, missing Node, and
analyzer/discovery failures. Both new regression checks fail before the
fix.
- A real clean-Git base/head and CLI counterexample selects only
affected A/B after the fix. Go compilation still detects the changed API
breaking B's tests, while unrelated C/D compile successfully.
- On the actual 466-owner/1231-variant graph, queryservice narrows from
a full 466-package scan to 39, protoc from full to 21, and hashmap from
229 to 210. These sets match Go's independently computed transitive
Deps.
- The pinned molint process and golangci-lint passed on the 39-package
selection; golangci-lint also passed on full analysis. A same-revision
x86 pair with warmed Go export cache, separate empty lint caches, two
workers, GOFLAGS=-p=2 and GOMAXPROCS=4 measured 86.9s selected versus
155.2s full (44.0% lower). Golangci's sampled peak memory was 6225.7MB
selected versus 8037.7MB full. This is one local pair, not an ARM CI
prediction; graph discovery and export-cache preparation are outside
that timing.
- The main counterpart's 51 CI contract tests and actual
dependency-graph oracle also passed. Source license headers and analyzer
recipes are unchanged by the variant correction.

The actual PR paths do not change the Python SDK classifier/control
file. Python SDK development and publication remain on main. New-head CI
is pending; the earlier successful ARM SCA exercised the previous head's
full fallback.

The legacy 4.2 molint invocation can report diagnostics while exiting
zero. That existing defect remains tracked by #32652; successful process
exit here does not establish a repaired diagnostic gate.
@XuPeng-SH XuPeng-SH closed this Nov 13, 2026
XuPeng-SH added a commit that referenced this pull request Nov 15, 2026
)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes #32664
Fixes #32706
Fixes #32715

Related to #32544, #32570, #32423, #32422, #32324, #32185 and #32179.
These historical incidents are not claimed fixed by this PR; the local
controls do not establish their original causes.

Supersedes #32666.

## What this PR does / why we need it:

Correct CI dependency selection and test ownership boundaries that cause
unnecessary work or make failures wait on resources that cannot
complete. The branch is rebased on main. This change does not add
runners or change DWARF settings.

- **SCA selection:** traverse `go list` production and test variants
before mapping them to package owners, preventing a test-only reverse
edge from pulling in unchanged production consumers. Changed production
still seeds its variants, and uncertain discovery or broad fan-out still
selects full analysis. Real Go/Make fixtures cover both internal and
external tests, reverse edges and fallbacks.
- **Bootstrap and transaction metrics:** require all five task tables in
one successful observation instead of combining partial observations,
retaining the original exact test-root name. Exclude heartbeat
transactions before the exact commit-counter fixture starts; keep the
existing commit and rollback counter assertions.
- **SQL fixture ownership:** preserve the prepared-cache scenarios, SQL,
data, plans and assertions while giving independent phases bounded child
contexts and restoring the AP flag before rollback, including Goexit.
Propagate teardown errors so shared fixtures cannot be silently reused
after uncertain cleanup. The committed-state assertion remains in the
parent test so selecting an existing subtest cannot filter it out. The
two-minute per-phase deadlines can extend the total worst-case root
timeout relative to the former shared deadline.
- **Frontend construction and tracing:** make `Stop` own the partially
constructed routine manager and listeners until successful handoff,
retaining the original panic and caller context. The parse-error test
restores its borrowed global trace-provider state; without that
restoration, later intentionally failing TCP/Unix binds can each wait
for the test tracer's acknowledgement. Cover both initial tracer states,
all three failure stages, worker/listener cleanup and a real one-CN
failure followed by port reuse. The selected local cross-owner race case
took 2.47s; this is not an end-to-end job increment.
- **Explicit trace and CDC oracles:** retain the original parse-error
cases and test both incoming tracer states without repeating its global
session fixture. Add explicit active/late transaction ID, peer,
memory-epoch, terminal plan summary and failure-log assertions; cover
log-field extraction and internal-account filtering in the tracer owner.
The existing CDC concurrent restart test remains, with a separate
deterministic test of the late-running fallback, owner fence and
conflicting states. Its error controls share one bounded child process
on the same runner so they cannot consume the parent suite’s log budget;
the selected local race root took 1.35s including the child.
- **Catalog replay:** run the three fixed-snapshot, read-only replay
queries with the existing optimistic transaction mode, so failed startup
does not need a heartbeat that was never started to retire its
transaction. Preserve the query, snapshot, predicates, workspace,
commit/rollback and cancellation behavior. The real-client test checks
all three outcomes and cleans up its goroutine by cancelling before
joining on a failure path.

## Coverage and measurements

No new test skip is introduced and no dataset is reduced.

| Existing behavior | Mapping after this change |
| --- | --- |
| Six parse-error classification cases and four real record calls |
Retained; the borrowed tracer enabled bit is restored after the original
session/controller cleanup. Separate false/true guards cover the
cleanup. |
| Session-manager, TCP and Unix constructor failures | All retained with
the original panic, context, listener and worker assertions; a real
one-CN case checks rollback and port reuse. |
| Trace-enabled later tests | Previously reached through a leaked global
bit. Equivalent frontend transaction, peer, resource and log
interactions are now explicit; tracer-owned logging and internal-account
behavior have their own assertions. |
| CDC restart timeout and late publication | The original concurrent
test remains. An added deterministic state/owner matrix verifies the
fallback update, conflict handling, account context and exact SQL order.
|
| Prepared-cache and native SQL issue cases | SQL, plans, fixtures and
result assertions remain; child-context and cleanup ownership change. |
| BVT scripts, queries and datasets | No BVT script is moved;
planner/explain query, table and row counts, statistical shape and
expected results are unchanged. |

The replay lifecycle test adds a real transaction and
commit/rollback/cancel checks instead of relying on mocked completion;
the frontend and tracing tests retain error and resource-lifecycle
checks and add state-restoration checks. Bootstrap and metrics retain
exact readiness/counter assertions while isolating their inputs.

On an earlier main graph (`1064837ae2`), the test-aware selector reduced
the queryservice example from the 510-package full graph to 170 packages
and protoc to 21; high fan-out still selected the full graph. These are
historical graph counts, not a final-head CI time measurement.

Recent main-target UT race jobs took 65m12s, 66m49s and 68m59s end to
end. Their slowest SQL-integration workers, not the sum of all case
durations, determine that wave's critical path. This PR does not yet
establish a whole-job reduction or an under-one-hour result. Before the
trace fix on the rebased branch, the leaked tracer caused a same-process
focused race run to time out after 20 seconds; on the rebased candidate
the same path plus state checks completed in 1.313 seconds of package
time. That is a local focused result, not a whole-CI saving.

The earlier proxy BVT job ended with runner shutdown signal / exit 143.
The last SQL script had started but had no terminal result and the log
contained no script-failure marker. The reason for the runner shutdown
is unknown; later runs on other revisions passed that script but cannot
establish what happened on the old runner. A new exact-head CI run is
required.

## Validation

Local checks use Go 1.27.1 on rebased main `3e68780237c`. Earlier
owning-package results are reused only where subsequent changes were
confined to other packages’ test files and did not alter that package’s
compiled test closure.

- CI selector contracts: all 51 Node tests passed, including the real
Go/Make fixture and fallback controls.
- Owning packages: full frontend normal and race passed locally (31.536s
/ 49.138s package time); full motrace normal and race passed. Full DML
and testutils normal/race and full disttae race passed; the local DML
package took 52.568s / 148.889s in normal/race modes. Focused affected
race tests include the real one-CN failure/rebind, prepared cache,
checkpoint, join spill and multi-CN shuffle paths. The pre-existing
frontend `TestRuleCacheDoubleCheckLocking` skip remains.
- Adaptive race repetitions passed for each affected lifecycle root: the
new frontend/tracer roots and related constructor/parse roots each
passed 100 times, and the isolated CDC timeout root passed 23 times. The
actual one-CN construction failure/rebind passed 12 times; the prepared,
snapshot, join-spill and shuffle roots passed 3, 3, 4 and 4 times
respectively. No selected iteration was skipped; each of the six
log-field subcases also passed when selected independently.
- A same-selection frontend race/atomic coverage comparison retained all
8,455 original named test/subtest terminal sequences. The 22 baseline
frontend blocks not exercised in the final frontend run are exercised by
the motrace owner with explicit matching oracles; no compared block
remained unmapped. The diagnostic comparison excludes the constructor
and parse-tracer guard in both versions; full owner runs include them.
The old bootstrap root and the two original prepared-cache subtest
selections were also verified explicitly. The CDC child coverage merge
and individual subtest selection were verified separately.
- Fault-injection overlays make the new transaction-ID, resource,
outer-statement, EOF, CDC fallback, logging and account-filter checks
fail as intended. Separate missing-restore and Goexit probes verify both
incoming tracer states; probe-only skips are not submitted tests.
- Full configured `make static-check-analysis` passed before the final
test-only additions. On the final affected closures, configured molint
and golangci-lint passed for frontend, motrace, disttae, DML and
testutils (0 reported issues), with affected `go vet`, formatting and
`git diff --check` passing.

Design and the final diff are reviewed with gpt-6.1-terra / max. The
pushed head still requires its own complete remote CI; results from the
old head are not treated as final verification.
@XuPeng-SH
XuPeng-SH deleted the codex/sca-variant-closure-main-20261113 branch November 30, 2026 12:57

This branch was previously deployed

1 inactive deployment
ci — f2b839e4 Deployed Nov 13, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/enhancement kind/test-ci size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SCA test dependencies expand into unrelated production consumers

2 participants