Skip to content

test: replace three wall-clock complexity bounds with work counts - #10672

Closed
Davmunrey wants to merge 3 commits into
morluto:mainfrom
Davmunrey:claude/src-misc-work-bounds
Closed

Davmunrey wants to merge 3 commits into
morluto:mainfrom
Davmunrey:claude/src-misc-work-bounds

Conversation

@Davmunrey

Copy link
Copy Markdown
Contributor

Summary

Refs #10513. This slice covers the remaining src/ files. It complements #10619, #10627 and the native-parser and JavaScript-lifetime slices. It replaces 3 of the 10 wall-clock bounds in these files with work counts. Two complexity bounds stay because no deterministic measure fits them. Five bounds are deadline contracts and are left unchanged. Production code is not changed.

Change and scope

  • src/dotnet/ManagedArtifactInspector.test.ts: counts TypeDef row decodes through the existing ManagedDecodeBudget.prototype.reserveRow. A normal run decodes 16,002 rows for 16,001 rows. The limit is 2 per row.
  • src/evm/SolidityMetadata.test.ts: counts JSON.stringify calls. A normal run makes exactly 2.
  • src/domain/analysisView/environmentStateWriteExplain.test.ts (copied/slugged fields): counts request-body reads through a Proxy, as environmentStateWriteComposed.test.ts already does. A normal run reads 8 times per member. The limit is 16.
  • Kept, because nothing deterministic fits:
    • WabtOutput.test.ts:520: the cost is regex backtracking inside V8, and calls and AST visits are identical either way.
    • environmentStateWriteExplain.test.ts:979: the cost is Array.prototype.shift on a 500,000-element queue. A spy on shift recurses.
  • Left unchanged, because elapsed time is the contract under test:
    • serveEnvironmentState.test.ts:1196: close must not wait for a stalled 30 s download.
    • PlaywrightScenarioBrowser.test.ts:1383, 1434: a 50 ms command_timeout_ms must fire.
    • ProviderProcess.launcherExit.test.ts:172, 205: the 1,000 ms kill grace.

Evidence and regression coverage

Each regression below was applied to production code in an uncommitted copy, then reverted:

  • .NET, per-attribute TypeDef scan: the old test failed after 133 s; the new test fails in 0.4 s.
  • Explain, body indexed again for every field: the old test failed after 191 s; the new test fails in 0.2 s.
  • Solidity, key identity rebuilt at every nesting level: the old test passed; the new test fails (63 serializations vs 2).
  • Solidity, identity computed twice per level: the old test never reached its bound and was killed at 90 s; the new test fails in 15 ms.

Gaps:

  • The Solidity bound was added together with its code (fix(evm): reject repeated container keys in Solidity metadata #6230), so there was no historical regression to restore. Both Solidity regressions above were constructed for this check.
  • Dropping the .NET owner-index cache passes the new row count. ManagedMemberOwnership.test.ts ("indexes wide valid member lists once per layout") still catches that change.

Validation performed

  • npm run test:local on the three files: 245 passed.
  • npm run check:fast passed.

Author readiness

Human owner: @Davmunrey

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Seven files in this slice bound elapsed time. Three bounds guarded a
complexity regression and now count the work that regression repeats:

- ManagedArtifactInspector: count TypeDef row decodes through
  ManagedDecodeBudget.reserveRow, which every metadata row cursor calls.
  The inspection decodes 16,002 for 16,001 rows; the bound is two per
  row. A per-attribute TypeDef scan decodes 16,000 x 16,001.
- SolidityMetadata: count JSON.stringify calls, one per scalar in a key
  identity. Two repeated keys nested 62 arrays deep serialize two
  scalars.
- environmentStateWriteExplain (copied and slugged fields): count reads
  of the request body through a Proxy, like the composed-body test. The
  explanation reads 8 per member; the bound is 16. Searching the body
  again for each field reads every member per field.

Each counter throws at its bound, so a regression fails at once instead
of running out the old workload.

Two complexity bounds stay. WabtOutput's 1,000 ms glue-literal bound
guards regex backtracking inside V8; the adapter's calls and AST visits
are the same either way. The explain queue bound (5,000 ms) guards
Array.prototype.shift moving a 500,000-element queue; body reads and
node visits are unchanged, and a vitest spy on shift recurses because
the spy itself calls shift.

The other five bounds time a lifecycle deadline, not work:
serveEnvironmentState (close does not wait for a stalled 30 s
download), PlaywrightScenarioBrowser x2 (a 50 ms command_timeout_ms
fires on a handshake or target lookup that never settles) and
ProviderProcess.launcherExit (stop does not wait the 1,000 ms kill
grace without new exit evidence). They are unchanged.

Validation: each regression was applied to production code
(uncommitted) and the base and new test files were run against it.
Per-attribute TypeDef scan (the pre-morluto#1943 loop, ported): base failed after 133 s
(bound 2,000 ms), new failed in 0.4 s. Body indexed again for each
field: base failed after 191 s (bound 5,000 ms), new failed in 0.2 s.
Key identity derived at every nesting level: base passed, new failed
(63 serializations vs 2). Identity derived twice per level: base never
reached its bound (killed after 90 s), new failed in 15 ms. Dropping
the owner index cache passes the new count, but
ManagedMemberOwnership.test.ts "indexes wide valid member lists once
per layout" fails on it. test:local on the three files: 245 passed.
check:fast: passed.

Refs morluto#10513
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T20:59:21.595796Z
We couldn’t complete this review. Comment @codex review to try again.
ca7bcfa PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The changes appear safe to merge.

Summary

Replaces three elapsed-time checks with work counts while leaving production code unchanged.

  • Managed artifact tests count TypeDef row reads instead of elapsed time.
  • Solidity tests count key-identity serializations instead of elapsed time.
  • Request-body tests count field reads instead of elapsed time.

Reviews (3) · Last reviewed commit: "test(dotnet): import the managed decode ..." · Reviewed by Greptile

Main moved ManagedDecodeBudget from src/dotnet to src/domain/managed/managedDecodeBudget. The row-reservation count spies on its prototype, so the test now imports the class from there.
@Davmunrey Davmunrey closed this Nov 16, 2026
@morluto morluto added the area: tests Test suite and verification label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Test suite and verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants