Repository navigation
fix(kuna): answer a repeated single-function request without re-running Kuna - #4169
Merged
Merged
Conversation
…ng Kuna A session dropped each single-function run once it settled, so a repeat request for the same procedure re-ran `kuna decompile --addr`, which analyzes the whole image again. After a failed export every pseudocode request uses that path for the rest of the session. Keep each completed text by entry address, within a 16 MiB least recently used budget, until the export's reader is adopted or the session closes. Failed and cancelled runs are not kept. The export's text still supersedes a kept one. Refs #1957 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Medium impact] The PR appears safe to merge; the revised test addresses the previous finding. Summary
Reviews (2) · Last reviewed commit: "test(kuna): pin that a kept text's hit r..." · Reviewed by Greptile |
With two 9 MiB texts only one fit the budget, so a repeated lookup could not change which entry was dropped. Use three 6 MiB texts: re-reading main leaves parse least recently used, so keeping broken must drop parse. Refs #1957 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While a Kuna session has no export reader, each
procedure_pseudo_coderequest for a procedure starts akuna decompile --addrrun, which analyzes the whole image again. Concurrent requests share one run (#4045), but the session dropped the run as soon as it settled. A repeat request for the same procedure therefore paid for a full new analysis, and got back the same text with the same evidence ID. After a failed export this applies to every pseudocode request for the rest of the session. Refs #1957.Problem and expected behavior
Observed on main, real Kuna 1.833, macOS arm64,
/usr/bin/zip(arm64e slice).REA_KUNA_PROJECT_TIMEOUT_MS=2000makes the export fail, andmainis then requested three times over MCP:The same happens while an export is still building. On Debian trixie linux/arm64,
/usr/bin/bash's export takes about 40 s, and each repeat ofmainre-ran Kuna for about 1.5 s.Expected: a completed single-function answer depends only on the session's target, its committed Kuna executable and the entry address. Within the session it is reusable work, and it remains so until the export can answer.
Change and scope
KunaSessionClientkeeps each successful single-function text by entry address:project_exportstatus is computed per request.The fake Kuna gains
decompilePaddingso the budget can be tested.docs/kuna-provider.mddescribes the retention.Not included: sharing these texts across sessions or servers. The export cache already does that once it finishes.
Scope: performance fix within the existing Kuna provider boundary; no maintainer scope decision applies.
Contract and boundary impact
KunaSessionClient, which owns single-function runs.raw_result.source.kind: "single-function"and its limitation.Expected effects:
(These are the existing effects of a Kuna decompile; the change removes repeated launches.)
Evidence and regression coverage
kunaSingleFunctionRuns.test.ts:main,parse,main,broken,main,parseruns0x1000,0x1040,0x1080,0x1040. The test fails when the refresh on a hit is removed.KunaSessionClient.ts, the three retention tests fail. The "failed run is not kept" test passes on both; it guards against keeping errors.mainmainAnswers match: the three zip answers are identical (193297 bytes each, same
resultSHA-256 prefix74234e98afe7, sourcesingle-function).Handoff to the export on bash: the repeats while building kept the same evidence ID and
project_export.state: "building". Afterprocedure_assemblywaited 39.8 s for the export,maincame fromproject-export, with its own text and no single-function limitation.Tokens: response sizes are unchanged. The saving is time, CPU and Kuna processes (each run held about 360 MiB on a 200 KiB image in earlier measurements).
Remaining proof gaps:
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 -- tests/boundary/providers/kuna/*.test.ts(20 files) — 194 passed.npm run test:focused -- tests/boundary/filesystem/directAnalysisPermissions.test.ts— 2 passed.npm run check:fast— passed.npm run docs:check— passed.kunaProjectConcurrency.test.ts > preserves concurrent results and reclaims capacity (pin: true)failed under CPU stress (9 ×yes), with main'sKunaSessionClient.tsas well (3 of 3). It passes on an idle host. This is pre-existing flakiness, not caused by this change.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.🤖 Generated with Claude Code