Skip to content

test(python): bound pyc parser work by counts instead of elapsed time - #11608

Merged
morluto merged 1 commit into
mainfrom
test/pyc-parser-work-counter
Nov 16, 2026
Merged

morluto merged 1 commit into
mainfrom
test/pyc-parser-work-counter

Conversation

@morluto

@morluto morluto commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Summary

Refs #10513. The eight wall-clock bounds in src/python/PythonPycParser.test.ts are replaced by exact work counts from an optional counter the parser accepts.

Problem and expected behavior

Eight pyc tests asserted Date.now() - started < 1000 (one < 250). Each guards an algorithmic property (a shared byte string hashed once, one summary per TYPE_REF'd object, a wide dict listed once, a shared container walked once for all owners, linear TYPE_REF walks, tuple-key expansion refused before it doubles). Elapsed time fails on loaded CI shards without a regression and passes on a fast machine with one. Expected: the same properties asserted as deterministic counts.

Change and scope

  • parsePythonPyc(bytes, artifact, input, work?): optional PythonPycWork (emptyPythonPycWork()); production callers pass nothing. Counted where the work happens: digestedBytes (SHA-256 input), constSummaries, listedChildren (container child slots listed for the nested walk), nestedSteps, keySteps, keyBytes (joined key bytes), codeVisits (report flattening). Counts accumulate even when the parse throws, so a refused parse is measurable too.
  • Tests: each timing replaced by counts, e.g. wide dict listedChildren === 2 * keys, shared container nestedSteps === copies + 1, shared byte string constSummaries === 1 and digestedBytes < 2 * payload, TYPE_REF tuple chain keySteps === 2 * links + 1, tuple-key refusal with keySteps <= 4 * depth and keyBytes <= 8 * depth.
  • Not included: the other wall-clock families tracked in Replace wall-clock test bounds with deterministic work measures #10513 (desktop selectors next).

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: The parser owns the work; the counter is incremented at the existing budget charge sites and caches, not reconstructed by the test.
  • Contribution scope fit and linked maintainer decision: Not applicable (tests plus a test-facing optional parameter).
  • CLI and MCP/tool-catalog contract: None.
  • Provider, bridge, target-format, or platform compatibility: None.
  • Evidence, artifact, provenance, or reconstruction contract: Unchanged; the report is identical.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): None.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): None.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/python/PythonPycParser.test.ts: 8 tests converted; no wall-clock assertion remains in the file.
  • Base reproduction or other evidence: Each new assertion was checked against an injected regression in the parser (then reverted): removing the per-owner nested dedup fails 4 tests including the shared-chain and shared-container counts; disabling the summary and digest caches fails the shared byte string, shared integer and shared-chain counts; listing a frame's children on every walk step fails the wide-dict, shared-container and TYPE_REF-chain counts; removing the expanded-key preflight fails the tuple-key refusal; disabling the key cache fails the TYPE_REF tuple chain count (and 17 others).
  • User-visible CLI/MCP output (if applicable): None.
  • Remaining proof gaps: None for this file.

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- src/python/PythonPycParser.test.ts src/artifacts/pyinstaller/PyzArchive.test.ts src/artifacts/pyinstaller/PyInstallerArtifactReader.test.ts: 128 passed.
  • Injected regressions above with npm run test:local -- src/python/PythonPycParser.test.ts: the expected tests fail.
  • npm run check:fast (typecheck, lint, architecture guards): passed. npx oxfmt on both files; pre-commit and pre-push hooks ran.

Compatibility, safety, and release

  • Breaking changes or migration steps: None.
  • Real Hopper/Ghidra, browser, or OS coverage: None.
  • Package or release metadata impact: None.
  • Security, privacy, process, or containment review: None.

Author readiness

Human owner:

  • 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.

PythonPycParser takes an optional work counter (digested bytes, constant
summaries, listed container children, nested and key walk steps, key bytes
and report flattening visits). The eight pyc tests that bounded wall-clock
time now assert those counts, so each regression they guard (repeated
hashing, per-reference summaries, per-step child copies, shared walks,
exponential key expansion) fails deterministically on any machine.

Refs #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-16T00:00:56.491941Z
We couldn’t complete this review. Comment @codex review to try again.
33d1916 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

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no blocking code issues were found.

Summary

The PR replaces eight elapsed-time assertions with counts recorded by the parser.

  • Pyc parser tests count work instead of elapsed time.

Reviews (2) · Last reviewed commit: "test(python): bound pyc parser work by c..." · Reviewed by Greptile

@morluto
morluto merged commit a80a47f into main Nov 16, 2026
15 checks passed
@morluto
morluto deleted the test/pyc-parser-work-counter branch November 16, 2026 00:45
@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.

1 participant