Skip to content

fix(errors): keep every desktop close failure and drop abort-guard false positives - #13168

Merged
N0zoM1z0 merged 2 commits into
mainfrom
refactor/abort-guard-negated-ok
Nov 21, 2026
Merged

N0zoM1z0 merged 2 commits into
mainfrom
refactor/abort-guard-negated-ok

Conversation

@N0zoM1z0

@N0zoM1z0 N0zoM1z0 commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Two error-composition cleanups tracked by the architecture guards:

  • Fixes refactor(verify): exclude negated .ok failure branches from completed-abort-reclassification guard #11920: the completed-abort-reclassification guard counted negated failure checks such as !outcome.ok && signal?.aborted, which attach a secondary cancellation to a failed primary and reclassify nothing. The guard now requires the receiver chain to start the check, so DesktopApplicationState.ts and FridaInstrumentationService.ts leave the baseline. The other 15 counted files are unchanged.
  • Refs refactor(errors): migrate remaining cleanup-dependency-binding sites onto shared owners #11859: the desktop state-reader close (withStateReaders in src/cli/desktopCaptureCommands.ts) collects up to three failures (artifact scope, SQLite service, export-worker retry). It composed only the first two with analysisErrorWithCleanupFailure and bound all of them by hand, so the third failure's reason never reached the caller. The failures are now folded through analysisErrorWithCleanupDependencies, so each keeps its reason and cleanup owner. The direct bindCleanupDependencies call leaves the baseline (31 → 30 files).

Supersedes #11922 (token-scanner version of the guard fix; a one-pattern change covers the current sites) and #12000. #12000 assumed at most two close failures. On current main there can be three, so its two-argument helper call would drop the third failure from the composite's cleanup dependencies. Its CLI-level test approach is reused here.

Problem and expected behavior

  • Guard: a negated .ok check is not a completed-result reclassification and should not count as debt.
  • Desktop close: when the scope, SQLite, and export worker all fail to close, the CLI result should report all three reasons. Before this change it reported the scope and SQLite reasons and omitted Export worker remains owned.

Change and scope

  • scripts/verify/completed-abort-guard.mjs (used by architecture-guards.mjs, with a .d.mts declaration like the other guard helpers): a receiver chain of member, optional, #private, element and call segments, or a leading parenthesized receiver, each optionally with a non-null assertion, must start the .ok && …aborted check; a leading ! excludes it.
  • src/cli/desktopCaptureCommands.ts: typed.reduce(analysisErrorWithCleanupDependencies). With two failures this builds the same composite as before. With three, the first composite becomes the primary of the second, so each part keeps its owner.
  • No other abort or cleanup sites change. The remaining baseline sites are custom or multi-dependency compositions (see refactor(errors): migrate remaining cleanup-dependency-binding sites onto shared owners #11859).

Sibling check (source-read): AdbProvider output-directory cleanup, DesktopApplicationExport handle closes, CompositeProvider, and decompileAll keep every failure (ProviderCleanupError over all parts or retainSecondaryFailure per part). Only the desktop state-reader close dropped one.

Contribution scope: ordinary fix within existing boundaries; maintainer scope decision not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: analysisErrorWithCleanupDependencies (src/domain/analysisErrorCleanup.ts) now owns the desktop close composite; architecture guard pattern.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: with three close failures (only export-desktop-application retries the worker), its CLI errors now include the third reason under nested diagnostics.primary_error. With one or two failures, output is unchanged. MCP is unchanged.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none; partial_observation is preserved as before.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): cleanup completion still follows every part's owner.
  • Generated metadata, package, or installation impact: guard baselines only.

Evidence and regression coverage

  • Tests added or updated: tests/evaluation/completedAbortGuard.test.ts (14 positive and 10 negative receiver forms, including results[0].ok, getResult().ok, (await settle()).ok, non-null assertions such as result!.ok, and their negations); tests/process-global/desktopStateReaderCleanup.test.ts (isolated project, since it uses module mocks) runs rea export-desktop-application --json through the CLI with a retained scope lease whose close fails, plus failing SQLite and worker closes. It asserts that all three reasons and resources are in the output, and that released parts leave the composite's pending resources while the unreleased lease keeps it incomplete.
  • Base reproduction: on the base revision the same test fails with expected '{"code":"cleanup_incomplete",…' to contain 'Export worker remains owned' (executed locally).
  • Guard: before/after counts compared by running the guard (executed). Only the two negated sites leave; 15 files / 16 sites remain.
  • Remaining proof gaps: no real desktop capture was run; the close failures are injected.

