Skip to content

refactor(verify): exclude negated .ok failure branches from completed-abort guard - #11922

Closed
Plastic-time wants to merge 2 commits into
morluto:mainfrom
Plastic-time:rrfz/tighten-completed-abort-guard
Closed

Plastic-time wants to merge 2 commits into
morluto:mainfrom
Plastic-time:rrfz/tighten-completed-abort-guard

Conversation

@Plastic-time

@Plastic-time Plastic-time commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Tighten the completed-abort-reclassification architecture guard so negated .ok checks on failed primaries (!outcome.ok && signal?.aborted) are no longer misclassified as completed-result abort reclassifications, shrinking scripts/verify/baselines/completed-abort-reclassification.json from 17 files / 18 sites to 15 files / 16 sites.

Fixes #11920.

Problem and expected behavior

scripts/verify/architecture-guards.mjs matched completed-abort-reclassification with:

/\.ok\s*&&\s*(?:isAborted\(|[\w.?]*signal\??\.aborted)/gu

Because it inspected only .ok without checking for a leading ! on the receiver expression, it false-matched two failure-branch cancellation attachments:

  1. src/application/desktop/DesktopApplicationState.ts:175: if (!outcome.ok && signal?.aborted) attaches the caller cancellation as a secondary failure (analysisErrorWithCancellation(primary, cancelledBy(OPERATION, signal))) when outcome already failed (!outcome.ok); the completed-outcome branch is handled separately above at lines 161–168.
  2. src/application/frida/FridaInstrumentationService.ts:164: if (!started.ok && signal?.aborted) attaches the caller cancellation onto started.error (analysisErrorWithCancellation(started.error, cancelledBy(operation, signal))) when #provider.startSession failed (!started.ok); the completed-session cancellation path follows at lines 171–172.

Expected: only positive completed-result checks (result.ok && ...) are counted, while negated !result.ok && ... failure branches are excluded.

Change and scope

  • scripts/verify/completed-abort-guard.mjs and scripts/verify/completed-abort-guard.d.mts: added completedAbortReclassificationCount using tokenize from scripts/verify/source-tokens.mjs to locate .ok && (isAborted( | ...signal?.aborted), walk backward across the full receiver expression (member accesses, #private names, calls, indexed reads, and parenthesized groups), and exclude unary ! negations (with zero external dependencies).
  • scripts/verify/architecture-guards.mjs: switched completed-abort-reclassification to completedAbortReclassificationCount.
  • tests/evaluation/completedAbortGuard.test.ts: added unit tests covering both true completed-result hits (including results[0].ok && signal?.aborted and !ready && outcome.ok && signal?.aborted) and negated failure-branch expressions (!outcome.ok, !started.ok, !results[0].ok, !this.readResult().outcome.ok, ! result.ok, !this.#state.outcome.ok, !readResult().ok, !(await readResult()).ok).
  • scripts/verify/baselines/completed-abort-reclassification.json: updated via node scripts/verify/architecture-guards.mjs --shrink-baselines (17 -> 15 files, 18 -> 16 sites), removing only:
    • src/application/desktop/DesktopApplicationState.ts (1 -> 0)
    • src/application/frida/FridaInstrumentationService.ts (1 -> 0)
  • Review follow-up (ac10b2077): replaced the regex lookbehind with source-tokens.mjs tokenize receiver-chain traversal so indexed and post-call member receivers (!results[0].ok, !this.readResult().outcome.ok) are also excluded, and added those positive/negative cases to tests/evaluation/completedAbortGuard.test.ts.

Not included: migrating the remaining 15 files / 16 completed-result sites onto runOwned (each has distinct provider session/retry/cleanup lifecycles and stays tracked by the tightened baseline).

Contribution scope: not applicable (internal architecture-guard matcher fix under #11920).

Contract and boundary impact

  • Semantic owner and earliest changed stage: scripts/verify/completed-abort-guard.mjs owns the pattern matcher consumed by scripts/verify/architecture-guards.mjs and tests/evaluation/completedAbortGuard.test.ts.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • 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: none.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: updated scripts/verify/baselines/completed-abort-reclassification.json only.

Expected effects:

  • 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: tests/evaluation/completedAbortGuard.test.ts (2 tests: positive completed-result cases and negated .ok failure-branch cases). Under the previous regex on origin/main (5cdd7d54b), the negated cases (!outcome.ok && signal?.aborted and !started.ok && signal?.aborted) matched (1 each instead of 0).
  • Base reproduction or other evidence: comparing the old regex against completedAbortReclassificationCount across all 2871 non-test source files in src/ on origin/main (5cdd7d54b) changes total hits from 18 to 16, with diffs exclusively in src/application/desktop/DesktopApplicationState.ts (1 -> 0) and src/application/frida/FridaInstrumentationService.ts (1 -> 0), and preserves every remaining completed-result site unchanged.
  • User-visible CLI/MCP output (if applicable): none.
  • Remaining proof gaps: 2 skipped cases in tests/boundary/filesystem/ciChangeScope.test.ts on Windows; full Linux CI runs on this draft PR.

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

Ran on Windows 11 (node v24.22.1) in the PR worktree after the final edit:

  • .\node_modules\.bin\oxfmt.cmd --check . — passed (8693 files).
  • npm run check:fast — passed (typecheck, lint, and Architecture guards passed across 2871 source files).
  • Before/after comparison scan across all 2871 non-test src/ files (blankComments + old regex vs completedAbortReclassificationCount): oldHits: 18, newHits: 16, diffs: [ { rel: 'src/application/desktop/DesktopApplicationState.ts', o: 1, n: 0 }, { rel: 'src/application/frida/FridaInstrumentationService.ts', o: 1, n: 0 } ].
  • npm run test:focused -- tests/evaluation/completedAbortGuard.test.ts tests/evaluation/sourceTokens.test.ts tests/evaluation/ciTestSelection.test.ts tests/boundary/filesystem/ciChangeScope.test.ts tests/boundary/filesystem/typedScriptDeclarationsGuard.test.ts tests/boundary/filesystem/countedBaseline.test.ts:
    • tests/evaluation/completedAbortGuard.test.ts — 2 passed.
    • tests/evaluation/sourceTokens.test.ts — 4 passed.
    • tests/evaluation/ciTestSelection.test.ts — 9 passed.
    • tests/boundary/filesystem/typedScriptDeclarationsGuard.test.ts — 4 passed.
    • tests/boundary/filesystem/countedBaseline.test.ts — 9 passed.
    • tests/boundary/filesystem/ciChangeScope.test.ts — 416 passed, 2 skipped.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: awaiting Linux CI on this draft PR for the 2 skipped ciChangeScope.test.ts cases.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: guard-only change; no runtime or target-execution behavior changed.

Author readiness

Human owner: @Plastic-time

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

@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no blocking issues remain.

Summary

Replaces the regex in completedAbortReclassificationCount with shared tokens and receiver-chain traversal.

  • The abort guard skips failed-result checks but keeps completed results.

Reviews (3) · Last reviewed commit: "refactor(verify): tokenize receiver chai..." · Reviewed by Greptile

@Plastic-time
Plastic-time marked this pull request as ready for review November 18, 2026 01:17
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 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-18T01:23:23.953833Z ac10b20 Draft marked ready
ℹ️ 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.

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thank you for this. #11920 is resolved on main by #13168, which keeps the guard to one counted pattern in scripts/verify/completed-abort-guard.mjs with positive and negative regression cases instead of a token scanner. I'm closing this PR as superseded.

@N0zoM1z0 N0zoM1z0 closed this Nov 21, 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.

refactor(verify): exclude negated .ok failure branches from completed-abort-reclassification guard

3 participants