You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vendored mode refuses an unreadable .yarnrc.yml ("cannot read … to verify the cache configuration"). The hosted takeover preflight treats an unreadable one as absent (.ok() in scan/hosted.rs#L1671-L1675).``
Hosted mode also imports vendor::yarn_berry_lock::yarnrc_compression_level (redirect/mod.rs#L30), which is a redirect → vendor layering edge.
Symptoms and impact
#628. Any future berry gate, such as a new cache-format version, would again have to be added twice. The risk is low.
Proposed change
Add formats/yarn/berry_gates.rs, a pure module with no I/O:
SUPPORTED_CACHE_KEY, plus cache_key(lock_text) -> Option<&str> built on scan_blocks/berry_field;
yarnrc_compression_level, moved here;
fn check(lock: &str, manifest: Option<&str>, yarnrc: YarnrcState) -> Result<(), BerryGate>, where BerryGate is { MixedLineEndings { file }, CacheKey { found }, Compression { level }, YarnrcUnreadable } and owns the detail text.
Each mode maps BerryGate to its own code prefix (vendor_yarn_berry_* or redirect_yarn_berry_*), so the codes don't change.
Delete:YARN_BERRY_SUPPORTED_CACHE_KEY, berry_cache_key, the three refuse_* bodies' text, and the hosted refusal text. Keep this PR behavior-neutral apart from what #628 decides: either land #628's policy here, or keep hosted mode's manifest argument None until #628.
Size and scope
About 150 production lines moved and about 90 deleted, across vendor/yarn_berry_lock.rs, patch/redirect/mod.rs, a new formats/yarn/berry_gates.rs and the takeover caller in commands/scan/hosted.rs. Out of scope: the berry entry writers and restorers (E08), and the classic grammar.
Acceptance criteria
One cacheKey constant, one extractor and one gate function, used by vendored vendor/preflight, the hosted rewriter and the vendored→hosted takeover.
The codes are unchanged: vendor_yarn_berry_cache_unsupported, vendor_yarn_berry_mixed_line_endings, redirect_yarn_berry_cache_unsupported, redirect_yarn_berry_mixed_line_endings.
A table test feeds the same inputs (cacheKey 10, missing __metadata, compressionLevel: mixed, a mixed lock, a BOM lock) to both modes and asserts the same BerryGate.
patch/redirect no longer imports from vendor::yarn_berry_lock for gates.
Dependencies
Blocks nothing, and pairs with #628. It is part of review fix D (hosted yarn writers on LockBlock, E08).
[agent] Filed by the scheduled architecture audit routine (ecosystems and formats). Register: discussion #560 register.
Kind: refactor. Source: review Part 4.4 ("Yarn berry project gates are written twice") and 4.7 D; register E09.
Problem
The berry project-level refusals (mixed line endings,
cacheKey,compressionLevel) are implemented once per mode. Verified on045d7ec:SUPPORTED_CACHE_KEYYARN_BERRY_SUPPORTED_CACHE_KEY("matches the vendored backend's")berry_metadata+berry_fieldoverscan_blocksberry_cache_key,`` asplit("\n\n")scan ("mirroring the vendored backend's `berry_field`")refuse_mixed_line_endings/refuse_unsupported_cache/refuse_unsupported_compression+yarn_berry_vendor_preflightpreflight_yarn_berry_hostedOnly
yarnrc_compression_levelis already shared (since #508 fixed #370 once for both modes). The rest has drifted:package.jsonat all (Hosted yarn berry rewrites a mixed-line-ending package.json that vendored mode refuses #628)..yarnrc.yml("cannot read … to verify the cache configuration"). The hosted takeover preflight treats an unreadable one as absent (.ok()inscan/hosted.rs#L1671-L1675).``Hosted mode also imports
vendor::yarn_berry_lock::yarnrc_compression_level(redirect/mod.rs#L30), which is aredirect→vendorlayering edge.Symptoms and impact
#628. Any future berry gate, such as a new cache-format version, would again have to be added twice. The risk is low.
Proposed change
Add
formats/yarn/berry_gates.rs, a pure module with no I/O:SUPPORTED_CACHE_KEY, pluscache_key(lock_text) -> Option<&str>built onscan_blocks/berry_field;yarnrc_compression_level, moved here;fn check(lock: &str, manifest: Option<&str>, yarnrc: YarnrcState) -> Result<(), BerryGate>, whereBerryGateis{ MixedLineEndings { file }, CacheKey { found }, Compression { level }, YarnrcUnreadable }and owns the detail text.Each mode maps
BerryGateto its own code prefix (vendor_yarn_berry_*orredirect_yarn_berry_*), so the codes don't change.Delete:
YARN_BERRY_SUPPORTED_CACHE_KEY,berry_cache_key, the threerefuse_*bodies' text, and the hosted refusal text. Keep this PR behavior-neutral apart from what #628 decides: either land #628's policy here, or keep hosted mode's manifest argumentNoneuntil #628.Size and scope
About 150 production lines moved and about 90 deleted, across
vendor/yarn_berry_lock.rs,patch/redirect/mod.rs, a newformats/yarn/berry_gates.rsand the takeover caller incommands/scan/hosted.rs. Out of scope: the berry entry writers and restorers (E08), and the classic grammar.Acceptance criteria
vendor_yarn_berry_cache_unsupported,vendor_yarn_berry_mixed_line_endings,redirect_yarn_berry_cache_unsupported,redirect_yarn_berry_mixed_line_endings.yarn_berry_warning_branches,mixed_line_endings_refuse_before_any_write, theyarnrc_compression_level_*tests and the takeover gate tests from Fix berry mode takeover reverting before gates (#468, #369) #470 stay green.10, missing__metadata,compressionLevel: mixed, a mixed lock, a BOM lock) to both modes and asserts the sameBerryGate.patch/redirectno longer imports fromvendor::yarn_berry_lockfor gates.Dependencies
Blocks nothing, and pairs with #628. It is part of review fix D (hosted yarn writers on
LockBlock, E08).