Repository navigation
fix(kuna): keep the run slot of an unproven stop until close proves it - #4052
Conversation
A single-function run whose process tree could not be proven stopped released its run slot immediately, so the next queued run started while the old tree might still run, and repeated unproven stops bypassed the bound. The retained run now carries its slot, and close releases it only after a retried stop is proven. 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. |
[Medium impact] The PR appears safe to merge; retained process trees continue to count against the run limit. SummarySingle-function Kuna runs now keep their run slot when REA cannot prove cleanup finished.
No actionable issues or new security issues were identified. Tests were not run during this review. Whether this PR has been superseded could not be checked because GitHub access required authentication. The supplied PR description by Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Acquire run slot] --> B[Run Kuna command]
B --> C{Cleanup proven?}
C -->|Yes| D[Return slot]
C -->|No| E[Keep cleanup owner and slot]
E --> F[Retry cleanup during close]
F --> G{Cleanup proven?}
G -->|Yes| D
G -->|No| E
Reviews (1) · Last reviewed commit: "fix(kuna): keep the run slot of an unpro..." · Reviewed by Greptile |
Summary
Follow-up to #4045, addressing its review finding (thread) after that PR merged. #4045 added run slots that bound concurrent single-function
kuna decompileruns. A run whose process tree REA could not prove stopped (retained) still released its slot right away. The next queued run then started while the old tree might still be alive, and repeated unproven stops could exceed the bound. Refs #1957.Problem and expected behavior
Smallest trigger: one slot, a single-function run that times out, and a cleanup whose stop cannot be proven. A second request for another function launched a second
kuna decompileimmediately. Expected: a slot stays taken while its process tree may still run, and is returned only once a stop is proven.Change and scope
Root cause:
#singleFunctionreleased the slot infinallywhatever the outcome, so slot ownership ended before process ownership did. Fix: aretainedoutcome hands its slot to the retained entry next to the cleanup owner (#retained[].slot).close()releases the slot only when its retriedstop()reports the tree stopped. Every other outcome releases the slot as before. If the stop is never proven, the slot stays held, which matches how the retained workspace stays owned.docs/kuna-provider.mdstates this in one sentence.The existing
unprovenCleanupLaunchertest helper moves fromkunaProvider.test.tstokunaSessionFixture.ts, so both test files share it. It is not duplicated.Not included: no other change to how runs are admitted. The export's own retained builds are separate (
KunaProjectCache) and do not use run slots.Scope: an ordinary fix within the existing Kuna provider boundary; no maintainer scope decision applies.
Contract and boundary impact
KunaSessionClientsingle-function run ownership.Expected effects:
(Only changes when existing
kunaruns may start.)Evidence and regression coverage
Tests added or updated:
kunaSingleFunctionRuns.test.tsgets "keeps the slot of a run whose stop is unproven until close proves it". It uses one slot, a 300 ms function deadline and a launcher whose stop stays unproven. After the first run fails withcleanupIncomplete, a request for another function must not start anotherkuna decompile. Cancelling that request returnsAnalysisCancelledError.close()fails until the stop is released, then succeeds, and a new session's request gets the freed slot and returns asingle-functionanswer.Base reproduction: on the base revision (
git stashofsrc/kuna/KunaSessionClient.ts) the test fails withexpected [ … ] to have a length of 1 but got 2: the second run launched while the first was retained.Real-provider behavior: an unproven stop cannot be forced with a real Kuna, so this path is covered with the fake only. The real lane was re-run to check that ordinary runs are unaffected.
Remaining proof gaps: no real unproven-stop reproduction; no Linux run.
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: 94 passed (11 files), three consecutive runs.npm run check:fast: typecheck and lint passed.npm run docs:check: passed.REA_KUNA_COMMAND=… npm run verify:kuna(real Kuna 1.833, darwin/arm64): passed, process lineage verified,cleanup: "complete".Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.🤖 Generated with Claude Code