fix(tool): scope read state by actor and instance#1282
Open
onlyfeng wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
Leaving context before marking this ready for review. This PR is intentionally scoped to the runtime read-state isolation change: scoping read state by actor and instance, plus the focused tests around that behavior. Targeted local verification passed:
The current full CI unit failures appear unrelated to this PR. The failing areas look like existing upstream baseline issues or separate fixes, including MCP eager-connect/pending behavior (#1269), fixture/root path handling, history FTS isolation, checkpoint writer expectations, and Anthropic I am not folding those baseline/test-only fixes into this PR, so maintainers can evaluate the runtime change independently. |
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
Scope runtime read-state marks by session, actor, and instance directory so edit validation does not leak across subagents or get over-cleared when one project instance is disposed.
Root Cause
The current read-state baseline still relies primarily on conversation history. Runtime marks added by the read tool need the same isolation boundaries as the execution context: actor-specific subagents must not share read marks, and disposing one project instance must not clear marks that belong to another live instance.
Changes
ReadTool.LocalContext.tryUse()helper andInstance.directoryOrUndefinedfor directory-aware module state.Validation
CI checks on this PR:
lintpassedtypecheckpassedtestis still red only in unit shards 1/4 and 4/4Targeted local validation on macOS with the same Bun version used by CI (
bun@1.3.14):bun typecheckpassedbun test --timeout 60000 test/tool/read-state.test.tspassed: 6 pass, 0 failbun test --timeout 60000 test/tool/edit.test.ts -t "tool.edit"passed: 25 pass, 0 failUpstream Main Baseline
As of 2026-06-24, latest
upstream/main@4a96a3730190dcd513b221064954e64be1fbe70dstill has a failingtestworkflow: https://github.com/XiaomiMiMo/MiMo-Code/actions/runs/28081064643Baseline failures observed there:
Instance.provide directory safety > rejects system paths containing secretsHistory.backfill > indexes existing text and tool partsClaude Code local MCP server is pending until explicitly connectedCheckpointContext producer (tryStartCheckpointWriter) > populates context before spawn and cleans up via Effect.ensuring after settleparentSessionID end-to-end (Axis A wiring) > clean parent checkpoint -> splitover plugin reads parent's path -> no ReAct reentry firedWorkflowRuntime cancel cascade > cancel during an in-flight fan-out reclaims every child (no orphan)timed out after 20000mssession.llm.stream > sends anthropic tool_use blocks with tool_result immediately after themLocal fork
origin/main@27b6435b4eb7c836a3c17906589e7d70b83fb898was also reviewed. It contains fork-side follow-up work, but the read-state implementation and tests in this PR match the corresponding fork-main read-state files. The only relevant-file delta is unrelated protected-path tightening insrc/project/instance.ts, so this PR remains narrowly scoped to upstreammain.Local Note
The original branch push was done with
--no-verifybecause the machine used at that time hadbun@1.3.11while the pre-push hook requiresbun@^1.3.14. The validation above was rerun withbun@1.3.14.