Skip to content

docs(go): clarify cumulative build-info search budget - #2731

Merged
morluto merged 17 commits into
morluto:mainfrom
cyanseek:codex/go-sectionless-pie
Oct 21, 2026
Merged

morluto merged 17 commits into
morluto:mainfrom
cyanseek:codex/go-sectionless-pie

Conversation

@cyanseek

@cyanseek cyanseek commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Document the cumulative Go build-info header-search budget in inspect_go_binary discovery. The remaining diff is one tool-description sentence; the later-load ELF parser fix and its regressions are already on main.

Problem and expected behavior

The description names the 256 MiB file bound but omits the independent cumulative search budget. Overlapping load ranges can exhaust that budget even when the file itself is smaller.

Change and scope

Clarify that each distinct search span is charged in full before searching, and partial overlaps are charged separately. readGoBinaryImage owns this accounting: identity is file offset, size and virtual-address alignment modulo 16. Identical identities are skipped; each remaining span consumes its full size, including a span in which a header is found early. Exactly 256 MiB is accepted; a next span that would exceed it raises the existing typed resource failure before scanning.

Contract and boundary impact

  • Owner: the inspect_go_binary description in goToolContracts.ts, checked against GoBinaryImage.ts on main c61c108b.
  • Scope decision: not applicable; documentation within existing offline inspection.
  • CLI/MCP: discovery wording only; no schema, parser, output, provenance, authority, cleanup or compatibility changes.
  • Generated metadata: product/tool catalogs inherit the description; generated files are not committed. No package or installation change.
  • Documentation or usability only; no target interaction.

Evidence and regression coverage

Source comparison confirms the scanner already enforces this budget. Existing executed coverage includes distinct overlapping spans, duplicate spans, the exact limit, different virtual alignments, public CLI resource diagnostics and subsequent MCP responsiveness.

Validation performed

On the branch synchronized with main c61c108b, Node 24.18.0 / Windows:

  • Five focused Go reader/mapping/provider/CLI/MCP files: 143 passed, 3 platform skips.
  • npm run check, npm run docs:check, git diff --check: passed.

Compatibility, safety, and release

Documentation-only; no breaking changes or runtime cost change. Real Go producer runs from the earlier implementation remain historical evidence, not new runs for this wording update.

Author readiness

Human owner: @cyanseek

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-21T13:23:36.384386Z 08f6b8d 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6ec84d23da

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/go/GoBinaryImage.ts Resolved
@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The documentation-only change appears safe to merge.

Summary

Clarifies the cumulative Go build-info search budget in inspect_go_binary.

  • Go binary inspection explains how search spans share their header budget.

Reviews (15) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/go/GoBinaryImage.ts Resolved
Comment thread scripts/verify-go-binary.mjs Resolved
@cyanseek

Copy link
Copy Markdown
Contributor Author

Addressed the overlapping-range findings and verifier cleanup finding in 43568cd.

The record reader now deduplicates identical file spans with the same virtual alignment and charges each remaining span before scanning against a cumulative 256 MiB byte budget. Partial overlaps cannot multiply work by the program-header count indefinitely. Exhaustion returns the existing resource-constraint contract with resource: cpu and the explicit search-byte limit; it cannot return a partial success. Program-header priority and first recognized malformed-record handling stay unchanged. Different alignment classes remain separate candidates.

The verifier now checks lstat(root.path) after closing its owned temporary root, instead of probing the obsolete go.mod location. This asserts removal of the directory actually created by the verifier.

Validation: the new overlapping-span reader and public CLI regressions fail before the fix and pass afterward. Coverage also includes duplicate spans, the exact cumulative limit, different virtual alignments, the MCP resource diagnostic and a subsequent successful ping. All 151 focused Go tests pass (three existing Windows ELOOP exclusions); static/docs checks pass. The real Go 1.27.2 verifier passed again on Windows: 14 compiler-produced binaries and 28 CLI/MCP cases, including the sectionless PIE/non-PIE pairs and the corrected root-removal assertion. Produced target binaries are inspected offline, not executed. Whole-process lineage observation remains unavailable on this Windows verifier host; the report retains that limitation explicitly.

@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior area: providers Provider and capability discovery, including provider proposal triage area: build Build, CI, packaging, and publishing P2: medium Medium priority issue labels Oct 13, 2026
morluto and others added 4 commits October 14, 2026 01:06
* fix(comparison): preserve incomplete function call evidence

Keep missing, unknown, partial and unresolved call relationships unknown in function comparisons and reconstruction claims. Aggregate IDA caller and callee coverage without overwriting uncertainty.

Validate with 144 focused tests, typecheck/lint, docs checks and test discovery. Real providers were not verified; the full headless IDA session suite requires unavailable Windows native controls.

* fix(comparison): recheck historical calls-only changes

---------

Co-authored-by: morluto <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ce0f0345c

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/go/GoBinaryImage.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28aa21f9fe

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/go/GoBinaryImage.ts Resolved
morluto added a commit that referenced this pull request Oct 14, 2026
Share tagged readiness observations, retain partial provider facts, authenticate bridge identity, bound diagnostics, and preserve cancellation and lost-session reasons. Fail closed for unparsed MIPS ABI attributes and macOS saved Hopper databases without a script-capable bridge route.

Reviewed fixes: #2010, #2108, #2513, #2695, #2731, #2771, #2828, #2867, #2868, #2870, #2880, #2919, #2945, #2961, #2981, #2998, #3000, #3002.

Validation: 285 focused source/boundary tests passed. Real Ghidra, IDA, Linux Hopper, and Windows provider runs were not repeated.

