Repository navigation
Commit 37714b4
committed
fix(workspace): close four attach races found by codex round 3
All four verified against the branch before fixing.
**A superseded attach can no longer overwrite the current one.** Re-linking a
live session started a second attach without ordering it against the first.
Both end in `MCP.add`, and whichever completes last owns the runtime client, so
a slower attach for the workspace just left could land after the new one and
restore its tools — with the new memo already settled, so no later turn would
repair it. Replacement attaches are now serialized per session: the superseded
task is awaited before the next one starts, which makes the final `MCP.add` the
current workspace's by construction.
**Persisting the entry now invalidates the config cache.** `Config.get()` is
cached per instance and `addMcpToConfig` is a raw file write that does not touch
that cache, so every later `existingEntry()` in the process still saw the
pre-write config. A managed entry then became unrecognisable to `isManagedEntry`,
which is what leaves a stale engine attached in a project whose binding stopped
resolving — the failure mode the previous commit's unbound teardown was supposed
to prevent. The local-config write path in `config.ts` already invalidates for
this exact reason; the engine entry now does too.
**A repairable failure is re-probed on the next turn.** `engine-missing`,
`engine-too-old` and `connect-failed` were memoised for the life of the session,
so a user who followed the install hint we had just printed saw nothing happen
until they started a new session. Those three outcomes are now retried; success
stays memoised, so this does not mean re-attaching every turn. The retry
deliberately does NOT re-arm the bounded wait: it runs on every turn, and a
`connect-failed` retry sitting in MCP's 30s connect budget would otherwise
charge each turn the full cap. Repaired tools arrive over `tools/list_changed`.
**The version probe targets the engine, not its wrapper.** For a pinned entry
like `npx @altimateai/[email protected] start-stdio --datamate 42`, the probe ran
`npx --version`, so a modern wrapper vouched for a pre-floor engine that does not
provide the locked workspace pin attribution relies on. Only a directly
identifiable `datamate` executable is probed now; anything else yields no version
and falls through to the below-floor handling — replaced from PATH, or reported.
Asking the running server instead is not an option: `serverInfo.version` is a
hard-coded placeholder on precisely the engines this floor excludes.
7 further tests: retry after install and after update, success still memoised,
the retry not re-arming the wait, npx not probed and replaced, an absolute
datamate path probed and reused, and a slow superseded attach losing to the
re-linked workspace.1 parent 2480439 commit 37714b4
2 files changed
Lines changed: 186 additions & 8 deletions
File tree
- packages/opencode
- src/altimate/workspace
- test/altimate/workspace
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
266 | 275 | | |
267 | 276 | | |
268 | 277 | | |
| |||
486 | 495 | | |
487 | 496 | | |
488 | 497 | | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
489 | 505 | | |
490 | | - | |
| 506 | + | |
| 507 | + | |
491 | 508 | | |
492 | 509 | | |
493 | 510 | | |
| |||
633 | 650 | | |
634 | 651 | | |
635 | 652 | | |
636 | | - | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
637 | 664 | | |
638 | 665 | | |
639 | 666 | | |
| |||
662 | 689 | | |
663 | 690 | | |
664 | 691 | | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
670 | 697 | | |
671 | | - | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
672 | 715 | | |
673 | 716 | | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
674 | 723 | | |
675 | 724 | | |
676 | 725 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
671 | 671 | | |
672 | 672 | | |
673 | 673 | | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
0 commit comments