[PR #7159] [MERGED] feat(native): make function matching allowance configurable #7684

Closed
opened 2026-11-03 13:39:38 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/7159
Author: @gensokyo-dev
Created: 10/25/2026
Status: ✅ Merged
Merged: 10/25/2026
Merged by: @gensokyo-dev

Base: main ← Head: feat/6406-native-matching-allowance


📝 Commits (5)

  • 9129030 feat(native): make the function-matching allowance a runtime setting
  • 94d9e3b refactor(native): keep matching allowance recovery with its parser
  • abcb1b2 test(native): verify configurable matching with real LLVM inventories
  • 6e9dc45 fix(config): expose native matching session repair
  • da30246 fix(native): reuse matching allowance owner in settings inspection

📊 Changes

27 files changed (+1511 additions, -27 deletions)

View changed files

📝 .agents/skills/reverse-engineer-anything/references/native-and-artifacts.md (+7 -0)
📝 docs/design/limits-and-recovery.md (+3 -0)
📝 docs/native-function-matching.md (+17 -4)
➕ experiments/analysis-efficiency/native-inventory-capture.mjs (+276 -0)
➕ experiments/analysis-efficiency/native-inventory-profile.json (+34 -0)
➕ experiments/analysis-efficiency/native-matching-capacity.md (+177 -0)
➕ experiments/analysis-efficiency/native-matching-capacity.mjs (+413 -0)
➕ experiments/analysis-efficiency/native-matching-elf-oracle.py (+23 -0)
📝 src/application/SetupRegistrationEnvironment.ts (+1 -0)
📝 src/application/native/NativeFunctionMatchingService.test.ts (+64 -0)
📝 src/application/native/NativeFunctionMatchingService.ts (+18 -4)
📝 src/application/native/NativeMatchingAdmission.ts (+32 -12)
📝 src/cli.ts (+1 -1)
📝 src/cli/nativeFunctionMatchingCommands.ts (+5 -1)
📝 src/config/analysisSettings.ts (+7 -0)
➕ src/config/nativeMatchingAllowance.test.ts (+108 -0)
➕ src/config/nativeMatchingAllowance.ts (+79 -0)
📝 src/config/runtimeAnalysisSettings.ts (+22 -0)
📝 src/domain/analysisErrorPresentation.ts (+7 -2)
📝 src/domain/analysisErrorProjection.test.ts (+25 -1)

...and 7 more files

📄 Description

Summary

match_native_functions could refuse ordinary large inventories at a fixed 96 MiB allowance with no override. Add the curated native.matching_representation_bytes runtime setting and REA_NATIVE_MATCHING_REPRESENTATION_BYTES launch seed: default 96 MiB, range 1 byte–1 GiB, effective on the next operation. Refusals preserve retryable: false and now include the effective limit, source, bounds and recovery. Invalid seeds affect matching only; an MCP runtime value repairs them. Setup forwards the selected seed.

Both adapters use the same admission owner and snapshot the allowance once per operation. Main's #7108 accounting is retained, including borrowing validated inventories and charging common provenance once. Matching semantics, default capacity and source Evidence identity remain unchanged. This adds no provider, execution authority or target mutation; a maintainer scope decision is not applicable.

Fixes #6406. Based on #7112 by @Kaoru0822; both original commits retain their authorship and Claude Opus 5.5 co-author credit. This integration resolves current-main conflicts and supplies the missing real-provider verification.

Verification

  • Final-head GitHub CI passed: static checks, source tests, all eight test shards, documentation/build/package lanes, SQLite compatibility, real binary-layout/crash/network lanes, Portable tests and CI required. Both actionable automated review threads are fixed and resolved. Human readiness remains unchecked as authorized below.
  • check:fast, formatting, cached build and docs:check passed (including nine documentation consistency cases).
  • 29 source cases pass, including parser bounds, operation-local invalid configuration, runtime precedence, original borrowed/shared-provenance accounting, cancellation and pre-parse capacity refusal.
  • After review, 74 configuration/error-projection regressions pass, including unchanged ordinary configuration recovery and the concrete live repair hint. Both recovery regressions failed before their owner fixes; settings inspection now reuses the matching parser and preserves its complete error.
  • Four real stdio MCP acceptance cases pass again after both fixes, including lower/reset/launch seed/invalid-seed repair, inspection and repaired snapshots, and advertised settings contracts.
  • Synthetic Ghidra-shaped inventories: CLI and MCP match all 20k/50k rows per side at 512 MiB, checking every source member and complete export. Original main CLI refuses both; the 50k retained MCP request is refused at default then succeeds unchanged after updating the setting. Original matching Evidence IDs agree across adapters and successful budget changes.
  • Real stripped LLVM 14/15, Ghidra 12.1.4/JDK 21.0.12.1: 43,643 / 45,230 real procedure observations produce identical CLI/MCP complete matching Evidence, with 34,008 exact-symbol correspondences and every source row preserved. Independent GNU nm corroborates 32,935 raw dynamic names; the remaining qualified/provider names are recorded separately. No byte/behavioral equivalence or complete discovery is claimed.
Completed matching harness Elapsed s CPU s Sampled family peak GiB
CLI synthetic 20k / side 27.55 31.04 1.02
CLI synthetic 50k / side 63.61 70.37 1.53
MCP synthetic 20k / side 25.89 30.77 1.77
MCP synthetic 50k / side 71.74 81.87 2.31
CLI real LLVM pair 74.04 79.28 1.36
MCP real LLVM pair 56.04 62.63 2.11

Whole harnesses include loading, client/catalog work, complete publication and offline verification. MCP also includes the default attempt, setting update, repeated matches and selected pages; these are not adapter speed comparisons. Separate cold captures cost 280.14/278.39 s elapsed and 366.63/358.03 s CPU, with at most 3.11 GiB family RSS. Their explicit 29-disabled-analyzer profile keeps ASCII Strings enabled and does not establish default-analysis/full-body coverage. All cases use two CPU affinity slots and an 8 GiB family guard; no OOM or cleanup failure occurred. The allowance is a representation policy, not an RSS limit.

Reproduction, full-task tokenizer estimates (including every discovery and continuation), capture/failed-attempt costs and limitations are in experiments/analysis-efficiency/native-matching-capacity.md and its drivers. Catalog discovery dominates serialized MCP token estimates; actual model usage is unmeasured and no speed/token reduction is claimed. The 1 GiB extreme is parser-tested, not a measured host-capacity guarantee.

Author readiness

Human owner: @gensokyo-dev

  • 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.

The repository owner authorized proceeding with these declarations unchecked and bypassing the readiness gate; no human-review attestation is made.


🔄 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/7159 **Author:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Base:** `main` ← **Head:** `feat/6406-native-matching-allowance` --- ### 📝 Commits (5) - [`9129030`](https://github.com/morluto/rea/commit/9129030a2d773f07ded5c51b11e003a7e6209f5d) feat(native): make the function-matching allowance a runtime setting - [`94d9e3b`](https://github.com/morluto/rea/commit/94d9e3b24f50d070a4c9761f7109460e60b34ab3) refactor(native): keep matching allowance recovery with its parser - [`abcb1b2`](https://github.com/morluto/rea/commit/abcb1b2cd33dd272fd47c797d49c8808959fda76) test(native): verify configurable matching with real LLVM inventories - [`6e9dc45`](https://github.com/morluto/rea/commit/6e9dc4534bc123321d9002bbf0971ba26b7b3c3f) fix(config): expose native matching session repair - [`da30246`](https://github.com/morluto/rea/commit/da302466d5112d357e5680fde5cd6076baa0fe47) fix(native): reuse matching allowance owner in settings inspection ### 📊 Changes **27 files changed** (+1511 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `.agents/skills/reverse-engineer-anything/references/native-and-artifacts.md` (+7 -0) 📝 `docs/design/limits-and-recovery.md` (+3 -0) 📝 `docs/native-function-matching.md` (+17 -4) ➕ `experiments/analysis-efficiency/native-inventory-capture.mjs` (+276 -0) ➕ `experiments/analysis-efficiency/native-inventory-profile.json` (+34 -0) ➕ `experiments/analysis-efficiency/native-matching-capacity.md` (+177 -0) ➕ `experiments/analysis-efficiency/native-matching-capacity.mjs` (+413 -0) ➕ `experiments/analysis-efficiency/native-matching-elf-oracle.py` (+23 -0) 📝 `src/application/SetupRegistrationEnvironment.ts` (+1 -0) 📝 `src/application/native/NativeFunctionMatchingService.test.ts` (+64 -0) 📝 `src/application/native/NativeFunctionMatchingService.ts` (+18 -4) 📝 `src/application/native/NativeMatchingAdmission.ts` (+32 -12) 📝 `src/cli.ts` (+1 -1) 📝 `src/cli/nativeFunctionMatchingCommands.ts` (+5 -1) 📝 `src/config/analysisSettings.ts` (+7 -0) ➕ `src/config/nativeMatchingAllowance.test.ts` (+108 -0) ➕ `src/config/nativeMatchingAllowance.ts` (+79 -0) 📝 `src/config/runtimeAnalysisSettings.ts` (+22 -0) 📝 `src/domain/analysisErrorPresentation.ts` (+7 -2) 📝 `src/domain/analysisErrorProjection.test.ts` (+25 -1) _...and 7 more files_ </details> ### 📄 Description ## Summary `match_native_functions` could refuse ordinary large inventories at a fixed 96 MiB allowance with no override. Add the curated `native.matching_representation_bytes` runtime setting and `REA_NATIVE_MATCHING_REPRESENTATION_BYTES` launch seed: default 96 MiB, range 1 byte–1 GiB, effective on the next operation. Refusals preserve `retryable: false` and now include the effective limit, source, bounds and recovery. Invalid seeds affect matching only; an MCP runtime value repairs them. Setup forwards the selected seed. Both adapters use the same admission owner and snapshot the allowance once per operation. Main's #7108 accounting is retained, including borrowing validated inventories and charging common provenance once. Matching semantics, default capacity and source Evidence identity remain unchanged. This adds no provider, execution authority or target mutation; a maintainer scope decision is not applicable. Fixes #6406. Based on [#7112](https://github.com/morluto/rea/pull/7112) by @Kaoru0822; both original commits retain their authorship and Claude Opus 5.5 co-author credit. This integration resolves current-main conflicts and supplies the missing real-provider verification. ## Verification - Final-head GitHub CI passed: static checks, source tests, all eight test shards, documentation/build/package lanes, SQLite compatibility, real binary-layout/crash/network lanes, Portable tests and CI required. Both actionable automated review threads are fixed and resolved. Human readiness remains unchecked as authorized below. - `check:fast`, formatting, cached build and `docs:check` passed (including nine documentation consistency cases). - 29 source cases pass, including parser bounds, operation-local invalid configuration, runtime precedence, original borrowed/shared-provenance accounting, cancellation and pre-parse capacity refusal. - After review, 74 configuration/error-projection regressions pass, including unchanged ordinary configuration recovery and the concrete live repair hint. Both recovery regressions failed before their owner fixes; settings inspection now reuses the matching parser and preserves its complete error. - Four real stdio MCP acceptance cases pass again after both fixes, including lower/reset/launch seed/invalid-seed repair, inspection and repaired snapshots, and advertised settings contracts. - Synthetic Ghidra-shaped inventories: CLI and MCP match all 20k/50k rows per side at 512 MiB, checking every source member and complete export. Original main CLI refuses both; the 50k retained MCP request is refused at default then succeeds unchanged after updating the setting. Original matching Evidence IDs agree across adapters and successful budget changes. - Real stripped LLVM 14/15, Ghidra 12.1.4/JDK 21.0.12.1: 43,643 / 45,230 real procedure observations produce identical CLI/MCP complete matching Evidence, with 34,008 exact-symbol correspondences and every source row preserved. Independent GNU `nm` corroborates 32,935 raw dynamic names; the remaining qualified/provider names are recorded separately. No byte/behavioral equivalence or complete discovery is claimed. | Completed matching harness | Elapsed s | CPU s | Sampled family peak GiB | | --- | ---: | ---: | ---: | | CLI synthetic 20k / side | 27.55 | 31.04 | 1.02 | | CLI synthetic 50k / side | 63.61 | 70.37 | 1.53 | | MCP synthetic 20k / side | 25.89 | 30.77 | 1.77 | | MCP synthetic 50k / side | 71.74 | 81.87 | 2.31 | | CLI real LLVM pair | 74.04 | 79.28 | 1.36 | | MCP real LLVM pair | 56.04 | 62.63 | 2.11 | Whole harnesses include loading, client/catalog work, complete publication and offline verification. MCP also includes the default attempt, setting update, repeated matches and selected pages; these are not adapter speed comparisons. Separate cold captures cost 280.14/278.39 s elapsed and 366.63/358.03 s CPU, with at most 3.11 GiB family RSS. Their explicit 29-disabled-analyzer profile keeps ASCII Strings enabled and does not establish default-analysis/full-body coverage. All cases use two CPU affinity slots and an 8 GiB family guard; no OOM or cleanup failure occurred. The allowance is a representation policy, not an RSS limit. Reproduction, full-task tokenizer estimates (including every discovery and continuation), capture/failed-attempt costs and limitations are in `experiments/analysis-efficiency/native-matching-capacity.md` and its drivers. Catalog discovery dominates serialized MCP token estimates; actual model usage is unmeasured and no speed/token reduction is claimed. The 1 GiB extreme is parser-tested, not a measured host-capacity guarantee. ## Author readiness Human owner: @gensokyo-dev - [ ] 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. The repository owner authorized proceeding with these declarations unchecked and bypassing the readiness gate; no human-review attestation is made. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 13:39:38 +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#7684
No description provided.