Skip to content

test(javascript): replace lifetime wall-clock bounds with work measures - #10670

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

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

Conversation

@Davmunrey

Copy link
Copy Markdown
Contributor

Summary

Refs #10513. This slice covers JavaScript semantic reference lifetimes and complements #10619, #10627 and the native-parser and remaining-src/ slices. It replaces all 8 of the 2000 ms elapsed-time bounds in src/domain/javascript/javascriptSemanticAnalysis.reference_lifetimes.test.ts with deterministic work measures. Production code is unchanged.

Problem and expected behavior

The bounds depended on host speed, and they almost never caught the regressions they guard. With each of the six guarded mechanisms removed in turn, the old bound fired in 1 of 78 runs. Most broken variants never return. Vitest cannot time out a synchronous loop, so those runs hung or ran out of memory before the bound was ever checked.

Change and scope

  • Seven tests: a test-local spy on SemanticPropertyPathCoverage.prototype.retain counts one step per path check and one per path key. It throws at a limit of about twice the measured steps. Two of these tests have a limit of 0.
  • Shallow-copy test: uses the existing alias_selections budget at 1024 and asserts that no resource limit is recorded. The test needs 742.

Evidence and regression coverage

  • Each guarded mechanism was removed in an uncommitted copy. Every regression fails at least one new test within 2–4 s. With the old file, the same regressions hung, ran out of memory, or passed.
  • Gaps: no regression ever broke many members: use(node). Work done before retain is not counted.

Validation performed

  • npm run test:local -- src/domain/javascript/javascriptSemanticAnalysis.reference_lifetimes.test.ts: 113 passed, including in 3 shuffled orders.
  • 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 tests in javascriptSemanticAnalysis.reference_lifetimes.test.ts
bounded elapsed time at 2000 ms. They fail on slow hosts without a
regression, and they rarely caught the regressions they guard. Removing
the repeated-prefix check, path normalization or the covering antichain
makes the collector loop without end. Vitest cannot time out a
synchronous loop, so those runs hung or ran out of memory before the
bound was read.

Seven bounds now count the member-mutation collector's own work. A
test-local spy on SemanticPropertyPathCoverage.prototype.retain charges
one step per path check and one per path key, and throws at the limit.
That also ends a cycle that never closes. Limits are about twice the
measured steps. A test is held at 0 where no path below the loop is
observable (null tail, numeric child). The shallow-copy bound uses the
existing alias_selections budget instead: at 1024 the unioned chain
records no alias-selections limit (it needs 742).

Validation: each regression was put back in an uncommitted copy of
javascriptSemanticMemberMutations.ts, and every bounded test was run
alone against it with the base file and with the new one.
- No repeated-prefix check: base hung (60 s cutoff) or ran out of
  memory; new failed in 2-4 s on 4 tests.
- No path normalization: base hung or ran out of memory; new failed on
  5 tests.
- Opaque class origins: base passed; new failed (linked list).
- No exclusion union: base passed; new failed (alias-selections limit).
- No covering antichain: base hit stack overflows and one hang; new
  failed on 6 tests.
- Depth-first worklist: base failed at 4,964 ms; new failed at 54,000
  steps.
test:local on the file: 113 passed, also in 3 shuffled orders.
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:07.992912Z
We couldn’t complete this review. Comment @codex review to try again.
a2828a5 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] This test-only change appears safe to merge.

Summary

Replaces eight wall-clock checks with deterministic work limits in the JavaScript reference-lifetime tests. Production code is unchanged.

  • Reference-lifetime tests cap analysis work instead of counting seconds.

Reviews (2) · Last reviewed commit: "test(javascript): replace lifetime wall-..." · 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; production code is unchanged.
  • Format and static checks pass with the branch merged into current main.

@Davmunrey

Copy link
Copy Markdown
Contributor Author

Superseded by f86b83c (#11635), which bounds the same reference-lifetime tests by alias states and leaves no elapsed-time read in javascriptSemanticAnalysis.reference_lifetimes.test.ts. 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