Repository navigation
fix(test): prevent new incomplete first-party module mocks - #164673
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed October 3, 2026, 10:21 PM ET / October 4, 2026, 02:21 UTC (Revision 4). ClawSweeper reviewWhat this changesAdds a static check requiring new first-party test mock factories to preserve real module exports or explain their isolation, while grandfathering existing factories through an exact shrinking baseline. Merge readiness⛔ Blocked before merge - 3 items remain This preventive guard remains useful and distinct from the merged test-selection fix. The previously reported implicit-fallthrough defect remains unresolved at the pinned head. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw's development checks scan test mock registrations before accepting changes. The new guard resolves first-party module targets, examines factories, and compares exceptions against the existing-debt baseline. flowchart TD
A[Test source and manifests] --> B[Resolve first-party modules]
B --> C[Inspect mock factories]
C --> D{Exports preserved or isolation explained}
D -->|Yes| E[Accept factory]
D -->|No| F[Compare exact baseline]
F --> G[Pass or report violations]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceTests +302, Docs +32, Config +3, Other +11637. Total +11974 across 15 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the existing ratchet owner and exact baseline, but require block factories to prove complete normal returns or use the documented isolation annotation. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the introduced failure path: a JavaScript block factory with only a conditional complete return passes the scanner but resolves to undefined when the condition is false. No target code was executed during this read-only review. Is this the best way to solve the issue? Yes, extending the existing ratchet and resolver is a focused approach; its block-return predicate needs to account for implicit normal completion before the guard fulfills its contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1836ae214644. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
Require real-module pass-through or an adjacent reasoned mock-isolation annotation for new first-party vi.mock and vi.doMock factories. Reuse the existing resolver and register the guard in existing check/CI ratchets. Peter approved the initial exact shrink-only baseline on 2026-10-03. Refreshing existing debt onto the publication base changes 10,843 entries to 10,852 (11 existing identities added and two removed). Candidate-only debt remains rejected, and published allowances can only shrink. Document that importOriginal and vi.importActual may produce a separate instance for stateful singletons; closed isolation mocks remain explicit. Validation: Linux check-changed, full test-types, boundary lint, source contracts, architecture, unit-fast, tooling-isolated, manifest smoke, and focused guard regressions passed. Whole-tooling has the coordinator-accepted unrelated SQLite compiler-policy failure/capacity gap; natural PR CI will provide the remaining evidence.
Natural PR CI exhausted its 2 GiB Node heap when the new mock ratchet parsed every candidate file into one syntax snapshot. Reload roots in 32-file batches through the existing parser owner, retaining fingerprints and diagnostics while allowing previous syntax trees to be collected. The full Linux scan passes under --max-old-space-size=2048 in 21.14s with 979 MiB maximum RSS and exactly 10,852 baseline identities. The exact failed PR merge also passes. Focused guard tests, Linux check-changed, boundary lint, and P2 review pass. No heap, timeout, or runner increase.
Regenerate the approved unpublished bootstrap from main 19e87bf. All 17 added identities already exist in main; seven obsolete identities are removed. The owner rejects candidate-only debt, and the final initial ledger contains 10,862 exact factories. Natural CI confirmed the bounded-memory scanner runs successfully. The stale-ledger failures came from unchanged upstream CLI and Doctor tests. Full scan under a 2 GiB heap and ledger-only P2 review passed; checker and scanner source remain unchanged from passing Linux proof.
5296e53 to
6bc1462
Compare
…164673) * fix(test): prevent new incomplete first-party module mocks Require real-module pass-through or an adjacent reasoned mock-isolation annotation for new first-party vi.mock and vi.doMock factories. Reuse the existing resolver and register the guard in existing check/CI ratchets. Peter approved the initial exact shrink-only baseline on 2026-10-03. Refreshing existing debt onto the publication base changes 10,843 entries to 10,852 (11 existing identities added and two removed). Candidate-only debt remains rejected, and published allowances can only shrink. Document that importOriginal and vi.importActual may produce a separate instance for stateful singletons; closed isolation mocks remain explicit. Validation: Linux check-changed, full test-types, boundary lint, source contracts, architecture, unit-fast, tooling-isolated, manifest smoke, and focused guard regressions passed. Whole-tooling has the coordinator-accepted unrelated SQLite compiler-policy failure/capacity gap; natural PR CI will provide the remaining evidence. * fix(test): bound mock ratchet syntax tree batches Natural PR CI exhausted its 2 GiB Node heap when the new mock ratchet parsed every candidate file into one syntax snapshot. Reload roots in 32-file batches through the existing parser owner, retaining fingerprints and diagnostics while allowing previous syntax trees to be collected. The full Linux scan passes under --max-old-space-size=2048 in 21.14s with 979 MiB maximum RSS and exactly 10,852 baseline identities. The exact failed PR merge also passes. Focused guard tests, Linux check-changed, boundary lint, and P2 review pass. No heap, timeout, or runner increase. * test: refresh initial mock baseline after upstream refactors Regenerate the approved unpublished bootstrap from main f4567d4. All 17 added identities already exist in main; seven obsolete identities are removed. The owner rejects candidate-only debt, and the final initial ledger contains 10,862 exact factories. Natural CI confirmed the bounded-memory scanner runs successfully. The stale-ledger failures came from unchanged upstream CLI and Doctor tests. Full scan under a 2 GiB heap and ledger-only P2 review passed; checker and scanner source remain unchanged from passing Linux proof.
…atchet Main's check:test-mock-exports (openclaw#164673) arrived with the merge and rejects six mock factories this branch adds or changes. The two health-state mocks now pass the real module through. The config, device-bootstrap, setup-completion and health-owner mocks stay closed because isolating that state is their purpose, and each says so in a mock-isolation line. The baseline drops the four entries those edits retire.
What Problem This Solves
Stops new closed first-party mock factories from creating the missing-export failures that escaped PR selection eight times on 2026-10-03.
User Impact
No product behavior changes. New test mocks must preserve real module exports or explain why isolation requires a closed mock; existing tests are not mass-rewritten.
Why This Change Was Made
The static guard checks literal first-party
vi.mockandvi.doMockfactories in the existing check, check-changed, and CI ratchet owners. A factory must return or spread the real module throughimportOriginalor same-modulevi.importActual, or use an immediately preceding one-line exception with a reason:Pass-through is recommended for export completeness.
importOriginalandvi.importActualcan return a separate module instance for stateful singletons, so closed mocks remain appropriate where isolation is the contract; those use the annotation. This caveat and the annotation are documented in the writing-tests guide.Peter approved the initial exact shrink-only baseline on 2026-10-03. The original reviewed baseline had 10,843 factories. Its initial PR snapshot had 10,852; upstream main changes before landing required a further 17 additions and seven removals, producing 10,862 factories in the final bootstrap snapshot. All added identities already exist on the comparison main revision. The generator rejects candidate-only additions, and a published baseline may only shrink. Fingerprints include source, resolved target, factory and local definitions, and duplicate ordinal; existing debt cannot authorize a different mock. No new job, dependency, permission, or repository setting is introduced.
This is independent of the selection fix in #164666 and targets main directly.
Evidence
111336399393exhausted its approximately 2 GiB Node heap while parsing all files together. The correction uses the existing parser's 32-file snapshot batches without changing fingerprints, diagnostics, or baseline entries. The full scan now passes under a 2 GiB limit on Linux in 21.14 seconds, with 979 MiB maximum resident memory; the same 10,852 identities also pass against the exact failed PR merge. The corrective P2 review is clean. Focused Linux check-changed and boundary lint passed; the proof lease stopped successfully.transport-process-registration.test.tscases in job111336402567:PluginStateStoreErrorcaused by a fresh Gateway owner in a different PID namespace. Test, registration, plugin-state, Gateway ownership, and runner source are identical to the tested main parent4525e1d28e2a; no independent main replay is claimed. Main subsequently fixed that fixture in fix: restore Codex registration tests on Linux #164676 (b323c0441a35); the corrected PR run can consume that fix without rebasing.19e87bf450a6; the checker and scanner code are unchanged from the passing Linux proof.6bc1462742acnatural run 37169998836 passedchecks-fast-baseline-ratchets(job 111341115073): 10,862 factories / 24.45 seconds. Eight observed failures are inherited from tested main070b7479dc3f: production types (111341272744), test types (111341272737), core test-type groups 2–5 (111341272697, 111341272690, 111341272714, 111341272721), and core lint (111341272642) reject the unusednormalizeProviderIdimport atsrc/agents/agent-model-discovery.ts:3; tooling job 111341117930 expects the deleteddoctor-sandbox-legacy-registry.test.tspath from the unchanged database-worker inventory. Source/config/test/inventory blobs match the tested main parent; no independent main suite replay is claimed. Remaining checks and coordinator verification/pinned merge are pending.