Skip to content

fix!: preserve results when source publication fails - #8444

Merged
morluto merged 44 commits into
mainfrom
codex/evidence-recovery-redesign
Nov 8, 2026
Merged

morluto merged 44 commits into
mainfrom
codex/evidence-recovery-redesign

Conversation

@morluto

@morluto morluto commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Problem and outcome

A provider or composed workflow can finish a result and then lose it when Evidence publication fails. Preserve the publication error and, when delivery permits, the completed observation with an explicit retention state. State when source closure is not established and when a completed result cannot safely be constructed or delivered. Unretained Evidence is not included in session exports. Addresses #8425.

Direct session, MCP and one-shot analysis now check authentication headroom before constructing completed Evidence. The session can reuse its own immutable retained record for the exact unchanged observation and request only when its path and caller metadata also match; transformed observations, mismatched parameters, missing ownership or separately supplied source records use the regular construction path. Source-ID accounting avoids constructing the full link array before admission. Cleanup and cancellation remain visible, and cleanup ownership is retained until release succeeds.

This changes error payloads and recovery guidance. It adds no target execution, mutation or provider capability.

Validation

  • Current head: seven focused MCP, one-shot, cancellation and snapshot suites passed (76 tests); five further workflow and cleanup suites passed (91 tests). check:fast, docs:check and git diff --check passed. Public MCP controls cover copied results, transformed parameters, forged provider IDs and linked source records. The copied-result and parameter controls fail against an ID-only reuse shortcut. One-shot controls cover cancellation during final close, an injected cleanup failure and cleanup retry.
  • Real Ghidra 12.1.4/JDK 21 on macOS arm64: a disposable saved project with a synthetic historical report was read through stdio MCP in both profiles. An injected zero authentication-headroom policy returned an explicit completed-result omission while retaining the historical source; the one-shot application path reported the same omission. With normal headroom, zero retained capacity returned linked unretained source and result, while a larger allowance retained both. REA left the project copy and unexecuted target unchanged during the reads.
  • Real Kuna 1.986 on macOS arm64 through stdio MCP, both profiles: an injected zero retained allowance returned the completed _main observation as unretained Evidence; a larger allowance returned and retained it. The unexecuted target was unchanged. A separate real Ghidra target-switch control used byte-identical files at two paths; both profiles returned the selected path with the same semantic ID, and both files were unchanged.
  • A separate local integration with the unmerged Kuna 1.990 pointer work exercised a 24,000-reference query. Three alternating runs per variant showed median first/repeated calls of 827/467 ms baseline and 788/355 ms with the session-owned reuse experiment; address and pointer hashes matched. Sampled process-family peak RSS and CPU lower bounds were 1,314,480 KiB/3.22 s baseline and 1,232,624 KiB/3.05 s experimental. These are small, host-specific samples; token use was not measured. The integration is not part of this PR.

Earlier heads also passed broader publication, error projection and cleanup checks, plus docs:check; see #8425 for the detailed controls. Limits above were injected, not public configuration. Actual OOM, real-provider cleanup failure, other hosts, and every provider-created source remain unverified.

Review follow-up: completed Evidence and admission

A previously retained record can share an Evidence ID with a completed observation from a different caller path because display metadata is excluded from that ID. Recovery now looks up the immutable retained record and compares its display metadata at the Evidence owner; it returns the retained ID only when those facts agree, otherwise preserving the current authenticated Evidence inline as unretained. This applies to provider, composed-workflow and other source-publication consumers. Source closure remains unestablished on the failure.

Admission no longer copies the variable-size locations, limitations or links arrays before checking headroom. It borrows them for the size check, accounts separately for the generated subjectless limitation, and constructs the independent normalized snapshot after admission. This prevents the rejected observation from creating an additional input-sized array before the check; it does not establish an RSS reduction for real providers.

On Node 24.22.1, seven source/one-shot/MCP test files passed 127 tests. The new real MCP recovery case fails on the previous head by returning the stale path, and passes after the change. An admission collection-identity regression also fails on the previous head; a subjectless admission control checks conservative accounting. check:fast, format:check, and git diff --check passed.

A small repeated in-memory MCP test task (nine existing cases, fresh processes; OS cache uncontrolled) took 5.09/4.85 s and 6.31/6.44 s user+system CPU on the prior head, versus 4.13/3.92 s and 5.46/5.22 s on this change. /usr/bin/time -l reported maximum individual-process RSS 942,686,208/953,171,968 bytes before and 931,446,784/955,940,864 bytes after; it does not establish process-family peak memory. Samples ran candidate before baseline and are not a general performance comparison. Model token usage, real-provider workload costs, actual OOM, and process-family peak memory were not measured.

After merging the updated #8424 base at 65a2d037, the same seven focused source, one-shot, and MCP suites passed 127 tests on Node 24.22.1, and check:fast passed uncached. Full CI and real-provider verification on this integrated head remain pending.

Review follow-up: the source-publication secondary failure now has a structured assertion for its error code, provider, and operation rather than a frozen explanatory sentence. The xrefs registration selects its named official contract family rather than loading the entire catalog. Both MCP boundary suites passed 16 tests after merging the updated #8424 base 967c695e; Node 24 check:fast, format:check, and git diff --check passed. Full CI and real-provider qualification on this head remain pending.

After #8424 landed on main, merged main 106ba1730f and reconciled the recovery changes with the updated session retention condition and ledger-failure partial observation. On the integrated head, ten focused Evidence, MCP, one-shot and cleanup test files passed 147 tests on Node 24.22.1; uncached check:fast, format:check, and git diff --check passed. CI and real-provider qualification on this integrated head remain pending.

The feature-trace replay profile retains main's workflow revision 8 after profile extraction (e663fc5). The cache regression failed before the fix; 44 cache tests, 37 snapshot replay boundary tests and check:fast passed on macOS with Node 24.22.1. Two Windows-only replay tests were skipped; this follow-up did not exercise a real provider.

Merged main a67525cdf1 and reconciled the shared workflow profile with the current trace-call-path revision. On the integrated head, ten focused Evidence and MCP suites passed 147 tests, and snapshot replay passed 37 tests (2 skipped). Node 24 check:fast, format:check, and git diff --check passed. CI and real-provider checks for this head remain pending.

Merged main 015a02d57b, preserving partial source closure on failures and the updated trace-feature coverage limitation in both constructed Evidence and admission accounting. Seven focused workflow, source recovery, snapshot replay and MCP suites passed 117 tests (2 skipped). Node 24 uncached check:fast, format:check, and git diff --check passed. CI and real-provider verification on this integrated head remain pending.

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.

BREAKING CHANGE: Strict clients that cached the previous full inspect_address_context output schema must refresh tools/list and accept the typed error field on unavailable facets.
BREAKING CHANGE: Clients validating unavailable context facets against a cached strict full output schema must refresh tools/list to accept resource_constraint errors.
@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed change appears safe to merge; the Frida assertion matches the recovery response and preserves its existing checks.

Summary

Preserves completed observations when recording source Evidence fails.

  • Completed analysis results stay available when recording source Evidence fails.
  • MCP errors keep recovery details within the response size limit.
  • Completed Evidence is checked before construction and reused only for matching session results.
  • Cleanup failures and late cancellations stay visible alongside analysis errors.
  • Diagnostic wording and view labels keep their existing meaning.

The earlier findings appear addressed in the current code. This review used source inspection; no tests were run. Checking whether another PR supersedes this one was blocked by missing GitHub authentication.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Analysis completes] --> B[Record source Evidence]
  B -->|Succeeds| C[Publish result normally]
  B -->|Fails| D[Keep source error]
  D --> E{Enough memory for recovery?}
  E -->|No| F[Report completed result omitted]
  E -->|Yes| G[Authenticate completed result]
  G --> H[Return retained reference or inline result]
  H --> I[Keep cleanup and cancellation facts]
  F --> I
Loading

Reviews (26) · Last reviewed commit: "test(frida): assert inline evidence reco..." · Reviewed by Greptile

Comment thread src/server/ToolResultDelivery.ts Resolved

@mhmdmhmdtahapnahy-star mhmdmhmdtahapnahy-star 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.

  • [ ]

@morluto

morluto commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

A real-Kuna, injected-zero-capacity integration control found an interaction with #8444: after the combined branches complete trace_native_values, failure to publish its source returns the unretained function dossier but loses the completed trace. With #8444 alone, the corresponding capacity failure returns the completed trace. Both full and compact MCP schema profiles reproduced this through production registration; the target was not executed. Details, normal-capacity control, and limitations: #8425 (comment).

This is a source-publication ownership and resource-boundary follow-up; it does not invalidate the normal-capacity source-closure fix. A fix needs to keep the failed source and completed workflow distinct and report actual retention/closure, while honoring headroom and transport bounds.

* fix: preserve completed evidence on retention refusal

* fix: preserve context when unretained evidence exceeds delivery limits

* fix(mcp): recover oversized context from session evidence

* fix(evidence): preserve completed atomic write results
Base automatically changed from codex/evidence-retention-recovery to codex/context-capacity-recovery November 1, 2026 09:23
@morluto
morluto force-pushed the codex/evidence-recovery-redesign branch from 285b5a5 to f7c1679 Compare November 1, 2026 13:01
@morluto
morluto marked this pull request as ready for review November 1, 2026 13:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-08T16:04:53.593628Z 5fb771d 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.

@morluto
morluto enabled auto-merge (squash) November 7, 2026 18:17
@morluto
morluto disabled auto-merge November 8, 2026 17:57
@morluto
morluto enabled auto-merge (squash) November 8, 2026 17:57
@morluto
morluto disabled auto-merge November 8, 2026 18:41
@morluto
morluto merged commit 88cf498 into main Nov 8, 2026
54 checks passed
@morluto
morluto deleted the codex/evidence-recovery-redesign branch November 8, 2026 18:41
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 8, 2026
morluto#8444 passes formatHint to BinarySession.open; on this branch the raw
load refactor carries the format in loadSelection.
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 8, 2026
Main's morluto#8444 tests pass formatHint to BinarySession.open. This branch's
raw load refactor carries the format in loadSelection, so those calls
now pass loadSelection: { format: "dos-com" }.
gensokyo-dev added a commit that referenced this pull request Nov 14, 2026
…ation

Since #8444 the completed observation is projected once at the composed
error's details.partial_observation rather than inside primary_error,
so restore #7319's retained-Evidence assertion there.

Refs #7279

Co-Authored-By: gensokyo-dev <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
N0zoM1z0 pushed a commit that referenced this pull request Nov 14, 2026
…ation

Since #8444 the completed observation is projected once at the composed
error's details.partial_observation rather than inside primary_error,
so restore #7319's retained-Evidence assertion there.

Refs #7279

Co-Authored-By: gensokyo-dev <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2SinceJuly added a commit to 2SinceJuly/rea that referenced this pull request Nov 17, 2026
warcLateCompletionMcp asserted that a cancelled inspect_warc_archive retains
its completed Evidence through toPartialErrorToolResult. Main no longer has
that behavior: 88cf498 (morluto#8444) removed the retention branch and
origin/main has no warc cancellation test at all, while
featureTraceViewsMcp keeps the opposite expectation for the same staging
step. Keeping both made Portable tests hang until the 240s timeout.
The sibling test in featureTraceViewsMcp still covers cancellation
delivery.
@morluto morluto added the bug Something isn't working label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants