~/bend-docscommunity

src/doctor/plan.bend fails

raw source on the hub · import ezx@1.9.0.0/src/doctor/plan.bend as Plan

doctor/plan: ez doctor as a pure planner. It reads a World (doctor/world.bend) and returns either the questions it still needs answered (step) or a Plan: the lines to print and how the command ends (plan). The interpreter (doctor/run.bend) loops on step, answering each question by IO, until nothing is left to ask, then prints the plan.

Doctor says what would stop this project from building. Each line reports what was found rather than a tick, because the useful answers here are values: which bend, which compiler, which packages are on disk, and which hashes the source and the ledger disagree about. A line that is a problem fails the command, as cargo check fails on the first thing it cannot build, though doctor goes on to say everything it found.

The plan is lines said and an outcome, and nothing else: doctor writes no file, lays no tree and removes nothing (EZ-VEN-4). The questions it asks write nothing either: a program asked for its version, ls of the library, git's listing of the tracked sources, and a package's files read from under BEND_LIB.

A named import, import <name>@<version>/..., is read the same way: its name is what the import line names, reported when no dependency of the ledger records it, and a dependency recorded by a name is used when an import line names it by that name or by its hash. Each name the lock records has its file under BEND_LIB/names, which bend reads the name's hash from before it asks the hub; one missing, or naming another hash, is reported with the library, and fails the command.

The drift report is the ledger against the import lines. A package's 0x hash is written in two places, the [deps.<name>] section of ez.toml and the import 0x... line that uses it, so the two can disagree. ez treats the ledger as the record and the import lines as the truth, and reports the disagreement both ways rather than rewriting anyone's source (EZ-VEN-5). An import line is one the lock reads as one: in the header of a .bend file git tracks outside .ez/, found by the package walk's own scan (P.roots), so doctor and ez lock never disagree about what the source imports. A ledger's [tools.*] pins are not dependencies, and the report never reads them (EZ-LED-5).

The lock is checked the way cargo --locked and uv lock --check check one, without the network: doctor puts a plain ez lock to the lock's own planner (lock/plan.bend), over the ledger as it is, tools and all, the sources git lists, and the trees BEND_LIB holds, and compares the text it would write with ez.lock.toml byte for byte (EZ-VEN-6). So every hash, source, file sum and tool pin the lock records is checked, by the code that writes them. A package the lock would read and BEND_LIB lacks is one doctor cannot see, and the lock is then said to be unchecked rather than guessed at; that, a lock ez lock would refuse to write, and a lock it would write otherwise, each fail the command.

The Effect, Plan and Outcome types are the lock's (lock/plan.bend), as for the other commands.

8 imports
import Base
import ../toml/toml.bend as T
import ./world.bend as DW
import ../lock/plan.bend as P
import ../lock/world.bend as W
import ../lock/lock.bend as L
import ../ledger/manifest.bend as M
import ../share/args.bend as Args