BREAKING CHANGE: MIPS targets with unresolved GNU ABI attributes and saved Hopper databases on macOS are refused rather than advertised as supported.
morluto added a commit that referenced this pull request Oct 14, 2026
Preserve XML and Interface Builder identity at their parsing boundary, retain usable Objective-C slots with precise coverage, and keep native trace failures distinct from absence. Add caller-selected Interface Builder summaries backed by complete retained Evidence, and preserve comparison limitations.

Reviewed fixes: #1969, #2088, #2108, #2513, #2639, #2684, #2731, #2759, #2875, #2888, #2889, #2970, #2971, #3002.

Validation: relevant native/domain focused lane passed 142 tests; earlier Interface Builder/MCP checks passed 24 tests. Real native UI and Ghidra producer coverage was not repeated.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@cyanseek

Copy link
Copy Markdown
Contributor Author

Updated in 7bf9be7 after merging current main and retaining its native-section facts. Main already incorporates the multi-load discovery and bounded-search implementation; the tool discovery description now also states the cumulative 256 MiB header-search budget, alongside the separate file bound.

Revalidation passed: 154 focused reader/mapping/provider/module/CLI/MCP tests (3 platform skips), check, docs:check, and the Go 1.27.2 real verifier with 14 compiler-produced binaries / 28 public CLI/MCP cases. Sectionless PIE recovers complete metadata equal to its original producer image; the original PIE, original executable and sectionless executable retain their baseline metadata. No directly related cleanup is deferred.

Cost evidence uses those four real ELF files (2.23–2.38 MiB), Node 24.18.0 on Linux, and the same bundled reader entry point at base 96fc84f and the current implementation. Each process reads and parses each file once, then three more times. The first read is distinguished from repeats; OS filesystem caches were not flushed.

Reader batch (16 reads/parses, including process startup) Elapsed Child CPU Sampled peak process-family RSS
Base 96fc84f 428.8 ms 117.8 ms 60.8 MiB
Current 400.1 ms 117.5 ms 62.7 MiB

For the sectionless PIE specifically, first-read parsing was 16.18 ms at base and 9.91 ms currently; subsequent reads were 10.01–10.11 ms and 9.81–10.51 ms respectively. Base returns no build information for this input; current returns the full compiler/module/dependency/settings record. The other three inputs have equal decoded metadata across versions. These observations describe the cost of metadata recovery; they are not a throughput estimate.

The completed current-head public CLI workflow was also measured in two fresh-process passes over all four files: first-pass elapsed 5.28–5.54 s / CPU 1.66–1.72 s, second-pass elapsed 5.22–5.32 s / CPU 1.64–1.68 s, sampled peak family RSS 317–322 MiB across both passes. RSS was sampled every 20 ms and CPU includes the owned child process family. Before/after end-to-end CLI comparison, physical cold-cache cost and agent-token usage were not measured; these runs do not invoke an LLM. Functional CLI/MCP parity is covered separately by the verifier above.

@CassieFox23

Copy link
Copy Markdown
Contributor

Heads up: main already has this change in 55dd21a. The code is in src/go/GoElfImage.ts. The test retains later-load ELF metadata without sections covers it. One tool description sentence is left. It is listed on tracker #3582. If this PR still adds something main doesn't have, please say so here and I'll take it off the list. Thanks for the fix!

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Compared this PR with main fc712b375 during the fixed/superseded backlog audit.

The current PR net diff is only the Go tool description's cumulative build-info header-search bound; the summary still describes the earlier later-segment parser fix.

Please retitle and rewrite the body around the remaining documentation/contract wording, checking that the advertised cumulative bound matches the owning scanner's actual accounting. If another parser behavior remains missing, show that separately with its smallest fixture instead of leaving delivered implementation work in the pending summary.

PR head reviewed: 7bf9be765. This is a source comparison; no new PR-branch tests or provider runs were performed for this comment.

@cyanseek cyanseek changed the title fix(go): retain build info in later ELF data segments docs(go): clarify cumulative build-info search budget Oct 15, 2026
@cyanseek

Copy link
Copy Markdown
Contributor Author

Retitled and rewrote the body around the remaining discovery-contract sentence. The parser and its delivered later-load behavior are no longer presented as pending work.

Checked the wording against readGoBinaryImage on main c61c108. The scanner deduplicates (offset, size, virtual address mod 16), then charges each remaining span's full size before findHeader; partial overlaps consume separate budget, and an early match does not reduce that span's charge. Exactly 256 MiB is admitted, while a span exceeding the remaining budget fails before it is searched. The revised description makes this range-based accounting explicit.

After synchronizing main, 143 focused Go reader/mapping/provider/CLI/MCP tests passed (3 platform skips), including the exact-limit, duplicate, overlap, alignment and public error-path checks. check, docs:check and git diff --check passed. The net diff remains one description sentence; no parser cleanup is deferred.

# Conflicts:
#	src/contracts/go/goToolContracts.ts
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

CI-track update: I merged latest main (6d356b8) into this branch to clear the conflict (merge commit 08f6b8d, no force-push). Main has since reworded the inspect_go_binary description in src/contracts/go/goToolContracts.ts (default complete detail, summary view output). I took main's description and re-applied only your resource-guard clause: each distinct build-info search span is charged in full against the cumulative 256 MiB header-search budget, with partial overlaps charged separately. That still matches readGoBinaryImage on main. Locally npm run check:fast, npm run format:check, npm run docs:check and the focused Go MCP/CLI tests (goBinaryMcp, goBinaryViews, goBinaryCli) passed.

@morluto
morluto merged commit 7fdf7a5 into morluto:main Oct 21, 2026
41 checks passed
@morluto morluto added the documentation Improvements or additions to documentation label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build Build, CI, packaging, and publishing area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior area: providers Provider and capability discovery, including provider proposal triage bug Something isn't working documentation Improvements or additions to documentation P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants