Skip to content

fix(session): settle native tools before compaction - #539

Merged
LeXwDeX merged 9 commits into
devfrom
fix/538-native-tool-settlement
Sep 4, 2026
Merged

fix(session): settle native tools before compaction#539
LeXwDeX merged 9 commits into
devfrom
fix/538-native-tool-settlement

Conversation

@LeXwDeX

@LeXwDeX LeXwDeX commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Closes #538
Closes #540

Why

High provider usage could request automatic compaction while a native local tool was still running, aborting it before its result reached the processor. Local-file npm tests also waited on unrelated online audit traffic before reaching their existing assertions.

What changed

  • Delay native step-finish and finish events until concurrent local tools settle and their results reach the session processor. Preserve tool IDs, parallel execution and explicit cancellation.
  • Exercise slow-tool success, parallel results and interruption through the real HTTP provider/LLM/processor boundary; share only the repeated model/processor setup.
  • Keep local npm fixture audits disabled in temporary project configuration. The merge retains dev's richer fix(core): preserve npm lock when plugin SDK resolves locally #541 package-lock preservation regressions and production fix.
  • Include v1.0.40 notes for the integrated native, npm, event-storage, delivery and macOS installer changes, with explicitly identified CI baseline evidence.

Evidence

Current head: 00695dab86358a34b5b756f30df07bccfbe4e309; parents are reviewed #539 head 93959afa302a058fdb6210904dd07f6dfaa23185 and dev 8060765fccf3c3f7daf3b8b2f87f8cbe48b7a8f9.

Independent Standards and Spec reviews found zero code blockers at 93959afa30. The three native implementation/test files are byte-identical at the current head. The two merge conflicts retain the #539 delivery binding and dev's exact npm test file; all other imported code is unchanged from dev.

Current merged-tree validation:

  • Native/session/TUI tests: 36 passed, 0 failed, 141 assertions.
  • Core npm regressions: 8 passed, 0 failed, 20 assertions.
  • opencode package typecheck passed; commit/push hooks passed the repository lint ratchet (4838 warnings, 0 errors) and all 29 configured typecheck tasks.
  • v1.0.40 release notes rendered and validated successfully; git diff --check passed.
  • Earlier native regression red/green evidence remains recorded in fix: settle native tools before compaction #538; these checks use temporary XDG directories and an in-memory test database.

All CI checks passed at 00695dab86: Typecheck, complete Test CI, and CodeQL. Core: 1225 passed / 6 skipped / 0 failed. Opencode: 4429 passed / 23 skipped / 1 todo / 0 failed. Generated client/SDK freshness passed; all three HttpAPI modes reported 230 passed with no failures, skips, missing or extra routes. Linux and Windows E2E passed. SpecGit 1.10.1 accepted this exact PR/head with exit 0; it will be rerun after this evidence update before merge. Earlier cancelled/superseded checks are not acceptance evidence. The user clarified that this Codex delivery uses subagents to carry out the review workflow. Independent Standards and Spec reviews, merge-resolution review and an independent synthesis checkpoint are complete, with zero code or merge blockers. The checkpoint binds the reviewed native files and dev imports to the current head; CI and SpecGit acceptance remain separate required gates. No external model endpoint is needed for this workflow.

Checklist

  • Preserve concurrent tools, exact results and caller cancellation.
  • Complete independent Standards/Spec source reviews and merged-tree local validation.
  • Resolve current dev conflicts without reverting either fix.
  • Complete the subagent Standards/Spec reviews, merge review and independent synthesis checkpoint.
  • Pass all current-head CI checks and specgit finish --json with exit 0 before merging to dev.

@LeXwDeX
LeXwDeX changed the base branch from feat/524-event-retention-reclamation to dev September 4, 2026 03:53
@LeXwDeX LeXwDeX changed the title fix: settle native tools before compaction fix(session): settle native tools before compaction Sep 4, 2026
@LeXwDeX
LeXwDeX marked this pull request as ready for review September 4, 2026 04:00

@LeXwDeX LeXwDeX left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Standards review for commit 8d99729, compared with 953ca98 using the three-dot diff.

Reviewed all five changed files, including the release notes and delivery binding, against the root/package/runtime/test AGENTS.md files, CONTEXT.md, the release-notes template, and the code-review smell baseline. This is an independent Standards review; I did not author the host change.

Hard findings: 0. The change keeps terminal-event buffering inside the native adapter's existing scoped stream. It does not move storage/session responsibilities or change runtime selection. The tests exercise the real processor and LLM path with an HTTP model fixture; the latency case tests ordering, and the parallel/cancellation cases synchronize on readiness signals.

Optional heuristic: possible Duplicated Code in packages/opencode/test/session/processor-effect.test.ts at lines 848–852, 927–931, and 982–986. The three cases repeat the 32K model and processor setup. A shared preparation helper could reduce future fixture drift. This is non-blocking, has no demonstrated correctness impact, and does not warrant expanding this fix.

The isolated checkout has no matching codebase graph project, so this review used the fixed diff and exact source. Formatting/type checks already covered by tooling were not repeated. This comment records source-review findings only; it does not assert that CI has passed or that a DAG workflow has run.

@LeXwDeX LeXwDeX left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent Spec review: 0 actionable findings for issue #538 at commit 8d9972908c308da1836a004cebe27c7c23db1acc.

Fixed comparison: 953ca98999eb1120fe9bf99a32178ea709b4dc2d...8d9972908c308da1836a004cebe27c7c23db1acc. The complete diff includes the native adapter, focused tests, delivery binding, and v1.0.40 release notes.

  • Slow-tool completion before automatic compaction: the adapter retains provider step-finish and finish events until local tools settle and their queued results reach the processor. The processor regression checks both the compact decision and a persisted successful result with its original input.
  • Parallel tools and result identity: immediate fiber dispatch remains concurrent; all settlements and queued results precede the retained completion events. The stream test checks the start barrier and event order; the processor test checks both distinct call IDs, completed states, and outputs.
  • Explicit cancellation: the existing abort signal remains connected. The interruption regression waits for tool startup, interrupts the processor fiber, and checks actual abort and the persisted interrupted error.
  • Scope: no changes alter DCP policy, compaction thresholds, model limits, or timeout/grace settings. The issue explicitly includes the release notes, and the binding matches issue #538 / PR #539.

This is a Spec-axis source/diff review. I inspected the test assertions; I did not independently repeat the author's reported full run of 66 passing tests, one existing skip, and package typecheck. CI, SpecGit, and publication remain separate gates.

The real-model DAG has not run. Its startup was rejected by automatic approval review before process creation and remains pending explicit authorization. There is no DAG run ID, node output, or aggregate verdict; this COMMENT review does not represent DAG approval or completion of all required review gates.

@LeXwDeX LeXwDeX left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Supplemental independent review for issue #540, commit 43894ec, compared with 8d99729.

Standards

Hard findings: 0. Actionable heuristic findings: 0. Both audit=false settings are scoped to automatically disposed temporary fixture directories. The real Npm service still loads those project settings through NpmConfig and runs Arborist.reify. No installer mock or global environment override was introduced. The other npm.test.ts changes only wrap existing long lines.

Spec

Findings: 0. The cache-reification test retains its entrypoint assertion; the omit test retains omit=dev and both production-present/development-absent assertions. The existing default five-second deadlines are unchanged. The diff adds only the issue binding and fixture/test-file changes: production npm defaults, runtime implementation, workflows, policies, and explicit security-audit gates are unchanged.

I inspected the exact isolated-checkout diff and configuration/install path. The available graph describes another checkout at an older generation, so it was not used as evidence of these changes. The author's reported six passing tests and package typecheck were not rerun for this source review. Required CI, DAG review/synthesis, and SpecGit acceptance remain separate gates; this comment does not assert their completion.

@LeXwDeX LeXwDeX left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Supplemental independent Standards and Spec review for e03ad87, compared with 43894ec.

Standards

Hard findings: 0. Actionable heuristic findings: 0. The earlier optional Duplicated Code observation is resolved. nativeCompactionProcessor is a named Effect helper reused by all three native regressions; it binds services explicitly and performs the shared model/processor setup without introducing a new runtime abstraction.

Spec

Findings: 0. The delta is confined to packages/opencode/test/session/processor-effect.test.ts and satisfies issue #538's review-cleanup scope. The model still uses the same provider reference and 32K/4K limits. Passing msg.sessionID to processors.create is equivalent here because each message is constructed by assistant(chat.id, ...). The delayed tool, parallel readiness signals, explicit Fiber.interrupt action, assertions, timeouts, and real runtime path remain unchanged.

The optional setup-duplication item is closed by this review. I inspected the exact final-commit diff and existing fixture construction; I did not author this change or rerun checks already reported by its author. CI must evaluate the new head. DAG review/synthesis and SpecGit acceptance remain separate requirements; this comment does not assert that those gates have completed.

@LeXwDeX LeXwDeX left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent merge-provenance review for 93959af. Verified its exact parents: reviewed feature head e03ad87 and dev 28f14d2.

Findings: 0. All 26 integrated files were individually compared by raw bytes, Git blob identity, and file mode; each exactly matches the dev parent. The five feature files (release notes, npm fixture tests, native runtime, and both native regression test files) exactly match the reviewed feature parent. The resolved .specgit.yaml also matches that feature parent and retains PR #539, issues #538/#540, and the delivery branch.

The complete diff against dev contains only those five previously reviewed files plus the binding. There are no unexpected paths, unresolved entries, or uncommitted changes. The merge introduces no hand-written behavior change.

This comment verifies the merge tree's provenance and closes the conflict-resolution review. Required CI, DAG review/synthesis, and SpecGit acceptance remain separate gates; it does not assert their completion.

@LeXwDeX
LeXwDeX merged commit 711e7b5 into dev Sep 4, 2026
8 checks passed
@LeXwDeX
LeXwDeX deleted the fix/538-native-tool-settlement branch September 4, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant