Skip to content

perf(qa-lab): avoid quadratic lane exclusions - #128072

Merged
steipete merged 1 commit into
mainfrom
codex/perf-qa-lane-exclusions-current
Aug 23, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-qa-lane-exclusions-current

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Large QA Lab runtime-pair lane plans repeatedly scanned the full selected-scenario array for every compatible scenario while deriving lane exclusions. This made that owner-local planning step quadratic as scenario catalogs grew.

Why This Change Was Made

The canonical runtime-pair lane selector now builds one identity-preserving Set from selected scenarios and uses constant-time membership checks when deriving the ordered exclusion list. Set.has and the previous Array.includes both use SameValueZero, so scenario identity semantics and exclusion ordering are unchanged. Provider behavior, run plans, artifacts, configuration, and errors are unchanged.

The quadratic scan originated with the runtime-pair lane selector introduced in #112838. This change was AI-assisted. I reviewed the selector owner, CLI and run-plan callers, catalog behavior, proof harness, and benchmark and understand the resulting behavior.

User Impact

QA Lab developers and operators should see faster runtime-pair suite planning for large scenario catalogs. Current catalog selections and exclusions remain byte-for-byte equivalent.

Evidence

  • Exact head: d06cbd3778fb3efb2edb491383cf6418cb361557; parent/current-main proof baseline: fc80a1d2998d00650b346290bbb71c4a0f0398f3.
  • Deterministic 4,096-scenario proof: selected IDs and exclusions were identical; identity probes fell from 8,390,656 to 0.
  • Current real catalog differential for mock-openai and live-frontier core lanes matched exactly (2,276-byte canonical JSON; SHA-256 869ae0db46ee5e267a56f010dd408cbbe04972b0762ee88c6c8419839fa6cc6a).
  • Fresh Node 24 benchmark with 16,384 scenarios: median planning time fell from 52.685 ms to 7.848 ms (6.71× faster / 85.10% lower) with identical checksums. This is owner-stage evidence, not an end-to-end suite-runtime claim.
  • Focused catalog, run-config, and CLI coverage: 3 files / 179 tests passed.
  • node scripts/check-changed.mjs -- extensions/qa-lab/src/runtime-pair-lane-selection.ts: passed formatting, boundaries, dead exports, production/test typechecks, Oxlint, storage/media/runtime guards, and import-cycle checks.
  • OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build: passed all build phases.
  • Mock-provider product smoke: runtime-tool-fs-read completed with 1 scenario / 1 pass / 0 failures using mock-openai/gpt-5.6-luna.
  • No test was added: a membership-call/complexity assertion would couple tests to this implementation; existing catalog, run-plan, and CLI tests protect the behavior contract.
  • Exact final-diff Codex Sol/high autoreview: clean at 0.99 confidence; TruffleHog preflight clean.
  • Fresh live overlap searches found no open PR for runtime-pair lane selection or exclusion performance.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 23, 2026 01:12
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 22, 2026, 9:19 PM ET / August 23, 2026, 01:19 UTC.

ClawSweeper review

What this changes

The PR changes QA Lab runtime-pair lane exclusion derivation from repeated array membership scans to a Set lookup, reducing planning work for large scenario catalogs.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this maintainer-authored, protected PR open: current main still performs the quadratic membership scan, while the proposed Set preserves identity membership and exclusion order with a small, owner-local change. No blocking findings.

Priority: P3
Reviewed head: d06cbd3778fb3efb2edb491383cf6418cb361557

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A narrowly scoped owner-local optimization with strong stated differential evidence and no identified correctness or security concern.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal planning optimization is exempt from the external-contributor proof gate; its PR body nevertheless records catalog equivalence, a benchmark, and a mock-provider smoke result.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal planning optimization is exempt from the external-contributor proof gate; its PR body nevertheless records catalog equivalence, a benchmark, and a mock-provider smoke result.
Evidence reviewed 6 items Current-main behavior: Current main still filters compatible scenarios by calling Array.includes for every scenario when building lane exclusions, so the reported quadratic scan remains present.
Patch behavior: The patch builds a Set from the already ordered compatible list and uses it only for membership; the surrounding filter still emits exclusions in compatible-scenario order.
Caller coverage: Both the CLI and dashboard plan owner consume the selected IDs and ordered exclusions from this single selector, so the optimization changes the canonical decision point rather than adding a parallel path.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-node.mjs qa suite --help

