Repository navigation
Conversation
A new zero-dependency crate, borzoi-verdict, with two types: Verdict<T, C> (Certain | Unknown(cause)) and Lookup<T, C> (Found | ProvedAbsent | Unknown(cause)), the same information converted losslessly both ways. It has no conversion from or to Option/bool, no Default, no iteration and no `or` on Verdict, each held by a compile_fail doctest. Every operation's laws (functor, monad, zip as sequencing, collect as a fold of zip, or_shadowed's identity/zeros/associativity/laziness, the isomorphism's round trips and naturality) are checked exhaustively over a finite domain, every function on it included. No consumers yet: #1121's plan wires it into msbuild's ParsedProject next. crates/verdict routes to the `workspace` change filter, as crates/spawn does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s, and the surface is an exact list Codex round 1 (xhigh) found two defects in `FromIterator for Verdict`: - A target that stops reading early (`Option<Vec<_>>` at its first `None`) hid a later `Unknown`, so the collection came back `Certain`. - The `map_while` adapter was not fused, so a target that asked again after being told the end read past the first `Unknown`, and reported a later cause. Collection now reads through a fused adapter that also stops at the source's first end, and checks the rest of the source when the target stopped early. The law tests run collection under every way a target can read (all, none, a prefix, through a value, asking again after the end), over a source that is not fused, and into `Option<Vec<_>>`. The old implementation fails them. A reading as `Option`/`bool`/`Default` can be added under any name, which `compile_fail` doctests cannot see, so `tests/surface.rs` holds every item of `src/lib.rs` to an exact list (syn and quote, as dev-dependencies only). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ve a hostile-table row
Codex round 2 (xhigh):
- The surface listing saw only plain `derive`s, so a
`#[cfg_attr(target_os = "macos", derive(Default))]` with a `#[default]`
variant left it unchanged while giving one platform a `Default`. The
listing now records every attribute other than docs:
- on each type, each variant (now listed with its fields), each method,
each impl, and the crate itself;
- a plain `derive` by its sorted names, everything else as written.
- Its own test mutated `src/lib.rs` by text, so reordering a derive there
broke it. It now runs on a fixture, holding the listing to move on every
change to a surface (new names, impls, plain and conditional derives,
`#[default]`, variants, `cfg` on methods and impls, crate attributes) and to
stay put on derive order, docs and formatting.
- `tests/laws.rs` runs a table-driven differential with no automatic marker,
so it gets a not-applicable row in the hostile-value table.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex round 3 (xhigh) found that the surface listing named each method but not its signature: changing `or_shadowed`'s `FnOnce` to `Fn` left every test green. This is the second round to find a dimension the listing modelled apart, so it no longer models dimensions at all. It lists the whole of `src/lib.rs` except what cannot change the surface: doc comments and function bodies. A plain `derive` has its names sorted. Each impl's header and each member get a line apiece. The fixture test now also moves on a loosened bound, a parameter, a return type, an impl bound, a where clause, a changed field and a bound on a trait method. It stays put on derive order, docs, formatting and function bodies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex round 4 (xhigh) found that an impl inside a function body (in a local module) adds methods callable from outside the crate, and that clearing bodies hid it. The listing now walks each function body before dropping its statements. It lists every item the body declares, recursively, as a top-level item is listed, and the path of every macro the body invokes, since a macro may expand to items. The fixture test moves on a nested impl in a local module, an impl directly in a body, a nested function, an `include!` and a macro in an expression. `tests/surface.rs` perturbs a fixture, so it gets a not-applicable row in the hostile-value table too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex round 5 (xhigh): - The surface listing recorded a body macro by its path alone. A local module declaring a public method on `Lookup`, placed in the scrutinee of the existing `matches!`, reached other crates unlisted. A macro's arguments are the one part of a body the syntax walk cannot see into, so the listing now records each invocation whole. The fixture covers changing an existing macro's arguments. - The collection law promised `Certain(values.collect())` for every target, but a target may read the size hint, and the adapter offers a lower bound of zero (an `Unknown` may cut the source short) and the source's upper bound. The law now says so, and qualifies the plain-collect form to targets whose result depends only on the values. The law tests add a target that reads the lower bound's worth and one that checks the upper bound. Forwarding the source's lower bound, or a too-small upper bound, fails them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and check the size hint offered The surface test read the crate's surface off its syntax. Rounds 2–5 each found another place an addition could hide from it (a conditional derive, a signature, an item declared in a body, a macro's arguments), and each fix grew the walker the next round probed. There is now no walker. `tests/pin.rs` pins every file under `src` whole, by SHA-1 and length in `tests/src.pin`, together with the set of file names. Any edit, and any new or removed file, fails until the pin is regenerated (`BORZOI_UPDATE_MANIFESTS=1`), so every change to this primitive is in a reviewed diff. Doc comments are pinned too, so the parser that excluded them goes, and with it the syn and quote dev-dependencies (sha1 replaces them). The hostile-value table's row for `tests/surface.rs` goes with that file. The pin perturbs nothing, so it needs no row. The row for `tests/laws.rs` still applies. Codex round 6 found that the collection laws checked a target's reads against the size hint's upper bound but not the hint itself, so an adapter offering `(0, None)` passed. A target now records the hint it is offered before every read and after the end, and the laws hold it to a lower bound of zero and the source's upper bound at each step, through to `(0, Some(0))` once the first `Unknown` or the end is reached. An adapter offering `(0, None)` fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex round 7 found that under `core.autocrlf=true`, Git checks out `src/lib.rs` with CRLF, so hashing its working-tree bytes failed the pin on an unchanged checkout. rustc reads a CRLF line end as LF, so the pin now hashes those bytes. A lone CR is kept, since rustc reads it. The pin file is compared by line, so its own line ends do not matter either. A unit test holds the normalisation, and a CRLF copy of the crate passes every test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Smaug123
marked this pull request as ready for review
November 26, 2026 08:11
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claim.
borzoi-verdictprovides two types, each of which can hold an answer only in a form that cannot be read as complete:Verdict<T, C>isCertain(T) | Unknown(C).Lookup<T, C>isFound(T) | ProvedAbsent | Unknown(C).Lookup<T, C>andVerdict<Option<T>, C>convert into each other without loss. Each operation obeys the laws written in its doc comment, and each law is checked exhaustively. This PR adds no consumers.Domain. The crate is the whole domain: its two types, the isomorphism between them, and these operations:
map,map_cause,and_thenandas_refon both types;zipandFromIteratoronVerdict;or_shadowedonLookup.This is the first PR of #1121's plan. The plan's PR 1b uses the crate to publish
ParsedProject's defines and reference edges as verdicts (#1112).Deliberately absent:
Optionorbool. It would assert that the search behind aNoneorfalsewas complete.Optionorbool, and iteration. Each mergesProvedAbsentorUnknowninto another variant.Default. It would give anUnknownwith no cause, or an unprovenProvedAbsent.oronVerdict. Falling back to another value is a guess.compile_faildoctests spell out each absence, and a passing control doctest shows that the allowed spelling of each line compiles. A reading can be added under any name, sotests/pin.rsalso pins every file undersrcwhole, by the SHA-1 of the bytes rustc compiles. Any change to the crate therefore fails untiltests/src.pinis regenerated, and the regenerated pin is in the diff.Laws, checked exhaustively (
tests/laws.rs). Values range over {0, 1} and causes over {a, b}, so a verdict takes 4 values and a lookup 5. Every function the laws quantify over is enumerated as a table: 4 value functions, 16 verdict-valued, 25 lookup-valued and 4 cause functions. The laws:Functors and monads.
mapandmap_causeare functors on both types.and_thenis a monad on both, withUnknown(and, for a lookup,ProvedAbsent) passing through.zip. It equals sequencing (v.and_then(|x| w.map(|y| (x, y)))), keeps the leftmostUnknown, and is associative up to regrouping.collect. It gives the leftmostUnknown, else the target's collection of the values, however the target reads. That is checked for each of seven ways of reading:The source is not fused, and every sequence up to length 4 is checked (341 sequences). Two more checks:
Option<Vec<_>>, over 781 sequences;Vec, where collecting equals the fold ofzip.The source is never read past its first
Unknownor its first end.or_shadowed.ProvedAbsentis the two-sided identity.FoundandUnknownare left zeros: an innerUnknownis never skipped.The isomorphism. It round-trips both ways, and commutes with
map,map_causeandand_then.Mutation check. Every guard was mutated and seen to fail a test (each mutation confirmed applied by comparing file contents, then restored from a saved copy):
From<Option>,From<Lookup> for Option,From<bool>,Into<bool>,Default(either type),IntoIteratororVerdict::orfails its owncompile_faildoctest, and only that one. Any edit tosrc/fails the pin.or_shadowed. Skipping an innerUnknown, or evaluating the outer scope eagerly, fails the law tests.zip. Keeping the rightmostUnknownfails the law tests.collect. Each of these fails the law tests:map_whileimplementation (codex round 1's repro);Unknown, or after the end;Unknownoverwriting the first;Some(0)orNone.map. Breaking either direction of the isomorphism, or losingFoundinmap, fails the law tests.src/.CI. No job in
.github/workflows/ci.ymlrunscargo test -p borzoi-verdict, and the agent token cannot push workflow changes.crates/verdictroutes to theworkspacefilter, ascrates/spawndoes.detect-changes.test.shgains that routing case.test-verdictjob, a copy oftest-spawnadded to the required-checks aggregate, is the patch below.dae95d59("ci: run the verdict crate's tests").test-verdictran the crate's 22 law tests, 3 pin tests and 13 doctests and passed, andall-required-checks-completeis green.detect-changes.test.shwould not have noticed the missing job. That gap is filed as detect-changes.test.sh passes a workspace crate whose tests no CI job runs #1165.ci.yml patch (also
ci-test-verdict.patchin the agent's worktree)Gate. Green on the build box at
f2c405da(and at779ac5c9before it): fmt, clippy, doc, the featurelessborzoi-verdictlint and doc,cargo test(whole workspace), the crate's tests, anddetect-changes.test.sh. The CI commit on top changes only the workflow, and the PR's CI runstest-verdicton it.Codex. Rounds 1–6 ran at xhigh, and rounds 7 and 8 at high (the user's setting since). Every round also flagged the missing CI job, which the patch below closes. The other findings, by round:
collectinto a target that stops early hid a laterUnknown.compile_failblocks check only the names they spell.cfg_attrderives.lib.rsis spelt.collectlaw did not account for size hints.Rounds 2–5 were one stream: each found another way to hide from a surface listing read off the syntax. So the listing was replaced by a whole-text pin, which has no walker for anything to hide from. Every finding is fixed, each with a test that fails without its fix.
dae95d59, which includes the user's CI commit, against merge basef935de31): no findings.Decline cost. None: the crate has no consumers, and every manifest is unchanged.
🤖 Generated with Claude Code