Several facts travelled through the resolver, the lockfile's YAML emitter,
the default reporter and pnpr as bare `bool`s that could not be read at
the use site: a `true`/`false` literal selecting which of two behaviors a
function performs, a `bool` travelling in a tuple with no name, two flags
where one implies the other, and a `bool` return meaning "which of two
things happened". Each of those now has a name.
In the resolver:
- `PeerWalkMode { Discovery, Final }` replaces `Walker::new`'s
`discovery: bool` and the traversal field it was stored in, and
`ChildOutputs::push` takes that mode instead of its own
`collect_dep_paths: bool`.
- `PeerIdRecording { Record, Skip }` replaces the `record_peer_ids: bool`
of the final-path pass, parameter and field.
- `ChildrenRecording` travels back to the callers of the children
realisation next to the children, instead of the `bool` that
`into_children` flattened it to; its callers ask it
`stales_other_occurrences`.
- `PackageRegistration { Created(Arc<str>), Existing(Arc<str>) }`
replaces the `(Arc<str>, bool)` the two package registrations
returned.
- `DependencySpec { alias, bare_specifier, optional, injected }` replaces
the `(String, String, bool, bool)` tuple that lived under two aliases,
`WantedSpec` and `ChildSpec`, and was read positionally in six files. Its
fields are named after `WantedDependency`'s, the resolved form they feed.
`hoisted_dependency` builds the shape both hoist rounds want, with the
rationale for its two defaults in one place.
- `collect_deps` takes a `DependencyGroup` instead of a manifest key and
an `optional: bool`, and derives both from the group, so a caller
cannot pair a key with the wrong flag.
- `WorkspacePeerSettings` groups the three consecutive booleans of
`resolve_peers_workspace` into named fields.
- `NodeKind { Link, Leaf, Branch }` replaces the `is_link`/`is_leaf`
field pair, of which only three of the four combinations were states.
- `ReusableResolution { Registry, Git }` replaces the `bool` inside the
`Option<bool>` that `reusable_resolution_is_git` answered.
- `reuse.rs` calls the shared `register_peer_dep_names` instead of
keeping a verbatim copy of it.
In the lockfile's YAML emitter, four `bool`s threaded through every node
and were read positionally by ten functions: `CollectionStyle`,
`FirstEntry`, `EntrySpacing` and `ScalarLines` replace them, in
`yaml_emit/style.rs`.
In the default reporter, `BlockPlacement { Scrolling, Pinned }` replaces
`Frame::emit`'s `fixed: bool`.
In the filesystem crate, `LockMode { Exclusive, Shared }` replaces the
`exclusive: bool` of `lock_file` and `try_lock_file`, and every
implementation maps it with a match: the standard library's methods,
Android's `flock` operation, and the WebContainer host lease's flag.
In the hoisted linker, `DirectLink { Unchanged, Created,
RootShadowRemoved }` replaces the `(bool, bool)` that linking one direct
dependency returned, of which only three combinations occurred.
In pnpr:
- `ResponseBody { Sent, Omitted }` replaces the `head: bool` of three OCI
response builders and derives itself from the request method in one
place.
- `MetadataFreshness { Cached, Refetched }` replaces the `refresh: bool`
of the OIDC provider-metadata read, and separates the freshness
question from the retry rate limit that shared the flag. A preparatory
commit moves that cache into `oidc/provider_metadata.rs`, which also
brings `oidc.rs` back under the file-length limit.
- `OrgGrant { Read, Publish }` replaces the `publish: bool` that main's
organization consolidation left on `CallerOrgs::authorize` and on
`authorized_owner_key`, so the pipeline-run, compiler-cache and
shared-artifact paths ask for a grant with one named type.
- `GroupMatching { shadowed, allow_unresolved }` replaces the
`(bool, &HashSet<&str>)` tuple parameter of the directory-dependency
freshness check, whose call site read `(false, &peers.shadowed)`.
- `reject_removed_blocks` takes the parsed `packages:` and `groups:`
blocks, whose distinct types make the transposition its two same-typed
flags allowed a compile error.
- `ExistingDestination { Replace, Keep }` replaces the `replace: bool`
behind `write_atomic` and `write_atomic_new`.
- `StaleEntry { Delete, Keep }` replaces the `delete_stale: bool` of the
cargo index cache read.
- The resolution cache's eviction helpers lose a `private_first: bool`
that their callers always passed as `true`, and the fallback branch
that only ran when it was `false`;
`CandidateScope { PrivateOnly, Any }` names the choice that remains.
- `CrateDocument::max_version` reads its two passes through named
closures instead of a `yanked_allowed` flag.
Every branch on one of these enums is an exhaustive `match` that names
every variant, with no wildcard arm, no `matches!` and no `==` against a
variant, so adding a variant is a compile error at each site that has to
decide.
The criteria behind these choices are written down in
pnpm/CODE_STYLE_GUIDE.md under "Boolean parameters and fields": which
questions a `bool` may answer, how its use sites must read, what a
neighbouring flag does to it, and the exemptions that keep most of the
workspace's `bool`s as they are. This branch adds the section, including
the rule that a flag named for one of several alternatives wants an enum
of those alternatives rather than a better name, and the wildcard arm
that gives an unreachable combination away.
No behavior changes. The lockfile, resolver, package-manager, reporter,
fs, store-dir, deps-restorer, CLI and pnpr suites pass, and the first two
compare emitted lockfiles byte for byte.