Result: PASS (completed)

node scripts/run-node.mjs qa suite --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128072-vxK6ZN/target$ node scripts/run-node.mjs qa suite --help
[openclaw] Building TypeScript (dist is stale: missing_private_qa_dist - private QA dist entry missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
node scripts/run-node.mjs qa suite --help
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 71.96 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.5s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 10.3s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 2749ms (slowest: built plugin control-plane loads 2061ms)
│
◇

OpenClaw 2026.8.1 (d06cbd3) — All your chats, one OpenClaw.

Usage: openclaw qa suite [options]

Run repo-backed QA scenarios against the QA gateway lane

Options:
  --allow-failures            Write artifacts without setting a failing exit code when scenarios fail (default: false)
  --alt-model ‹ref›           Alternate provider/model ref
  --channel ‹id›              Channel id for --channel-driver crabline or live
  --channel-driver ‹i
… output truncated …

Assertions:

  • PASS expect_output: --runtime-pair-lane

How this fits together

QA Lab turns catalog scenarios and runtime-pair lane options into a resolved suite plan for CLI and dashboard runs. This selector identifies eligible scenarios and reports exclusions before execution begins.

flowchart LR
  A[Scenario catalog] --> B[Runtime-pair lane selector]
  C[Runtime-pair lane request] --> B
  B --> D[Provider and channel eligibility]
  D --> E[Selected scenarios]
  D --> F[Ordered exclusions]
  E --> G[CLI suite run]
  F --> H[Dashboard and CLI diagnostics]
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed: the submitted patch is a normal, correct maintainer PR awaiting the repository’s ordinary exact-head review and merge gates.
Agent review details

Security

None.

PR surface

Source +1. Total +1 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 2 1 +1

Review metrics

Metric Value Why it matters
Production versus test delta production +2/-1 (net +1), tests 0 The one-file change adds a single Set allocation and swaps only the membership operation; no test-support or configuration surface changes.

Technical review

Best possible solution:

Merge the canonical-selector optimization after normal exact-head CI and maintainer review; retain the existing output-contract tests rather than adding an implementation-coupled complexity assertion.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: current main performs Array.includes inside a filter over the same compatible-scenario collection, establishing the quadratic planning path without needing a live provider.

Is this the best way to solve the issue?

Yes. Replacing only the internal membership representation at the canonical selector preserves the caller-visible IDs and exclusion order while removing repeated linear scans.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d75164c46d43.

Labels

Label changes:

  • add P3: This is a contained QA Lab planning performance improvement with no change to user configuration or execution semantics.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal planning optimization is exempt from the external-contributor proof gate; its PR body nevertheless records catalog equivalence, a benchmark, and a mock-provider smoke result.

Label justifications:

  • P3: This is a contained QA Lab planning performance improvement with no change to user configuration or execution semantics.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal planning optimization is exempt from the external-contributor proof gate; its PR body nevertheless records catalog equivalence, a benchmark, and a mock-provider smoke result.

Evidence

What I checked:

  • Current-main behavior: Current main still filters compatible scenarios by calling Array.includes for every scenario when building lane exclusions, so the reported quadratic scan remains present. (extensions/qa-lab/src/runtime-pair-lane-selection.ts:71, d75164c46d43)
  • Patch behavior: The patch builds a Set from the already ordered compatible list and uses it only for membership; the surrounding filter still emits exclusions in compatible-scenario order. (extensions/qa-lab/src/runtime-pair-lane-selection.ts:71, d06cbd3778fb)
  • Caller coverage: Both the CLI and dashboard plan owner consume the selected IDs and ordered exclusions from this single selector, so the optimization changes the canonical decision point rather than adding a parallel path. (extensions/qa-lab/src/run-config.ts:304, d06cbd3778fb)
  • Existing behavior tests: CLI coverage asserts lane expansion and exclusion diagnostics, while dashboard-plan coverage asserts runtime-pair exclusions; these protect the output contract without coupling to the membership implementation. (extensions/qa-lab/src/cli.runtime.test.ts:2328, d06cbd3778fb)
  • Feature history: The selector originated in the merged QA Lab planning work and was subsequently maintained by the recent module-flow refactor and current-main touch; the performance patch is adjacent, distinct follow-up work. (extensions/qa-lab/src/runtime-pair-lane-selection.ts:71, 71b5de406111)
  • Release status: The latest release tag v2026.7.1-2 predates current main, and the PR head is not contained in either that release or current main; this remains an unshipped open improvement. (0790d9f593ad)

Likely related people:

  • Ayaan Zaidi: Current-main blame assigns the selector’s eligibility and exclusion block to Ayaan’s recent QA Lab touch. (role: recent area contributor; confidence: high; commits: 71b5de406111; files: extensions/qa-lab/src/runtime-pair-lane-selection.ts)
  • Dallin Romney: Dallin authored the merged runtime-pair planning introduction and the later module-flow refactor spanning the selector, callers, and eligibility owner. (role: feature owner; confidence: high; commits: 9310586b092d, d6fc4a2a9536; files: extensions/qa-lab/src/runtime-pair-lane-selection.ts, extensions/qa-lab/src/run-config.ts, extensions/qa-lab/src/scenario-lane.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Copy link
Copy Markdown
Contributor Author

Land-ready evidence for exact head d06cbd3778fb3efb2edb491383cf6418cb361557:

  • Root cause and owner: resolveQaRuntimePairLaneScenarioIds derived ordered exclusions by running Array.includes across the selected scenario array for every compatible scenario. The canonical selector now builds one identity-preserving Set; SameValueZero membership and the outer filter's order are unchanged. Production LOC is +2/-1; tests +0/-0.
  • Deterministic proof: a 4,096-scenario case preserved selected IDs and exclusions while identity probes fell from 8,390,656 to 0. The current real catalog differential for mock-openai and live-frontier lanes matched exactly (2,276 bytes; SHA-256 869ae0db46ee5e267a56f010dd408cbbe04972b0762ee88c6c8419839fa6cc6a).
  • Performance: a fresh Node 24 16,384-scenario benchmark improved median owner planning from 52.685 ms to 7.848 ms (6.71× / 85.10% lower) with identical checksums. This is owner-stage evidence, not an end-to-end suite-runtime claim.
  • Focused tests: node scripts/run-vitest.mjs extensions/qa-lab/src/scenario-catalog.runtime-pair.test.ts extensions/qa-lab/src/run-config.test.ts extensions/qa-lab/src/cli.runtime.test.ts — 3 files / 179 tests passed.
  • Changed gates: node scripts/check-changed.mjs -- extensions/qa-lab/src/runtime-pair-lane-selection.ts — passed all selected format, typecheck, lint, boundary, dead-export, storage/media/runtime, and cycle gates.
  • Build: OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build — passed all phases.
  • Product smoke: pnpm openclaw qa suite --provider-mode mock-openai --scenario runtime-tool-fs-read --output-dir .artifacts/qa-e2e/runtime-pair-selection-smoke-fc80a1d — 1 scenario / 1 pass / 0 failures with mock-openai/gpt-5.6-luna.
  • Independent review: exact final-diff Codex Sol/high autoreview was clean at 0.99 confidence after a clean TruffleHog preflight. Repository-native review artifacts validate READY FOR /prepare-pr with zero findings and a complete branch sweep.
  • Exact-head CI: run 32609789302 completed green for the reviewed SHA.
  • Native preparation: OPENCLAW_TESTBOX=1 scripts/pr prepare-run 128072 completed in hosted_exact_or_recent_parent mode and verified the remote PR tree equals the prepared head.
  • ClawSweeper: the final exact-head review found no correctness or security issue and no repair finding. Its sole rank-up move was to complete ordinary exact-head review and merge gates; the validated native review, green exact-head CI, and completed native prepare satisfy that move. Its maintainer-review recommendation is fulfilled by this maintainer landing review.

No implementation-call-count test was added because it would couple the suite to includes versus Set.has; existing catalog, run-plan, and CLI behavior tests are the stable guardrail. No live provider was needed for this internal planning-only change; the real catalog differential and mock-provider suite smoke cover the shipped path.

Ready for repository-native merge.

@steipete
steipete merged commit 2f3f540 into main Aug 23, 2026
189 checks passed
@steipete
steipete deleted the codex/perf-qa-lane-exclusions-current branch August 23, 2026 01:32

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

extensions: qa-lab maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants