~/bend-docscommunity

src/doctor/run.bend relies on unsafe/foreign

raw source on the hub · import ezx@1.14.0.0/src/doctor/run.bend as Run

doctor/run: the interpreter for ez doctor. It reads $CC, $BEND_LIB, the ledger's text and the lock's text into a World, then loops: it asks the planner (doctor/plan.bend) what is still open, answers each question, and adds the answers to the World, until nothing is left to ask. Then it runs the planner's plan with the lock's effect runner (Run.exec.plan), which prints each line and exits 1 when the plan fails the command.

A version question runs the program with --version, except bend, which is asked through run/bend since it has answered the question two ways over its versions. The library is listed with ls, the sources are read as ez lock reads them (Run.read.listing), and a package's tree is read from under BEND_LIB as ez lock reads one there (Run.disk.all), and never fetched, and a name's file under BEND_LIB/names is read as it is. None of these writes anything, and the plan writes nothing either. It decides nothing; that it reads and executes faithfully is trusted in ez/app.bend.

12 imports
import Base
import 0x8e26a6f8c31689519e618374376ee3dd/main.bend as R
import ../run/bend.bend as Bend
import ../io/file.bend as F
import ../share/args.bend as Args
import ../lock/run.bend as Run
import ../lock/world.bend as W
import ../lock/lock.bend as L
import ./world.bend as DW
import ./plan.bend as DP
import ../ws/run.bend as WsRun
import ../ws/doctor.bend as WsDoc

Definitions

def probe.ask source · line 32 · raw

@is_bend:Bool -> @name:String -> IO(String)

how a program is asked for its version, once it is known whether this is bend. Everything else answers the flag.

def tree.read source · line 42 · raw

@+dir:String -> @+manifest:String -> IO(0xe21073738926f8a159714d5cdaf60edb/src/doctor/world.Answer)

a tree under BEND_LIB, as it is: its manifest and every file it names, read from beside it. A file that is not there reads as "", which does not hash to its sum.

def tree.seen source · line 48 · raw

@got:Maybe<&2, String> -> @+dir:String -> IO(0xe21073738926f8a159714d5cdaf60edb/src/doctor/world.Answer)

a tree whose manifest was looked for; none there is none at all

def tree source · line 56 · raw

@+dir:String -> IO(0xe21073738926f8a159714d5cdaf60edb/src/doctor/world.Answer)

a package's tree under the library directory

def answer source · line 62 · raw

@+lib:String -> @ask:0xe21073738926f8a159714d5cdaf60edb/src/doctor/world.Ask -> IO(0xe21073738926f8a159714d5cdaf60edb/src/doctor/world.Answer)

one question, answered. lib is the library directory the planner names.

def answer.all source · line 84 · raw

@+lib:String -> @asks:List<&2, 0xe21073738926f8a159714d5cdaf60edb/src/doctor/world.Ask> -> IO(List<&2, 0xe21073738926f8a159714d5cdaf60edb/src/doctor/world.Reply>)

every question, answered

def more source · line 95 · raw

@world:0xe21073738926f8a159714d5cdaf60edb/src/doctor/world.World -> @rs:List<&2, 0xe21073738926f8a159714d5cdaf60edb/src/doctor/world.Reply> -> 0xe21073738926f8a159714d5cdaf60edb/src/doctor/world.World

the World with more answers in it

def loop.step source · line 101 · raw

@st:0xe21073738926f8a159714d5cdaf60edb/src/doctor/plan.Step -> @+lib:String -> @world:0xe21073738926f8a159714d5cdaf60edb/src/doctor/world.World -> @go:(@_:0xe21073738926f8a159714d5cdaf60edb/src/doctor/world.World -> IO(Unit)) -> IO(Unit)

the planner's step: its questions answered and the loop gone round again, or its plan run

def rounds source · line 114 · raw

Nat

the rounds the loop may take. The lock check's trees follow the sources and each other, and the packages they reach are not known until BEND_LIB has answered, so this is a guard against a planner that keeps asking, not a limit on a project: running out of it dies loudly.

def loop source · line 120 · raw

@fuel:Nat -> @+lib:String -> @+back:0xe21073738926f8a159714d5cdaf60edb/src/ws/doctor.Back -> @+world:0xe21073738926f8a159714d5cdaf60edb/src/doctor/world.World -> IO(Unit)

the loop, under fuel. Every round adds at least one answer, since the planner never asks what the World answers already, and the lock check asks about each package at most once.

def var source · line 128 · raw

@name:String -> IO(String)

a variable's text, "" when it is unset

def run.doctored source · line 134 · raw

@dd:0xe21073738926f8a159714d5cdaf60edb/src/ws/doctor.Doctored -> @+cc:String -> @+lib:String -> @lk:Maybe<&2, String> -> IO(Unit)

the loop, on the ledger the doctor judges

def run source · line 139 · raw

IO(Unit)

ez doctor: the toolchain and the project, reported on