[PR #5573] [CLOSED] fix(native): mark Objective-C declarations partial when the budget cuts their methods #6971

Closed
opened 2026-11-01 21:44:24 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5573
Author: @kaoru0822-kitauji
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: fix/objc-method-budget-coverage


📝 Commits (1)

  • 23ec993 fix(native): mark Objective-C declarations partial when the budget cuts their methods

📊 Changes

4 files changed (+92 additions, -30 deletions)

View changed files

📝 src/native/AppleDispatchMetadata.test.ts (+41 -0)
📝 src/native/AppleObjcCategories.ts (+23 -16)
📝 src/native/AppleObjcDispatchFacets.ts (+12 -7)
📝 src/native/AppleObjcProtocols.ts (+16 -7)

📄 Description

Summary

Fixes #5543. When --max-records stopped decoding inside an Objective-C method list, inspect-native-dispatch-metadata still returned the protocol or class with decode: {status: "decoded"} and methods: [], so a truncated list looked like a genuinely empty one. The declaring record now reports partial with reason method_list_record_budget_exhausted. Aggregate truncation warnings are unchanged, and the methods are still returned when the budget admits them.

Problem and expected behavior

The method-list loops in AppleObjcProtocols.ts (protocol methods) and AppleObjcDispatchFacets.ts (class and category methods) break when budget.admit() fails. The declaring record never learned of that, so its decode status stayed decoded. docs/tool-design.md requires unknown coverage to remain distinguishable from absence, and AppleObjcProtocols.ts already marks a declaration partial for a skipped empty selector.

Change and scope

  • Protocol methods() sets a per-record budget.exhausted flag. Class/category methods() returns { selectors, budgetExhausted }.
  • Protocol, class and category records report partial / method_list_record_budget_exhausted when any of their method lists was cut. The recoverable budget reason takes precedence over existing record-local reasons, matching how other limit reasons are reported first.
  • Not included: ivar, property and adopted-protocol lists cut by the same budget. Those facets keep their existing behavior, and only aggregate truncation reports them. That is a possible follow-up, kept out of this PR to keep it focused on the reported method facts.

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

Contract and boundary impact

  • Semantic owner and earliest changed stage: Objective-C metadata decoders in src/native/AppleObjc*.ts.

  • Contribution scope fit and linked maintainer decision: ordinary fix; not applicable.

  • CLI and MCP/tool-catalog contract: no schema change (decode.reason is a nullable string); affected records change from decoded to partial.

  • Provider, bridge, target-format, or platform compatibility: Mach-O Objective-C metadata only.

  • Evidence, artifact, provenance, or reconstruction contract: records now state their own omission; returned methods and evidence unchanged.

  • Target selection, authority, upstream behavior, and cleanup details: not applicable.

  • Generated metadata, package, or installation impact: none.

  • Read existing files or captured data.

  • Launch or attach to a process.

  • Inject instrumentation or run scripts/code.

  • Change process memory, registers, files, or configuration.

  • Contact network services.

  • Recover protected code or work around protections.

  • Documentation or usability only; no target interaction.

  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Test added: src/native/AppleDispatchMetadata.test.ts decodes the synthetic fixture at every budget from 1 to 39. It asserts that every protocol/class record still marked decoded has exactly the full-budget method lists, and that some budgets yield method_list_record_budget_exhausted for both a protocol and a class.

  • Base reproduction: with the three source files stashed, the new test fails.

  • Real CLI repro (the issue's tiny.m, compiled with Apple clang, inspected statically, built CLI):

    --max-records TinyProtocol TinyClass (instance)
    1 0 methods, partial / method_list_record_budget_exhausted not admitted
    2 1 method, decoded not admitted
    3 1 method, decoded 0 methods, partial / method_list_record_budget_exhausted
    4 1 method, decoded 1 method, decoded
    5000 1 method, decoded 1 method, decoded
  • Remaining proof gaps: category records have no budget-cut regression case (the fixture has no categories); they share the class method reader. macOS arm64 only.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- src/native/AppleDispatchMetadata.test.ts tests/boundary/cli/nativeDispatchPropertyAttributes.test.ts tests/boundary/mcp/nativeDispatchAvailability.test.ts: 71 passed
  • npm run test:focused -- src/native/AppleDispatchMetadata.test.ts with the source fix stashed: 1 failed (new test), 52 passed
  • npm run check:fast: passed
  • npm run build:cached, then the issue's five-budget CLI loop above: all exited 0 with the results shown

Compatibility, safety, and release

  • Breaking changes or migration steps: none; budget-cut records now report partial instead of decoded.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS arm64 with Apple clang; no provider involved; fixture never executed.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new reads, processes or side effects.

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.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/5573 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/objc-method-budget-coverage` --- ### 📝 Commits (1) - [`23ec993`](https://github.com/morluto/rea/commit/23ec9931ba07810bbe6b9068c06c98bae2809bfc) fix(native): mark Objective-C declarations partial when the budget cuts their methods ### 📊 Changes **4 files changed** (+92 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `src/native/AppleDispatchMetadata.test.ts` (+41 -0) 📝 `src/native/AppleObjcCategories.ts` (+23 -16) 📝 `src/native/AppleObjcDispatchFacets.ts` (+12 -7) 📝 `src/native/AppleObjcProtocols.ts` (+16 -7) </details> ### 📄 Description ## Summary Fixes #5543. When `--max-records` stopped decoding inside an Objective-C method list, `inspect-native-dispatch-metadata` still returned the protocol or class with `decode: {status: "decoded"}` and `methods: []`, so a truncated list looked like a genuinely empty one. The declaring record now reports `partial` with reason `method_list_record_budget_exhausted`. Aggregate truncation warnings are unchanged, and the methods are still returned when the budget admits them. ## Problem and expected behavior The method-list loops in `AppleObjcProtocols.ts` (protocol methods) and `AppleObjcDispatchFacets.ts` (class and category methods) `break` when `budget.admit()` fails. The declaring record never learned of that, so its decode status stayed `decoded`. `docs/tool-design.md` requires unknown coverage to remain distinguishable from absence, and `AppleObjcProtocols.ts` already marks a declaration partial for a skipped empty selector. ## Change and scope - Protocol `methods()` sets a per-record `budget.exhausted` flag. Class/category `methods()` returns `{ selectors, budgetExhausted }`. - Protocol, class and category records report `partial` / `method_list_record_budget_exhausted` when any of their method lists was cut. The recoverable budget reason takes precedence over existing record-local reasons, matching how other limit reasons are reported first. - Not included: ivar, property and adopted-protocol lists cut by the same budget. Those facets keep their existing behavior, and only aggregate truncation reports them. That is a possible follow-up, kept out of this PR to keep it focused on the reported method facts. Contribution scope: ordinary fix within existing boundaries; maintainer scope decision not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: Objective-C metadata decoders in `src/native/AppleObjc*.ts`. - Contribution scope fit and linked maintainer decision: ordinary fix; not applicable. - CLI and MCP/tool-catalog contract: no schema change (`decode.reason` is a nullable string); affected records change from `decoded` to `partial`. - Provider, bridge, target-format, or platform compatibility: Mach-O Objective-C metadata only. - Evidence, artifact, provenance, or reconstruction contract: records now state their own omission; returned methods and evidence unchanged. - Target selection, authority, upstream behavior, and cleanup details: not applicable. - Generated metadata, package, or installation impact: none. - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Test added: `src/native/AppleDispatchMetadata.test.ts` decodes the synthetic fixture at every budget from 1 to 39. It asserts that every protocol/class record still marked `decoded` has exactly the full-budget method lists, and that some budgets yield `method_list_record_budget_exhausted` for both a protocol and a class. - Base reproduction: with the three source files stashed, the new test fails. - Real CLI repro (the issue's `tiny.m`, compiled with Apple clang, inspected statically, built CLI): | `--max-records` | TinyProtocol | TinyClass (instance) | |---|---|---| | 1 | 0 methods, `partial` / `method_list_record_budget_exhausted` | not admitted | | 2 | 1 method, `decoded` | not admitted | | 3 | 1 method, `decoded` | 0 methods, `partial` / `method_list_record_budget_exhausted` | | 4 | 1 method, `decoded` | 1 method, `decoded` | | 5000 | 1 method, `decoded` | 1 method, `decoded` | - Remaining proof gaps: category records have no budget-cut regression case (the fixture has no categories); they share the class method reader. macOS arm64 only. - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:focused -- src/native/AppleDispatchMetadata.test.ts tests/boundary/cli/nativeDispatchPropertyAttributes.test.ts tests/boundary/mcp/nativeDispatchAvailability.test.ts`: 71 passed - `npm run test:focused -- src/native/AppleDispatchMetadata.test.ts` with the source fix stashed: 1 failed (new test), 52 passed - `npm run check:fast`: passed - `npm run build:cached`, then the issue's five-budget CLI loop above: all exited 0 with the results shown ## Compatibility, safety, and release - Breaking changes or migration steps: none; budget-cut records now report `partial` instead of `decoded`. - Real Hopper/Ghidra, browser, or OS coverage: macOS arm64 with Apple clang; no provider involved; fixture never executed. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no new reads, processes or side effects. ## Author readiness Human owner: <!-- @GitHub-handle --> - [ ] 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. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:44:24 +00:00
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#6971
No description provided.