Repository navigation
Commit 2480439
committed
fix(workspace): detach rejected engines, and report the gap on reuse
Codex round 2 on ec21cc0. Three findings, all verified against the branch.
**A rejected engine is now detached at the moment of rejection.** Teardown ran
just before the replacement spawn, so every exit that failed to produce a
replacement — `engine-missing`, and both `engine-too-old` returns — came back
with the rejected engine still connected. The turn's `resolveTools` then handed
the model exactly the tools the attribution check had just decided it must not
have: an unpinned engine serving whichever workspace its owner had active, or
one below the floor whose `--datamate` pin the engine does not lock. Worse than
the pre-attribution behaviour, because the client had explicitly judged it
untrustworthy and served it anyway. `detachRejected` now runs at each rejection
site, so "we will not use this engine" and "this engine is no longer serving
this session" are the same event. It stays runtime-only (`MCP.remove`): the
config file is never touched.
**Reuse reports declared-versus-delivered, like the fresh attach.** A running
engine that lost an integration — a deleted connection, a restart that dropped
one — serves fewer tools than the workspace declares, and only the fresh-attach
path said so. Reuse is the common path, so silence there is exactly where the
gap goes unnoticed; it was visible in this branch's own testing, where a
workspace declaring 52 keys delivered 12 and then 7 across a connection change.
`reused` now carries `declared` and `missing` and warns when the gap is
non-empty. An unreadable allowlist degrades quietly rather than inventing a gap.
**An unbound project no longer keeps a stale managed entry.** MCP bootstrap
starts every enabled config entry before the prompt (`src/mcp/index.ts:762-781`),
while `run()` returned for an unbound project without touching it — so unlinking
a project left the previously pinned workspace's tools still attached. Only an
entry matching the exact command we persist is torn down; an IDE-written or
hand-edited entry is the user's and is left alone, and the config is not
modified either way.
The related half of that finding — a project attached under the pilot flag keeps
its tools when the flag is later off — is NOT fixed here. Acting on it means
doing MCP work while the gate is closed, which is the opposite of what the gate
is for, and deciding whether a pilot flag should retroactively disable an entry
the user now has in their project config is a product call. Recorded in the PR
body under "Held for Ralph" instead of guessed at.
9 further tests: detach on each irreplaceable-rejection exit, the reuse gap and
its toast, an unreadable allowlist, and unbound detaching our managed entry while
leaving an IDE entry alone.1 parent ec21cc0 commit 2480439
2 files changed
Lines changed: 197 additions & 32 deletions
File tree
- packages/opencode
- src/altimate/workspace
- test/altimate/workspace
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
315 | 323 | | |
316 | 324 | | |
317 | 325 | | |
| |||
366 | 374 | | |
367 | 375 | | |
368 | 376 | | |
| 377 | + | |
| 378 | + | |
369 | 379 | | |
370 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
371 | 398 | | |
372 | | - | |
373 | 399 | | |
374 | 400 | | |
375 | 401 | | |
| |||
385 | 411 | | |
386 | 412 | | |
387 | 413 | | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
393 | 433 | | |
394 | 434 | | |
395 | 435 | | |
| |||
436 | 476 | | |
437 | 477 | | |
438 | 478 | | |
439 | | - | |
440 | 479 | | |
441 | 480 | | |
442 | 481 | | |
443 | | - | |
| 482 | + | |
444 | 483 | | |
445 | 484 | | |
446 | 485 | | |
447 | 486 | | |
| 487 | + | |
448 | 488 | | |
449 | 489 | | |
450 | 490 | | |
451 | 491 | | |
452 | | - | |
453 | | - | |
454 | | - | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
455 | 522 | | |
456 | 523 | | |
457 | 524 | | |
| |||
460 | 527 | | |
461 | 528 | | |
462 | 529 | | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
463 | 533 | | |
464 | 534 | | |
465 | 535 | | |
| |||
470 | 540 | | |
471 | 541 | | |
472 | 542 | | |
473 | | - | |
474 | 543 | | |
475 | | - | |
| 544 | + | |
476 | 545 | | |
477 | 546 | | |
478 | 547 | | |
479 | 548 | | |
| 549 | + | |
480 | 550 | | |
481 | 551 | | |
482 | 552 | | |
| |||
515 | 585 | | |
516 | 586 | | |
517 | 587 | | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | 588 | | |
534 | 589 | | |
535 | 590 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
403 | | - | |
| 403 | + | |
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
| |||
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
0 commit comments