Skip to content

fix(native): share value trace node budgets across node roles - #2889

Closed
IvenKooLab wants to merge 2 commits into
morluto:mainfrom
IvenKooLab:fix/native-value-node-budget
Closed

IvenKooLab wants to merge 2 commits into
morluto:mainfrom
IvenKooLab:fix/native-value-node-budget

Conversation

@IvenKooLab

@IvenKooLab IvenKooLab commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Apply the existing 8 MiB node-payload budget to both operation and parameter nodes in trace_native_values. Omitted parameters no longer contribute parameter-use or argument-binding edges.

Problem and expected behavior

Only operation nodes contributed to byte accounting. A valid dossier with a 9 MiB parameter name could return more than 8 MiB of nodes with truncated=false. Escaped JSON can also exceed the budget despite a shorter source string. The limit must cover the encoded payload of all node roles before allocating a complete oversized serialized node.

The existing mixed operation/parameter ID membership check could additionally treat a retained operation named parameter:0 as a retained parameter, leaving a false dependency after the parameter was omitted.

Change and scope

Use one node-admission owner for the shared count and byte limits. Reuse the existing bounded jsonParts encoder to count actual JSON escapes and UTF-8 bytes. Once admission fails, stop admitting later node roles/functions.

Replace mixed-role membership with a retained-parameter ordinal-to-ID map. Preserve provider operation IDs, and choose parameter IDs against the complete operation-ID set so collision handling is stable across budgets and pagination. Noncolliding parameter IDs retain their existing spelling. Call bindings already consume retained node objects and their actual IDs.

Routine correction of existing static analysis and resource bounds; advance maintainer scope decision is not applicable. No separate issue: independently reproduced focused defects at the same node-admission/identity boundary.

Contract and boundary impact

  • Semantic owner: shared application node admission and dependency composition.
  • CLI/MCP/catalog: existing schemas and requested budgets. Oversized parameter nodes now produce bounded, explicitly truncated output; dependencies on omitted parameters are absent.
  • Providers/platform: no bridge or platform change; operation source IDs preserved. Source inspection shows normal Ghidra IDs do not use the generated parameter spelling, but real engine behavior was not executed.
  • Evidence/artifacts: retained node provenance and failure/unknown observations remain visible.
  • Target/authority/cleanup: existing static provider calls; no new execution, mutation, network, or cleanup authority.
  • Generated metadata/package/installation: none.

Expected existing workflow effects: [x] read captured data; [x] dispatch existing provider analysis, which can launch an engine. No new effect is introduced.

Evidence and regression coverage

Executed application tests through simulated analysis ports cover:

  • 9 MiB plain parameter text and 2 MiB NUL text whose JSON escape expansion exceeds the budget.
  • Two individually fitting 5 MiB parameters exceeding the shared aggregate budget.
  • An oversized operation followed by a small parameter: admission stops for both roles.
  • Operation IDs colliding with generated parameter IDs, under both partial and complete node budgets.
  • Omitted callee parameter argument bindings while preserving valid call and return bindings.
  • Existing count limits, successful-callee fan-out, pagination, cancellation, target identity, and selector origin.

Exploratory base reproduction retained 9,437,409 node bytes with truncated=false; the affected owner is unchanged through PR base 9407236. The existing collision test was corrected because it previously expected a parameter-use edge when only the colliding operation was retained.

Representative shared output: the oversized-parameter cases retain the two fitting operation nodes, report total_nodes=2, total_edges=0, and truncated=true.

  • Observation, derivation, and unknown distinctions preserved.
  • Artifact identity and source provenance preserved.
  • Unavailable parameter bindings remain explicit unknowns.

Validation performed

Pinned Node 24.18.0/npm 11.16.0, locked dependencies:

  • npm run test:local -- src/application/native/NativeValueTrace.test.ts src/application/native/EnhancedNativeInvestigation.test.ts — 38 tests passed.
  • npm run check:fast — passed during push.
  • npm exec --no -- turbo run typecheck lint:built knip metadata:check --output-logs=errors-only — all five tasks, including the compile dependency, passed.
  • npm run verify:architecture-guards and npm run verify:test-discovery — passed.
  • Touched-file oxfmt --check, commit lint hook, and git diff --check — passed.
  • npm run check — passed on the current PR branch (typecheck, lint, format, knip, metadata, compile dependency, and architecture guards).

Cost comparison and tradeoff

A completed simulated task containing 1000 operations, 1000 parameters, and 1000 parameter-use edges returns byte-identical JSON before/after (result SHA-256 compared). It fits all budgets and retains all nodes. Separate Node/Vitest workers; first call and median of seven subsequent warm calls:

Metric Base Fix
Analysis / resolution requests 1 / 0 1 / 0
Returned JSON tokenx estimate 256210 256210
First elapsed / CPU, ms 42.664 / 96.058 48.700 / 113.053
Warm elapsed / CPU median, ms 23.389 / 28.848 28.442 / 34.640
Worker cumulative peak RSS, first / final KiB 128560 / 223264 130752 / 267088

