Repository navigation
fix: expose authenticated records refused by the evidence ledger - #8426
Merged
morluto merged 4 commits intoNov 1, 2026
Merged
Conversation
This was referenced Nov 1, 2026
Contributor
[Medium impact] The reviewed changes appear safe to merge within the stated scope. SummaryReturns authenticated Evidence inline when retention fails. The latest change extends this recovery to atomic Evidence-and-Unknown writes and returns a saved ID when the Evidence already exists.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Completed Evidence and proposed unknown"] --> B["Authenticate records and check links"]
B -->|Invalid| C["Return error without a partial"]
B -->|Valid| D{"Retention fits?"}
D -->|Yes| E["Commit the complete write"]
D -->|No| F{"Evidence already saved?"}
F -->|Yes| G["Return capacity error with saved ID"]
F -->|No| H{"Inline record fits MCP?"}
H -->|Yes| I["Return capacity error with Evidence"]
H -->|No| J["Return omission details or delivery recovery"]
Reviews (4) · Last reviewed commit: "fix(evidence): preserve completed atomic..." · Reviewed by Greptile |
3 tasks done
This was referenced Nov 1, 2026
morluto
marked this pull request as ready for review
November 1, 2026 03:55
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
3 tasks
morluto
added a commit
that referenced
this pull request
Nov 7, 2026
* fix: retain address context cleanup failures * fix!: preserve address context input errors 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. * test: use session contract for address context * fix!: preserve address context resource recovery BREAKING CHANGE: Clients validating unavailable context facets against a cached strict full output schema must refresh tools/list to accept resource_constraint errors. * fix: expose authenticated records refused by the evidence ledger (#8426) * 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 * fix(cli): preserve caller path in unretained evidence * style(test): format CLI help default annotations (#9280) --------- Co-authored-by: Cursor Agent <[email protected]>
morluto
added a commit
that referenced
this pull request
Nov 8, 2026
* fix: retain address context cleanup failures * fix!: preserve address context input errors 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. * test: use session contract for address context * fix!: preserve address context resource recovery BREAKING CHANGE: Clients validating unavailable context facets against a cached strict full output schema must refresh tools/list to accept resource_constraint errors. * fix: expose authenticated records refused by the evidence ledger (#8426) * 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 * fix: retain completed results when source publication fails * test: cover bounded recovery with unknown retention * fix(evidence): preserve recovery identity and finalization facts * fix(evidence): clarify retention of omitted observations * test(evidence): compare omission guidance with its owner * fix(evidence): preserve completed composed workflows * fix(evidence): clarify unretained recovery export * test(evidence): cover mixed recovery guidance * fix(evidence): preserve caller scope in secondary failures * refactor(evidence): remove superseded cleanup projection * test(evidence): align recovery checks with owners * fix: preserve cleanup on partial recovery limits * test: use owners for diagnostic wording * fix: admit completed analysis before evidence construction * fix: preserve selected paths when reusing evidence * fix(cli): preserve caller path in unretained evidence * fix(evidence): preserve recovery metadata and admission bounds * refactor: consolidate evidence closure imports * style(test): format CLI help default annotations (#9280) * test(mcp): keep recovery checks focused on contract facts * fix(evidence): preserve feature trace replay revision * test: align evidence recovery checks with ownership * test: align partial recovery and cleanup diagnostics * fix(evidence): preserve nested partials during cleanup * fix(evidence): respect outer recovery ownership * fix(capture): discard rejected nested observations * test(frida): assert inline evidence recovery --------- Co-authored-by: Cursor Agent <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A provider can complete a direct operation, then REA's Evidence ledger can refuse the record because its retained-representation allowance is full. Today the caller receives only the capacity error and loses the completed observation. Return an authenticated record inline as
details.partial_observation: {kind: "unretained-evidence", evidence: ...}when retention admission fails. The error remains a failure, and the ID is not a session reference.Partially addresses #8425; a source-record admission failure can still discard the completed primary observation, as described below. This draft is stacked on #8424, which is stacked on #8419 and #8417; integrate those parents first. It does not implement the composed Evidence handoff in #8364.
The ledger attaches a record only after authentication succeeds and before failed admission could mutate the ledger. This also covers a capacity refusal of an atomic derived-Evidence and Unknown write: if the Evidence already exists, the error returns its retained reference; otherwise it returns the authenticated record inline. The refused write commits neither new Evidence nor an Unknown revision. Authentication or headroom failures do not claim an authenticated record. If the inline observation cannot fit within MCP delivery limits, the original retention error instead reports
partial_observation_omittedand its response constraint when the remaining error fits. The oversized-error fallback excludes a second unretained partial from its nested retention error so it cannot recursively overflow. For an oversized context reply, REA omits unretained facet observations in estimated size order until the reply fits, marks each omission, and keeps successful facets and smaller partials. If the remaining context still cannot fit, recovery directs the caller to discover and export retained Evidence through session tools, while stating that some facets may not have been retained. No uncommittedretained-evidencereference is offered.Validation
050362143, a controlled SDK MCP handoff with synthetic function dossiers exported the retained bundle after atomic refusal, closed the session, and imported it into a fresh target-free session. An already-retained comparison worked by reference withfind_changed_behavior. An unretained comparison was rejected by reference, then worked inline with its retained sources; both the default input-element allowance and an explicitREA_MCP_MAX_INPUT_ELEMENTS=65536worked for this fixture. Two cases passed under each setting; larger inline records may still exceed the limit. No provider was launched.050362143: 13 focused MCP tests passed, including four comparison/atomic-capacity cases across compact and full output profiles, with and without the same comparison preexisting; the earlier unretained-result regression failed on the prior head in both profiles. The error projection validates, retained source records remain available, and no Unknown revision is committed. 100 source tests,check:fast,docs:checkandgit diff --checkpassed.address_namereturned_main; the caller received the same provider/profile/limitations as inline unretained Evidence and the ledger remained empty. A normal-allowance control returned and retained the direct Evidence.458674fba: 13 focused MCP tests andcheck:fastpassed. The session-only catalog advertises neither directaddress_namenor other direct calls; the recovery test follows the advertised summary and export tools, checks the complete oversized record when retained, and verifies the empty result when no profile permitted retention. The prior guidance fails this test.npm run check:fast,npm run docs:check, formatting andgit diff --checkpassed. Ajv 2020 accepted the real Ghidra context result against both parent-advertised output profiles; the error details schema permits the additional observation.Limits and tradeoffs
When admission fails for a provider source before the primary Evidence is recorded, the inline partial is the source and the completed primary result can still be lost. In a real selected-project Ghidra test with synthetic project-history metadata and an injected zero-byte allowance, the provider resolved
audit_checkpoint_evaluatewhile the response contained only the unretainedhealthsource. A normal-allowance control retained both; REA did not modify the test project or execute the target. A synthetic-provider test also showed that a source and primary may have the same operation and parameters, so those fields cannot establish the partial's role. In a separate synthetic three-source MCP test, the first source was retained, the second refused, and the third unattempted; a retry failed again at the second without duplicating the first. This source-stage gap remains in #8425 and has implications for #8364.A controlled context test on this head also combined a source-retention refusal with a separate facet cleanup failure: the aggregate preserved the cleanup owner but lost the refused source partial. The unpublished completed-primary prototype still lost both the source and primary in that sequence. This used a simulated provider and injected zero-byte allowance; it is not a real-provider cleanup reproduction. See the issue comment.
A public
compare_functionsMCP control also reproduced completed-result loss at a separate composed-workflow boundary: with a zero-byte injected allowance and two synthetic inline dossiers, the producer computed the comparison, but source recording returned the refused input dossier and discarded the comparison. At normal capacity the same input returned the identical computed comparison and retained both sources. This is not a real-provider or default-capacity reproduction. See the issue comment. A fix limited toBinarySessionwould not cover this path. Before the atomic follow-up, another controlled case retained both sources but lost the comparison when the comparison-and-Unknown write was refused. The current change preserves that authenticated result, without claiming that an uncommitted Unknown was saved.The fix applies to single-record and atomic Evidence/Unknown capacity admission after authentication. It does not cover bundle import, failures before authentication or capacity admission, another recorder's failures, SDK-suppressed cancellation replies, or aggregate handoff. A complete inline unretained record has no dedicated public record-import workflow; #8427 discusses fresh-session handoff without manually assembling a canonical bundle. An observation too large for MCP remains unretained and is explicitly reported as omitted. Context omission uses estimated representation size for ordering, so unusual escaping can cause more records to be omitted than an optimal wire-size ordering; at most five facet alternatives are tried. If the remaining context or reduced error is still too large, the applicable delivery recovery applies. Windows, real cleanup failures, default-heap exhaustion, autonomous agents and process-family CPU/memory impact are unverified.
For the single real fixtures, minified
o200k_basepayloads grew from 130 to 730 tokens for the Kuna direct error and 334 to 1,309 for the Ghidra context result. These are JSON counts, not latency, CPU, memory, or agent-task measurements; full Evidence is carried inline when it fits.A warm test-suite measurement of the same four controlled overflow cases sampled 7.65 seconds, at least 9.83 CPU seconds and 1,867,664 KiB summed process-family RSS with the full catalog; limiting that focused test to the session catalog sampled 3.90 seconds, at least 5.09 CPU seconds and 1,263,776 KiB. One run each included npm, Turbo, Vitest startup and all four cases; sampled RSS includes shared pages and CPU may miss short-lived processes. A marker field name changed between runs, and cold runs and provider costs were not measured. The two-large structured response was 1,121
o200k_basetokens, excluding the tool catalog. These are test-harness observations, not production or agent-task benchmarks.Author readiness
Human owner:
Before merge
type(scope): outcome.