Repository navigation
Commit 18ada3e
committed
fix(workspace): revalidate the binding before mutating MCP state
Codex round 6. run() snapshots the binding at the top, but reaching a mutation
costs seconds: a status call, one or two process spawns for --version, and the
workspace allowlist over the network. A re-link inside that window left the
attach acting for a workspace the project had already left.
Per-project serialization did not help, and made one case worse. It orders the
writes, so a stale attach installs FIRST and the replacement queues behind it;
the waiting session's bounded first-turn wait is spent in that queue, so its tool
list could be resolved while the stale workspace's engine was the one attached.
Everything that mutates MCP state now revalidates the binding immediately before
doing so and abandons instead: the spawn returns `superseded` without persisting
or adding, and a teardown decided for a workspace we have left is skipped rather
than executed. The check is a local cache read, cheap enough to repeat before
each mutation. `superseded` is repairable, so the next turn attaches the
workspace the project actually holds.
Residual, deliberately not addressed here: a superseded attach still occupies the
project queue until it reaches its guard, so a session waiting behind it can
still spend part of its wait on work that will be discarded. Cancelling in-flight
attaches rather than letting them reach the guard is a larger change.
2 tests: a re-link during the slow phase abandons without installing the old
workspace, and an unchanged binding still attaches. The first fails with the
guard reverted.1 parent a719eb5 commit 18ada3e
2 files changed
Lines changed: 68 additions & 1 deletion
File tree
- packages/opencode
- src/altimate/workspace
- test/altimate/workspace
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
419 | 420 | | |
420 | 421 | | |
421 | 422 | | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
422 | 440 | | |
423 | 441 | | |
424 | 442 | | |
| |||
433 | 451 | | |
434 | 452 | | |
435 | 453 | | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
436 | 458 | | |
437 | 459 | | |
438 | 460 | | |
| |||
620 | 642 | | |
621 | 643 | | |
622 | 644 | | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
623 | 651 | | |
624 | 652 | | |
625 | 653 | | |
| |||
674 | 702 | | |
675 | 703 | | |
676 | 704 | | |
677 | | - | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
678 | 712 | | |
679 | 713 | | |
680 | 714 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
918 | 918 | | |
919 | 919 | | |
920 | 920 | | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
0 commit comments