[PR #6943] [MERGED] feat(erlang): query selected BEAM table facts #7464

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

📋 Pull Request Information

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

Base: main ← Head: perf/6938-beam-selected-views-20261024


📝 Commits (3)

  • bcc3f76 feat(erlang): query selected BEAM table facts
  • 5d379b1 docs(perf): record BEAM selected-view measurements
  • fb382a9 chore: integrate current main before BEAM qualification

📊 Changes

20 files changed (+4206 additions, -66 deletions)

View changed files

📝 .agents/skills/reverse-engineer-anything/SKILL.md (+4 -2)
📝 .agents/skills/reverse-engineer-anything/references/native-and-artifacts.md (+5 -1)
📝 docs/erlang-beam.md (+59 -0)
➕ experiments/analysis-efficiency/erlang-beam-costs.py (+111 -0)
➕ experiments/analysis-efficiency/erlang-beam-oracle.py (+108 -0)
➕ experiments/analysis-efficiency/erlang-beam-sdk-cache.json (+534 -0)
➕ experiments/analysis-efficiency/erlang-beam-views.json (+2118 -0)
➕ experiments/analysis-efficiency/erlang-beam-views.md (+125 -0)
➕ experiments/analysis-efficiency/erlang-beam-views.mjs (+255 -0)
📝 src/cli/erlangCommands.ts (+50 -29)
📝 src/contracts/analysisViewToolContracts.ts (+1 -1)
📝 src/contracts/erlang/beamToolContracts.ts (+43 -7)
➕ src/contracts/erlangBeamDeliveryContracts.test.ts (+88 -0)
📝 src/domain/analysisView/analysisView.ts (+25 -0)
➕ src/domain/analysisView/erlangBeamView.ts (+236 -0)
📝 src/server/createServer.ts (+1 -0)
📝 src/server/registerErlangTools.ts (+38 -5)
➕ tests/acceptance/applications/erlangBeamViews.test.ts (+334 -0)
📝 tests/acceptance/erlangBeamCli.test.ts (+14 -20)
📝 tests/boundary/mcp/erlangBeamMcp.test.ts (+57 -1)

📄 Description

Summary

Fixes #6938. Return selected BEAM facts in the initial inspection and page the same complete retained Evidence later. Complete output remains the default.

Problem and expected behavior

Reading four exports from real erl_lint previously returned about 147 KB of unrelated atom/import/lambda facts. detail: "summary", view: {kind: "beam", collection: "exports", names: [...], fields: [...]} now returns those rows immediately. Atoms, imports, lambdas and chunks support the same query shape; import modules intersects function names.

Change and scope

The domain projector queries the existing reader's typed facts. It reuses the schema-specific immutable-result reader, shared application retention/publication and CLI delivery parser. Same-name exports retain every arity and original atom indexes; parent+collection+source_index identifies each row. Parsing and format budgets are unchanged. Maintainer target-execution/injection/mutation scope decision: not applicable to this existing static/Evidence-publication workflow.

Contract and boundary impact

  • CLI/MCP: additive opt-in detail/view; exact field enums per collection, filters and matching-row pages. Complete delivery rejects a supplied view. Named contracts and converted draft2020-12/draft07 inputs agree.
  • Evidence: complete source remains retained/exportable; source coverage, byte ranges/digests, null missing-table counts, empty decoded tables and unresolved names survive. Retained/offline queries work after deleting the original file.
  • Compatibility: existing complete calls and parent/source IDs remain equivalent. New-view real qualification covers OTP27 on Linux; existing legacy/compact reader controls also pass. Other real platforms/versions are unverified here.
  • Docs and authored skill guidance updated; generated metadata regenerated/checked and left uncommitted. No package, installer or configuration changes.

Expected effects:

  • 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. (Only caller-selected complete Evidence publication through the existing workflow.)
  • Contact network services.
  • Recover protected code or work around protections.

Evidence and regression coverage

Executed 18 alternating fresh production stdio tasks on unmodified public Debian OTP27 erl_lint/erl_parse/pg2, with independent Python struct decoding of every table, chunk range/hash and Code header. Both complete/selected lanes answer the same question and export/check the complete source. All answer, parent-ID and source digests agree. Six additional cached-catalog/default-SDK-validator tasks pass separately.

Whole-task token estimates (question, instructions, all 221 input-tool definitions once, every argument/text reply including export): 76,907→58,090 (−24.5%), 72,499→58,087 (−19.9%), small pg2 57,733→58,018 (+0.5%). tiktoken 0.14.0/cl100k_base; actual model usage/inference quality unmeasured. Directory cost grows 55,409→56,359; raw catalog including output schemas grows 829,075→834,792 and is reported separately. No stable general wall/CPU/memory improvement established; small selected tasks have a higher wall/CPU median. Pinned measurements, ranges, commands and receipt hashes.

Public regressions cover all collections, arities/row identity, empty/intersecting selectors, fields/pages, null versus empty tables, unresolved references, source deletion/offline bundles and refusal before reading when retention/delivery is unavailable. Example pg2 export rows retain function_index:2, function:"module_info" with both arities 1/0 and distinct original row indexes.

Validation performed

After integrating main cd10ee1f8:

  • Five affected source suites: 74 passed (BEAM reader/service, delivery schema conversion, shared view and snapshot reader).
  • Public BEAM CLI, MCP and view suites: 17 passed.
  • Serialized typecheck/lint/format/knip/metadata with compile dependency; architecture guards; generated docs check with 9 README tests passed.
  • Current-tree real qualification: three additional stdio/export tasks plus complete/selected CLI calls on all three artifacts, checking every oracle fact and identical parent/source/answer digests. This qualifies integration; the repeated performance table retains its original revision pins.
  • npm run check:fast: passed. Codex review completed on exact head fb382a9d54, with no major issues and no inline findings.
  • CI 40058317023 failed on 12 native-plist cases; a clean exact-main d662fa54 control reproduces all 12 identities/multiplicities (12 failed/30 passed). Source 17,223 passed/13 skipped, static/build/docs/quality and all 17 BEAM public cases plus 3 filesystem cases passed. Several other shards were canceled; broad coverage is incomplete. The qualification comment records message-matching limits and the authorized baseline bypass.
  • One aggregate CPU, 3 GiB early stop/4 GiB hard cap, no swap. All measured/qualification tasks verify payload exit/cleanup without guard stop/OOM. Final integration check peak 2.66 GiB; final whole-scope counters unavailable. Failed development attempts remain recorded separately.

Compatibility, safety, and release

Additive selection; whole-source parsing and retention costs remain. Missing structural tables do not establish runtime absence. No Erlang installation/emulator or target-bytecode execution was used. Real Hopper/Ghidra/browser verification is not applicable. No breaking change or migration.

Author readiness

The requester explicitly authorized ready PRs and merge and waived repeated human declarations. Human-review declarations remain unchecked; no human review is asserted.

Human owner: not recorded in this PR.

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

🔄 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/6943 **Author:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Base:** `main` ← **Head:** `perf/6938-beam-selected-views-20261024` --- ### 📝 Commits (3) - [`bcc3f76`](https://github.com/morluto/rea/commit/bcc3f761127e4a369e36ed17b4eb766578400562) feat(erlang): query selected BEAM table facts - [`5d379b1`](https://github.com/morluto/rea/commit/5d379b10e05a51e5e125b09189f7a11b1f955830) docs(perf): record BEAM selected-view measurements - [`fb382a9`](https://github.com/morluto/rea/commit/fb382a9d5486145f701ac5dd9a065d1a484d6439) chore: integrate current main before BEAM qualification ### 📊 Changes **20 files changed** (+4206 additions, -66 deletions) <details> <summary>View changed files</summary> 📝 `.agents/skills/reverse-engineer-anything/SKILL.md` (+4 -2) 📝 `.agents/skills/reverse-engineer-anything/references/native-and-artifacts.md` (+5 -1) 📝 `docs/erlang-beam.md` (+59 -0) ➕ `experiments/analysis-efficiency/erlang-beam-costs.py` (+111 -0) ➕ `experiments/analysis-efficiency/erlang-beam-oracle.py` (+108 -0) ➕ `experiments/analysis-efficiency/erlang-beam-sdk-cache.json` (+534 -0) ➕ `experiments/analysis-efficiency/erlang-beam-views.json` (+2118 -0) ➕ `experiments/analysis-efficiency/erlang-beam-views.md` (+125 -0) ➕ `experiments/analysis-efficiency/erlang-beam-views.mjs` (+255 -0) 📝 `src/cli/erlangCommands.ts` (+50 -29) 📝 `src/contracts/analysisViewToolContracts.ts` (+1 -1) 📝 `src/contracts/erlang/beamToolContracts.ts` (+43 -7) ➕ `src/contracts/erlangBeamDeliveryContracts.test.ts` (+88 -0) 📝 `src/domain/analysisView/analysisView.ts` (+25 -0) ➕ `src/domain/analysisView/erlangBeamView.ts` (+236 -0) 📝 `src/server/createServer.ts` (+1 -0) 📝 `src/server/registerErlangTools.ts` (+38 -5) ➕ `tests/acceptance/applications/erlangBeamViews.test.ts` (+334 -0) 📝 `tests/acceptance/erlangBeamCli.test.ts` (+14 -20) 📝 `tests/boundary/mcp/erlangBeamMcp.test.ts` (+57 -1) </details> ### 📄 Description ## Summary Fixes #6938. Return selected BEAM facts in the initial inspection and page the same complete retained Evidence later. Complete output remains the default. ## Problem and expected behavior Reading four exports from real erl_lint previously returned about 147 KB of unrelated atom/import/lambda facts. `detail: "summary", view: {kind: "beam", collection: "exports", names: [...], fields: [...]}` now returns those rows immediately. Atoms, imports, lambdas and chunks support the same query shape; import modules intersects function names. ## Change and scope The domain projector queries the existing reader's typed facts. It reuses the schema-specific immutable-result reader, shared application retention/publication and CLI delivery parser. Same-name exports retain every arity and original atom indexes; parent+collection+source_index identifies each row. Parsing and format budgets are unchanged. Maintainer target-execution/injection/mutation scope decision: not applicable to this existing static/Evidence-publication workflow. ## Contract and boundary impact - CLI/MCP: additive opt-in detail/view; exact field enums per collection, filters and matching-row pages. Complete delivery rejects a supplied view. Named contracts and converted draft2020-12/draft07 inputs agree. - Evidence: complete source remains retained/exportable; source coverage, byte ranges/digests, null missing-table counts, empty decoded tables and unresolved names survive. Retained/offline queries work after deleting the original file. - Compatibility: existing complete calls and parent/source IDs remain equivalent. New-view real qualification covers OTP27 on Linux; existing legacy/compact reader controls also pass. Other real platforms/versions are unverified here. - Docs and authored skill guidance updated; generated metadata regenerated/checked and left uncommitted. No package, installer or configuration changes. Expected effects: - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [x] Change process memory, registers, files, or configuration. (Only caller-selected complete Evidence publication through the existing workflow.) - [ ] Contact network services. - [ ] Recover protected code or work around protections. ## Evidence and regression coverage Executed 18 alternating fresh production stdio tasks on unmodified public Debian OTP27 erl_lint/erl_parse/pg2, with independent Python struct decoding of every table, chunk range/hash and Code header. Both complete/selected lanes answer the same question and export/check the complete source. All answer, parent-ID and source digests agree. Six additional cached-catalog/default-SDK-validator tasks pass separately. Whole-task token estimates (question, instructions, all 221 input-tool definitions once, every argument/text reply including export): **76,907→58,090 (−24.5%)**, **72,499→58,087 (−19.9%)**, small pg2 **57,733→58,018 (+0.5%)**. `tiktoken 0.14.0/cl100k_base`; actual model usage/inference quality unmeasured. Directory cost grows 55,409→56,359; raw catalog including output schemas grows 829,075→834,792 and is reported separately. No stable general wall/CPU/memory improvement established; small selected tasks have a higher wall/CPU median. [Pinned measurements, ranges, commands and receipt hashes](https://github.com/morluto/rea/blob/fb382a9d5486145f701ac5dd9a065d1a484d6439/experiments/analysis-efficiency/erlang-beam-views.md). Public regressions cover all collections, arities/row identity, empty/intersecting selectors, fields/pages, null versus empty tables, unresolved references, source deletion/offline bundles and refusal before reading when retention/delivery is unavailable. Example pg2 export rows retain `function_index:2, function:"module_info"` with both arities 1/0 and distinct original row indexes. ## Validation performed After integrating main `cd10ee1f8`: - Five affected source suites: **74 passed** (BEAM reader/service, delivery schema conversion, shared view and snapshot reader). - Public BEAM CLI, MCP and view suites: **17 passed**. - Serialized typecheck/lint/format/knip/metadata with compile dependency; architecture guards; generated docs check with **9 README tests passed**. - Current-tree real qualification: three additional stdio/export tasks plus complete/selected CLI calls on all three artifacts, checking every oracle fact and identical parent/source/answer digests. This qualifies integration; the repeated performance table retains its original revision pins. - `npm run check:fast`: passed. [Codex review](https://github.com/morluto/rea/pull/6943#issuecomment-6379320860) completed on exact head `fb382a9d54`, with no major issues and no inline findings. - CI [40058317023](https://github.com/morluto/rea/actions/runs/40058317023) failed on 12 native-plist cases; a clean exact-main `d662fa54` control reproduces all 12 identities/multiplicities (12 failed/30 passed). Source 17,223 passed/13 skipped, static/build/docs/quality and all 17 BEAM public cases plus 3 filesystem cases passed. Several other shards were canceled; broad coverage is incomplete. The qualification comment records message-matching limits and the authorized baseline bypass. - One aggregate CPU, 3 GiB early stop/4 GiB hard cap, no swap. All measured/qualification tasks verify payload exit/cleanup without guard stop/OOM. Final integration check peak 2.66 GiB; final whole-scope counters unavailable. Failed development attempts remain recorded separately. ## Compatibility, safety, and release Additive selection; whole-source parsing and retention costs remain. Missing structural tables do not establish runtime absence. No Erlang installation/emulator or target-bytecode execution was used. Real Hopper/Ghidra/browser verification is not applicable. No breaking change or migration. ## Author readiness The requester explicitly authorized ready PRs and merge and waived repeated human declarations. Human-review declarations remain unchecked; no human review is asserted. Human owner: not recorded in this PR. - [ ] 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 - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:48:02 +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#7464
No description provided.