Skip to content

fix!: preserve address context resource recovery - #8424

Merged
morluto merged 9 commits into
mainfrom
codex/context-capacity-recovery
Nov 7, 2026
Merged

morluto merged 9 commits into
mainfrom
codex/context-capacity-recovery

Conversation

@morluto

@morluto morluto commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

When an inspect_address_context facet reaches the investigation's Evidence retention limit, it currently advises calling the operation directly. That call can hit the same limit, while the actionable capacity recovery and reported limits are lost. Preserve the canonical resource_constraint error and its recovery on the unavailable facet, alongside any successful siblings and their retained records.

Addresses #8421. The earlier parent changes #8417 and #8419 are merged. This branch also incorporates the authenticated-but-unretained observation work from #8426; #8444 remains a separate follow-up stacked on this branch. Aggregate Evidence handoff remains #8364.

For example, a procedure facet now returns error.code: "resource_constraint", the reported retention limits, and the existing export/new-investigation or larger-heap guidance. Other errors retain their current behavior, and incomplete cleanup remains a top-level failure.

Compatibility and size

Breaking for strict clients caching the earlier full MCP schema: it only accepts invalid_request in a facet's error; refresh tools/list to accept resource_constraint. The real result was rejected by the prior full schema, accepted by the prior compact schema, and accepted by both newly advertised profiles. No compatibility shim is introduced.

On one real Ghidra case, minified structured context increased from 206 to 334 o200k_base tokens. The inspect_address_context tool definition increased from 227 to 231 tokens in compact mode and 954 to 1,172 in full mode. These are local JSON counts, not latency, CPU, memory, or autonomous-agent measurements. Large diagnostic and response-budget behavior remains unverified.

Validation

  • Hosted static checks failed on the unrelated main formatting defect fixed by style(test): format CLI help default annotations #9280. The branch now includes that fix, and Node 24 npm run format:check passed; new hosted checks are pending.

  • After merging main 0ecf3a4cbf, Node 24.22.1 focused Vitest runs passed 61 tests: four capacity, overflow and retention suites (15), plus direct cleanup and Ghidra Evidence MCP suites (46). The earlier CI shard failure was the stale Ghidra Evidence wording assertion fixed on main. No full CI or real-provider run was performed after this merge.

  • The following observations and checks were performed on earlier revisions, not the merged head:

  • Review follow-up (c99ab7ee21): one-shot failures now bind the exact caller-selected path to authenticated Evidence inside an unretained-evidence wrapper. A production-session capacity regression failed on the prior head and passed after the fix. directAnalysisCleanup.test.ts and evidenceRetentionRecovery.test.ts passed (39 tests); npm run typecheck and targeted lint passed (lint reported one existing warning). No real-provider capacity run was performed for this follow-up.

  • Real Ghidra 12.1.4 on macOS arm64, JDK 21: the real MCP server and SDK used an in-memory transport and production BinarySession with an injected 20,000-byte Evidence allowance. A name facet and its record survived; the procedure facet returned the same typed capacity error and recovery as the direct call. Both advertised schema profiles passed, with an unexecuted arm64 Mach-O whose digest was unchanged. A default-allowance control returned available name and procedure facets. This does not reproduce exhaustion of the default production allowance.

  • Real Kuna 1.986 zero-allowance control: context returned the name with no retained Evidence; a subsequent direct name call returned resource_constraint. This does not exercise the new facet error path and illustrates the separate live-provider handoff gap in [Design] Preserve contributing evidence for address-context handoffs #8364.

  • Production-session MCP regression with a controlled provider and limited real Evidence ledger: 2 tests passed under full and compact profiles; both failed on the parent because they returned generic direct-call advice. Successful sibling and retained record are asserted.

  • npm run test:focused -- tests/boundary/mcp/addressContextCapacity.test.ts tests/boundary/mcp/addressContextInputErrors.test.ts tests/boundary/mcp/addressContextBookmarks.test.ts — 17 passed after rebasing.

  • npm run check:fast — passed after rebasing. npm run docs:check, formatting and git diff --check — passed; the rebase only added a parent test-only change.

  • Ajv 2020 checked actual fetched old and new schema profiles against the real-Ghidra result and rejected a deliberately wrong error code in the new full profile; compact remains intentionally broad.

The new resource-error facet path was not exercised with Kuna. Windows, real cleanup failure, autonomous agents, and unusually large diagnostics were not exercised. No provider replay policy is changed.

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.

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.

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 changes appear safe to merge, with no outstanding findings.

Summary

Preserves resource_constraint errors and recovery guidance in inspect_address_context facets. Authenticated records that cannot be retained remain available inline when they fit the reply.

  • Address context keeps capacity errors beside the affected facet.
  • Capacity refusals carry authenticated results and their session status.
  • MCP replies trim unretained Evidence only when a response is too large.
  • The CLI help test keeps the same checks with clearer line wrapping.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Inspect address facets] --> B{Record fits retention allowance?}
  B -->|Yes| C[Keep successful facet and retained record]
  B -->|No| D[Keep resource error and unretained record]
  C --> E{Context reply fits delivery limit?}
  D --> E
  E -->|Yes| F[Return context]
  E -->|No| G[Omit unretained records in estimated size order]
  G --> H{Smaller reply fits?}
  H -->|Yes| F
  H -->|No| I[Return delivery error and recovery guidance]
Loading

Reviews (6) · Last reviewed commit: "style(test): format CLI help default ann..." · Reviewed by Greptile

@morluto
morluto marked this pull request as ready for review November 1, 2026 03:55
@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-07T14:46:11.434430Z 65a2d03 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.

* 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/context-input-errors to main November 1, 2026 16:52
morluto and others added 3 commits November 7, 2026 15:30
Facet refusals still carry resource_constraint recovery and unretained
Evidence, while caller lifetime, capability guidance, and evidence-bundle
overflow steps from main stay in the same projection.
@morluto
morluto merged commit 106ba17 into main Nov 7, 2026
16 of 18 checks passed
@morluto
morluto deleted the codex/context-capacity-recovery branch November 7, 2026 15:34
@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.

2 participants