Skip to content

test(python): replace pyc wall-clock bounds with work measures - #10627

Closed
Davmunrey wants to merge 1 commit into
morluto:mainfrom
Davmunrey:claude/pyc-work-bounds
Closed

Davmunrey wants to merge 1 commit into
morluto:mainfrom
Davmunrey:claude/pyc-work-bounds

Conversation

@Davmunrey

Copy link
Copy Markdown
Contributor

Summary

Refs #10513. This covers only src/python/PythonPycParser.test.ts. It replaces or deletes 7 of the file's 8 Date.now() - started bounds. The parser is unchanged.

Change and scope

  • 390 and 1050 are deleted. The same tests already pin exact counts and a 64 KiB report bound.
  • 613 now counts Hash.prototype.update input bytes, which must stay under 2× the payload.
  • 783 now counts BigInt.prototype.toString calls, at most 1.
  • 1016 must now reject at the key-size preflight (boundary: "string").
  • 1491 and 1634 now parse under the tightest limits that still admit the file, so the parser's own budgets are the work bound.

Evidence and regression coverage

Each regression was put back into the parser, then both the old and new tests were run:

Regression Old test New test
Per-reference digest passes fails (1.26 GB hashed)
Per-reference bit length passes fails (401 conversions)
Shared keys walked again passes fails (objects instead of string)

The remaining regressions fail in both versions.

Gap: the 250 ms wide-dictionary bound (1282) is left unchanged. It has no deterministic measure without a production counter, a global push wrapper or a perf lane, so it needs a maintainer decision.

Validation performed

  • npm run test:local -- src/python/PythonPycParser.test.ts: 66 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.

Eight assertions in PythonPycParser.test.ts bounded elapsed time (1000 ms,
one 250 ms). They depend on host speed and fail on loaded CI shards without
a regression. On an idle host two of them did not catch the regression they
were written for.

Seven are replaced or removed:
- Deleted where the test already pins exact code-object lists, nested_code
  indexes, relationship counts and a 64 KiB report bound (shared TYPE_REF
  chain; shared container listed once per owner).
- Shared byte string: count SHA-256 input bytes during the parse; the
  payload is digested once.
- Shared 300,000-bit integer: count BigInt string conversions during the
  parse.
- Doubling tuple key: require the expansion preflight (boundary "string")
  to reject it, not the key-walk step budget.
- Long TYPE_REF chains: parse under the tightest limits that admit the
  stream (objects read, marshal depth, file size), so the parser's own
  nested-walk step, key-walk step and key-byte budgets bound the work.

The 250 ms wide-dictionary bound stays. Rebuilding the dict child list on
every walk step leaves every parser counter unchanged and its copies are
garbage, so neither a counter nor retained heap observes it, and spying on
Array.prototype.push recurses into the spy.

Validation: each regression was reintroduced in PythonPycParser.ts
(uncommitted) and the base and new test files were run against it.
Digest per reference: base passed (840 ms), new failed (1,259,339,778
bytes hashed). Bit length per reference: base passed, new failed (401
conversions). Re-walking shared keys: base passed, new failed (boundary
"objects"). No expansion preflight, nested re-walk (36,018,000 steps vs
12,000), no key interning (36,018,002 key bytes vs 34,672) and nested code
per reference: both failed. test:local on the file: 66 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-14T19:16:08.192012Z
We couldn’t complete this review. Comment @codex review to try again.
721a5d6 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 PR appears safe to merge; no actionable defects were found.

Summary

Replaces or removes seven elapsed-time checks in PythonPycParser.test.ts. The parser is unchanged.

  • Parser tests measure repeated work instead of elapsed time.

Reviews (1) · Last reviewed commit: "test(python): replace pyc wall-clock bou..." · Reviewed by Greptile

@Davmunrey Davmunrey 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.

Status:

  • Greptile found no issues.
  • The 250 ms wide-dictionary bound is left unchanged pending your decision, as described in the PR body.
  • Format and static checks pass with the branch merged into current main.

@Davmunrey

Copy link
Copy Markdown
Contributor Author

Superseded by a80a47f (#11608), which bounds the pyc parser by counts and leaves no elapsed-time read in PythonPycParser.test.ts (this PR kept two). Closing.

@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