diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d818e2e..026ebb8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - # The site's tests need folio's views hook, in folio-kb 0.5.0 and later: the `site` extra brings it. + # The site's tests need folio's views hook, in folio-kb 0.7.0 and later: the `site` extra brings it. - name: Install lab-kit, and folio for the site's tests run: | python -m pip install --upgrade pip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bfaf3c6..35bb184 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,7 +22,7 @@ jobs: with: python-version: "3.12" # Never publish untested: the same gate CI runs, and here the site's tests must run too, so - # folio-kb 0.5.0 or later has to be on PyPI before lab-kit is released. + # folio-kb 0.7.0 or later has to be on PyPI before lab-kit is released. - run: python -m pip install -e ".[dev,site]" - run: python -m pytest -q -rs env: diff --git a/CHANGELOG.md b/CHANGELOG.md index 987b380..889e6c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,34 @@ # Changelog +## 1.6.0 + +One set of states for every card, and the checks that keep a card from saying what the record does not. The site's +Now page is a dashboard and its rail is the tree of goals, questions and steps; the Graph page is gone. It needs +folio 0.7.0, whose rail draws the tree. The skill `lab-work` and the method changed: run `lab init` in a lab after +upgrading. + +- **Seven states, the same for every kind of card:** open, waiting, running, parked, done, replaced, dropped. What + was `planned`, `active` or `in progress` is open or running; `built` and `reached` are done; `under discussion` + is waiting. A done card may carry a label: a question's answer (yes, no or mixed) and an experiment's outcome + (confirmed, refuted, unclear, or void when its results review failed). `lab show` and `lab now` print + `done, confirmed`. A decision is open or done. +- **A failed results review makes an experiment done and void,** not a step to replace. No page uses its numbers, + and what it made may still be used. +- **`lab answer yes|no|mixed`.** An answer rests on a done experiment that is not void. +- **A need is met by a done step, and by a replaced or dropped experiment whose run finished:** a later step may + use what such an experiment made (a frozen program), and says so with `needs:`. +- **`drops:` on a decision** drops the questions and steps it names once it is settled, like `parks:`. It is frozen + with the rest of what a settled decision says. +- **`waiting_on:` is for what is outside the lab.** `lab check` refuses one that names a goal, question, step or + decision: that wait never clears by itself. Builds and readings may carry it too. +- **So far says what was learned.** `lab check` refuses a question's So far with words that say where a step + stands ("is running", "is next", "no result yet"), and reports a So far last committed before a `result` line + about a step under the question, or one it names. `lab log result` says so. +- **The site.** Now shows what is live with a pulsing sign (runs, the current mission, what the agent is on), what + needs the operator, what is next for the agent in the agreed order, a tile per question with one sign per step, + the resources and the latest events. The rail nests goal, question and step, opens on the current page, marks each + with a sign for its state, folds what was replaced, dropped or set aside, and ends with a key. + ## 1.5.0 A closed mission is kept. In 1.4.0 `lab mission close` removed the mission's file, and with it the only account of diff --git a/README.md b/README.md index 2905769..fb2d865 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ record to the operator as a live site: `lab_kit.site` draws the pages, and nothi ``` Goal what the lab wants to be able to say - Question a yes-or-no question: what we expect, what would prove us wrong, what we know so far + Question a question answered yes, no or mixed: what we expect, what would prove us wrong, what we know so far Build something an experiment needs that has to be made first Reading a look at what already exists: it suggests, and never confirms Experiment what is compared, what would confirm, what would refute; then what was found diff --git a/docs/model.md b/docs/model.md index 9db6208..08138ef 100644 --- a/docs/model.md +++ b/docs/model.md @@ -9,14 +9,36 @@ A lab is a tree, and the decisions that shaped it. | Thing | What it says | States | | --- | --- | --- | -| **Goal** | A short name, what the lab wants to be able to say, and the claim: what we would report if the questions come out as expected, and against whose work. | active, reached, dropped | -| **Question** | A short name, and a yes-or-no question under a goal, written in full: why we ask it, how we would know, what we expect, what would prove us wrong, what we know so far. | under discussion, open, parked, yes, no, dropped | -| **Experiment** | One thing tried to answer a question. What it is for. Before the run: what is compared, each arm by name with what it is, the cases it runs on, what would confirm, what would refute. After: what was found, what it means. | planned, running, waiting, done (confirmed, refuted or unclear), review failed, replaced, dropped | -| **Build** | One thing an experiment needs that has to be made first: what it is for, how it works in plain words, and how we know it works. | planned, in progress, built, dropped | -| **Reading** | One look at what already exists: sealed runs, traces, the benchmark's own definitions. What it looks at; then what was seen and what that suggests. It sets no bar in advance, so it can suggest and never confirm. | planned, in progress, done, dropped | +| **Goal** | A short name, what the lab wants to be able to say, and the claim: what we would report if the questions come out as expected, and against whose work. | open, done, dropped | +| **Question** | A short name, and a question under a goal, answered yes, no or mixed, written in full: why we ask it, how we would know, what we expect, what would prove us wrong, what we know so far. | open, waiting, parked, done (yes, no or mixed), dropped | +| **Experiment** | One thing tried to answer a question. What it is for. Before the run: what is compared, each arm by name with what it is, the cases it runs on, what would confirm, what would refute. After: what was found, what it means. | open, waiting, running, done (confirmed, refuted, unclear or void), replaced, dropped | +| **Build** | One thing an experiment needs that has to be made first: what it is for, how it works in plain words, and how we know it works. | open, waiting, running, done, dropped | +| **Reading** | One look at what already exists: sealed runs, traces, the benchmark's own definitions. What it looks at; then what was seen and what that suggests. It sets no bar in advance, so it can suggest and never confirm. | open, waiting, running, done, dropped | | **Run** | One try at producing what an experiment demands: when, on which resource, what changed since the run before, how it ended, what it used. An experiment has one or more, until one finishes. | running, finished, failed | | **Result** | One number from a finished run: a plain label, how it reads, and the command that prints it again. | | -| **Decision** | One thing discussed with you and settled: first what there is to discuss, then what was decided and why. | open, decided | +| **Decision** | One thing discussed with you and settled: first what there is to discuss, then what was decided and why. | open, done | + +**One set of states for everything.** A goal, a question, an experiment, a build and a reading use the same +seven words, and each type uses only those it can be in: + +| State | Means | Goal | Question | Experiment | Build | Reading | +| --- | --- | --- | --- | --- | --- | --- | +| open | not finished, and free to move | yes | yes | yes | yes | yes | +| waiting | held by a step it needs, an open decision, or something outside the lab | | yes | yes | yes | yes | +| running | work under way | | | yes | yes | yes | +| parked | set aside by a decision; may come back | | yes | | | | +| done | finished; it carries a label where its type has one | yes | yes | yes | yes | yes | +| replaced | redone by a newer experiment | | | yes | | | +| dropped | will not be done | yes | yes | yes | yes | yes | + +Two types carry a label on done. A question's is its answer: **yes**, **no** or **mixed**, the answer to +the question as asked, with one sentence on what it rests on. Mixed says which part held and which did +not, and usually leads to a narrower question. An answer is a finding, never good or bad: no is not a +failure. A question has no "unclear": while the evidence cannot answer it, it is open. An experiment's +label is its outcome: **confirmed**, **refuted** or **unclear**, read against the bars set before the +run, or **void** when its results review failed, so that its numbers cannot be cited. A decision is open, +then done; a mission's `status:` (next, current, done, stopped) reads on the pages as open, running, +done and dropped. Goal, question, experiment, run, result: each sits inside the one before it. Ids spell the path: `G1`, `G1.Q2`, `G1.Q2.3`, and a result is `G1.Q2.3:attack-success`. Decisions are `D1`, `D2`. @@ -94,7 +116,7 @@ what it means and what was found, then says how many bars were met and names the outcome. There are no confidence numbers and no score sheet. A caveat the results raise goes in *Means*; what the experiment could never show is its Limits, written before the run. -A build has no lock, no lines and no result. It ends as built, naming its commits and its tests. +A build has no lock, no lines and no result. It is done once it names its commits and its tests. A reading has no lock, no lines, no run and no review. It exists because much of what a lab learns comes from reading what it already has: why each failure failed, which tasks a defence costs, what @@ -203,10 +225,11 @@ Each arrow is a command that refuses when the step before it is missing. You see or from a trial run that measured it. A trial that only showed the apparatus starts does not count. 5. a failed run's partial numbers were read before the apparatus was changed for the next run. - A plan review that fails is fixed before the lock, and read again. A results review that fails does - not finish the experiment: its outcome is not shown and no card may name its results. The plan and - the rows stay as they are. The remedy is a new experiment that names the one it replaces; the site - folds the old one under it, and the old results keep re-deriving. + A plan review that fails is fixed before the lock, and read again. A results review that fails ends + the experiment as done with the outcome **void**: its run finished, but no card may name its results. + The plan and the rows stay as they are. A new experiment may name the one it replaces; the site then + folds the old one under it, and the old results keep re-deriving. What the void experiment made (a + frozen program, a built file) may still be used by later steps, which name it under `needs:`. A card never types a result's number. It names the result, and the value is filled in when the card is shown, written the way its row says it reads: a share as a percentage, a difference between two shares @@ -243,11 +266,15 @@ approval: an experiment added later under a settled question is the agent's to p **Parking a question.** A question can be set aside without being dropped: not now, perhaps later. A settled decision parks it by listing it under `parks:`, and lists it under `about:` too. The decision's Decided text says -why, and what would bring it back. A parked question leaves Now, the rail and the graph, as a dropped one does. +why, and what would bring it back. A parked question leaves Now's map and the rail's list of live questions, as a dropped one does. Nothing under it moves: `lab new` refuses a step under it, and `lab lock` and `lab run` refuse its experiments. It comes back only by a later settled decision that lists it under `unparks:`. The last settled decision, by number, that parks or brings back a question has the say. An open decision parks nothing yet. Drop a question that will -never come back, with `dropped: ` on its card; park one that may. A goal is closed by `reached: true` or +never come back, with `dropped: ` on its card; park one that may. + +**Dropping by a decision.** A settled decision may drop steps and questions by listing them under `drops:` +(each also under `about:`). A step or a question a settled decision drops is dropped, with that decision as +its reason, whether or not its card says so: the card needs no edit, and none can be forgotten. A goal is closed by `reached: true` or `dropped: `, and a dropped goal drops every question under it. **The order of the work.** What the agent takes up first is agreed with you, and a settled decision records @@ -265,12 +292,12 @@ work (a decision with a new `order:`), stop a run. Say it, and the agent records you as for the agent: a locked plan is changed by a new experiment that replaces it, and an outcome is worked out from the results, not decided. -**A settled decision stays as it was settled.** Its `decided:`, its `about:`, its `parks:`, its `unparks:`, its `order:` and its Decided text never +**A settled decision stays as it was settled.** Its `decided:`, its `about:`, its `parks:`, its `unparks:`, its `drops:`, its `order:` and its Decided text never change once committed; a change of mind is a new decision. `lab check` holds this against the lab's history. So a decision cannot be made, afterwards, to be about something it never discussed. The agent decides everything else and records each choice in the log. It drops an experiment or a -build that will not be done, saying why. It marks a question yes or no itself, with `lab answer`, and +build that will not be done, saying why. It answers a question itself, yes, no or mixed, with `lab answer`, and the command refuses while an experiment of that question is neither done, replaced nor dropped, and when no experiment of it is done: a reading alone answers nothing. `lab check` asks the same of every answered question, and that the log holds the line `lab answer` wrote. It never asks you to check @@ -356,7 +383,7 @@ missions before it takes a machine. `log` and `close` may leave out the mission while only one is current, and refuse to guess when several are. `lab now` names every open mission under **Right now**. A mission is not part of the record: `lab check` checks its form (section 9) and that it carries a decision, and does not hold it against history; the site does not draw -it; its log is not the lab's log. The lab-mission skill says what to do on each step. +it, except that Now names the current mission and the last line of its log; its log is not the lab's log. The lab-mission skill says what to do on each step. The log is one file. Every line carries its time. A line is one of five kinds: a decision was recorded, the agent decided, a result, something is stuck, and what the agent is starting on now. @@ -431,8 +458,17 @@ A folder is named after its card's title, so a short title gives a short path. ## 7. The site -Now, Graph, a page per goal, question, experiment, build, reading and decision, Decisions, Log, -Resources, Glossary. Every page has the copy-path control. +Now (the dashboard), a page per goal, question, experiment, build, reading and decision, Decisions, +Log, Resources, Glossary. Every page has the copy-path control. + +**The rail** on the left of every page is the lab as a tree: each goal, its questions under it, and +each question's steps under that. A row shows a mark for its type (G, Q, E, B, R), its short id, its +title and a mark for its state, whose colour and shape follow the state and, on done, the label; the +word is on hover. A running step's mark pulses. A goal or a question opens and closes, and a closed +one shows how many of the steps under it are in each state. The page being read is always opened in +place and marked, with its goal, its question and its siblings in view. A question's replaced and +dropped steps fold into one line at its end; a goal's parked and dropped questions into one line at +its end. **How a page of a card reads.** Every page of a goal, a question or a step reads in the same order: @@ -466,11 +502,13 @@ and where each stands, what it costs, what it cannot show, where to look. Half o the same briefing as text, which is what the agent says in chat when asked what is going on: the page and the answer in chat cannot differ. An experiment's page is the evidence behind one step. -**Now** is read top to bottom in the order the operator asks: what is happening at this moment and -how fresh the record is; what there is to discuss with you; what is next and who moves it, in the agreed -order of the work and naming the decision that set it; where each -question stands (what is known so far, and nothing else); the latest events; what is left of each -resource. Nothing on it is static text except one line per goal. +**Now** is the dashboard, read top to bottom in the order the operator asks, and all of it worked out: +what is live at this moment (each run going, the current mission with the last line of its log, what +the agent says it is on), each with a pulsing mark, and when the record last moved; what needs you (the +open decisions) and what is next for the agent, in the agreed order of the work; the map, one row per +goal with how many of its questions are answered, and one tile per live question with its state, its +answer and one mark per step in tree order; what each resource has used of its grant, as a bar; the +latest events. There is no graph page: the rail is the tree and Now is the map. **An example on every question.** A question's page carries one case, step by step, as a numbered list that says who does what: the user, the agent, the tools, the gate, the scorer. A real episode @@ -479,7 +517,7 @@ each role, states the design before the approximation, and lists its vocabulary: uses the same way, each drawn with the glossary's definition. **What was set aside** stays in the record: a dropped goal or question, and a parked question, keeps its -card and its page, and leaves Now, the rail and the graph. Now lists it apart, under Set aside: each parked +card and its page, and leaves Now's map and the rail's live lists. Now lists it apart, under Set aside: each parked question with the decision that parked it and the first sentence of what was decided, then the dropped questions and the closed goals, folded. A goal's page folds its parked and its dropped questions; a parked question's page says, at the top, which decision parked it and why. `lab now` lists the parked questions in @@ -537,17 +575,17 @@ and its sealed runs across as what they were. **A card** is front matter, then its description as a paragraph, then `## Slot` sections. It never holds an id, a state or an outcome. Every file of a lab is UTF-8 text; line ends of either kind read the same, and so hash the same where a review is bound to a file. The front matter sits between -the first two lines that are exactly `---`. A key that holds a list (`needs`, `uses`, `see`, `about`, `holds`, `parks`, `unparks`, `order`, `commits`, +the first two lines that are exactly `---`. A key that holds a list (`needs`, `uses`, `see`, `about`, `holds`, `parks`, `unparks`, `drops`, `order`, `commits`, `tests`) is written as one, `[a, b]`; every other key holds one value. | Card | Front matter | Slots (word budget) | | --- | --- | --- | | `goal.md` | `title:`, `from:` (its decision); `reached: true`; `dropped: ` | description (70), Claim (90), Example: the idea in one case, from the reader's own domain (260), Approach: the design, how this lab approximates it, and where it knowingly differs (340), Roles: a list, `- : ` (170), Vocabulary: a list of names only, `- `, the few words every card uses the same way; each is a term of `GLOSSARY.md`, which defines it (260) | -| `question.md` | `title:` (a short name), `asks:` (the question in full), `from:`, `needs:`; `dropped: `; `answer:` and `answered:` are written by `lab answer` | description: why we ask (150), How we would know (180), Example: one case step by step, a numbered list (380), We expect (70), Wrong if (70), So far (220) | -| `experiment.md` | `title:`, `needs:`, `uses:` (resources), `override: {resource: cap}`, `cost:`, `replaces:` with `because:` (one sentence), `waiting_on:`, `dropped: ` | description (80), So far: optional, everything observed since the plan was written (300), Compares: the comparison, in a sentence or a numbered list of the whole work (300), Arms (260), Cases (120), Confirmed if (150), Refuted if (110), Outcomes (260), Limits (160), Found (180), Means (150) | -| `reading.md` | `title:`, `needs:`, `dropped: ` | description (70), Looks at: what, and where it is (120), Seen (360), Suggests (150) | -| `build.md` | `title:`, `needs:`, `commits:`, `tests:`, `dropped: ` | description (60), How it works (200), Works when (80) | -| `D-.md` | `title:`, `about:` (the goals, questions, experiments or resources it concerns), `date:`, `holds:`; `parks:` and `unparks:` (questions, each also under `about:`); `order:` (goals, questions and steps, first to last); `decided: {date, with}` is written by `lab decide` | Seen (150), Options: a list, one option an item (200), Recommendation (80), Decided (150), Note: optional, what a reader of the pages it is about must know from it (60) | +| `question.md` | `title:` (a short name), `asks:` (the question in full), `from:`, `needs:`; `dropped: `; `answer:` (yes, no or mixed) and `answered:` are written by `lab answer` | description: why we ask (150), How we would know (180), Example: one case step by step, a numbered list (380), We expect (70), Wrong if (70), So far (220) | +| `experiment.md` | `title:`, `needs:`, `uses:` (resources), `override: {resource: cap}`, `cost:`, `replaces:` with `because:` (one sentence), `waiting_on:` (something outside the lab; never a goal, question, step or decision of the lab, which go under `needs:` and are waited on by themselves), `dropped: ` | description (80), So far: optional, everything observed since the plan was written (300), Compares: the comparison, in a sentence or a numbered list of the whole work (300), Arms (260), Cases (120), Confirmed if (150), Refuted if (110), Outcomes (260), Limits (160), Found (180), Means (150) | +| `reading.md` | `title:`, `needs:`, `waiting_on:`, `dropped: ` | description (70), Looks at: what, and where it is (120), Seen (360), Suggests (150) | +| `build.md` | `title:`, `needs:`, `waiting_on:`, `commits:`, `tests:`, `dropped: ` | description (60), How it works (200), Works when (80) | +| `D-.md` | `title:`, `about:` (the goals, questions, experiments or resources it concerns), `date:`, `holds:`; `parks:` and `unparks:` (questions, each also under `about:`); `drops:` (steps and questions, each also under `about:`); `order:` (goals, questions and steps, first to last); `decided: {date, with}` is written by `lab decide` | Seen (150), Options: a list, one option an item (200), Recommendation (80), Decided (150), Note: optional, what a reader of the pages it is about must know from it (60) | **Why these budgets.** A budget is a ceiling. In 1.3.0 the budgets of the slots that hold a table or a numbered list (an experiment's Compares, Cases, Outcomes and So far, a question's So far and How we @@ -563,6 +601,14 @@ plan, so it may change after the lock; a card written before 1.3.0 may leave it carry a Note: one or two sentences a reader of the pages it is about must know. While a card's So far says nothing, its page shows there the Notes of the settled decisions about it. +**So far says what was learned, never where a step stands.** The pages draw each step's state from the +record, so a So far that says a step "is running", "is next" or has "no result yet" can only go stale, +and `lab check` reports those words in a question's So far. It also reports a question whose card was +last committed before the newest `result` line about a step under it, or about a step its So far names: +the result came in and the question was not brought up to date. `lab log result` says which +question to bring up to date. Where git cannot tell (no history, the card changed and not committed), +nothing is reported. + **A picture.** Any goal, question, experiment, build or reading may have a `picture.svg` beside its card. It is drawn inline at the top of its page, after the title and the lead. It shows the whole work as numbered steps: what goes in, who does what, the checks, the tools, how it is counted, the @@ -660,7 +706,7 @@ A test is a result's name, one of `<`, `<=`, `>`, `>=`, and a number. At most si **A named result** on a card is `{name}` inside its own experiment and `{G1.Q1.2:name}` elsewhere. **`results.tsv`** is tab-separated: `name`, `label` (what the number is, as a phrase that stands on its -own: what is counted, out of what, under which arm, with no "that" or "the same" pointing at another row), `value` (a +own: what is counted, out of how many and of which set of cases, named the same way on every row that uses it, under which arm, with no "that" or "the same" pointing at another row), `value` (a plain number), `reads` (`percent` for a share, `points` for a difference between two shares, or empty), `versus` (what it is compared with), `command` (run from the lab's root with `RUN` set to the finished run's folder; prints `value` exactly, and reads `$RUN`, or it would not be printing from the sealed @@ -771,20 +817,26 @@ holds the line `launched`, else next, and `lab check` asks for the status to be reports a mission that breaks any of this, one whose `carries:` is not a decision, and a current mission whose decision is still open. -**Worked-out states.** A question is under discussion while the decision it came from is open, then -open, then yes or no; it is parked while the last settled decision that parks or brings it back parks it; a page calls an open question with nothing under it "not started". A build is in -progress once the log has a line about it, and built once it names its commits. An experiment whose -results review failed shows as review failed until it is replaced or dropped. +**Worked-out states.** A goal is open until `reached: true` makes it done or `dropped:` drops it. A +question is waiting while the decision it came from is open, then open, then done with its answer; it +is parked while the last settled decision that parks or brings it back parks it. A step is waiting while +something holds it: a step it needs, an open decision, its question or goal not being open, or its +`waiting_on:`. A build or a reading is running once the log has a line about it; a build is done once +it names its commits, a reading once it says what was seen and what it suggests. An experiment is running +while a run of it is going, and done once its results are reviewed (its label is the outcome) or its +results review failed (its label is void). **What a step needs.** `needs:` on an experiment, a build or a reading names other steps, anywhere in the tree: under its own question or another, before it or after it. A step is not the agent's to move -while one it needs is neither done nor built, and `lab lock` and `lab run` refuse it until then. Each +while one it needs is not done, and `lab lock` and `lab run` refuse it until then. An experiment that +was replaced or dropped after a run of it finished made what it made: a need on it is met, and its page +lists the steps that use it. Each step's state is worked out after the state of everything it needs, wherever that sits, so the order of the cards changes nothing: a build under the second question that needs a reading under the third moves as soon as that reading is done. Every view says the same: `lab now`, `lab show`, `lab brief`, and the site's pages and rail. Steps that need each other in a circle are a problem `lab check` reports. Until the circle is broken none of them moves, whatever the others' states, and each says -which of its needs leads back to it. A step that needs one that is dropped or replaced would wait +which of its needs leads back to it. A step that needs one that was dropped or replaced before any run of it finished would wait for ever, so what it waits on says so, and says what to do: remove the need or replace it. A need that names nothing in the lab, or something that is not a step, holds the step in `lab lock` and `lab run` as `lab check` reports it. A question's `needs:` names the questions it builds on, for its diff --git a/method/METHOD.md b/method/METHOD.md index 4b54155..fbbac7a 100644 --- a/method/METHOD.md +++ b/method/METHOD.md @@ -13,8 +13,9 @@ judgement. The lab's own `AGENTS.md` adds only what is local. `lab check`; the review itself is judged.* 3. **A miss is recorded like a hit, and nothing recorded is edited. What a locked plan demands is never changed; its words may be made clearer.** A failed run is kept. A refuted line is an outcome like - any other. A changed plan, a failed review or a partial score is a new experiment that replaces the - old one and says why in a sentence. What an experiment demands (each bar's role, result, comparison and + any other. A changed plan or a partial score is a new experiment that replaces the old one and + says why in a sentence. An experiment whose results review failed is done and void: no page uses its + numbers, and what it made may still be used through `needs:`. What an experiment demands (each bar's role, result, comparison and number, each arm's name, the resources it uses) is locked once; a clearer word keeps its meaning, and a reviewer who did not write it reads it. It is run until one run finishes, and a run after a fix says what changed. Once a run has finished, nothing more runs under it. Every run is listed in the experiment's `runs.tsv`, @@ -24,7 +25,10 @@ judgement. The lab's own `AGENTS.md` adds only what is local. 4. **Write for a reader who was not there.** Every page stands on its own: it says what each thing it mentions is, names each arm of an experiment and what it is, names another page by its exact title, and uses a term only as the glossary defines it, the one place a word is defined. A number is said once: it lives in its result row, and a card names it. A state is - worked out, never written. *The numbers and the budgets are held by `lab check`; whether a page + worked out, never written, and So far says what was learned, never where a step stands. Every + card has one of the same states: open, waiting, running, parked, done, replaced or dropped. A + number's label says what it counts and of how many, in one set of cases named once: "of the 20 + checks the solver leaves open", not "of 20". *The numbers and the budgets are held by `lab check`; whether a page can be read cold is judged, and the reviewer reads for it.* 5. **Decide everything that is not direction or resources, and never wait idle.** Direction is the goals and the questions. Resources are what `resources.toml` lists and how much. For those two, diff --git a/pyproject.toml b/pyproject.toml index 4774d3b..09228d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "hatchling.build" [project] dynamic = ["readme"] name = "lab-kit-cli" -version = "1.5.0" +version = "1.6.0" description = "A research lab's record, its method, and the command that keeps both." license = "MIT" authors = [{ name = "Piergiuseppe Mallozzi" }] @@ -14,9 +14,9 @@ dependencies = ["pyyaml", "tomli; python_version < '3.11'"] [project.optional-dependencies] dev = ["pytest"] -# folio serves the operator's site and lab_kit.site draws its pages, through the views hook of folio-kb 0.5.0. +# folio serves the operator's site and lab_kit.site draws its pages, through the views hook of folio-kb 0.7.0. # The `lab` command itself needs no folio. -site = ["folio-kb>=0.5.0"] +site = ["folio-kb>=0.7.0"] [project.urls] Homepage = "https://github.com/pierg/lab-kit" diff --git a/skills/lab-work/SKILL.md b/skills/lab-work/SKILL.md index b8a7bc0..ba3d9b8 100644 --- a/skills/lab-work/SKILL.md +++ b/skills/lab-work/SKILL.md @@ -70,7 +70,7 @@ the plan in fixed boxes, then the steps and the record. Write the card for that no result: a number observed never goes in a picture. Use the site's colours (`var(--ink)`, `var(--ink-2)`, `var(--accent)`, `var(--surface)`, `var(--rule)`, `var(--sans)`) and never a fixed colour, so it reads in light and dark. Keep its text at least 12 pixels at its own width. -- **What we know so far holds everything observed.** The card's `## So far`: where it stands, what +- **What we know so far holds everything observed.** The card's `## So far`: what was learned, what was learned after the plan was written, later decisions and what they change, reference runs. On an experiment it sits outside the plan, so you keep it current after the lock. When a decision changes how a node is read, give the decision a `## Note` of one or two sentences: a node whose So @@ -178,6 +178,10 @@ until that decision is settled; after that it needs no further yes. 9. Once the review has passed, write **Found** and **Means** on the card. Name each result instead of typing its number: `{attack-success}`. It is shown the way its row says it reads. Bring the experiment's **So far** up to date, and rewrite the question's **So far** the same way, with full names: `{G1.Q1.2:attack-success}`. + So far says what was learned, never where a step stands ("is running", "is next", "no result yet"): + the pages draw each step's state. `lab check` reports a question's So far that was last committed + before a result under it, or one it names. Give each result a label that says what it counts and + of how many, in a set of cases the lab names once ("of the 20 checks the solver leaves open"). 10. `lab log result "" ""`. The outcome is worked out from the lines: you never write it. @@ -232,8 +236,10 @@ repository, tests first. When it works, put `commits:` and `tests:` on the card ## When all experiments of a question are done -Decide whether they answer it. `lab answer yes|no ""`, and bring -**So far** up to date. If they do not answer it, add the next experiment. An answer usually changes +Decide whether they answer it. `lab answer yes|no|mixed ""`, and +bring **So far** up to date. Yes and no say whether what the question expected held; mixed says part +held and part did not, and the sentence says which. An answer rests on a done experiment that is not +void. If they do not answer it, add the next experiment. An answer usually changes what should come next: open a decision. ## When something is in the way @@ -241,9 +247,15 @@ what should come next: open a decision. - **It is yours to decide.** Decide, `lab log agent "" ""`, go on. - **It is the operator's** (direction or resources). Open a decision, then work on what it does not hold. -- **It waits on something outside the lab.** Put `waiting_on: ` on the card, log a `stuck` - line, and remove both when it clears. -- **It will not be done.** Put `dropped: ` on the card and log it. +- **It waits on something outside the lab** (an account, a person, a machine being repaired). Put + `waiting_on: ` on the card, log a `stuck` line, and remove both when it clears. A wait on the + lab's own work is a `needs:`, or a decision's `holds:`: `lab check` refuses a `waiting_on:` that + names a goal, question, step or decision. +- **It will not be done.** Put `dropped: ` on the card and log it. When a decision drops it, + the decision lists it under `drops:`, and the card needs nothing more. +- **A later step uses what a replaced or void step made** (a frozen program, a data set). Put the + step under `needs:`: a need is met by a done step, and by a replaced or dropped experiment whose + run finished. - **A run's process died.** `lab runs close ""`. It stops whatever the run left going and reads the run's `used.json`. If the run used a metered resource and wrote none, say what it used: `--used =`. diff --git a/src/lab_kit/__init__.py b/src/lab_kit/__init__.py index de02da9..f04bc7d 100644 --- a/src/lab_kit/__init__.py +++ b/src/lab_kit/__init__.py @@ -1,2 +1,2 @@ """lab-kit: a research lab's record, its method, and the command that keeps both.""" -__version__ = "1.5.0" +__version__ = "1.6.0" diff --git a/src/lab_kit/checks.py b/src/lab_kit/checks.py index 480acc1..cb51909 100644 --- a/src/lab_kit/checks.py +++ b/src/lab_kit/checks.py @@ -9,12 +9,16 @@ "goal": {"title", "from", "reached", "dropped", "see"}, "question": {"title", "asks", "from", "needs", "answer", "answered", "dropped", "see"}, "experiment": {"title", "needs", "uses", "override", "replaces", "because", "cost", "waiting_on", "dropped", "see"}, - "build": {"title", "needs", "commits", "tests", "dropped", "see"}, - "reading": {"title", "needs", "dropped", "see"}, - "decision": {"title", "about", "date", "holds", "parks", "unparks", "order", "decided", "see"}, + "build": {"title", "needs", "commits", "tests", "waiting_on", "dropped", "see"}, + "reading": {"title", "needs", "waiting_on", "dropped", "see"}, + "decision": {"title", "about", "date", "holds", "parks", "unparks", "drops", "order", "decided", "see"}, } +LAB_ID = re.compile(r"\b(G\d+(?:\.Q\d+(?:\.\d+)?)?|D\d+)\b") # a goal, a question, a step or a decision of the lab +STATE_WORDS = ("is running", "are running", "currently running", "no result yet", "is next", "are next", "is waiting", "is planned") # where a step stands, which the pages draw + + def run(lab, rederive=True): """Every problem, notes on what could not be checked here, and whether anything was left unchecked.""" problems, notes, unchecked = list(lab.problems), [], False @@ -89,13 +93,13 @@ def see(where, page, who=""): for need in q["needs"]: if nodes.get(need, {}).get("type") != "question": bad("links", q["path"], f"needs {need}, which is not a question") - if q.get("answer") is not None and q.get("answer") not in ("yes", "no"): - bad("cards", q["path"], "`answer:` is yes or no, written by `lab answer`") - if q.get("answer") in ("yes", "no"): # what `lab answer` requires holds for an answer however it got on the card - waiting = [x["id"] for x in q["items"] if x["state"] not in ("done", "built", "replaced", "dropped")] + if q.get("answer") is not None and q.get("answer") not in R.ANSWERS: + bad("cards", q["path"], "`answer:` is yes, no or mixed, written by `lab answer`") + if q.get("answer") in R.ANSWERS: # what `lab answer` requires holds for an answer however it got on the card + waiting = [x["id"] for x in q["items"] if x["state"] not in R.CLOSED] if waiting: bad("questions", q["path"], f"is answered while {', '.join(waiting)} is not done") - if not any(x["state"] == "done" and x["type"] == "experiment" for x in q["items"]): + if not any(x["state"] == "done" and x["type"] == "experiment" and x["label"] != "void" for x in q["items"]): bad("questions", q["path"], "is answered with no finished experiment to rest the answer on; a reading suggests and answers nothing") if not R.day(q.get("answered")) or not any(l["about"] == q["id"] and l["kind"] == "agent" and l["what"].startswith(f"Answered {q['id']} {q['answer']}.") for l in lab.lines): bad("questions", q["path"], "its answer was not recorded by `lab answer`: the log holds no line for it, or the card no `answered:` day") @@ -105,6 +109,17 @@ def see(where, page, who=""): for need in x["needs"]: if nodes.get(need, {}).get("type") not in R.STEPS: bad("links", x["path"], f"needs {need}, which is not an experiment, a build or a reading") + named = sorted(set(LAB_ID.findall(str(x.get("waiting_on") or ""))) & set(nodes)) + if named: # a wait on the lab's own work clears by itself only through `needs:` or a decision's `holds:` + bad("cards", x["path"], f"`waiting_on:` names {', '.join(named)}, which is part of the lab: put a step under `needs:`, and let a decision hold it with `holds:`; `waiting_on:` is for something outside the lab") + for q in lab.questions: # So far says what was learned; the pages say where each step stands + so_far = R.flat(q["slots"].get("So far", "")) + for words in STATE_WORDS: + if re.search(rf"\b{words}\b", so_far, flags=re.I): + bad("questions", q["path"], f"So far says {words!r}: the pages show where each step stands, so So far says only what was learned") + break + for q, step, at in history.stale_so_far(lab): + bad("questions", q["path"], f"So far was last committed before the result of {step} ({at}): bring it up to date with what that result taught") for n in lab.questions + lab.items: # nothing needs itself, directly or through what it needs seen, todo = set(), list(n["needs"]) while todo: @@ -131,6 +146,11 @@ def see(where, page, who=""): bad("links", d["path"], f"{key} names {i}, which is not under `about:`: a decision that parks a question or brings it back is about it") for i in sorted(set(d["parks"]) & set(d["unparks"])): bad("links", d["path"], f"both parks and unparks {i}") + for i in d["drops"]: # a decision drops steps and questions, and is about what it drops + if nodes.get(i, {}).get("type") not in ("question",) + R.STEPS: + bad("links", d["path"], f"drops names {i!r}, which is not a question or a step of the lab") + elif i not in d["about"]: + bad("links", d["path"], f"drops names {i}, which is not under `about:`: a decision that drops something is about it") for i in d["order"]: # the order of the work names what it orders: goals, questions and steps, each once if nodes.get(i, {}).get("type") not in ("goal", "question") + R.STEPS: bad("links", d["path"], f"order names {i!r}, which is not a goal, a question or a step of the lab") @@ -181,7 +201,7 @@ def see(where, page, who=""): if stray: bad("locks", p, f"plan/ holds a compiled file outside __pycache__, {stray[0]}: Python would import it, and a `.pyc` is not pinned") if x["lock"]: - if lab.nodes[x["question"]]["state"] == "under discussion": + if lab.nodes[x["question"]]["state"] == "waiting": bad("locks", p, f"is locked under {x['question']}, whose decision is not settled") if not x["lock"].get("unreadable") and not lab.lock_holds(x): bad("locks", p, "what it demands (a bar's role, result, comparison or number, an arm's name) or the resources it uses changed after the lock; that is a new experiment") @@ -267,7 +287,7 @@ def see(where, page, who=""): bad("results", p, "its results or its run changed after the review that passed them") elif any(R.flat(x["slots"].get(k, "")) for k in ("Found", "Means")): bad("cards", p, "says what was found with no result behind it") - if x["state"] == "review failed" and (R.flat(x["slots"].get("Found", "")) or R.flat(x["slots"].get("Means", ""))): + if x["label"] == "void" and (R.flat(x["slots"].get("Found", "")) or R.flat(x["slots"].get("Means", ""))): bad("cards", p, "its results failed their review, so the card says nothing was found: replace the experiment") for r in lab.runs: if r.get("experiment") not in nodes: @@ -283,8 +303,9 @@ def see(where, page, who=""): if not row: bad("names", n["path"], f"{slot} names {written}, which is not a result" + ("" if home or ":" in written else " (a question names it in full: {G1.Q1.2:name})")) elif not row["usable"]: - state = nodes[row["experiment"]]["state"] - bad("names", n["path"], f"{slot} names {written}, whose experiment is {state}" + ("" if state in ("replaced", "dropped", "review failed") else " and not yet reviewed")) + owner = nodes[row["experiment"]] + state = "void: its results review failed" if owner["label"] == "void" else owner["state"] + bad("names", n["path"], f"{slot} names {written}, whose experiment is {state}" + ("" if owner["state"] in ("replaced", "dropped") or owner["label"] == "void" else " and not yet reviewed")) typed = set(re.findall(r"(? "" [--replaces <experiment> --because "<why>"] lab log <id> doing "<what you are starting on>" "<why now>" lab log <id> agent|result|stuck "<what happened>" ["<so what>"] - lab answer <question> yes|no "<what the answer rests on>" + lab answer <question> yes|no|mixed "<what the answer rests on>" To carry out a decision lab mission [<mission>] [--all] the open missions (--all: the closed too), or one whole: its rules, its steps, its log lab mission new "<title>" --carries <decision> save a mission; it is next until launched @@ -128,6 +128,9 @@ def flag(name, many=False, switch=False): if not 3 <= len(rest) <= 4: raise SystemExit(USAGE) print(f"added to {write.log(lab, rest[0], rest[1], rest[2], rest[3] if len(rest) == 4 else '')}") + q = lab.question_of(rest[0]) if rest[1] == "result" else None + if q and q["id"] != rest[0]: + print(f"now bring So far of {q['id']} {q['title']} up to date with what this result taught: `lab check` reports it until then") elif cmd == "decide": with_ = flag("--with") if len(rest) != 2: diff --git a/src/lab_kit/history.py b/src/lab_kit/history.py index c698369..027e156 100644 --- a/src/lab_kit/history.py +++ b/src/lab_kit/history.py @@ -116,7 +116,7 @@ def resources(lab): continue if any(k in a for k in ("granted", "per_run")) and tuple(a.get(k) for k in ("granted", "per_run", "unit")) != tuple(b.get(k) for k in ("granted", "per_run", "unit")): d = lab.nodes.get(str(b.get("from"))) - if b.get("from") == a.get("from") or not d or d["type"] != "decision" or d["state"] != "decided" or name not in d["about"]: + if b.get("from") == a.get("from") or not d or d["type"] != "decision" or d["state"] != "done" or name not in d["about"]: bad(f"{name}: `granted`, `per_run` or `unit` changed {when}, and `from` does not name another settled decision: an amount changes out of a decision") lost = subsequence(rows(a), rows(b)) if lost is not None: @@ -143,7 +143,7 @@ def settled(text): return None ids = lambda v: sorted(str(i) for i in (v if isinstance(v, list) else [v] if v is not None else [])) order = [str(i) for i in (fm.get("order") if isinstance(fm.get("order"), list) else [fm.get("order")] if fm.get("order") is not None else [])] # its order is kept as written: first to last - return str(fm.get("decided")), ids(fm.get("about")), ids(fm.get("parks")), ids(fm.get("unparks")), order, R.flat(slots.get("Decided", "")) + return str(fm.get("decided")), ids(fm.get("about")), ids(fm.get("parks")), ids(fm.get("unparks")), ids(fm.get("drops")), order, R.flat(slots.get("Decided", "")) for where, commits in sorted(versions.items()): if not DECISION.fullmatch(commits[-1][1]): @@ -156,7 +156,7 @@ def settled(text): if was: mine = path if path in now[where] else now[where][0] if settled(R.read(os.path.join(root, mine))) != was: - bad(mine, f"was settled in {c[:8]}" + ("" if mine == path else f", as {path}") + ", and what it parks or brings back, the order it sets, its `decided:`, its `about:` or its Decided text has changed since; a change of mind is a new decision") + bad(mine, f"was settled in {c[:8]}" + ("" if mine == path else f", as {path}") + ", and what it parks, drops or brings back, the order it sets, its `decided:`, its `about:` or its Decided text has changed since; a change of mind is a new decision") break return problems @@ -178,6 +178,29 @@ def uncommitted(lab): return found +def stale_so_far(lab): + """The questions whose So far was last committed before the newest `result` line about a step under them, or about + a step their So far names: [(question, step, when)]. Where git cannot tell (no history, or the card changed and not + yet committed), nothing is reported.""" + root, out = lab.root, [] + if not committed(root): + return out + for q in lab.questions: + if q["state"] in ("parked", "dropped"): + continue + if (git(root, "status", "--porcelain", "--", q["path"]) or "").strip(): + continue # being brought up to date now + last = R.moment((git(root, "log", "-1", "--format=%cI", "--", q["path"]) or "").strip()) + if not last: + continue + named = set(re.findall(r"\bG\d+\.Q\d+\.\d+\b", R.flat(q["slots"].get("So far", "")))) + mine = {x["id"] for x in q["items"]} | {i for i in named if lab.nodes.get(i, {}).get("type") in R.STEPS} + newer = [l for l in lab.lines if l["kind"] == "result" and l["about"] in mine and l["time"] and (R.moment(l["at"]) or last) > last] + if newer: + out.append((q, newer[-1]["about"], f"{newer[-1]['day']} {newer[-1]['time']}")) + return out + + def check(lab): root, problems = lab.root, [] bad = lambda where, what: problems.append(f"history: {where}: {what}") diff --git a/src/lab_kit/record.py b/src/lab_kit/record.py index 760ada3..215c9ac 100644 --- a/src/lab_kit/record.py +++ b/src/lab_kit/record.py @@ -30,7 +30,13 @@ MISSION_LINE = re.compile(r"^- (\d{4}-\d\d-\d\d) (\d\d:\d\d) \| ([^|]+)$") # a line of a mission's log MISSION_BUDGET = {"description": 80, "Rules": 200} MISSION_STATES = ("next", "current", "done", "stopped") # a mission's `status:`; done and stopped are closed, and the file is kept -STEPS = ("experiment", "build", "reading") # what sits under a question: a locked comparison, something made, a look at what already exists +STEPS = ("experiment", "build", "reading") +# One set of states for every goal, question and step (the model, section 1). A type uses only those it can be in. On +# done, a question carries its answer (yes, no or mixed) and an experiment its outcome (confirmed, refuted, unclear or +# void) as its label. +STATES = ("open", "waiting", "running", "parked", "done", "replaced", "dropped") +ANSWERS = ("yes", "no", "mixed") +CLOSED = ("done", "replaced", "dropped") # a step in one of these will not move again # what sits under a question: a locked comparison, something made, a look at what already exists READS = ("", "percent", "points") # how a result's value reads on a page BEFORE = ("Compares", "Arms", "Cases", "Confirmed if", "Refuted if", "Outcomes", "Limits") # what an experiment says before it runs: its plan, which So far, Found and Means are not part of ROLES = {"answer": "The answer", "readable": "The answer can be read only if", "counts": "The answer counts only if"} # what a confirmed-if bar is there for @@ -48,7 +54,7 @@ HASH = 2 # how a folder is hashed in the locks and runs made now; one without the marker was made with the first way NUMBER = re.compile(r"[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?") LISTS = {"goal": ("see",), "question": ("needs", "see"), "experiment": ("needs", "uses", "see"), "build": ("needs", "commits", "tests", "see"), - "reading": ("needs", "see"), "decision": ("about", "holds", "parks", "unparks", "order", "see")} # the front matter keys that hold a list + "reading": ("needs", "see"), "decision": ("about", "holds", "parks", "unparks", "drops", "order", "see")} # the front matter keys that hold a list TEXTS = ("title", "asks", "from", "replaces", "because", "cost", "waiting_on", "dropped", "answered") # and those that hold one value @@ -88,6 +94,8 @@ def items(text): def moment(text): """A recorded day or time as a UTC datetime, or None.""" text = str(text or "").strip() + if text[-1:] in ("Z", "z"): + text = text[:-1] + "+00:00" # git and others write UTC as Z, which Python before 3.11 does not read try: d = datetime.datetime.fromisoformat(text if len(text) > 10 else text + "T00:00:00") except ValueError: @@ -329,7 +337,13 @@ def __init__(self, root=None): n["title"], n["description"] = flat(n.get("title") or n["id"]), flat(n.get("description") or "") if n["type"] == "question": # the question in full; a card without `asks:` has it as its title n["asks"] = flat(n.get("asks") or n["title"]) + n["label"] = None # on done: a question's answer, an experiment's outcome self.nodes[n["id"]] = n + for d in self.decisions: # a settled decision drops what it lists under `drops:`, whatever the card says + for ident in d["drops"] if d["state"] == "done" else []: + n = self.nodes.get(ident) + if n and (n["type"] in STEPS or n["type"] == "question") and not n.get("dropped"): + n["dropped"], n["dropped_by"] = f"{d['id']} {d['title']}", d["id"] self.runs = self._runs() for x in self.experiments: mine = sorted((r for r in self.runs if r.get("experiment") == x["id"]), key=lambda r: (str(r.get("started")), r["id"])) # in the order they started @@ -344,6 +358,8 @@ def __init__(self, root=None): self.reach = self._reach() for x in self._in_order(): # a step after everything it needs, wherever that sits in the tree x["state"], x["next"], x["mine"] = {"build": self._build_state, "reading": self._reading_state, "experiment": self._experiment_state}[x["type"]](x) + for x in self.experiments: # a done experiment's label is its outcome + x["label"] = x["outcome"] if x["state"] == "done" else None for row in self.results.values(): # a number may be used on a card once its experiment is reviewed, and until it is replaced x = self.nodes[row["experiment"]] row["usable"] = x["reviewed"] and x["state"] not in ("replaced", "dropped") @@ -590,7 +606,7 @@ def _tree(self): gdir, gid = os.path.dirname(gp), f"G{gn}" fm, gslots = self._card(gp, "goal") goal = {"title": gid, "description": "", "see": [], **fm, "id": gid, "type": "goal", "slots": gslots, "path": self.rel(gp), "dir": self.rel(gdir), "questions": []} - goal["state"] = "dropped" if fm.get("dropped") else "reached" if fm.get("reached") else "active" + goal["state"] = "dropped" if fm.get("dropped") else "done" if fm.get("reached") else "open" for qn, qp in self._numbered(f"{gdir}/*/question.md", r"/Q(\d+)-[^/]+/question\.md$", {}, "Q<n>-<name>"): qdir, qid = os.path.dirname(qp), f"{gid}.Q{qn}" qfm, qslots = self._card(qp, "question") @@ -633,9 +649,9 @@ def _decisions(self): out = [] for n, path in self._numbered(f"{self.root}/decisions/D*.md", r"/D(\d+)-[^/]+\.md$", {}, "D<n>-<name>.md"): fm, slots = self._card(path, "decision") - d = {"title": f"D{n}", "about": [], "holds": [], "parks": [], "unparks": [], "order": [], "decided": None, "date": "", "see": [], **fm, "id": f"D{n}", "type": "decision", "slots": slots, + d = {"title": f"D{n}", "about": [], "holds": [], "parks": [], "unparks": [], "drops": [], "order": [], "decided": None, "date": "", "see": [], **fm, "id": f"D{n}", "type": "decision", "slots": slots, "path": self.rel(path), "dir": self.rel(os.path.dirname(path))} - d["state"] = "decided" if d["decided"] else "open" + d["state"] = "done" if d["decided"] else "open" out.append(d) return out @@ -739,13 +755,13 @@ def live(self, nodes): def pursued(self): """The steps still pursued: under a question that is neither parked nor dropped, of a goal still active. What was set aside waits on a decision, not on the work, and is listed apart.""" - keep = {q["id"] for q in self.live(self.questions) if self.nodes[q["goal"]]["state"] == "active"} + keep = {q["id"] for q in self.live(self.questions) if self.nodes[q["goal"]]["state"] == "open"} return self.in_order([x for x in self.items if x["question"] in keep]) def ordered_by(self): """The settled decision that sets the order of the work, or None: the last settled decision, by number, that carries an `order:`. The order is agreed with the operator, so it comes only out of a decision.""" - return next((d for d in reversed(self.decisions) if d["state"] == "decided" and d["order"]), None) + return next((d for d in reversed(self.decisions) if d["state"] == "done" and d["order"]), None) def in_order(self, steps): """Steps in the agreed order of the work: each takes the place of its own id in the order, else of its question's, @@ -765,7 +781,7 @@ def set_aside(self): were reached or dropped.""" return {"parked": [q for q in self.questions if q["state"] == "parked"], "dropped": [q for q in self.questions if q["state"] == "dropped"], - "goals": [g for g in self.goals if g["state"] != "active"]} + "goals": [g for g in self.goals if g["state"] != "open"]} def question_of(self, ident): m = re.match(r"(G\d+\.Q\d+)", ident) @@ -780,17 +796,17 @@ def holding(self, ident): def settled(self, node): """Whether the decision a goal or a question came from has been settled.""" - return self.nodes.get(str(node.get("from")), {}).get("state") == "decided" + return self.nodes.get(str(node.get("from")), {}).get("state") == "done" def settled_for(self, ident): """A settled decision that is about exactly this node: what a cap above the lab's amounts rests on.""" - return next((d for d in self.decisions if d["state"] == "decided" and ident in d["about"]), None) + return next((d for d in self.decisions if d["state"] == "done" and ident in d["about"]), None) def held_by(self, decision): """The experiments and builds an open decision holds, still to be done.""" if decision["state"] != "open": return [] - return [x for x in self.items if x["state"] not in ("done", "built", "dropped", "replaced") and any(x["id"] == h or x["id"].startswith(h + ".") for h in decision["holds"])] + return [x for x in self.items if x["state"] not in CLOSED and any(x["id"] == h or x["id"].startswith(h + ".") for h in decision["holds"])] def metered(self, name): r = self.resources.get(name) or {} @@ -799,7 +815,7 @@ def metered(self, name): def granted_by(self, name): """The settled decision that set a metered resource's amounts, or None.""" d = self.nodes.get(str((self.resources.get(name) or {}).get("from"))) - return d if d and d["type"] == "decision" and d["state"] == "decided" and name in d["about"] else None + return d if d and d["type"] == "decision" and d["state"] == "done" and name in d["about"] else None def cap(self, x, name): """What one run of this experiment may use of a resource: its override, or the lab's amount for one run.""" @@ -946,18 +962,19 @@ def parked_by(self, ident): unparks it has the say: a question is set aside, and brought back, only by a decision.""" last = None for d in self.decisions: - if d["state"] == "decided" and (ident in d["parks"] or ident in d["unparks"]): + if d["state"] == "done" and (ident in d["parks"] or ident in d["unparks"]): last = d return last if last and ident in last["parks"] else None def _question_state(self, q): if q.get("dropped") or self._goal_of(q).get("dropped"): return "dropped" - if q.get("answer") in ("yes", "no"): - return q["answer"] + if q.get("answer") in ANSWERS: + q["label"] = q["answer"] + return "done" if self.parked_by(q["id"]): return "parked" - return "open" if self.settled(q) else "under discussion" + return "open" if self.settled(q) else "waiting" def _reach(self): """For each step, every step it needs, directly or through what it needs: {id: {ids}}. A step that is in its @@ -997,23 +1014,25 @@ def _in_order(self): def _blocked(self, x): """Why nothing under this item may move yet, or None.""" q, g = self.nodes[x["question"]], self.nodes[x["goal"]] - if g["state"] != "active": - return f"{g['id']} is {g['state']}" - if q["state"] == "under discussion": + if g["state"] != "open": + return f"{g['id']} is {'reached' if g['state'] == 'done' else g['state']}" + if q["state"] == "waiting": return f"the decision {q.get('from') or 'it comes from'} to be settled" if q["state"] == "parked": return f"{q['id']} is parked by {self.parked_by(q['id'])['id']}: a decision that unparks it comes first" if q["state"] != "open": - return f"{q['id']} is {'answered ' + q['state'] if q['state'] in ('yes', 'no') else q['state']}" + return f"{q['id']} is {'answered ' + q['label'] if q['state'] == 'done' else q['state']}" for need in x.get("needs") or []: n = self.nodes.get(need) if n and x["id"] in self.reach.get(need, {need} if need == x["id"] else ()): # a circle of needs: nothing in it moves return f"{need} {n['title']}, which needs {x['id']} in turn: no step in a circle of needs can move" if need != x["id"] else f"{need}, which is itself: a step cannot need itself" if not n or n["type"] not in STEPS: # held here as `lab check` reports it: a need names a step return f"{need}, which {'is not an experiment, a build or a reading' if n else 'does not exist'}: correct the need or remove it" - if n.get("state") in ("dropped", "replaced"): # it will never be done: waiting on it is waiting for ever - return f"{need} {n['title']}, which is {n['state']}: remove the need or replace it" - if n.get("state") not in ("done", "built"): + if n.get("state") in ("dropped", "replaced"): + if n.get("finished"): # a run of it finished before it was set aside: what it made is there to use + continue + return f"{need} {n['title']}, which is {n['state']}: remove the need or replace it" # it will never be done + if n.get("state") != "done": return f"{need} {n['title']}" return None @@ -1024,30 +1043,34 @@ def _reading_state(self, r): return "dropped", "", False if all(flat(r["slots"].get(k, "")) for k in ("Seen", "Suggests")): return "done", "", False - held = self.holding(r["id"]) - if held: - return "planned", f"the decision {held[0]['id']} to be settled", False - why = self._blocked(r) + why = self._held(r) if why: - return "planned", why, False + return "waiting", why, False if not flat(r["slots"].get("Looks at", "")): - return "planned", "say what it looks at, and where that is", True + return "open", "say what it looks at, and where that is", True started = any(l["about"] == r["id"] for l in self.lines) - return ("in progress" if started else "planned"), "read it; then write what was seen and what it suggests", True + return ("running" if started else "open"), "read it; then write what was seen and what it suggests", True def _build_state(self, b): if b.get("dropped"): return "dropped", "", False if b["commits"]: - return "built", "", False - held = self.holding(b["id"]) - if held: - return "planned", f"the decision {held[0]['id']} to be settled", False - why = self._blocked(b) + return "done", "", False + why = self._held(b) if why: - return "planned", why, False + return "waiting", why, False started = any(l["about"] == b["id"] for l in self.lines) - return ("in progress" if started else "planned"), "build it; then put its commits and its tests on the card", True + return ("running" if started else "open"), "build it; then put its commits and its tests on the card", True + + def _held(self, x): + """What a step that has not run waits on, or None: an open decision that holds it, something outside the lab + (`waiting_on:`), or what `_blocked` names.""" + held = self.holding(x["id"]) + if held: + return f"the decision {held[0]['id']} to be settled" + if x.get("waiting_on"): + return str(x["waiting_on"]) + return self._blocked(x) def _experiment_state(self, x): """An experiment's state, what is next for it, and whether that is the agent's to do.""" @@ -1058,45 +1081,41 @@ def _experiment_state(self, x): return "dropped", "", False if self.replaced_by(x["id"]): return "replaced", "", False - if verdict == "fail": - return "review failed", "replace it with a new experiment, or drop it", True + if verdict == "fail": # its run finished and its results may not be named: done, and void + x["outcome"] = "void" + return "done", "", False if x["reviewed"] and x["outcome"] and all(flat(x["slots"].get(k, "")) for k in ("Found", "Means")): return "done", "", False going = [r for r in x["runs"] + x["trials"] if r["state"] == "running"] if any(not r["orphan"] for r in going): return "running", "the run to end", False if going: - return "planned", "close its run, whose process is gone (`lab runs` names it)", True + return "open", "close its run, whose process is gone (`lab runs` names it)", True if not x["finished"]: # an open decision or a missing need holds what has not run; what has run is read and reviewed regardless - held = self.holding(x["id"]) - if held: - return "waiting", f"the decision {held[0]['id']} to be settled", False - if x.get("waiting_on"): - return "waiting", str(x["waiting_on"]), False - why = self._blocked(x) + why = self._held(x) if why: - return "planned", why, False + return "waiting", why, False if not x["lock"]: lines = x["lines"]["confirmed"] + x["lines"]["refuted"] if not flat(x["slots"].get("Compares", "")) or not x["arms"] or not flat(x["slots"].get("Cases", "")) or not x["lines"]["confirmed"] or not x["lines"]["refuted"] or any(not l["test"] for l in lines): - return "planned", "write what it compares, each arm, the cases, and its lines, each with the result it tests", True + return "open", "write what it compares, each arm, the cases, and its lines, each with the result it tests", True if not os.path.isdir(os.path.join(self.root, x["dir"], "plan")) or not os.listdir(os.path.join(self.root, x["dir"], "plan")): - return "planned", "put the configuration and the code the run executes in plan/", True + return "open", "put the configuration and the code the run executes in plan/", True if any(self.metered(r) for r in x["uses"]) and self.reviewed(x, "plan") != ("pass", True): - return "planned", "send the plan to a reviewer: its run uses a metered resource", True - return "planned", "lock it", True + return "open", "send the plan to a reviewer: its run uses a metered resource", True + return "open", "lock it", True if not x["finished"]: if x["runs"]: - return "planned", "read why its last run failed; run it again under the same lock, or replace the experiment", True - return "planned", "run it", True + return "open", "read why its last run failed; run it again under the same lock, or replace the experiment", True + return "open", "run it", True if not x["results"]: - return "planned", "write a result row for each number its lines test", True + return "open", "write a result row for each number its lines test", True missing = sorted({l["name"] for l in x["lines"]["confirmed"] + x["lines"]["refuted"] if l["test"]} - {r["name"] for r in x["results"]}) if missing: - return "planned", f"add the results its lines test: {', '.join(missing)}", True + return "open", f"add the results its lines test: {', '.join(missing)}", True if not x["reviewed"]: - return "planned", "send the results to a reviewer", True - return "planned", "write Found and Means, naming its results", True + return "open", "send the results to a reviewer", True + return "open", "write Found and Means, naming its results", True def doing(self): """What the record says the agent is on: its last `doing` line, until a later line about the same card ends it.""" @@ -1106,7 +1125,7 @@ def doing(self): last = l elif last and l["kind"] in CLOSES and l["about"] == last["about"]: last = None - if last and self.nodes.get(last["about"], {}).get("state") in ("done", "built", "dropped", "replaced", "yes", "no", "reached"): + if last and self.nodes.get(last["about"], {}).get("state") in CLOSED: return None return last diff --git a/src/lab_kit/runs.py b/src/lab_kit/runs.py index 56ffdbc..c97bb18 100644 --- a/src/lab_kit/runs.py +++ b/src/lab_kit/runs.py @@ -96,8 +96,8 @@ def _start(lab, ident, command, trial, changed): x = lab.nodes.get(ident) if not x or x["type"] != "experiment": stop(f"no experiment {ident}") - if x["state"] in ("dropped", "replaced", "review failed"): - stop(f"{ident} is {x['state']}") + if x["state"] in ("dropped", "replaced") or x.get("outcome") == "void": + stop(f"{ident} is {'void: its results review failed, so it never runs again; a new experiment replaces it' if x.get('outcome') == 'void' else x['state']}") why = lab._blocked(x) if why: stop(f"{ident} waits on {why}") diff --git a/src/lab_kit/site.py b/src/lab_kit/site.py index 80f1db4..c3da252 100644 --- a/src/lab_kit/site.py +++ b/src/lab_kit/site.py @@ -11,9 +11,19 @@ GENERIC = {"model", "field", "source", "group", "stop", "case", "score", "port", "step", "pass", "run", "result"} e = html.escape -TONES = {"active": "info", "reached": "ok", "under discussion": "warn", "open": "info", "yes": "ok", "no": "warn", "decided": "ok", - "confirmed": "ok", "refuted": "bad", "unclear": "warn", "running": "info", "waiting": "warn", "in progress": "info", "built": "ok", - "review failed": "bad", "finished": "ok", "failed": "bad", "pass": "ok", "fail": "bad", "done": "ok", "parked": "plain"} +TONES = {"running": "info", "finished": "ok", "failed": "bad", "pass": "ok", "fail": "bad"} # a run's state and a review's verdict, as pills +# How every state and label is drawn, on every page, on Now and in the rail: its tone (the colour) and its sign (the +# shape), so that colour is never the only signal. On done the label decides, and an answer is a finding, never good or +# bad: yes, no and mixed share one neutral tone. +LOOK = {"open": ("plain", "\u25cb"), "waiting": ("warn", "\u2016"), "parked": ("plain", "\u2016"), "running": ("info", "\u25cf"), + "done": ("ok", "\u2713"), "confirmed": ("ok", "\u2713"), "unclear": ("warn", "?"), "refuted": ("bad", "\u2717"), "void": ("bad", "!"), + "yes": ("ink", "Y"), "no": ("ink", "N"), "mixed": ("ink", "M"), "replaced": ("gone", "\u2013"), "dropped": ("gone", "\u2013"), + "to discuss": ("warn", "\u25cf"), "decided": ("ok", "\u2713")} +ORDER = ("running", "waiting", "open", "done", "confirmed", "yes", "no", "mixed", "unclear", "refuted", "void", "parked", "replaced", "dropped") # how counts are listed +MARK = {"goal": "G", "question": "Q", "experiment": "E", "build": "B", "reading": "R", "decision": "D"} +MEANS = {"running": "running", "waiting": "waiting", "open": "open", "done": "done", "confirmed": "confirmed", "yes": "answered yes", "no": "answered no", + "mixed": "answered mixed", "unclear": "unclear", "refuted": "refuted", "void": "void: its results review failed", "parked": "parked", + "replaced": "replaced", "dropped": "dropped"} def nice(day): @@ -58,23 +68,28 @@ def ordinal(n): return {1: "first", 2: "second", 3: "third", 4: "fourth", 5: "fifth", 6: "sixth"}.get(n, f"{n}th") +def key(n): + """The word a node's look is read from: its label on done (an answer, an outcome), else its state.""" + if n.get("type") == "decision": + return "decided" if n["state"] == "done" else "to discuss" + return n["label"] if n.get("state") == "done" and n.get("label") else n["state"] + + def label(n): - """A node's state as the operator reads it: a finished experiment shows its outcome.""" - if n["type"] == "experiment" and n["state"] == "done": - return n["outcome"] - if n["type"] == "question" and n["state"] in ("yes", "no"): - return f"answered {n['state']}" - if n["type"] == "question" and n["state"] == "open" and not n["items"]: - return "not started" + """A node's state as the operator reads it: on done, a question shows its answer and an experiment its outcome.""" + if n.get("type") == "decision": + return "decided" if n["state"] == "done" else "open" + if n["state"] == "done" and n.get("label"): + return f"answered {n['label']}" if n["type"] == "question" else n["label"] return n["state"] def tone(n): - if n.get("type") == "decision": - return "ok" if n["state"] == "decided" else "warn" - if n.get("type") == "question" and n["state"] == "open" and not n["items"]: - return "plain" - return TONES.get(n["outcome"] if n.get("type") == "experiment" and n["state"] == "done" else n["state"], "plain") + return LOOK.get(key(n), ("plain", ""))[0] + + +def sign(n): + return LOOK.get(key(n), ("plain", "\u25cb"))[1] def you(text): @@ -87,7 +102,8 @@ def pill(text, t="plain"): def dot(n): - return f'<i class="dot t-{tone(n)}"></i>' + """A node's state as a sign in its tone: the same shape and colour as in the rail. A running step's sign pulses.""" + return f'<span class="sg t-{tone(n)}{" live" if n.get("state") == "running" else ""}" title="{e(label(n))}">{sign(n)}</span>' def libraries(lab): @@ -305,9 +321,38 @@ def anchor(term): .lv .kv{display:grid;grid-template-columns:8.5rem 1fr;gap:.25rem .8rem;font:400 .88rem/1.45 var(--sans)} .lv .kv dt{color:var(--ink-3)} .lv .kv dd{margin:0;overflow-wrap:anywhere} -.lv svg.graph text{font-family:var(--sans)} -.lv svg.graph a{text-decoration:none} -.lv svg.graph a:hover rect{stroke:var(--accent);stroke-width:2} +.lv .sg{display:inline-block;min-width:.95em;text-align:center;font:700 .82em/1 var(--sans);color:var(--ink-3);background:none;text-decoration:none} +.lv .sg.t-ok{color:var(--ok)}.lv .sg.t-warn{color:var(--warn)}.lv .sg.t-bad{color:var(--bad)}.lv .sg.t-info{color:var(--info)}.lv .sg.t-ink{color:var(--ink)}.lv .sg.t-gone{color:var(--ink-3)} +.lv .t-ink{background:var(--sunk);color:var(--ink)} +.lv .t-gone{background:none;color:var(--ink-3);text-decoration:line-through} +.lv .live{animation:lv-pulse 1.6s ease-in-out infinite} +@keyframes lv-pulse{0%,100%{opacity:1}50%{opacity:.3}} +@media (prefers-reduced-motion:reduce){.lv .live{animation:none}} +.lv .dash-live{background:var(--surface);border:1px solid var(--rule);border-left:3px solid var(--info);border-radius:8px;padding:.7rem 1rem;margin:.2rem 0 1rem;font:400 .95rem/1.5 var(--sans)} +.lv .dash-live.quiet{border-left-color:var(--rule-strong)} +.lv .dash-live p{margin:.15rem 0} +.lv .dash-live .who{display:inline-block;min-width:5.2rem;color:var(--ink-3);font-size:.8rem;text-transform:uppercase;letter-spacing:.06em} +.lv .dash-live .stamp{color:var(--ink-3);font-size:.8rem;margin-top:.4rem} +.lv .dash-lines{display:grid;grid-template-columns:1fr 1fr;gap:.6rem 1.2rem;margin:0 0 1.2rem;font:400 .9rem/1.45 var(--sans)} +.lv .dash-lines>div{border:1px solid var(--rule);border-radius:8px;padding:.55rem .8rem;background:var(--surface)} +.lv .dash-lines>div.ask{border-color:var(--warn);background:var(--warn-soft)} +.lv .dash-lines ol{margin:.25rem 0 0;padding-left:1.3rem}.lv .dash-lines li{margin:.1rem 0} +.lv .dash-lines b{display:block;font:650 .72rem var(--sans);text-transform:uppercase;letter-spacing:.08em;color:var(--ink-3);margin-bottom:.15rem} +.lv .goalrow{display:flex;gap:.6rem;align-items:baseline;margin:1.3rem 0 .45rem;font:600 1.05rem var(--sans)} +.lv .goalrow a{color:inherit;text-decoration:none} +.lv .goalrow .n{margin-left:auto;font:400 .8rem var(--sans);color:var(--ink-3)} +.lv .tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(13.5rem,1fr));gap:.6rem} +.lv .tile{display:block;border:1px solid var(--rule);border-radius:8px;padding:.5rem .7rem .55rem;background:var(--surface);font:400 .86rem/1.4 var(--sans);color:var(--ink-2);text-decoration:none} +.lv .tile:hover{border-color:var(--accent)} +.lv .tile.t-done{background:var(--sunk)} +.lv .tile .top{display:flex;gap:.4rem;align-items:baseline} +.lv .tile .id{font:500 .74rem var(--mono);color:var(--ink-3)} +.lv .tile .ttl{font-weight:600;color:var(--ink)} +.lv .tile .st{margin:.15rem 0 .3rem;font-size:.78rem;color:var(--ink-3)} +.lv .tile .marks{display:flex;flex-wrap:wrap;gap:.15rem .3rem;font-size:.95rem} +.lv .tile .marks .gone{font:500 .75rem var(--sans);color:var(--ink-3);margin-left:.2rem} +.lv .aside{margin:.4rem 0 0;font:400 .82rem var(--sans);color:var(--ink-3)} +@media (max-width:640px){.lv .dash-lines{grid-template-columns:1fr}} .lv .filters{display:flex;gap:.4rem;flex-wrap:wrap;margin:0 0 1rem;font:500 .8rem var(--sans)} .lv .filters a{text-decoration:none} .lv h2{font:600 1.2rem/1.3 var(--serif);margin:2.1rem 0 .6rem} @@ -571,7 +616,7 @@ def decided_notes(lab, T, n): """The settled decisions about a node that carry a Note: what changes how the node is read, each with its decision.""" out = [] for d in lab.decisions: - if d["state"] == "decided" and n["id"] in d["about"] and L.flat(d["slots"].get("Note", "")): + if d["state"] == "done" and n["id"] in d["about"] and L.flat(d["slots"].get("Note", "")): out.append(f'<p><b>Decided in {named(lab, d["id"])}:</b></p>{block(T, d["slots"]["Note"])}') return "".join(out) @@ -615,7 +660,7 @@ def happened(lines): def decision_box(lab, T, d, link=True, title=True): """One decision as the operator reads it: what there is to discuss, or what was decided and why.""" - done = d["state"] == "decided" + done = d["state"] == "done" about = ", ".join(named(lab, i) if i in lab.nodes else f'the resource <a href="/resources#{e(i)}">{e(i)}</a>' for i in d["about"] if i in lab.nodes or i in lab.resources) head = f'{ref(lab, d["id"]) if link else e(d["id"])} · raised {nice(d["date"])}' + (f" · about {about}" if about else "") rows = [] @@ -647,7 +692,7 @@ def edges_panel(lab, n): out.append("<h4>Needs</h4><ul>" + "".join(f"<li>{dot(lab.nodes[i])} {named(lab, i)}</li>" for i in n["needs"] if i in lab.nodes) + "</ul>") by = [x for x in lab.questions + lab.items if n["id"] in (x.get("needs") or []) and x["state"] not in ("replaced", "dropped")] if by: - out.append("<h4>Needed by</h4><ul>" + "".join(f"<li>{dot(x)} {named(lab, x['id'])}</li>" for x in by) + "</ul>") + out.append(f"<h4>{'Used by' if n.get('state') in L.CLOSED else 'Needed by'}</h4><ul>" + "".join(f"<li>{dot(x)} {named(lab, x['id'])}</li>" for x in by) + "</ul>") if n.get("uses"): rows = [] for r in n["uses"]: @@ -764,7 +809,7 @@ def item_line(lab, T, x): def qcard(lab, T, q): """A question in a list: its title and what is known so far. Why we ask it is shown only until something is known.""" live = [x for x in q["items"] if x["state"] not in ("replaced", "dropped")] - done = sum(x["state"] in ("done", "built") for x in live) + done = sum(x["state"] == "done" for x in live) asks = f'<p class="asks">{e(q["asks"])}</p>' if q["asks"] != q["title"] else "" body = asks + (block(T, q["slots"].get("So far", "")) if live else f'<p class="muted">{T(q["description"])}</p>') count = f"{done} of {len(live)} steps done" if live else "" @@ -772,29 +817,77 @@ def qcard(lab, T, q): f'<div class="side">{pill(label(q), tone(q))}<br>{count}</div></div>') -def right_now(lab, T): - """The top of the front page: what is going on at this moment, as far as the record says, and how fresh the record is.""" +def live_box(lab, T): + """The top of Now: everything live at this moment, each with a pulsing sign, and how fresh the record is.""" rows = [] for x in lab.experiments: for r in x["runs"] + x["trials"]: if r["state"] == "running" and not r["orphan"]: - rows.append(f'<p class="what">{pill("running", "info")} {named(lab, x["id"])}, since {clock(r["started"])}' + (f' on {e(", ".join(x["uses"]))}' if x["uses"] else "") + ".</p>") + rows.append(f'<p><span class="who">running</span><span class="sg t-info live">\u25cf</span> {named(lab, x["id"])}, since {clock(r["started"])}' + + (f' on {e(", ".join(x["uses"]))}' if x["uses"] else "") + ".</p>") + for m in [m for m in lab.missions if m["state"] == "current"]: + last = next((l for l in reversed(m["log"]) if l.get("what")), None) + rows.append(f'<p><span class="who">mission</span><span class="sg t-info live">\u25cf</span> {e(m["id"])} {e(m["title"])}' + + (f' <span class="muted">last, {nice(last["day"])} {e(last["time"])}: {T(last["what"])}</span>' if last else "") + "</p>") d = lab.doing() if d: - rows.append(f'<p class="what">{pill("the agent is on", "info")} {named(lab, d["about"])}</p><p>{T(d["what"])} <span class="muted">Why now:</span> {T(d["so"])} <span class="muted">Since {clock(d["at"])}.</span></p>') + rows.append(f'<p><span class="who">the agent</span><span class="sg t-info live">\u25cf</span> on {named(lab, d["about"])}: {T(d["what"])} <span class="muted">Why now:</span> {T(d["so"])} <span class="muted">Since {clock(d["at"])}.</span></p>') + elif rows: + rows.append('<p><span class="who">the agent</span><span class="muted">has not said it is on anything.</span></p>') if not rows: - mine = lab.yours() - if mine: - x = mine[0] - rows.append(f'<p class="what">{pill("nobody is on it", "warn")} Nothing is running, and no agent has said it is working.</p>' - f'<p>The next step is the agent\'s: {named(lab, x["id"])}: {T(you(x["next"]))}.</p>') - else: - waits = [x for x in lab.pursued() if x["state"] == "waiting" or (x["state"] == "planned" and x["next"])] - rows.append(f'<p class="what">{pill("idle", "plain")} Nothing is running and nothing is the agent\'s to move.</p>' - + (f'<p>{named(lab, waits[0]["id"])} waits on {T(you(waits[0]["next"]))}.</p>' if waits else "")) + rows.append('<p><span class="who">quiet</span>Nothing is running and nobody is on anything.</p>') last = lab.last_record() stamp = f'<p class="stamp">Last recorded activity: {clock(last.isoformat())} UTC, {ago(last)}.</p>' if last else "" - return f'<div class="nowbox{"" if d or len(rows) > 1 or "running" in rows[0][:60] else " quiet"}">{"".join(rows)}{stamp}</div>' + quiet = "" if d or any("live" in r for r in rows) else " quiet" + return f'<div class="dash-live{quiet}">{"".join(rows)}{stamp}</div>' + + +def ask_and_next(lab, T): + """Two short lines under what is live: what needs the operator, and what is next for the agent.""" + talk = lab.open_decisions() + ask = ("".join(f'<p>{dot(d)} {named(lab, d["id"])}</p>' for d in talk)) if talk else '<p class="muted">Nothing.</p>' + busy = lab.doing()["about"] if lab.doing() else None + nxt = [x for x in lab.yours() if x["id"] != busy] + waits = [x for x in lab.pursued() if x["state"] == "waiting"] + by = lab.ordered_by() + if nxt: + then = (f'<p class="muted">In the order of the work set by {named(lab, by["id"])}.</p>' if by and len(nxt) > 1 else "") + "<ol>" + "".join( + f'<li>{dot(x)} {named(lab, x["id"])}: {T(you(x["next"]))}</li>' for x in nxt) + "</ol>" + else: + then = '<p class="muted">Nothing is the agent\'s to move.</p>' + if waits: + then += f'<p class="muted">{len(waits)} step{"s" if len(waits) != 1 else ""} wait{"" if len(waits) != 1 else "s"}: ' + "; ".join(f'{named(lab, x["id"])} on {T(you(x["next"]))}' for x in waits[:3]) + (f"; and {len(waits) - 3} more" if len(waits) > 3 else "") + ".</p>" + return f'<div class="dash-lines"><div class="{"ask" if talk else ""}"><b>Needs you</b>{ask}</div><div><b>Next for the agent</b>{then}</div></div>' + + +def counts(steps): + """How many steps are in each state, in a fixed order: [(key, n)].""" + seen = {} + for x in steps: + seen[key(x)] = seen.get(key(x), 0) + 1 + return [(k, seen[k]) for k in ORDER if k in seen] + [(k, n) for k, n in seen.items() if k not in ORDER] + + +def tile(lab, T, q): + """A question on Now: its state and answer, and one sign per step in tree order; what was replaced or dropped is a count.""" + live = [x for x in q["items"] if x["state"] not in ("replaced", "dropped")] + gone = len(q["items"]) - len(live) + marks = "".join(f'<span class="sg t-{tone(x)}{" live" if x["state"] == "running" else ""}" title="{e(x["id"])} {e(x["title"])}: {e(label(x))}">{sign(x)}</span>' for x in live) + marks += f'<span class="gone" title="replaced or dropped">\u2013{gone}</span>' if gone else "" + marks = marks or '<span class="muted" style="font-size:.78rem">nothing under it yet</span>' + return (f'<a class="tile t-{q["state"]}" href="/{q["id"]}" title="{e(q["asks"])}"><div class="top">{dot(q)}<span class="id">{e(q["id"].split(".")[-1])}</span>' + f'<span class="ttl">{e(q["title"])}</span></div><div class="st">{e(label(q))}</div><div class="marks">{marks}</div></a>') + + +def lab_map(lab, T): + """The lab at a glance: one row per goal, with how many of its questions are answered, and one tile per question.""" + out = [] + for g in lab.live(lab.goals): + qs = lab.live(g["questions"]) + answered = sum(q["state"] == "done" for q in qs) + out.append(f'<div class="goalrow">{dot(g)}<a href="/{g["id"]}">{e(g["id"])} {e(g["title"])}</a><span class="n">{answered} of {len(qs)} question{"s" if len(qs) != 1 else ""} answered</span></div><p class="goalwhy">{T(g["description"])}</p>') + out.append('<div class="tiles">' + "".join(tile(lab, T, q) for q in qs) + "</div>") + return "".join(out) def story(lab, T, g): @@ -832,25 +925,18 @@ def story(lab, T, g): # ---------------------------------------------------------------- pages def home(lab, T): - out = [right_now(lab, T)] + """Now, the dashboard: what is live, what needs the operator and what is next, the map of the lab, the resources, + the latest events. All of it is worked out from the record.""" + out = [live_box(lab, T), ask_and_next(lab, T)] talk = [decision_box(lab, T, d) for d in lab.open_decisions()] - out.append("<h2>To discuss with you</h2>" + ("".join(talk) or '<p class="muted">Nothing.</p>')) - busy = lab.doing()["about"] if lab.doing() else None - nxt = [x for x in lab.yours() if x["id"] != busy] - held = [x for x in lab.pursued() if x["state"] == "waiting" or (x["state"] == "planned" and not x["mine"] and x["next"])] - if nxt or held: - by = lab.ordered_by() - out.append('<h2>Next</h2>' + (f'<p class="muted" style="font:.84rem var(--sans)">In the order of the work set by {named(lab, by["id"])}.</p>' if by else "") + '<table class="t"><tr><th>What</th><th>Who moves it</th><th>What happens next</th></tr>' + "".join( - f'<tr><td>{named(lab, x["id"])}</td><td>{"the agent" if x["mine"] else "waits"}</td><td>{("" if x["mine"] else "on ") + T(you(x["next"]))}</td></tr>' for x in nxt + held) + "</table>") - out.append("<h2>Where each question stands</h2>") - for g in lab.live(lab.goals): - out.append(f'<div class="goalhead">{dot(g)}<a href="/{g["id"]}">{e(g["title"])}</a></div><p class="goalwhy">{T(g["description"])}</p>' - + "".join(qcard(lab, T, q) for q in lab.live(g["questions"]))) - out.append(set_aside_html(lab, T)) - latest = happened(lab.lines)[-5:] - out.append('<h2>Latest</h2>' + log_html(lab, T, latest) + '<p style="font:.85rem var(--sans)"><a href="/log">The whole log</a></p>') + if talk: + out.append("<h2>To discuss with you</h2>" + "".join(talk)) + out.append("<h2>The lab</h2>" + lab_map(lab, T)) if lab.resources: out.append('<h2>Resources</h2>' + resources_table(lab)) + latest = happened(lab.lines)[-5:] + out.append('<h2>Latest</h2>' + log_html(lab, T, latest) + '<p style="font:.85rem var(--sans)"><a href="/log">The whole log</a></p>') + out.append(set_aside_html(lab, T)) return frame(lab, lab.cfg.get("title", lab.cfg["name"]), "".join(out)) @@ -1088,11 +1174,12 @@ def experiment_page(lab, T, x): body.append(f'<div class="box"><b>Replaced by</b> {named(lab, by["id"])}' + (f": {T(why)}" if why else ".") + " Its plan and its results stay as they were.</div>") failed = next((r for r in x["reviews"] if r.get("stage") == "results" and r.get("verdict") == "fail"), None) if failed: - body.append(f'<div class="box bad"><b>Its results failed their review.</b> {plain(failed.get("note", ""))} No outcome is shown, and no page uses its numbers.</div>') + body.append(f'<div class="box bad"><b>Void: its results failed their review.</b> No outcome is shown, and no page uses its numbers; what it made may still be used ' + f'by later steps, listed beside this page. The reviewer: {review_note(failed.get("note", ""))}</div>') body.append(where_box(lab, T, x)) body += [decision_box(lab, T, d) for d in lab.open_decisions() if x["id"] in d["about"] or x["id"] in d["holds"]] body.append(picture(lab, x)) - if x["state"] == "done": # what was observed comes first, apart from the plan + if x["state"] == "done" and x["label"] != "void": # what was observed comes first, apart from the plan body.append(slots(boxed(T, "What it means", s.get("Means", ""), "full key", x["id"]), boxed(T, "What was found", s.get("Found", ""), "full key", x["id"]))) body.append(f'<p class="outcome-line">{pill(x["outcome"], tone(x))} {e(decided_by(lab, x))}</p>') body.append(slots(so_far(lab, T, x, x["id"]))) @@ -1151,7 +1238,7 @@ def decision_page(lab, T, d): def decisions_page(lab, T): """Every decision: what is open first, then what was decided, the latest first.""" body = ["<h1>Decisions</h1>"] - for title, group in (("To discuss", lab.open_decisions()), ("Decided", sorted([d for d in lab.decisions if d["state"] == "decided"], key=lambda d: str(d["decided"].get("date")), reverse=True))): + for title, group in (("To discuss", lab.open_decisions()), ("Decided", sorted([d for d in lab.decisions if d["state"] == "done"], key=lambda d: str(d["decided"].get("date")), reverse=True))): if group: body.append(f"<h2>{title}</h2>" + "".join(decision_box(lab, T, d) for d in group)) if not lab.decisions: @@ -1236,69 +1323,6 @@ def glossary_page(lab, T): return frame(lab, "Glossary", "".join(body)) -def graph_page(lab, T): - W, colw, y0, row = 266, 232, 156, 66 - cols = lab.live(lab.questions) - width = max(len(cols) * W, 600) - fill = {"ok": "var(--ok-soft)", "warn": "var(--warn-soft)", "bad": "var(--bad-soft)", "info": "var(--info-soft)", "plain": "var(--sunk)"} - ink = {"ok": "var(--ok)", "warn": "var(--warn)", "bad": "var(--bad)", "info": "var(--info)", "plain": "var(--ink-3)"} - pos, out, col_of = {}, [], {} - - def box(n, x, y, sub=None, h=50): - pos[n["id"]] = (x, y) - t = tone(n) - title = n["title"] if len(n["title"]) <= 30 else n["title"][:28] + "…" - return (f'<a href="/{n["id"]}"><title>{e(n["title"])}. {e(L.bare(n.get("description") or ""))}' - f'{e(title)}' - f'{e(sub or n["id"] + " · " + label(n))}') - - centre = {} # each goal sits above the middle of its own questions - for g in lab.live(lab.goals): - mine = [i for i, q in enumerate(cols) if q["goal"] == g["id"]] - centre[g["id"]] = ((mine[0] + mine[-1] + 1) / 2 * W if mine else width / 2) - colw / 2 - out.append(box(g, centre[g["id"]], 10)) - shown = {q["id"]: [x for x in q["items"] if x["state"] not in ("replaced", "dropped")] for q in cols} - for i, q in enumerate(cols): - x = i * W + (W - colw) / 2 - gx = centre[q["goal"]] - col_of[q["id"]] = i - out.append(box(q, x, 84)) - out.append(f'') - for j, s in enumerate(shown[q["id"]]): - col_of[s["id"]] = i - out.append(box(s, x, y0 + j * row, f'{s["id"]} · {s["type"]} · {label(s)}')) - py = 134 if j == 0 else y0 + (j - 1) * row + 50 - out.append(f'') - k = 0 - for n in cols + lab.items: - for need in n.get("needs") or []: - if need not in pos or n["id"] not in pos: - continue - a, b = pos[need], pos[n["id"]] - ca, cb = col_of[need], col_of[n["id"]] - if ca == cb and 0 < b[1] - a[1] <= row: - continue # the one just above: the grey line already says it - k += 1 - off = (k % 4) * 4 - sy, ty, gut = a[1] + 30 + off / 2, b[1] + 18 + off / 2, (W - colw) / 2 - if ca == cb: - gx2 = a[0] + colw + 6 + off - d = f"M{a[0] + colw} {sy} H{gx2} V{ty} H{b[0] + colw + 1}" - elif cb == ca + 1: - gx2 = a[0] + colw + gut - 4 + off - d = f"M{a[0] + colw} {sy} H{gx2} V{ty} H{b[0] - 1}" - else: - g1, g2, lane = a[0] + colw + gut - 4 + off, b[0] - gut + 4 - off, b[1] - 8 + off / 2 - d = f"M{a[0] + colw} {sy} H{g1} V{lane} H{g2} V{ty} H{b[0] - 1}" - out.append(f'') - height = y0 + max([len(v) for v in shown.values()] or [0]) * row + 20 - svg = (f'' - f'{"".join(out)}') - legend = (f'

{pill("confirmed, built or answered yes", "ok")} {pill("unclear, waiting or under discussion", "warn")} {pill("refuted or failed", "bad")} {pill("open or running", "info")} {pill("planned", "plain")}' - "   A dashed arrow points from what is needed to what needs it.

") - return frame(lab, "Graph", f"

Graph

{legend}{svg}") - - # ---------------------------------------------------------------- the provider folio loads def _links(text): @@ -1349,8 +1373,6 @@ def get(self, inner): genre, status, description, page, path = "", "", "", None, "" if inner == "": page = home(lab, T) - elif inner == "graph": - page = graph_page(lab, T) elif parts[0] == "log" and (len(parts) == 1 or (len(parts) == 2 and parts[1] in L.KINDS)): page, path = log_page(lab, T, parts[1] if len(parts) == 2 else ""), "log.md" elif inner == "decisions": @@ -1372,13 +1394,43 @@ def get(self, inner): genre=genre, status=status, head=f"", panels=panels, path=path) def rail(self): + """The lab as a tree: each goal, its questions, each question's steps. Each row has the mark of its kind, its short + id, its title and its state as a sign; a closed group counts what is under it by state. What was replaced or + dropped folds into one line at the end of its question, and what was set aside at the end of its goal.""" lab = self.lab() - out = [{"title": t, "url": f"/lab/{p}"} for t, p in (("Now", ""), ("Graph", "graph/"), ("Decisions", "decisions/"), ("Log", "log/"), ("Resources", "resources/"), ("Glossary", "glossary/"))] + + def row(n, short): + return {"title": n["title"], "url": f"/lab/{n['id']}/", "id": short, "kind": n["type"], "status": label(n), **({"mark": MARK[n["type"]]} if n["type"] in L.STEPS else {}), + "tone": tone(n), "sign": sign(n), "pulse": n["state"] == "running", "gone": n["state"] in ("replaced", "dropped")} + + def summary(steps): + out = {} # done and confirmed share a sign: one count + for k, n in counts(steps): + look = LOOK.get(k, ("plain", "")) + was = out.get(look, (0, [])) + out[look] = (was[0] + n, was[1] + [f"{n} {MEANS.get(k, k)}"]) + return [{"sign": look[1], "tone": look[0], "count": n, "title": ", ".join(words)} for look, (n, words) in out.items()] + + talk = len(lab.open_decisions()) + out = [{"title": "Now", "url": "/lab/"}, {"title": "Decisions", "url": "/lab/decisions/", **({"status": f"{talk} to discuss", "tone": "warn"} if talk else {})}] + out += [{"title": t, "url": f"/lab/{p}"} for t, p in (("Log", "log/"), ("Resources", "resources/"), ("Glossary", "glossary/"))] for g in lab.live(lab.goals): - out.append({"title": g["title"], "url": f"/lab/{g['id']}/", "status": g["state"], "tone": tone(g)}) + questions, under = [], [] for q in lab.live(g["questions"]): - items = [{"title": x["title"], "url": f"/lab/{x['id']}/", "status": label(x), "tone": tone(x)} for x in q["items"] if x["state"] not in ("replaced", "dropped")] - out.append({"title": q["title"], "url": f"/lab/{q['id']}/", "status": label(q), "tone": tone(q), "open": q["state"] == "open" and bool(items), "items": items}) + live = [x for x in q["items"] if x["state"] not in ("replaced", "dropped")] + gone = [x for x in q["items"] if x["state"] in ("replaced", "dropped")] + under += live + items = [row(x, x["id"].split(".")[-1]) for x in live] + if gone: + items.append({"title": f"replaced and dropped ({len(gone)})", "key": f"{q['id']}:gone", "fold": True, "items": [row(x, x["id"].split(".")[-1]) for x in gone]}) + questions.append({**row(q, q["id"].split(".")[-1]), **({"items": items, "summary": summary(live)} if items else {})}) + aside = [q for q in g["questions"] if q["state"] in ("parked", "dropped")] + if aside: + questions.append({"title": f"set aside ({len(aside)})", "key": f"{g['id']}:aside", "fold": True, "items": [row(q, q["id"].split(".")[-1]) for q in aside]}) + out.append({**row(g, g["id"]), "items": questions, "summary": summary(under)}) + legend = [{"mark": MARK[k], "text": k} for k in L.STEPS] + legend += [{"sign": LOOK[k][1], "tone": LOOK[k][0], "status": MEANS[k], "text": MEANS[k]} for k in ORDER] + out.append({"title": "Key", "legend": legend}) return out def search(self): @@ -1398,7 +1450,7 @@ def search(self): def paths(self): lab = self.lab() - return ["", "graph", "decisions", "log", "resources", "glossary"] + [f"log/{k}" for k in L.KINDS] + list(lab.nodes) + return ["", "decisions", "log", "resources", "glossary"] + [f"log/{k}" for k in L.KINDS] + list(lab.nodes) def backlinks(self): lab = self.lab() diff --git a/src/lab_kit/views.py b/src/lab_kit/views.py index f6466ca..fba3599 100644 --- a/src/lab_kit/views.py +++ b/src/lab_kit/views.py @@ -11,7 +11,7 @@ def num(x): def state(n): - return n["state"] + (f", {n['outcome']}" if n.get("outcome") and n["state"] == "done" else "") + return n["state"] + (f", {n['label']}" if n.get("label") and n["state"] == "done" else "") def line(l): @@ -23,7 +23,7 @@ def decision_text(lab, d): about = ", ".join(f"{i} {lab.nodes[i]['title']}" if i in lab.nodes else f"the resource {i}" for i in d["about"] if i in lab.nodes or i in lab.resources) when = f"decided {d['decided'].get('date')} with {d['decided'].get('with')}" if d["decided"] else "open: to discuss with the operator" out = [f"{d['id']} {d['title']} (raised {d.get('date')}, {when})" + (f"\nAbout: {about}" if about else "")] - for key, verb in (("parks", "Parks"), ("unparks", "Brings back")): + for key, verb in (("parks", "Parks"), ("unparks", "Brings back"), ("drops", "Drops")): if d[key]: out += [f"{verb}: " + ", ".join(f"{i} {lab.nodes[i]['title']}" if i in lab.nodes else i for i in d[key])] if d["order"]: @@ -77,20 +77,20 @@ def _now(lab): by = lab.ordered_by() order = f" (in the order {by['id']} set)" if by else "" out += ["", "Yours next" + order] + ([f"- {x['id']} {x['title']} ({x['type']}): {x['next']}" for x in lab.yours()] or ["- nothing"]) - held = [f"- {x['id']} {x['title']}: on {x['next']}" for x in lab.pursued() if x["state"] == "waiting" or (x["state"] == "planned" and not x["mine"])] + held = [f"- {x['id']} {x['title']}: on {x['next']}" for x in lab.pursued() if x["state"] == "waiting" or (x["state"] == "open" and not x["mine"])] out += ["", "Not yours to move yet" + order] + (held or ["- nothing"]) out += ["", "Questions"] for q in lab.live(lab.questions): counts = {} for x in q["items"]: - key = x["outcome"] if x["state"] == "done" and x.get("outcome") else x["state"] + key = x["label"] if x["state"] == "done" and x.get("label") else x["state"] counts[key] = counts.get(key, 0) + 1 - out += [f"- {q['id']} ({q['state']}): {q['title']} [{', '.join(f'{n} {k}' for k, n in counts.items()) or 'nothing under it'}]"] + out += [f"- {q['id']} ({state(q)}): {q['title']} [{', '.join(f'{n} {k}' for k, n in counts.items()) or 'nothing under it'}]"] aside = lab.set_aside() if any(aside.values()): out += ["", "Set aside"] + [f"- {q['id']} (parked by {lab.parked_by(q['id'])['id']}): {q['title']}" for q in aside["parked"]] rest = [f"{len(aside['dropped'])} question{'' if len(aside['dropped']) == 1 else 's'} dropped"] if aside["dropped"] else [] - rest += [f"{len(aside['goals'])} goal{'' if len(aside['goals']) == 1 else 's'} closed ({', '.join(g['id'] + ' ' + g['state'] for g in aside['goals'])})"] if aside["goals"] else [] + rest += [f"{len(aside['goals'])} goal{'' if len(aside['goals']) == 1 else 's'} closed ({', '.join(g['id'] + ' ' + ('reached' if g['state'] == 'done' else g['state']) for g in aside['goals'])})"] if aside["goals"] else [] out += [f"- {', '.join(rest)}: lab show "] if rest else [] if lab.resources: out += ["", "Resources"] + [resource_line(lab, name) for name in lab.resources] @@ -147,7 +147,7 @@ def mission(lab, ident=None, everything=False): if not d["order"]: out += ["", f"{d['id']} orders no steps: what it decided says what to carry out."] else: - open_ = [x for x in steps if x["state"] not in ("done", "built", "dropped", "replaced")] + open_ = [x for x in steps if x["state"] not in R.CLOSED] out += ["", f"Steps {d['id']} orders, first to last, as they stand now ({len(steps) - len(open_)} of {len(steps)} finished)"] for x in open_: who = "yours" if x["mine"] else "not yours to move yet" @@ -196,7 +196,7 @@ def _show(lab, ident): raised = [d for d in lab.decisions if ident in d["about"]] if n["type"] == "goal": out = [f"{n['id']} ({n['state']}): {n['title']}", n["description"]] + came(n) + ["", f"Claim. {R.flat(n['slots'].get('Claim', '')) or 'not written yet'}", "", "Questions"] - out += [f"- {q['id']} ({q['state']}): {q['title']}. {q['description']}" for q in n["questions"]] + out += [f"- {q['id']} ({state(q)}): {q['title']}. {q['description']}" for q in n["questions"]] words = lab.vocabulary(n) if words: # the names are the card's; each is drawn with the glossary's definition out += ["", "Vocabulary (defined in GLOSSARY.md)"] + [entry_text(w["entry"], "- ") if w["entry"] else f"- {w['name']}: not in the glossary" for w in words] @@ -204,7 +204,7 @@ def _show(lab, ident): about = [l for l in lab.lines if l["about"] == ident or l["about"].startswith(ident + ".")] decisions = ["", "Decisions about it"] + [f"- {d['id']} ({d['state']}): {d['title']}" for d in raised] if raised else [] if n["type"] == "question": - out = [f"{n['id']} ({n['state']}): {n['title']}", f"Asks: {n['asks']}", n["description"]] + came(n) + [""] + out = [f"{n['id']} ({state(n)}): {n['title']}", f"Asks: {n['asks']}", n["description"]] + came(n) + [""] by = lab.parked_by(n["id"]) if n["state"] == "parked" else None out += [f"Parked by {by['id']} {by['title']}: nothing under it moves until a decision brings it back (`unparks:`).", ""] if by else [] out += [f"{slot}. {lab.fill(R.flat(n['slots'].get(slot, '')))}\n" for slot, _ in R.SLOTS["question"]] diff --git a/src/lab_kit/write.py b/src/lab_kit/write.py index 1cc3783..3088ae3 100644 --- a/src/lab_kit/write.py +++ b/src/lab_kit/write.py @@ -233,19 +233,19 @@ def decide(lab, ident, text, with_): def answer(lab, target, verdict, text): """The agent's answer to a question, once its experiments are done.""" n = lab.nodes.get(target) - if verdict not in ("yes", "no"): - stop("an answer is yes or no") + if verdict not in R.ANSWERS: + stop("an answer is yes, no or mixed: mixed when part of what was expected held and part did not, saying which") if not n or n["type"] != "question": stop(f"no question {target}") if not R.flat(text): stop("an answer says what it rests on") if n["state"] != "open": - stop(f"{target} is {n['state']}, not open") - waiting = [x["id"] for x in n["items"] if x["state"] not in ("done", "built", "replaced", "dropped")] + stop(f"{target} is {n.get('label') or n['state']}, not open") + waiting = [x["id"] for x in n["items"] if x["state"] not in R.CLOSED] if waiting: stop(f"{target} cannot be answered while {', '.join(waiting)} {'is' if len(waiting) == 1 else 'are'} not done: finish, replace or drop {'it' if len(waiting) == 1 else 'them'}") - if not any(x["state"] == "done" and x["type"] == "experiment" for x in n["items"]): # a reading suggests; it answers nothing - stop(f"{target} has no finished experiment to rest an answer on") + if not any(x["state"] == "done" and x["type"] == "experiment" and x["label"] != "void" for x in n["items"]): # a reading suggests; it answers nothing + stop(f"{target} has no finished experiment to rest an answer on (one whose results review failed is void, and rests nothing)") if n.get("answer") is not None or n.get("answered") is not None: stop(f"{target} already holds an `answer:` or an `answered:` that this command did not write: remove it from the card first") line = log_line(lab, target, "agent", f"Answered {target} {verdict}.", text) # everything is validated before the first write @@ -433,7 +433,7 @@ def mission_launch(lab, ident=None): stop(f"{m['path']}: {m['bad'][0]}") if lab.nodes.get(m["carries"], {}).get("type") != "decision": stop(f"{m['path']}: `carries:` names no decision") - if lab.nodes[m["carries"]]["state"] != "decided": + if lab.nodes[m["carries"]]["state"] != "done": stop(f"{m['carries']} is still open: a mission carries out a settled decision. Settle it with the operator first") if not m["description"]: stop(f"{m['path']}: say what the mission is for, in the paragraph under the front matter") diff --git a/tests/test_flow.py b/tests/test_flow.py index 9376e74..d5ae289 100644 --- a/tests/test_flow.py +++ b/tests/test_flow.py @@ -117,7 +117,7 @@ def test_from_a_decision_to_a_reviewed_result(tmp_path): ident, d, command = experiment(root) assert ident == "G1.Q1.2" front(f"{d}/experiment.md", needs="[G1.Q1.1]") - assert "the decision D1 to be settled" in lab(root, "lock", ident, ok=False) and "(under discussion)" in lab(root, "show", "G1.Q1") + assert "the decision D1 to be settled" in lab(root, "lock", ident, ok=False) and "G1.Q1 (waiting)" in lab(root, "show", "G1.Q1") assert "does not say what was seen" in lab(root, "decide", "D1", "--with", "Ada", "One goal.", ok=False) fill(card, Seen="The repository holds a coin sampler and no measurement of how its estimate converges.", Options="(a) Start with the square-root law. (b) Start with the bias of the sampler.", Recommendation="(a): it is the cheapest check that can fail.") @@ -141,7 +141,7 @@ def test_from_a_decision_to_a_reviewed_result(tmp_path): assert "G1.Q1.1 The sampler" in lab(root, "lock", ident, ok=False) assert "G1.Q1.1 The sampler (build): build it" in lab(root, "now") front(f"{folder(root, 'G1.Q1.1')}/build.md", commits="[abc1234]", tests="[tests/test_sampler.py]") - assert "(built)" in lab(root, "show", "G1.Q1.1") + assert "(done)" in lab(root, "show", "G1.Q1.1") # every line carries the result it tests, or the lock refuses fill(f"{d}/experiment.md", Refuted_if="- the error barely falls (`ratio > 0.9`)\n- the curve looks wrong") @@ -196,7 +196,7 @@ def test_from_a_decision_to_a_reviewed_result(tmp_path): describe(f"{folder(root, 'G1.Q1.3')}/experiment.md", "A third sample size.") front(f"{folder(root, 'G1.Q1.3')}/experiment.md", dropped="The two sizes already answer it.") lab(root, "answer", "G1.Q1", "yes", "The ratio is one half, as the theory gives.") - assert "G1.Q1 (yes)" in lab(root, "now") and "the record is sound" in lab(root, "check") + assert "G1.Q1 (done, yes)" in lab(root, "now") and "the record is sound" in lab(root, "check") assert "Answered G1.Q1 yes" in lab(root, "since", "2026-01-01") # what was recorded stays: git is the witness @@ -238,10 +238,10 @@ def test_resources_a_failed_review_and_a_replacement(tmp_path): assert "finished" in lab(root, "run", ident, "--wait", "--", *command) assert "gpu: 1.5 of 10 hours used; one run may use 2" in lab(root, "now") and "rule for gpu: Shut down" in lab(root, "show", ident) - # a results review that fails is final: the experiment is replaced, and the old one stays + # a results review that fails is final: the experiment is done and void, and what it found may not be named results(d) lab(root, "review", ident, "results", "fail", "The command reads the right file, but the seed was fixed after a first look.") - assert "(review failed)" in lab(root, "show", ident) and "replace it with a new experiment" in lab(root, "now") + assert "(done, void)" in lab(root, "show", ident) and "1 void" in lab(root, "now") assert "that is final" in lab(root, "review", ident, "results", "pass", "on second thoughts", ok=False) out = lab(root, "new", "experiment", "G1.Q1", "Error at 100 and at 400 flips, seed fixed first", "--replaces", ident, "--because", "The seed was fixed after a first look at the numbers.") assert "made G1.Q1.2" in out @@ -321,7 +321,7 @@ def test_a_card_stands_on_its_own_a_replacement_says_why_and_the_agent_says_what # a question's briefing joins what is under it, as text for the chat: the same thing its page shows front(f"{d}/experiment.md", cost='"Two hundred estimates per arm, a minute on the laptop."') brief = lab(root, "brief", ident) - assert all(x in brief for x in ("**Why we ask.** The simplest check of the square-root law", "**The steps.**", "1. **Error at 100 and at 400 flips** (experiment, planned)", "**Where to look.**")) + assert all(x in brief for x in ("**Why we ask.** The simplest check of the square-root law", "**The steps.**", "1. **Error at 100 and at 400 flips** (experiment, open)", "**Where to look.**")) # a question has a short name and the question in full lab(root, "new", "question", "G1", "Larger samples", "--asks", "Does the law still hold at ten thousand flips?", "--from", "D1") @@ -358,7 +358,7 @@ def test_a_reading_looks_at_what_exists_and_is_done_when_it_says_what_it_suggest fill(card, Looks_at="The 12 estimates of 200 outside the band, in the sampler's own log.") assert "read it; then write what was seen and what it suggests" in lab(root, "now") shown = lab(root, "show", "G1.Q1.1") - assert "reading (planned)" in shown and "it can suggest, never confirm" in shown + assert "reading (open)" in shown and "it can suggest, never confirm" in shown fill(card, Seen="- Nine used the short sample.\n- Three had the seed reset.", Suggests="Fix the seed, then measure again.") assert "reading (done)" in lab(root, "show", "G1.Q1.1") and "(reading)" not in lab(root, "now").split("Yours next")[1].split("Questions")[0] assert "has no finished experiment to rest an answer on" in lab(root, "answer", "G1.Q1", "yes", "The reading says so.", ok=False) # a reading answers nothing diff --git a/tests/test_integrity.py b/tests/test_integrity.py index 82ce918..34ee453 100644 --- a/tests/test_integrity.py +++ b/tests/test_integrity.py @@ -430,7 +430,7 @@ def test_what_points_at_itself_is_reported_and_stops_nothing(tmp_path): front(f"{da}/experiment.md", needs=f"[{b}]") front(f"{db}/experiment.md", needs=f"[{a}]") assert "needs itself, directly or through what it needs" in lab(root, "check", "--no-rederive", ok=False) - assert "Not yours to move yet" in lab(root, "now") and "planned)" in lab(root, "brief", "G1.Q1") + assert "Not yours to move yet" in lab(root, "now") and "open)" in lab(root, "brief", "G1.Q1") front(f"{da}/experiment.md", needs="[]") front(f"{db}/experiment.md", needs="[]") lab(root, "new", "question", "G1", "A second question", "--from", "D1") diff --git a/tests/test_needs.py b/tests/test_needs.py index d921f28..66bdc28 100644 --- a/tests/test_needs.py +++ b/tests/test_needs.py @@ -71,7 +71,7 @@ def test_a_step_waits_while_what_it_needs_is_not_done_wherever_that_sits(tmp_pat fill(later_card, Suggests="") # the reading under the second question is not done yet assert mine(root) == (["G1.Q2.1"], ["G1.Q1.1", "G1.Q1.2", "G1.Q1.3"]) assert "G1.Q1.1 Which sizes to compare: on G1.Q2.1 Every estimate that missed, by cause" in lab(root, "now") - assert "Waiting on: G1.Q2.1 Every estimate that missed, by cause" in lab(root, "show", "G1.Q1.1") and "Needs: G1.Q2.1 (planned)" in lab(root, "show", ident) + assert "Waiting on: G1.Q2.1 Every estimate that missed, by cause" in lab(root, "show", "G1.Q1.1") and "Needs: G1.Q2.1 (open)" in lab(root, "show", ident) assert lab(root, "brief", "G1.Q1").count("Waiting on G1.Q2.1") == 3 assert f"{ident} waits on G1.Q2.1" in lab(root, "lock", ident, ok=False) assert f"{ident} waits on G1.Q2.1" in lab(root, "run", ident, "--trial", "--wait", "--", "true", ok=False) diff --git a/tests/test_order.py b/tests/test_order.py index fe3c1f4..ec19e21 100644 --- a/tests/test_order.py +++ b/tests/test_order.py @@ -79,7 +79,7 @@ def test_the_site_lists_next_in_the_agreed_order(tmp_path): lab(root, "decide", d2, "--with", "Ada", "The weight on heads first, then the fair coin, then the rest of the biased coin.") site = Provider(root) home = site.get("").main - nxt = home.split("

Next

", 1)[1].split("", 1)[0] + nxt = home.split("Next for the agent", 1)[1].split("", 1)[0] assert "In the order of the work set by" in nxt assert nxt.index("A weight on heads") < nxt.index("A fair sampler") < nxt.index("A biased sampler") assert "Orders the work" in site.get(d2).main diff --git a/tests/test_parked.py b/tests/test_parked.py index d716eac..94b2c02 100644 --- a/tests/test_parked.py +++ b/tests/test_parked.py @@ -60,7 +60,10 @@ def test_the_site_shows_what_was_set_aside_apart_from_the_work(tmp_path): page = site.get("G1.Q2").main assert "Set aside" in page and "nothing under it moves" in page assert "Parks" in site.get(d2).main - assert not any("biased coin?" in str(r) for r in site.rail()) + def shown(items): # what the rail shows unfolded: a parked question sits only in its goal's folded "set aside" + return [i for i in items if not i.get("fold")] + [j for i in items if not i.get("fold") for j in shown(i.get("items", []))] + assert not any("biased coin?" in i.get("title", "") for i in shown(site.rail())) + assert any(i.get("fold") and "biased coin?" in str(i["items"]) for r in site.rail() for g in r.get("items", []) for i in [g] + g.get("items", [])) def test_parking_names_a_question_the_decision_is_about_and_stays_as_settled(tmp_path): @@ -77,4 +80,4 @@ def test_parking_names_a_question_the_decision_is_about_and_stays_as_settled(tmp git(root, "add", ".") git(root, "commit", "-qm", "settled") front(card, parks="[]") # what a settled decision parked cannot be taken back by editing it - assert "and what it parks or brings back, the order it sets, its `decided:`" in lab(root, "check", "--no-rederive", ok=False) + assert "and what it parks, drops or brings back, the order it sets, its `decided:`" in lab(root, "check", "--no-rederive", ok=False) diff --git a/tests/test_refusals.py b/tests/test_refusals.py index 77a8eea..8c66880 100644 --- a/tests/test_refusals.py +++ b/tests/test_refusals.py @@ -21,8 +21,8 @@ def test_what_the_writing_commands_refuse(tmp_path): assert "holds no |" in lab(root, "log", "G1.Q1", "agent", "Chose a | b.", ok=False) assert open(f"{root}/log.md").read().count("\n- ") == 1 # only the decision's line - # an answer is yes or no - assert "an answer is yes or no" in lab(root, "answer", "G1.Q1", "maybe", "It depends.", ok=False) + # an answer is yes, no or mixed + assert "an answer is yes, no or mixed" in lab(root, "answer", "G1.Q1", "maybe", "It depends.", ok=False) # a plan is reviewed before its lock, never after ident, d, command = experiment(root) diff --git a/tests/test_site.py b/tests/test_site.py index fddbecd..ec2402c 100644 --- a/tests/test_site.py +++ b/tests/test_site.py @@ -20,6 +20,22 @@ from test_needs import across # noqa: E402 +def shown(items): + """Every row the rail shows unfolded, at any depth: what was replaced, dropped or set aside sits in a fold.""" + return [i for i in items if not i.get("fold")] + [j for i in items if not i.get("fold") for j in shown(i.get("items", []))] + + +def steps(rail): + """The steps the rail shows unfolded, in tree order.""" + return [i for i in shown(rail) if i.get("kind") in ("experiment", "build", "reading")] + + +def agents_next(front_page): + """How many steps Now lists as next for the agent.""" + part = front_page.split("Next for the agent", 1)[1].split("", 1)[0] + return part.count("
  • ") + + def a_lab(tmp_path): """One done experiment, a build, a second experiment held by an open decision, and a settled decision.""" root, ident, d, command = locked(tmp_path) @@ -44,7 +60,7 @@ def test_every_page_draws_and_every_link_lands(tmp_path): root = a_lab(tmp_path) site = Provider(root) paths = site.paths() - assert {"", "graph", "decisions", "log", "resources", "glossary", "G1", "G1.Q1", "G1.Q1.1", "G1.Q1.2", "G1.Q1.3", "D1", "D2"} <= set(paths) + assert {"", "decisions", "log", "resources", "glossary", "G1", "G1.Q1", "G1.Q1.1", "G1.Q1.2", "G1.Q1.3", "D1", "D2"} <= set(paths) seen = set() for path in paths: view = site.get(path) @@ -61,8 +77,9 @@ def test_every_page_draws_and_every_link_lands(tmp_path): assert 'class="box decision"' in front_page and 'class="decisionq">A third size, on the GPU' in front_page assert 'class="decisionq">The lab' not in front_page # a settled decision is no longer something to discuss assert "A coin estimate converges" in front_page and "The simplest check of the square-root law" not in front_page # a goal in a line; a question that has a So far shows only that - assert front_page.index("nobody is on it") < front_page.index("To discuss with you") < front_page.index("Where each question stands") # the present first - assert "The error at 400 flips is" in front_page and ">50%" in front_page # a named result reads the way its row says + assert front_page.index("nobody is on anything") < front_page.index("To discuss with you") < front_page.index("

    The lab

    ") # the present first + question_page = site.get("G1.Q1").main + assert "The error at 400 flips is" in question_page and ">50%" in question_page # a named result reads the way its row says decided = site.get("decisions").main assert "One goal, convergence" in decided and "What came out of it" in site.get("D1").main and "Decided:" in site.get("log").main @@ -87,7 +104,7 @@ def test_a_failed_review_shows_no_outcome_and_what_is_replaced_or_dropped_is_fol lab(root, "review", ident, "results", "fail", "The seed was fixed after a first look.") site = Provider(root) page = site.get(ident) - assert page.status == "review failed" and "failed their review" in page.main and "not known yet" in page.main and 'id="r-ratio"' not in page.main + assert page.status == "void" and "failed their review" in page.main and "not known yet" in page.main and 'id="r-ratio"' not in page.main lab(root, "new", "experiment", "G1.Q1", "The same, with the seed fixed first", "--replaces", ident, "--because", "The seed was fixed after a first look at the numbers.") third, d3, _ = experiment(root, title="A size nobody needs") front(f"{d3}/experiment.md", dropped="The two sizes already answer it.") @@ -96,16 +113,18 @@ def test_a_failed_review_shows_no_outcome_and_what_is_replaced_or_dropped_is_fol assert "The same, with the seed fixed first" in question and "second plan" in question and "Earlier plans, replaced" in question and "after a first look at the numbers" in question and question.count('
    the agent' in front_page and "Porting the sampler to the GPU." in front_page and "Why now:" in front_page and "Last recorded activity:" in front_page + assert front_page.index('the agent') < front_page.index("To discuss with you") and "nobody is on anything" not in front_page assert "Porting the sampler" not in site.get("G1.Q1").main and "Porting the sampler" in site.get("log/doing").main # a doing line is the present, not history goal = site.get("G1").main @@ -168,7 +187,7 @@ def test_a_questions_page_is_its_briefing_and_a_bar_says_what_it_is_for(tmp_path describe(third, "Follows [the square-root law](https://example.org/law), as the textbook states it.") site = Provider(root) assert 'the square-root law' in site.get("G1.Q1.3").main and "](https" not in site.get("G1.Q1.3").main - assert "](https" not in site.get("graph").main and not any("](https" in s["description"] + s["text"] for s in site.search()) + assert "](https" not in site.get("").main and not any("](https" in s["description"] + s["text"] for s in site.search()) assert "Follows the square-root law, as the textbook states it." in lab(root, "show", "G1.Q1.3") @@ -193,7 +212,7 @@ def test_a_readings_page_says_it_is_exploratory_and_what_was_dropped_leaves_the_ assert "The words this lab uses" in site.get("G1").main and "One share of heads, from one sample." in site.get("G1").main and "never shown" not in site.get("G1").main and "The design. Flip, count, compare." in site.get("G1").main assert "Who plays what" in site.get("G1").main and "It draws every estimate." in site.get("G1").main and "Dropped questions (1)" in site.get("G1").main home = site.get("").main # off the working part of the front page; listed, folded, among what was set aside - assert "A side question" not in home.split("

    Set aside

    ")[0] and "Dropped questions (1)" in home.split("

    Set aside

    ")[1] and not any("A side question" in str(r) for r in site.rail()) and site.get("G1.Q2") is not None + assert "A side question" not in home.split("

    Set aside

    ")[0] and "Dropped questions (1)" in home.split("

    Set aside

    ")[1] and not any("A side question" in i["title"] for i in shown(site.rail())) and site.get("G1.Q2") is not None def test_an_experiments_page_lists_its_runs_in_order_with_what_changed(tmp_path): @@ -318,16 +337,16 @@ def test_a_step_that_needs_a_later_one_reads_on_every_page_as_it_does_in_the_com ident, d, later_card = across(root) # a reading, a build and an experiment under Q1, each needing a done reading under Q2 site = Provider(root) front_page = site.get("").main - assert front_page.count("the agent") == 3 and "waits" not in front_page + assert agents_next(front_page) == 3 and "wait:" not in front_page for step in ("G1.Q1.1", "G1.Q1.2", ident): assert "Next, for the agent:" in site.get(step).main and "Waiting on" not in site.get(step).main, step assert "Waiting on" not in site.get("G1.Q1").main and site.get("G1.Q1").main.count("Next: ") == 3 - assert [i["status"] for r in site.rail() if "items" in r for i in r["items"]] == ["planned", "planned", "planned", "done"] + assert [i["status"] for i in steps(site.rail())] == ["open", "open", "open", "done"] fill(later_card, Suggests="") # the reading they need is not done: all three wait on it, on every page site = Provider(root) front_page = site.get("").main - assert front_page.count("waits") == 3 and front_page.count("the agent") == 1 + assert "3 steps wait:" in front_page and agents_next(front_page) == 1 for step in ("G1.Q1.1", "G1.Q1.2", ident): assert "Waiting on" in site.get(step).main and "Every estimate that missed, by cause" in site.get(step).main, step assert site.get("G1.Q1").main.count("Waiting on ") == 3 diff --git a/tests/test_states.py b/tests/test_states.py new file mode 100644 index 0000000..9794fb4 --- /dev/null +++ b/tests/test_states.py @@ -0,0 +1,118 @@ +"""One set of states for every kind of card, and the rules that keep a card from saying something the record does not.""" +import glob, os, subprocess + +from lab_kit import record + +from test_flow import describe, experiment, fill, folder, front, lab, open_question, results +from test_integrity import WRITES, commit, done +from test_parked import park + +PAST = "2000-01-01T00:00:00+00:00" + + +def git_out(root, *args): + return subprocess.run(["git", *args], cwd=root, check=True, capture_output=True, text=True).stdout + + +def git_env(root, *args, **env): + subprocess.run(["git", "-c", "user.name=t", "-c", "user.email=t@t", *args], cwd=root, check=True, capture_output=True, env={**os.environ, **env}) + + +def test_waiting_on_is_for_what_is_outside_the_lab(tmp_path): + root = str(tmp_path) + open_question(root) + lab(root, "new", "reading", "G1.Q1", "Which sizes to compare") + card = f"{folder(root, 'G1.Q1.1')}/reading.md" + describe(card, "Reads what the sampler already wrote.") + front(card, waiting_on='"The cluster account, which the department opens on Monday"') + assert "G1.Q1.1 reading (waiting)" in lab(root, "show", "G1.Q1.1") and "the record is sound" in lab(root, "check", "--no-rederive") + front(card, waiting_on='"Whatever Does the error halve (G1.Q1) finds first"') # the lab's own work: refused, since it would never clear + assert "`waiting_on:` names G1.Q1, which is part of the lab" in lab(root, "check", "--no-rederive", ok=False) + + +def test_so_far_says_what_was_learned_and_never_where_a_step_stands(tmp_path): + root = str(tmp_path) + qdir = open_question(root) + fill(f"{qdir}/question.md", So_far="The error at 400 flips is about half the error at 100, on one seed.") + assert "the record is sound" in lab(root, "check", "--no-rederive") + fill(f"{qdir}/question.md", So_far="Error at 100 and at 400 flips (G1.Q1.1) is running, and there is no result yet.") + assert "So far says 'is running'" in lab(root, "check", "--no-rederive", ok=False) + + +def test_a_time_in_utc_written_with_z_is_read(): # git 2.56 writes UTC as Z; Python 3.10 reads only +00:00 + assert record.moment("2000-01-01T00:00:00Z") == record.moment("2000-01-01T00:00:00+00:00") is not None + + +def test_so_far_older_than_a_result_under_it_is_stale(tmp_path): + root = str(tmp_path) + qdir = open_question(root) + ident, d, command = experiment(root, command=WRITES % "0.5") + lab(root, "lock", ident) + lab(root, "run", ident, "--wait", "--", *command) + done(root, ident, d) + fill(f"{qdir}/question.md", So_far="Nothing has been measured.") + git_env(root, "init", "-q") + git_env(root, "add", "-A") + git_env(root, "commit", "-qm", "the question", GIT_AUTHOR_DATE=PAST, GIT_COMMITTER_DATE=PAST) # well before the result + assert git_out(root, "log", "-1", "--format=%cI").startswith("2000-01-01") + out = lab(root, "log", ident, "result", "The error halves.", "It converges as the theory says.") + assert "So far of G1.Q1" in out # the command reminds the agent + commit(root, "the result") + assert f"So far was last committed before the result of {ident}" in lab(root, "check", "--no-rederive", ok=False) + fill(f"{qdir}/question.md", So_far="The error at 400 flips is {G1.Q1.1:ratio} of the error at 100.") + commit(root, "So far brought up to date") + assert "the record is sound" in lab(root, "check", "--no-rederive") + + +def test_an_answer_is_yes_no_or_mixed_and_never_rests_on_a_void_experiment(tmp_path): + root = str(tmp_path) + open_question(root) + ident, d, command = experiment(root, command=WRITES % "0.5") + lab(root, "lock", ident) + lab(root, "run", ident, "--wait", "--", *command) + results(d) + lab(root, "review", ident, "results", "fail", "The seed was fixed after a first look.") + assert f"{ident} experiment (done, void)" in lab(root, "show", ident) + assert "has no finished experiment to rest an answer on" in lab(root, "answer", "G1.Q1", "yes", "It halves.", ok=False) + assert "void: its results review failed, so it never runs again" in lab(root, "run", ident, "--wait", "--", *command, ok=False) + again, d2, command2 = experiment(root, title="The same, with the seed fixed first", command=WRITES % "0.5") + lab(root, "lock", again) + lab(root, "run", again, "--wait", "--", *command2) + done(root, again, d2) + lab(root, "answer", "G1.Q1", "mixed", "It halves at 400 flips and not at 1600.") + assert "G1.Q1 (done, mixed)" in lab(root, "show", "G1.Q1") + + +def test_a_decision_drops_what_it_names_once_it_is_settled(tmp_path): + root = str(tmp_path) + open_question(root) + ident, d, _ = experiment(root) + card, dn = park(root, ident, "Drop the two sizes", "", key="drops") + front(card, about=f"[{ident}]") + assert f"{ident} experiment (open)" in lab(root, "show", ident) # an open decision drops nothing yet + lab(root, "decide", dn, "--with", "Ada", "Drop it: one size answers the question.") + assert f"{ident} experiment (dropped)" in lab(root, "show", ident) + front(card, about="[G1.Q1]") + assert f"drops names {ident}, which is not under `about:`" in lab(root, "check", "--no-rederive", ok=False) + front(card, about="[G1.Q1]", drops="[G1.Q9.9]") + assert "drops names 'G1.Q9.9', which is not a question or a step of the lab" in lab(root, "check", "--no-rederive", ok=False) + + +def test_a_need_is_met_by_what_a_replaced_experiment_made(tmp_path): + root = str(tmp_path) + open_question(root) + ident, d, command = experiment(root, command=WRITES % "0.5") + lab(root, "lock", ident) + lab(root, "run", ident, "--wait", "--", *command) + lab(root, "new", "experiment", "G1.Q1", "The same, with the seed fixed first", "--replaces", ident, "--because", "The seed was fixed after a first look.") + lab(root, "new", "reading", "G1.Q1", "What the first run wrote") + reading = f"{folder(root, 'G1.Q1.3')}/reading.md" + describe(reading, "Reads the files the first run left.") + front(reading, needs=f"[{ident}]") + assert f"{ident} experiment (replaced)" in lab(root, "show", ident) and "G1.Q1.3 reading (open)" in lab(root, "show", "G1.Q1.3") + front(f"{d}/experiment.md", dropped='"Dropped too: the seed is fixed in the next one."') + assert f"{ident} experiment (dropped)" in lab(root, "show", ident) and "G1.Q1.3 reading (open)" in lab(root, "show", "G1.Q1.3") # dropped, with a finished run: still met + never = glob.glob(f"{root}/goals/G1-*/Q1-*/2-*/experiment.md")[0] + front(reading, needs="[G1.Q1.2]") + front(never, dropped='"Not needed after all."') # dropped with no finished run: what needs it waits for ever + assert "which is dropped: remove the need or replace it" in lab(root, "show", "G1.Q1.3")