[GH-ISSUE #4934] [Bug] Document selection falls back through cancellation and incomplete cleanup #3061

Closed
opened 2026-10-31 00:35:44 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @morluto on GitHub (Oct 18, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/4934

Before submitting

  • Searched open/closed reports. Exact resolveAnalysisDocument search returned #2680, #2513 and #2836, which concern headless fallback/segment support/navigation selection rather than this lifecycle gap. #4227 is the parent audit.
  • Only controlled provider fixtures; no credentials/private targets.

Area

Evidence, artifacts, or reconstruction

Observed behavior

At main94bc7ed32, resolveAnalysisDocument discards the caller reason on pre-aborted admission; starts list_documents after current_document returns capability unavailable while cancellation or incomplete cleanup is present; and returns success when a valid current/list selection finishes under cancellation. The incomplete-cleanup path is also observable through binary_overview over SDK MCP.

Reproduction

Ran a new source-owned helper test with typed production analysis ports: eight assertions failed and three controls passed before repair. Cases cover null/string/object reasons, incomplete-cleanup capability errors with/without late abort, a clean unavailable current selection followed by abort, completed current/list selection, malformed output under abort, and explicit caller selection. A separate SDK MCP control returns an unavailable current selection with cleanupIncomplete=true and observes whether fallback starts. No native engine was launched.

Expected behavior

The owner should refuse fallback while cleanup is incomplete or after cancellation; preserve exact opaque reasons and primary failure identity; validate completed output before classifying cancellation; and retain the producing observation, provenance and explicit unknowns in Evidence on late cancellation. Explicit document input remains authoritative. Navigation's valid empty UI state has a separate contract and is not reinterpreted as a nonempty analysis identity.

Impact and scope

Observed at the shared document-selection boundary; source consumers are binary overview and address-context composition. NOT_ENOUGH_INFO for naturally occurring provider faults or a real MCP cancellation-delivery race. Tests use controlled provider reports and SDK in-memory transport.

REA version

6.5.0,94bc7ed3222ab6ca33fe68f58326eefb91689904.

Runtime and platform

Node24.18.0,macOS arm64.

Target and artifact context

Controlled selected-document and inventory reports; no native target.

Interface

Other: shared application boundary; MCP binary_overview cleanup control.

Earliest failure stage

Cleanup, cancellation, or lifecycle.

Relevant output or evidence

Baseline8failed/3passed. src/application/AnalysisDocument.ts returns bare admission cancellation, falls back for every AnalysisCapabilityUnavailableError without checking cleanup/cancellation, and returns documentName directly after successful reads. The same helper is consumed by EnhancedTools.binaryOverview and AnalysisContextQueries.inspectAddressContext.

Typed outcome or recovery expected

Original incomplete-cleanup error unchanged and no fallback; cancelled result with exact reason and validated completed selection Evidence; no address facets admitted after cancelled selection. No ownership is inferred from arbitrary caller reason values.

Originally created by @morluto on GitHub (Oct 18, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/4934 ### Before submitting - [x] Searched open/closed reports. Exact resolveAnalysisDocument search returned #2680, #2513 and #2836, which concern headless fallback/segment support/navigation selection rather than this lifecycle gap. #4227 is the parent audit. - [x] Only controlled provider fixtures; no credentials/private targets. ### Area Evidence, artifacts, or reconstruction ### Observed behavior At main94bc7ed32, resolveAnalysisDocument discards the caller reason on pre-aborted admission; starts list_documents after current_document returns capability unavailable while cancellation or incomplete cleanup is present; and returns success when a valid current/list selection finishes under cancellation. The incomplete-cleanup path is also observable through binary_overview over SDK MCP. ### Reproduction Ran a new source-owned helper test with typed production analysis ports: eight assertions failed and three controls passed before repair. Cases cover null/string/object reasons, incomplete-cleanup capability errors with/without late abort, a clean unavailable current selection followed by abort, completed current/list selection, malformed output under abort, and explicit caller selection. A separate SDK MCP control returns an unavailable current selection with cleanupIncomplete=true and observes whether fallback starts. No native engine was launched. ### Expected behavior The owner should refuse fallback while cleanup is incomplete or after cancellation; preserve exact opaque reasons and primary failure identity; validate completed output before classifying cancellation; and retain the producing observation, provenance and explicit unknowns in Evidence on late cancellation. Explicit document input remains authoritative. Navigation's valid empty UI state has a separate contract and is not reinterpreted as a nonempty analysis identity. ### Impact and scope Observed at the shared document-selection boundary; source consumers are binary overview and address-context composition. NOT_ENOUGH_INFO for naturally occurring provider faults or a real MCP cancellation-delivery race. Tests use controlled provider reports and SDK in-memory transport. ### REA version 6.5.0,94bc7ed3222ab6ca33fe68f58326eefb91689904. ### Runtime and platform Node24.18.0,macOS arm64. ### Target and artifact context Controlled selected-document and inventory reports; no native target. ### Interface Other: shared application boundary; MCP binary_overview cleanup control. ### Earliest failure stage Cleanup, cancellation, or lifecycle. ### Relevant output or evidence Baseline8failed/3passed. src/application/AnalysisDocument.ts returns bare admission cancellation, falls back for every AnalysisCapabilityUnavailableError without checking cleanup/cancellation, and returns documentName directly after successful reads. The same helper is consumed by EnhancedTools.binaryOverview and AnalysisContextQueries.inspectAddressContext. ### Typed outcome or recovery expected Original incomplete-cleanup error unchanged and no fallback; cancelled result with exact reason and validated completed selection Evidence; no address facets admitted after cancelled selection. No ownership is inferred from arbitrary caller reason values.
bsakaguchi 2026-10-31 00:35:44 +00:00
  • closed this issue
  • added the
    triage
    bug
    labels
Author
Owner

@morluto commented on GitHub (Oct 18, 2026):

Published 9df559b7e7 on main.

Fixed the selection owner, with consumer regressions.

resolveAnalysisDocument now returns the original incomplete-cleanup failure without fallback, stops before list_documents after cancellation, and preserves exact opaque admission reasons. It validates current/list output before late-cancellation classification and retains the completed producing query as Evidence using the existing createAnalysisExecutionEvidence owner. Evidence is assembled only for interrupted completion; normal selection does not allocate an extra envelope. Explicit document selection and the separate navigation empty-state contract retain their existing meanings.

Validation: initial controlled baseline8failed/3passed; final50passed across7files, plusdocs:check including5conformance tests, check:fast andtest-discovery1570. Public SDK MCP binary_overview refuses fallback through incomplete cleanup. Address context stops downstream facets after cancelled document selection. Exact null/string/object/typed-error reasons, no caller-error cleanup adoption, malformed output precedence, headless ambiguity, provenance/raw output/subject/locations andexplicit selection controls pass. One read-only review found no blocker. No native engine, actual client-cancellation delivery race or spontaneous provider fault is claimed.

Bounded comparison: six completed SDK MCP tasks alternate pinned baseline94bc7ed32 andfixed build. Each performs catalog discovery, controlled headless binary_overview, reply and clean close. Complete normalized output and six provider calls agree. Warm medians: observed elapsed 1.9017->1.9028s; child-process-family CPU 2.5070->2.4898s; sampled family peakRSS 647.92->648.04MiB. cl100k serialized reply estimate425 andcatalog estimate895772 unchanged. These are serialized-data estimates, not actual model usage; full agent prompt/retry costs and cancelled-path Evidence costs are unmeasured. Observed elapsed includes parent output read/JSON validation; CPU/RSS exclude that parent.10ms sampling can miss transient/reparented children. First process andwarm repeats, noOS-cacheflush. No speedup claim. Heavy stress/profiling remain stopped; temporary baseline removed. The catalog cost is an audit lead, not a new diagnosed regression.

This closes the named document-selection lifecycle issue. EnhancedTools' other cancellation paths andthe broader issue/codebase audit remain active.

<!-- gh-comment-id:6244157595 --> @morluto commented on GitHub (Oct 18, 2026): Published 9df559b7e712298a761ff26e9caae8d659b7e54b on main. Fixed the selection owner, with consumer regressions. resolveAnalysisDocument now returns the original incomplete-cleanup failure without fallback, stops before list_documents after cancellation, and preserves exact opaque admission reasons. It validates current/list output before late-cancellation classification and retains the completed producing query as Evidence using the existing createAnalysisExecutionEvidence owner. Evidence is assembled only for interrupted completion; normal selection does not allocate an extra envelope. Explicit document selection and the separate navigation empty-state contract retain their existing meanings. Validation: initial controlled baseline8failed/3passed; final50passed across7files, plusdocs:check including5conformance tests, check:fast andtest-discovery1570. Public SDK MCP binary_overview refuses fallback through incomplete cleanup. Address context stops downstream facets after cancelled document selection. Exact null/string/object/typed-error reasons, no caller-error cleanup adoption, malformed output precedence, headless ambiguity, provenance/raw output/subject/locations andexplicit selection controls pass. One read-only review found no blocker. No native engine, actual client-cancellation delivery race or spontaneous provider fault is claimed. Bounded comparison: six completed SDK MCP tasks alternate pinned baseline94bc7ed32 andfixed build. Each performs catalog discovery, controlled headless binary_overview, reply and clean close. Complete normalized output and six provider calls agree. Warm medians: observed elapsed 1.9017->1.9028s; child-process-family CPU 2.5070->2.4898s; sampled family peakRSS 647.92->648.04MiB. cl100k serialized reply estimate425 andcatalog estimate895772 unchanged. These are serialized-data estimates, not actual model usage; full agent prompt/retry costs and cancelled-path Evidence costs are unmeasured. Observed elapsed includes parent output read/JSON validation; CPU/RSS exclude that parent.10ms sampling can miss transient/reparented children. First process andwarm repeats, noOS-cacheflush. No speedup claim. Heavy stress/profiling remain stopped; temporary baseline removed. The catalog cost is an audit lead, not a new diagnosed regression. This closes the named document-selection lifecycle issue. EnhancedTools' other cancellation paths andthe broader issue/codebase audit remain active.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#3061
No description provided.