Validation performed

  • npm run test:focused -- tests/process-global/desktopStateReaderCleanup.test.ts tests/evaluation/completedAbortGuard.test.ts — 26/26 passed.
  • npm run test:focused -- tests/boundary/cli/desktopApplicationCli.test.ts tests/boundary/cli/desktopCaptureCli.test.ts (with the new test) — 20/20 passed.
  • npx oxlint and npx oxfmt --check on changed files — no errors.
  • node scripts/verify/architecture-guards.mjs — passed across 2936 source files.
  • npm run typecheck — passed.
  • pre-push npm run check:fast — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: cleanup ownership is preserved; no new signaling or deletion.

Author readiness

Human owner: gensokyo-dev (exempt from the readiness declaration per CONTRIBUTING.md)

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 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-21T18:04:37.370066Z 6783e8b 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 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5 Tier: plus

[Medium impact] The runtime change reaches desktop export's state-reader cleanup reporting.

The PR needs the new test moved to an isolated project before merge.

Findings

  1. P1 New test blocks lint ▶
  2. P2 Positive checks escape the guard ▶
Fix with agent prompt
### Issue 1
tests/boundary/cli/desktopStateReaderCleanup.test.ts:20-24
This test adds four `vi.mock` calls, but its `cli-boundary` project has `isolate: false`. The repository requires module mocks to run in an isolated project, and `rea/no-shared-module-mock` rejects these calls as errors. Move the file to `tests/process-global/`, or explicitly give it an isolated owner and exclude it from `cli-boundary`.

### Issue 2
scripts/verify/architecture-guards.mjs:640
The new pattern drops valid positive checks that the old guard counted. For example, `results[0].ok && signal.aborted` and `getResult().ok && isAborted(signal)` now produce no match. Both can still reclassify a completed result, so new copies can pass without a baseline entry. Keep these receiver forms covered while excluding unary negation, and add positive and negative regression cases.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR folds all desktop close failures through analysisErrorWithCleanupDependencies and stops counting negated failure checks as completed-result reclassification.

  • Desktop export errors keep every state-reader close failure.
  • The architecture guard counts only checks that start with a result receiver.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Scope["Artifact scope failure"] --> First["Compose first two failures"]
  SQLite["SQLite close failure"] --> First
  First --> Final["Compose with worker failure"]
  Worker["Worker retry failure"] --> Final
  Final --> Output["CLI error keeps every reason"]
  Final --> Owners["Completion follows every child owner"]
Loading

Reviews (1) · Last reviewed commit: "fix(desktop): keep every state-reader cl..." · Reviewed by Greptile

Comment thread scripts/verify/architecture-guards.mjs Resolved
@gensokyo-dev
gensokyo-dev force-pushed the refactor/abort-guard-negated-ok branch from 15160ee to 89cb9d7 Compare November 21, 2026 17:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 89cb9d72b2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

gensokyo-dev and others added 2 commits November 21, 2026 18:01
…ication guard

The completed-abort-reclassification pattern matched any `.ok && …aborted`,
including `!outcome.ok && signal?.aborted`, which attaches a secondary
cancellation to an already failed primary and reclassifies nothing. Move
the pattern to completed-abort-guard.mjs, where the receiver chain
(member, optional, private, element and call segments) must start the
check, and cover positive and negated forms in tests.
DesktopApplicationState and FridaInstrumentationService leave the
baseline.

Fixes #11920

Co-Authored-By: gensokyo-dev <[email protected]>
…mposite

The desktop state-reader close collects up to three failures (artifact
scope, SQLite service, and the export worker retry), but composed only
the first two with analysisErrorWithCleanupFailure and bound the rest by
hand. The third failure's reason never reached the caller. Fold the
failures through analysisErrorWithCleanupDependencies so each keeps its
reason and owner; two failures produce the same composite as before.

Refs #11859

Co-Authored-By: gensokyo-dev <[email protected]>
@gensokyo-dev
gensokyo-dev force-pushed the refactor/abort-guard-negated-ok branch from 89cb9d7 to 6783e8b Compare November 21, 2026 18:01

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6783e8b66a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@gensokyo-dev gensokyo-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved: guard accuracy and desktop close composition fix with regressions; review findings addressed; CI green.

@N0zoM1z0
N0zoM1z0 merged commit 10597e1 into main Nov 21, 2026
40 checks passed
@N0zoM1z0
N0zoM1z0 deleted the refactor/abort-guard-negated-ok branch November 21, 2026 18:07
@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

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