Skip to content

test: bound folder collapse, echo search and ELF section admission by work, not elapsed time - #10783

Merged
morluto merged 2 commits into
mainfrom
test/domain-work-bounds
Nov 15, 2026
Merged

morluto merged 2 commits into
mainfrom
test/domain-work-bounds

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Refs #10513 (Phase 6.3). Two complexity-regression tests in src/domain asserted elapsed time (performance.now() deltas under 2 s and 5 s). They now count the operations a quadratic implementation would repeat and fail at a linear bound, so a regression is caught deterministically and stops early instead of running on.

Problem and expected behavior

Wall-clock bounds flake on loaded CI shards and pass on a fast host even when the work has grown. docs/development/testing.md reserves elapsed assertions for cases where speed itself is the behavior under test; here the intent is "no pairwise or per-member search".

Change and scope

  • src/domain/desktop/appExportUnowned.test.ts: counts Set.prototype.has and String.prototype.startsWith calls during unownedChangedFolders over 20,003 paths. Bound 24 * files (observed about 11 per path); the spy throws at the bound.
  • src/domain/analysisView/environmentStateWriteCopies.test.ts: counts String.prototype.includes and indexOf calls during explainCreate over an 8,000-member body. Bound 16 * n (observed 27,401, about 3.4n); the spy throws at the bound.
  • src/native/hardening/BinaryHardeningParsers.test.ts: "admits a hostile section table without rescanning every span" (65,000 disjoint SHT_NOTE sections) replaced performance.now() < 5 s with a count of array elements walked during readElfHardening, through Array.prototype[Symbol.iterator] and the element-visiting methods (some, find, filter, map, sort, toSorted, ...). Bound 64 * sections (observed 1,235,343, about 19 per section); counting throws at the bound. The methods are patched directly rather than with vi.spyOn, whose bookkeeping iterates arrays and would recurse. The test runs in about 70 ms, so its long-running tag is dropped.

Same spy-and-throw pattern as the sibling 6.3 PRs (#10672, #10671, #10670, #10627, #10619), which cover other files. Production code is unchanged.

Not included: javascriptRouteScan.test.ts, WabtOutput.test.ts and ElfNoteParser.test.ts guard against regex backtracking inside a single exec, which a call counter cannot observe, so their elapsed bounds stay. getter_aliases and the process, deadline and cancellation tests are left to their owning workstreams.

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: tests only; production owners unchanged
  • Contribution scope fit and linked maintainer decision: not applicable (test-only, Phase 6.3 tracker Replace wall-clock test bounds with deterministic work measures #10513)
  • CLI and MCP/tool-catalog contract: none
  • Provider, bridge, target-format, or platform compatibility: none
  • Evidence, artifact, provenance, or reconstruction contract: none
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable
  • 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: the three tests above.
  • Base reproduction or other evidence (executed locally, then reverted): replacing the ancestor lookup in unownedChangedFolders with a pairwise [...folders].some((other) => folder.startsWith(${other}/)) fails the test with folders compared pairwise in under a second; replacing holdersOf with a per-token text.indexOf(token) search fails with texts searched per member. Adding a per-candidate admitted.some(...) rescan to admitDisjointTables in ElfHardening.ts fails the ELF test with array elements walked past bound. (Replacing the binary search inside overlapIndex with findLast does not trip the bound, because this fixture queries that index only a few times; the per-candidate rescan is the quadratic case it targets.)
  • User-visible CLI/MCP output (if applicable): none
  • Remaining proof gaps: a quadratic rewrite that uses neither counted method would not be caught; the counted methods are the ones each comparison uses today.

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:local -- src/domain/desktop/appExportUnowned.test.ts src/domain/analysisView/environmentStateWriteCopies.test.ts — 2 files, 24 tests passed
  • npm run check:fast — passed
  • npx vitest run src/native/hardening/BinaryHardeningParsers.test.ts — 78 tests passed; pre-push typecheck and lint passed
  • Temporary quadratic variants described above — each test failed at its bound

Compatibility, safety, and release

  • Breaking changes or migration steps: none
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (test-only)
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: not applicable

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.

…sed time

Two quadratic-regression tests in src/domain asserted elapsed time. Count
the comparisons and text searches instead, failing at a linear bound so a
pairwise or per-member search stops early instead of running on.

Refs #10513
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T06:11:22.227128Z 777376b New commits
ℹ️ 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.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

Replaces elapsed-time checks with operation limits in three regression tests. Production code is unchanged.

  • Folder-collapse tests now cap comparisons by the number of paths.
  • Echo-search tests now cap string searches in wide bodies.
  • ELF section tests now cap array visits while admitting large tables.

Reviews (4) · Last reviewed commit: "test(native): bound hostile ELF section ..." · Reviewed by Greptile

…time

The 65,000-section case asserted it finished within 5 s, which a loaded
runner can miss and a fast one can pass while quadratic. Count array
elements walked through iteration and the element-visiting methods, and
stop at 64 per section; the parser walks about 19. A per-candidate rescan
of the admitted spans now fails at the bound.
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