Repository navigation
Commit 72206e4
Keep the in-memory hosted engine off the disk for Go workspaces (#2031)
* Read the governing go.work in Go discovery
Go discovery read only a go.work at the project root and only members
inside the root. With GOWORK unset it ignored an ancestor go.work and read
the root go.mod in module mode, so in a member of a parent workspace it
could attest a go.mod replace that the workspace overrides, doesn't `use`,
or makes inert by version selection. Hosted and vendored modes resolve the
workspace go itself would use and refuse to write such a replace.
On disk, discovery now loads the governing workspace with the same
go_workspace::load_with loader hosted mode uses: GOWORK (environment, then
the go env -w file), else the nearest go.work at or above the root, with
`use` members anywhere. Out-of-root members' requires and replaces now
count toward selection and conflicts. In-root members are still re-read
through the view, so recognition and parse diagnostics stay the same.
A wired Socket replace that this workspace keeps from the build, at
exactly the points where hosted mode's host_conflict check refuses, stays a
ref (list, rollback and remove still find it) but is marked unattested
with the new UnattestedKind::GoWorkspaceOverride. The same applies to a
replace in the root go.work while GOWORK makes go build another one.
vex_sources reports these under the existing `go_workspace_override`
reason, the one vex's own go.mod gate already uses. A replace that
workspace selection makes inert is still diagnosed, as in module mode.
A GOWORK that go rejects still withholds every ref as patched_ref_invalid.
In memory there is no directory to search from and no environment the
project builds under. The root go.work and its in-root members are the
workspace there, as the in-memory hosted engine reads them, and the same
conflict gate applies. GOWORK keeps its old effect in memory and GOFLAGS
is not read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Keep Go replaces the workspace ignores even when they look inert
Version-selection inertness in replaced_purl, and the hosted selection
checks, ran before Workspace::bypass. A Socket replace that the
governing go.work also refuses (not used, overridden by a go.work
replace, member conflict) was dropped as inert with a diagnostic
instead of being kept as a GoWorkspaceOverride ref, so list, rollback
and remove could not find wiring that re-running scan or vendor would
never clear. Compute the bypass first and skip the inertness checks for
a bypassed replace; it stays a ref and is reported unattested.
Found by Cursor Bugbot on #2011.
Co-Authored-By: Claude <noreply@anthropic.com>
* Address code review findings on Go workspace discovery
This fixes the confirmed /code-review high findings on #2011. Each fix
has a test that fails on the previous commit.
- A Go workspace mark now applies to one file only. The new
UnattestedKind::file_scoped is true only for GoWorkspaceOverride.
vex_sources drops the bypassed ref from the candidate's basis and
vetoes the patch only when no live ref of it remains. wiring_conflicts
ignores bypassed refs. So a root go.work replace that go never reads no
longer withholds the root go.mod's mirror of it. A leftover member pin
that Socket's own go.work replace overrides no longer turns into a
wiring conflict that also withholds the go.work patch, which is what
vex.rs's WorkHosted exemption intends.
- A replace of a module that is itself a `use` member is diagnosed as
inert again, both on disk and in memory, hosted and vendored. This
check now runs before the workspace bypass.
- SumPins now also reads the sum files the loader already read: the
governing go.work.sum and each out-of-root member's go.sum. They are
used only when they lie inside the git repository.
- In memory, workspace conflicts are evaluated in
go_workspace::PathSpace::Memory. Paths are compared lexically against
the view's files and never against the filesystem or the working
directory. conflict/work_conflict delegate to the new *_in variants,
so disk behavior is unchanged.
- The snapshot probe list is now built by one shared helper
(workspace_probes), spelled the way resolve_with spells it.
- A root go.work that go doesn't read is no longer judged unparseable,
and its wiring stays an unattested ref.
- The go_workspace_override omission phrase now covers every case.
- read_loaded_workspace uses members_within. The view re-reads only the
in-root members' go.mod, which recognition and parse diagnostics need.
The duplicate go.sum and go.work.sum reads are gone.
- Tests that use a nested project now create a .git, so they keep
working once reads are bounded to the repository root (#2025).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Keep the in-memory hosted engine off the disk for Go workspaces
The hosted engine hands the golang rewriter the Go workspace it read
(HostedGoWorkspace). In memory its paths are root-relative, but the
rewriter still judged them with the disk checks: replace_host,
rooted_at, selection and host_conflict canonicalized against the
process's cwd and probed `<cwd>/go.mod`. So an in-memory project whose
root module go.work does not `use` got "nowhere to go" (no go.mod)
when the server's cwd had none, and the member answer when it did.
HostedGoWorkspace now carries `files`: in memory, the root-relative
files that exist (go.work, a readable root go.mod, each in-root
member's readable go.mod), filled by the engine as discovery lists
them. The rewriter routes every workspace check through
`PathSpace::Memory` when it is set, via new `_in` variants of
`replace_host`, `selection`, `host_conflict` and `conflict` on
GoWorkspace / Loaded. Disk behaviour is unchanged (the old names
delegate with `PathSpace::Disk`).
`GoWorkspace::selection` also displayed a main-module member through
the disk display_path; discovery's build-list graph now carries the
workspace's PathSpace so in-memory discovery uses `selection_in` too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Keep a root go.mod pin of another patch a Go wiring conflict
2984629 dropped every workspace-bypassed ref from wiring_conflicts, so a
leftover member pin that Socket's go.work replace overrides would not
withhold the go.work patch. That also caught the root go.mod. A
GOWORK=off build from the root reads the root go.mod, so a different
patch there still disagrees with go.work about what the build links.
The behavior is the same reasoning ReplaceHost::mirrors_root_go_mod
uses. e2e_vex_lockfile golang_go_mod_and_go_work_disagreeing_attest_neither
went red in coverage (2): it got go_workspace_override plus
go_version_not_selected skips, not one wiring_conflict skip.
Count bypassed refs in the root go.mod as wiring again. Member go.mod
pins are still exempt, as a_bypassed_leftover_pin_is_no_wiring_conflict
requires.
Co-Authored-By: Claude <noreply@anthropic.com>
* Address code review findings on the in-memory Go workspace
- GoWorkspace carries its own `files` (in memory: the root-relative
files that exist; `None` on disk) and every method routes through
`GoWorkspace::paths()`. The `_in(PathSpace, ..)` variants and their
Disk-default wrappers are gone, so no caller can judge an in-memory
workspace against the disk or the cwd. HostedGoWorkspace::files and
its paths() go with them; the rewriter's code is back to the base's.
- One builder for the in-memory workspace, go_workspace::read_memory,
over a MemoryFiles reader: the hosted engine reads through
read_advisory, discovery through its guarded reads (diagnosing an
unparseable member go.mod). Both list a file in `files` when it
exists (a link, an entry without content, a go.mod go cannot parse
all count), checked without reading it, and both drop an unparseable
member go.mod's text.
- members_within no longer counts `../out` or an absolute member as
inside the empty in-memory root (strip_prefix("") matched them), so
the NoModule hint names in-root members only.
- PathSpace::from_files builds the space from an optional file list.
- The cwd test moved to hosted::engine's tests; read_go_workspace is
private again. The redirect fixtures list the root go.mod whenever
the project has one, as read_memory does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Keep inert Go member replaces as refs; recognize stale sums
Second review round on Go workspace discovery.
- A Socket replace of a module that is itself a `use` member (every
replace of it is inert, and the writers refuse it with
`WorkspaceConflict::MainModule`, which a re-run never clears) was
dropped with a diagnostic, so rollback, remove and list lost wiring
still in the file. It stays a ref, marked `GoWorkspaceOverride`
with the same "is inert" detail (owner decision 4).
- go.sum / member sums / go.work.sum were read only when a hosted ref
existed, so a sum left by a reverted patch was no longer recognized
and a dead ledger claim could be re-derived from its raw text
(rule 11). They are recognized either way.
- The plan both attested a purl (the live go.work patch) and reported
it skipped for a lockfile-only candidate whose only ref is a stale,
bypassed leftover pin of another patch. That candidate is now dropped
with a note when another candidate attests the purl.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Keep an unparseable member go.mod in the in-memory engine
Second review round on the in-memory Go workspace.
The in-memory hosted engine dropped the text of a member go.mod go
cannot parse, while the disk loader keeps it: a member declaring the
patched module (every replace of it inert, `MainModule`) or replacing
it was refused on disk but pinned over in memory. `MemoryFiles::
unparseable` now says whether the text is kept: the engine keeps it,
discovery still drops it after its diagnostic.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Keep go.mod as host for an unreadable in-memory root module
In memory, GoWorkspace::files counts a root go.mod that exists but
has no text the rewriter holds (a link, an unreadable file), and
conflict() reports such a root as "not a member" when go.work does not
use it. The rewriter passes has_go_mod from its candidate texts, so
replace_host saw no root module, chose go.work, and ran work_conflict:
the replace went into go.work, where it patches the members but never
the project. When the root is not a member, treat a root go.mod that
the in-memory workspace lists as the root's module, as on disk, so
go.mod hosts the replace and conflict() refuses it.
Found by Bugbot on df219a6.
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent bb17e0d commit 72206e4
4 files changed
Lines changed: 627 additions & 158 deletions
File tree
- crates/socket-patch-core/src
- hosted
- patch/redirect
- vendor
- vex/discover
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
493 | 493 | | |
494 | 494 | | |
495 | 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 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
496 | 525 | | |
497 | 526 | | |
498 | 527 | | |
499 | 528 | | |
500 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
501 | 534 | | |
502 | 535 | | |
503 | 536 | | |
504 | 537 | | |
505 | 538 | | |
506 | | - | |
| 539 | + | |
507 | 540 | | |
508 | | - | |
| 541 | + | |
509 | 542 | | |
510 | 543 | | |
511 | 544 | | |
512 | 545 | | |
513 | 546 | | |
514 | 547 | | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
552 | 556 | | |
553 | | - | |
| 557 | + | |
554 | 558 | | |
555 | 559 | | |
556 | 560 | | |
| |||
3677 | 3681 | | |
3678 | 3682 | | |
3679 | 3683 | | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
| 3735 | + | |
| 3736 | + | |
| 3737 | + | |
| 3738 | + | |
| 3739 | + | |
| 3740 | + | |
| 3741 | + | |
| 3742 | + | |
| 3743 | + | |
| 3744 | + | |
| 3745 | + | |
| 3746 | + | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
| 3760 | + | |
| 3761 | + | |
| 3762 | + | |
| 3763 | + | |
| 3764 | + | |
| 3765 | + | |
| 3766 | + | |
| 3767 | + | |
| 3768 | + | |
| 3769 | + | |
| 3770 | + | |
| 3771 | + | |
| 3772 | + | |
| 3773 | + | |
| 3774 | + | |
| 3775 | + | |
| 3776 | + | |
| 3777 | + | |
| 3778 | + | |
| 3779 | + | |
| 3780 | + | |
| 3781 | + | |
| 3782 | + | |
| 3783 | + | |
| 3784 | + | |
| 3785 | + | |
| 3786 | + | |
| 3787 | + | |
| 3788 | + | |
| 3789 | + | |
| 3790 | + | |
| 3791 | + | |
| 3792 | + | |
| 3793 | + | |
| 3794 | + | |
| 3795 | + | |
| 3796 | + | |
| 3797 | + | |
| 3798 | + | |
| 3799 | + | |
| 3800 | + | |
| 3801 | + | |
| 3802 | + | |
| 3803 | + | |
| 3804 | + | |
| 3805 | + | |
| 3806 | + | |
| 3807 | + | |
| 3808 | + | |
| 3809 | + | |
| 3810 | + | |
| 3811 | + | |
| 3812 | + | |
| 3813 | + | |
| 3814 | + | |
| 3815 | + | |
| 3816 | + | |
| 3817 | + | |
| 3818 | + | |
3680 | 3819 | | |
3681 | 3820 | | |
3682 | 3821 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24403 | 24403 | | |
24404 | 24404 | | |
24405 | 24405 | | |
24406 | | - | |
24407 | | - | |
| 24406 | + | |
| 24407 | + | |
| 24408 | + | |
| 24409 | + | |
| 24410 | + | |
| 24411 | + | |
| 24412 | + | |
24408 | 24413 | | |
24409 | 24414 | | |
24410 | 24415 | | |
| |||
24436 | 24441 | | |
24437 | 24442 | | |
24438 | 24443 | | |
| 24444 | + | |
| 24445 | + | |
| 24446 | + | |
| 24447 | + | |
24439 | 24448 | | |
24440 | 24449 | | |
24441 | 24450 | | |
| |||
24446 | 24455 | | |
24447 | 24456 | | |
24448 | 24457 | | |
| 24458 | + | |
| 24459 | + | |
| 24460 | + | |
| 24461 | + | |
| 24462 | + | |
| 24463 | + | |
| 24464 | + | |
| 24465 | + | |
| 24466 | + | |
| 24467 | + | |
| 24468 | + | |
| 24469 | + | |
| 24470 | + | |
| 24471 | + | |
| 24472 | + | |
| 24473 | + | |
| 24474 | + | |
| 24475 | + | |
| 24476 | + | |
| 24477 | + | |
| 24478 | + | |
| 24479 | + | |
| 24480 | + | |
24449 | 24481 | | |
24450 | 24482 | | |
24451 | 24483 | | |
24452 | 24484 | | |
24453 | 24485 | | |
24454 | 24486 | | |
24455 | 24487 | | |
24456 | | - | |
| 24488 | + | |
24457 | 24489 | | |
24458 | 24490 | | |
24459 | 24491 | | |
| |||
24482 | 24514 | | |
24483 | 24515 | | |
24484 | 24516 | | |
24485 | | - | |
24486 | | - | |
| 24517 | + | |
| 24518 | + | |
| 24519 | + | |
| 24520 | + | |
| 24521 | + | |
24487 | 24522 | | |
24488 | 24523 | | |
24489 | 24524 | | |
| |||
24501 | 24536 | | |
24502 | 24537 | | |
24503 | 24538 | | |
| 24539 | + | |
24504 | 24540 | | |
24505 | 24541 | | |
24506 | 24542 | | |
| |||
24516 | 24552 | | |
24517 | 24553 | | |
24518 | 24554 | | |
24519 | | - | |
| 24555 | + | |
24520 | 24556 | | |
24521 | 24557 | | |
24522 | 24558 | | |
| |||
24526 | 24562 | | |
24527 | 24563 | | |
24528 | 24564 | | |
24529 | | - | |
| 24565 | + | |
24530 | 24566 | | |
24531 | 24567 | | |
24532 | 24568 | | |
| |||
24659 | 24695 | | |
24660 | 24696 | | |
24661 | 24697 | | |
| 24698 | + | |
24662 | 24699 | | |
24663 | 24700 | | |
24664 | 24701 | | |
| |||
0 commit comments