The additional bounded accounting costs about 5 ms in this mock, with roughly 22% warm elapsed and 20% warm CPU overhead. This is a resource-bound correctness fix with a measured cost, not a speedup. Timing excludes fixture setup, output serialization/token estimation, and process startup. Worker RSS includes initialization, prior calls, and later estimation allocations; it is not incremental trace memory. Peak process-family memory, whole-agent tokens/catalog/prompts, transport costs, and real provider costs are unmeasured. No real Ghidra/Hopper/IDA or end-to-end CLI/MCP workflow was executed.

Compatibility, safety, and release

No input-schema change, migration, package metadata change, or new target authority. Noncolliding IDs remain compatible; colliding generated parameter IDs now distinguish node roles. The 8 MiB limit continues to describe node payloads, with the existing final 32 MiB serialized-result bound separate. Real-provider proof remains unavailable.

Before merge

  • Concrete focused defect; Conventional Commit title.
  • Existing scope and authority preserved; no separate decision required.
  • No separate issue; reason stated.
  • Changed behavior and meaningful failure/capacity paths covered.
  • Existing documented 8 MiB node-payload contract enforced; schemas/generated metadata unaffected.
  • Representative shared CLI/MCP output included.
  • Final diff checked for secrets, unrelated cleanup, and unsupported claims.

@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 ✅ Completed 2026-10-13T18:53:04.223205Z d933d98 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.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue was found.

Summary

traceNativeValues now shares the 8 MiB node budget across operations and parameters.

  • Native value traces count operation and parameter nodes against one 8 MiB limit.
  • Parameter edges use retained nodes with IDs distinct from operation names.

No actionable new issue or security issue was found. Tests were inspected, not executed. Whether another PR supersedes this one could not be verified because GitHub access was unavailable. No previous review threads were supplied.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Validated function dossier] --> B[Operation nodes]
  A --> C[Parameter nodes]
  B --> D[Shared node admission]
  C --> D
  D -->|Fits count and encoded byte limits| E[Retained nodes]
  D -->|Exceeds either limit| F[Mark truncated and stop admission]
  E --> G[Compose dependencies using retained IDs]
  G --> H[Return node page and related edges]
Loading

Reviews (4) · Last reviewed commit: "fix(native): separate admitted parameter..." · Reviewed by Greptile

@morluto
morluto force-pushed the fix/native-value-node-budget branch 2 times, most recently from 68f66e3 to 936cfda Compare October 13, 2026 18:26
@morluto
morluto force-pushed the fix/native-value-node-budget branch from 936cfda to d933d98 Compare October 13, 2026 18:47
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working labels Oct 14, 2026
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.
@IvenKooLab

IvenKooLab commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Current-main verification: upstream commit 55dd21a5e already includes this PR's shared node-admission budget, retained-parameter identity map, collision handling, and regression tests. Its commit message explicitly references #2889 (and #2888). The implementation is therefore already incorporated; please confirm the appropriate disposition of this still-open PR.

The historical red Windows native build job failed after approximately 60 seconds with DOMException [TimeoutError] while fetchBytes downloaded Node prerequisites from nodejs.org, before native artifact compilation. This PR does not change that build script. The package lane was skipped downstream, causing the aggregate CI failure. All six test shards, portable tests, static checks, and the package build passed for d933d98.

Local verification on that exact PR branch, using pinned Node 24.18.0/npm 11.16.0: 38 relevant native application tests and the full npm run check gate passed. Real Windows compilation was not run on this macOS host. If this PR is kept for a merge, its failed CI jobs still need a rerun; my upstream permission is READ. No rerun is needed solely to diagnose a new node-budget defect: none was found.

@kaoru0822-kitauji kaoru0822-kitauji added the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

CI-fix track: the failing "Build bundled Windows x64 native controls" job is infra, not this PR: scripts/build-windows-native.mjs hit its 60 s download timeout (DOMException [TimeoutError]) before anything compiled. Separately, this change is already on main. Merging current main into this branch yields a tree identical to main: 55dd21a (which lists #2889 among its reviewed fixes) contains the shared node budget in NativeValueTrace.ts plus these tests. src/application/native passes (50) on that tree. I didn't push an empty merge. This PR looks safe to close as superseded.

@kaoru0822-kitauji kaoru0822-kitauji removed the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@IvenKooLab

Copy link
Copy Markdown
Contributor Author

Thanks for verifying the tree-identical merge against 55dd21a — closing as superseded. Appreciate the CI triage on the Windows native-controls job too.

@IvenKooLab IvenKooLab closed this Oct 14, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Thanks @IvenKooLab for catching that parameter nodes could bypass the value-trace byte budget and still emit dependent edges. Main now accounts for both node roles under one budget and keeps omitted parameter facts from contributing relationships (main).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants