lab-kit-cli 1.0.3__tar.gz → 1.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/.github/workflows/policy.yml +6 -2
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/AGENTS.md +4 -2
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/CHANGELOG.md +38 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/PKG-INFO +1 -1
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/docs/model.md +33 -9
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/pyproject.toml +1 -1
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/skills/lab-talk/SKILL.md +11 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/skills/lab-work/SKILL.md +8 -1
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/src/lab_kit/__init__.py +1 -1
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/src/lab_kit/checks.py +14 -1
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/src/lab_kit/history.py +5 -4
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/src/lab_kit/record.py +49 -5
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/src/lab_kit/site.py +38 -4
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/src/lab_kit/views.py +18 -3
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/src/lab_kit/write.py +2 -0
- lab_kit_cli-1.2.0/tests/test_order.py +85 -0
- lab_kit_cli-1.2.0/tests/test_parked.py +80 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/tests/test_site.py +2 -1
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/.github/workflows/ci.yml +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/.github/workflows/release.yml +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/.gitignore +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/CLAUDE.md +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/CONTRIBUTING.md +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/LICENSE +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/README.md +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/agents/reviewer.md +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/method/METHOD.md +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/skills/lab-review/SKILL.md +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/skills/lab-set-up/SKILL.md +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/src/lab_kit/cli.py +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/src/lab_kit/runs.py +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/src/lab_kit/supervise.py +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/tests/test_flow.py +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/tests/test_held.py +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/tests/test_integrity.py +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/tests/test_needs.py +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/tests/test_refusals.py +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/tests/test_vocabulary.py +0 -0
- {lab_kit_cli-1.0.3 → lab_kit_cli-1.2.0}/tools/import_run.py +0 -0
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
name: policy
|
|
2
2
|
|
|
3
|
+
# Runs on pull requests only: a push straight to main is checked by the pre-push hook on the
|
|
4
|
+
# machine that pushes (setup-machine), so GitHub spends no minutes on it (decision 0033).
|
|
3
5
|
on:
|
|
4
6
|
pull_request:
|
|
5
7
|
types: [opened, edited, synchronize, reopened]
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: policy-${{ github.event.pull_request.number }}
|
|
11
|
+
cancel-in-progress: true
|
|
8
12
|
|
|
9
13
|
permissions:
|
|
10
14
|
contents: read
|
|
@@ -37,9 +37,11 @@ Every change goes through a pull request; `main` accepts nothing else.
|
|
|
37
37
|
3. When the work is done and the gate passes, squash-merge it with a clear title and description,
|
|
38
38
|
then delete the branch and the worktree.
|
|
39
39
|
|
|
40
|
-
**Gate:** `python -m pytest -q
|
|
40
|
+
**Gate:** `python -m pytest -q`.
|
|
41
|
+
Run it before every push; CI also runs it on every pull request.
|
|
41
42
|
|
|
42
43
|
**Authorship.** Every commit is authored with the repository owner's git identity. No co-author
|
|
43
44
|
line, tool or agent name, "generated with" footer or session link appears in a commit message, a
|
|
44
|
-
branch name or a pull request.
|
|
45
|
+
branch name or a pull request. The pre-push hook enforces it on every push, and a required `policy`
|
|
46
|
+
check on every pull request.
|
|
45
47
|
<!-- ops:lanes:end -->
|
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
The order of the work can be agreed with the operator and recorded by a decision. Before, `lab now` and the
|
|
6
|
+
site listed next steps in the order of the tree, and an agreed order lived only as prose in a lab's
|
|
7
|
+
`AGENTS.md`, where a new session could miss it. The skills `lab-work` and `lab-talk` changed: run `lab init` in
|
|
8
|
+
a lab after upgrading, or `lab check` reports that they differ from the installed kit.
|
|
9
|
+
|
|
10
|
+
- A decision card may carry `order: [<ids>]`: goals, questions and steps, first to last. Once the decision is
|
|
11
|
+
settled, "Yours next" and "Not yours to move yet" in `lab now`, and Next and the idle line on the site's Now
|
|
12
|
+
page, list steps in that order. A step takes its own place if the order names it, else its question's, else
|
|
13
|
+
its goal's; steps sharing a place, and steps not named, keep the tree's order, the unnamed after the named.
|
|
14
|
+
The last settled decision, by number, that carries an `order:` has the say. An open decision orders nothing.
|
|
15
|
+
- `lab now` says which decision set the order; `lab show <decision>` and the decision's page list the order.
|
|
16
|
+
- `lab check` reports an `order:` that names something other than a goal, a question or a step, or names one
|
|
17
|
+
twice. A settled decision's `order:` is held against the lab's history, like its `about:`.
|
|
18
|
+
|
|
19
|
+
## 1.1.0
|
|
20
|
+
|
|
21
|
+
A question can be parked: set aside by a decision, not dropped, and brought back only by another. Before, a
|
|
22
|
+
question the lab chose not to pursue now stayed open, with nothing to say it was set aside on purpose, or was
|
|
23
|
+
dropped for good. The skills `lab-work` and `lab-talk` changed: run `lab init` in a lab after upgrading, or
|
|
24
|
+
`lab check` reports that they differ from the installed kit.
|
|
25
|
+
|
|
26
|
+
- A decision card may carry `parks: [<question>]` and `unparks: [<question>]`. Each question named is also
|
|
27
|
+
under `about:`. Once the decision is settled, the question is parked; a later settled decision that lists
|
|
28
|
+
it under `unparks:` brings it back. The last settled decision, by number, that names it has the say.
|
|
29
|
+
- A parked question leaves Now, the rail and the graph. `lab new` refuses a step under it, and `lab lock` and
|
|
30
|
+
`lab run` refuse its experiments, each naming the decision that parked it.
|
|
31
|
+
- `lab now` has a Set aside section: each parked question in one line with the decision that parked it, and a
|
|
32
|
+
count of the dropped questions and the closed goals. The site's front page has the same section, with the
|
|
33
|
+
first sentence of what was decided; a goal's page folds its parked questions; a parked question's page says
|
|
34
|
+
at the top which decision parked it and why; a decision shows what it parks or brings back.
|
|
35
|
+
- Steps under a parked or dropped question, or a goal that is not active, no longer show under "Not yours to
|
|
36
|
+
move yet" or as what the idle front page names next.
|
|
37
|
+
- `lab check` reports a `parks:` or `unparks:` that names something other than a question, a question not
|
|
38
|
+
under `about:`, and a question both parked and brought back by one decision. What a settled decision parks
|
|
39
|
+
or brings back is held against the lab's history, like its `about:`.
|
|
40
|
+
|
|
3
41
|
## 1.0.3
|
|
4
42
|
|
|
5
43
|
A word is now defined in one place, `GLOSSARY.md`. Before, the glossary and the goal's Vocabulary
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: lab-kit-cli
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: A research lab's record, its method, and the command that keeps both.
|
|
5
5
|
Project-URL: Homepage, https://github.com/pierg/lab-kit
|
|
6
6
|
Project-URL: Issues, https://github.com/pierg/lab-kit/issues
|
|
@@ -10,7 +10,7 @@ A lab is a tree, and the decisions that shaped it.
|
|
|
10
10
|
| Thing | What it says | States |
|
|
11
11
|
| --- | --- | --- |
|
|
12
12
|
| **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 |
|
|
13
|
-
| **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, yes, no, dropped |
|
|
13
|
+
| **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 |
|
|
14
14
|
| **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 |
|
|
15
15
|
| **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 |
|
|
16
16
|
| **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 |
|
|
@@ -237,12 +237,31 @@ the resources it sets need no further yes. Every goal and question names the dec
|
|
|
237
237
|
nothing under a question is locked or run while that decision is still open. Nothing else asks for your
|
|
238
238
|
approval: an experiment added later under a settled question is the agent's to plan and run.
|
|
239
239
|
|
|
240
|
+
**Parking a question.** A question can be set aside without being dropped: not now, perhaps later. A settled
|
|
241
|
+
decision parks it by listing it under `parks:`, and lists it under `about:` too. The decision's Decided text says
|
|
242
|
+
why, and what would bring it back. A parked question leaves Now, the rail and the graph, as a dropped one does.
|
|
243
|
+
Nothing under it moves: `lab new` refuses a step under it, and `lab lock` and `lab run` refuse its experiments. It
|
|
244
|
+
comes back only by a later settled decision that lists it under `unparks:`. The last settled decision, by number,
|
|
245
|
+
that parks or brings back a question has the say. An open decision parks nothing yet. Drop a question that will
|
|
246
|
+
never come back, with `dropped: <why>` on its card; park one that may. A goal is closed by `reached: true` or
|
|
247
|
+
`dropped: <why>`, and a dropped goal drops every question under it.
|
|
248
|
+
|
|
249
|
+
**The order of the work.** What the agent takes up first is agreed with you, and a settled decision records
|
|
250
|
+
it: `order:` lists goals, questions and steps, first to last. `lab now` ("Yours next", "Not yours to move yet")
|
|
251
|
+
and the site's Now page list steps in that order. A step takes the place of its own id where the order names it,
|
|
252
|
+
else of its question's, else of its goal's; steps that share a place, and every step the order does not name,
|
|
253
|
+
keep the order of the tree, the unnamed ones after the named. The last settled decision, by number, that carries
|
|
254
|
+
an `order:` has the say; an open decision orders nothing yet. The order only sorts: it moves nothing a step's
|
|
255
|
+
state holds, and a step under a parked or dropped question stays off the list wherever the order puts it. Each
|
|
256
|
+
id is a goal, a question or a step of the lab, named once. A step never carries its own place: the order is
|
|
257
|
+
worked out from the decision, never written on a card.
|
|
258
|
+
|
|
240
259
|
You may also decide something nobody raised: add, change or drop an experiment or a build, reorder the
|
|
241
|
-
work, stop a run. Say it, and the agent records it as a decision and follows it. Two things hold for
|
|
260
|
+
work (a decision with a new `order:`), stop a run. Say it, and the agent records it as a decision and follows it. Two things hold for
|
|
242
261
|
you as for the agent: a locked plan is changed by a new experiment that replaces it, and an outcome is
|
|
243
262
|
worked out from the results, not decided.
|
|
244
263
|
|
|
245
|
-
**A settled decision stays as it was settled.** Its `decided:`, its `about:` and its Decided text never
|
|
264
|
+
**A settled decision stays as it was settled.** Its `decided:`, its `about:`, its `parks:`, its `unparks:`, its `order:` and its Decided text never
|
|
246
265
|
change once committed; a change of mind is a new decision. `lab check` holds this against the lab's
|
|
247
266
|
history. So a decision cannot be made, afterwards, to be about something it never discussed.
|
|
248
267
|
|
|
@@ -380,7 +399,8 @@ the same briefing as text, which is what the agent says in chat when asked what
|
|
|
380
399
|
and the answer in chat cannot differ. An experiment's page is the evidence behind one step.
|
|
381
400
|
|
|
382
401
|
**Now** is read top to bottom in the order the operator asks: what is happening at this moment and
|
|
383
|
-
how fresh the record is; what there is to discuss with you; what is next and who moves it
|
|
402
|
+
how fresh the record is; what there is to discuss with you; what is next and who moves it, in the agreed
|
|
403
|
+
order of the work and naming the decision that set it; where each
|
|
384
404
|
question stands (what is known so far, and nothing else); the latest events; what is left of each
|
|
385
405
|
resource. Nothing on it is static text except one line per goal.
|
|
386
406
|
|
|
@@ -390,8 +410,12 @@ where one exists, and said to be only the flow where none does. The goal's page
|
|
|
390
410
|
each role, states the design before the approximation, and lists its vocabulary: the words every card
|
|
391
411
|
uses the same way, each drawn with the glossary's definition.
|
|
392
412
|
|
|
393
|
-
**What was
|
|
394
|
-
and leaves Now, the rail and the graph.
|
|
413
|
+
**What was set aside** stays in the record: a dropped goal or question, and a parked question, keeps its
|
|
414
|
+
card and its page, and leaves Now, the rail and the graph. Now lists it apart, under Set aside: each parked
|
|
415
|
+
question with the decision that parked it and the first sentence of what was decided, then the dropped
|
|
416
|
+
questions and the closed goals, folded. A goal's page folds its parked and its dropped questions; a parked
|
|
417
|
+
question's page says, at the top, which decision parked it and why. `lab now` lists the parked questions in
|
|
418
|
+
one line each and counts the rest.
|
|
395
419
|
|
|
396
420
|
**A goal's page** holds its claim and its story: one list, oldest first, of what was found, what got
|
|
397
421
|
stuck, what the agent chose and what was decided with you, each decision with its text. It is the
|
|
@@ -445,7 +469,7 @@ and its sealed runs across as what they were.
|
|
|
445
469
|
**A card** is front matter, then its description as a paragraph, then `## Slot` sections. It never
|
|
446
470
|
holds an id, a state or an outcome. Every file of a lab is UTF-8 text; line ends of either kind
|
|
447
471
|
read the same, and so hash the same where a review is bound to a file. The front matter sits between
|
|
448
|
-
the first two lines that are exactly `---`. A key that holds a list (`needs`, `uses`, `see`, `about`, `holds`, `commits`,
|
|
472
|
+
the first two lines that are exactly `---`. A key that holds a list (`needs`, `uses`, `see`, `about`, `holds`, `parks`, `unparks`, `order`, `commits`,
|
|
449
473
|
`tests`) is written as one, `[a, b]`; every other key holds one value.
|
|
450
474
|
|
|
451
475
|
| Card | Front matter | Slots (word budget) |
|
|
@@ -455,7 +479,7 @@ the first two lines that are exactly `---`. A key that holds a list (`needs`, `u
|
|
|
455
479
|
| `experiment.md` | `title:`, `needs:`, `uses:` (resources), `override: {resource: cap}`, `cost:`, `replaces:` with `because:` (one sentence), `waiting_on:`, `dropped: <why>` | description (70), Compares: the comparison in a sentence (80), Arms (260), Cases (100), Confirmed if (150), Refuted if (110), Outcomes (200), Limits (120), Found (180), Means (150) |
|
|
456
480
|
| `reading.md` | `title:`, `needs:`, `dropped: <why>` | description (70), Looks at: what, and where it is (110), Seen (320), Suggests (150) |
|
|
457
481
|
| `build.md` | `title:`, `needs:`, `commits:`, `tests:`, `dropped: <why>` | description (60), How it works (200), Works when (80) |
|
|
458
|
-
| `D<n>-<slug>.md` | `title:`, `about:` (the goals, questions, experiments or resources it concerns), `date:`, `holds:`; `decided: {date, with}` is written by `lab decide` | Seen (120), Options: a list, one option an item (200), Recommendation (80), Decided (120) |
|
|
482
|
+
| `D<n>-<slug>.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 (120), Options: a list, one option an item (200), Recommendation (80), Decided (120) |
|
|
459
483
|
|
|
460
484
|
Any card may carry `see:`, a list of pages that explain it: pages of the lab's own library, and pages
|
|
461
485
|
of another library its charter names, written as folio writes them (`pier-folio:/content/readings/...`),
|
|
@@ -593,7 +617,7 @@ in UTC. The file holds no other heading, and a line no other `|`. The kinds are
|
|
|
593
617
|
starting on and why now. A line written before the kit kept the time has none.
|
|
594
618
|
|
|
595
619
|
**Worked-out states.** A question is under discussion while the decision it came from is open, then
|
|
596
|
-
open, then yes or no; a page calls an open question with nothing under it "not started". A build is in
|
|
620
|
+
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
|
|
597
621
|
progress once the log has a line about it, and built once it names its commits. An experiment whose
|
|
598
622
|
results review failed shows as review failed until it is replaced or dropped.
|
|
599
623
|
|
|
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
|
|
|
5
5
|
[project]
|
|
6
6
|
dynamic = ["readme"]
|
|
7
7
|
name = "lab-kit-cli"
|
|
8
|
-
version = "1.0
|
|
8
|
+
version = "1.2.0"
|
|
9
9
|
description = "A research lab's record, its method, and the command that keeps both."
|
|
10
10
|
license = "MIT"
|
|
11
11
|
authors = [{ name = "Piergiuseppe Mallozzi" }]
|
|
@@ -58,6 +58,17 @@ resource's new amount names the decision in `from`.
|
|
|
58
58
|
`lab new decision "<what it is about>" --about <id>`, fill **Seen** with what prompted it, then
|
|
59
59
|
`lab decide` as above, and do it.
|
|
60
60
|
|
|
61
|
+
When they set a question aside: "not now, maybe later" parks it, "never" drops it. Ask which, if it is not
|
|
62
|
+
clear. To park, list the question under `parks:` and `about:` on the decision before `lab decide`, and say in
|
|
63
|
+
the Decided text why and what would bring it back. To bring one back, a new decision lists it under
|
|
64
|
+
`unparks:`. To close a goal, put `reached: true` or `dropped: <why>` on its card, out of a decision.
|
|
65
|
+
|
|
66
|
+
When they agree an order of work ("this first, then these side by side"), record it on the decision as
|
|
67
|
+
`order: [<ids>]`, first to last: goals, questions or steps, each once. A question or a goal stands for every
|
|
68
|
+
step under it; a step named on its own takes its own place. Steps not named follow, in the tree's order. Say
|
|
69
|
+
the order in the Decided text too. To change it, a new decision with a new `order:`; never edit a settled one,
|
|
70
|
+
and never write the order anywhere else (not in `AGENTS.md`, not on a step).
|
|
71
|
+
|
|
61
72
|
## Rules
|
|
62
73
|
|
|
63
74
|
- Never copy the operator's messages into the lab. The record says what was decided and why.
|
|
@@ -17,6 +17,8 @@ discussion, recorded as a decision. What a decision settled needs no further yes
|
|
|
17
17
|
|
|
18
18
|
`lab now`. If something is under **To discuss with the operator** and they are here, bring it to them
|
|
19
19
|
first (the lab-talk skill). Otherwise take the first line under **Yours next**: it says what to do.
|
|
20
|
+
When a decision has set the order of the work, **Yours next** is already in that order and says which
|
|
21
|
+
decision set it; follow it, and bring a change of order to the operator rather than skipping ahead.
|
|
20
22
|
`lab show <id>` before you touch anything.
|
|
21
23
|
|
|
22
24
|
Then say what you are on, before the first edit: `lab log <id> doing "<what you are starting on>"
|
|
@@ -55,9 +57,14 @@ The operator reads every card on the site, usually days later and without you. W
|
|
|
55
57
|
## When to open a decision
|
|
56
58
|
|
|
57
59
|
Open one when a question is answered or an experiment refutes what was expected, when a result
|
|
58
|
-
changes what the next question should be, when you want to add, reword or drop a goal or a question,
|
|
60
|
+
changes what the next question should be, when you want to add, reword, park or drop a goal or a question,
|
|
59
61
|
or when the resources do not cover the settled work. Not for anything else.
|
|
60
62
|
|
|
63
|
+
Park a question that may come back, drop one that will not. A decision parks a question by listing it
|
|
64
|
+
under `parks:` and under `about:`; its Decided text says why, and what would bring it back. Nothing under
|
|
65
|
+
a parked question moves until a later decision lists it under `unparks:`. Never start work under a
|
|
66
|
+
parked question, and never take it up because it looks open: it is listed under Set aside in `lab now`.
|
|
67
|
+
|
|
61
68
|
1. `lab new decision "<what it is about>" --about <the goals, questions or experiments it concerns>`.
|
|
62
69
|
2. On its card write **Seen** (what was observed, naming results), **Options** (a list of two or
|
|
63
70
|
three, each item an option with what it costs and what it changes) and **Recommendation**. Put under `holds:` only the
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""lab-kit: a research lab's record, its method, and the command that keeps both."""
|
|
2
|
-
__version__ = "1.0
|
|
2
|
+
__version__ = "1.2.0"
|
|
@@ -11,7 +11,7 @@ KEYS = { # what a card's front matter may hold; a state is never among them
|
|
|
11
11
|
"experiment": {"title", "needs", "uses", "override", "replaces", "because", "cost", "waiting_on", "dropped", "see"},
|
|
12
12
|
"build": {"title", "needs", "commits", "tests", "dropped", "see"},
|
|
13
13
|
"reading": {"title", "needs", "dropped", "see"},
|
|
14
|
-
"decision": {"title", "about", "date", "holds", "decided", "see"},
|
|
14
|
+
"decision": {"title", "about", "date", "holds", "parks", "unparks", "order", "decided", "see"},
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
|
|
@@ -123,6 +123,19 @@ def run(lab, rederive=True):
|
|
|
123
123
|
for i in d[key]:
|
|
124
124
|
if nodes.get(i, {}).get("type") not in ("goal", "question") + R.STEPS and not (key == "about" and i in lab.resources):
|
|
125
125
|
bad("links", d["path"], f"{key} names {i!r}, which does not exist")
|
|
126
|
+
for key in ("parks", "unparks"): # only a question is parked, and a decision that parks it or brings it back is about it
|
|
127
|
+
for i in d[key]:
|
|
128
|
+
if nodes.get(i, {}).get("type") != "question":
|
|
129
|
+
bad("links", d["path"], f"{key} names {i!r}, which is not a question: only a question is parked")
|
|
130
|
+
elif i not in d["about"]:
|
|
131
|
+
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")
|
|
132
|
+
for i in sorted(set(d["parks"]) & set(d["unparks"])):
|
|
133
|
+
bad("links", d["path"], f"both parks and unparks {i}")
|
|
134
|
+
for i in d["order"]: # the order of the work names what it orders: goals, questions and steps, each once
|
|
135
|
+
if nodes.get(i, {}).get("type") not in ("goal", "question") + R.STEPS:
|
|
136
|
+
bad("links", d["path"], f"order names {i!r}, which is not a goal, a question or a step of the lab")
|
|
137
|
+
for i in sorted({i for i in d["order"] if d["order"].count(i) > 1}):
|
|
138
|
+
bad("links", d["path"], f"order names {i} more than once: each has one place")
|
|
126
139
|
done = d["decided"]
|
|
127
140
|
if done and not ({"date", "with"} <= set(done) and R.flat(d["slots"].get("Decided", ""))):
|
|
128
141
|
bad("cards", d["path"], "a settled decision holds when, with whom, and what was decided and why under Decided")
|
|
@@ -14,7 +14,7 @@ same place: what was committed under the old name is held under the new one.
|
|
|
14
14
|
- A `results.tsv` that a review has passed keeps every committed row. Once a results review that passed is committed
|
|
15
15
|
together with the rows it read, those rows stay, whatever the card and the file say later. Rows committed while
|
|
16
16
|
the last passed review was of other rows, such as a draft row added after it, were never reviewed and are not held.
|
|
17
|
-
- A settled decision keeps its `decided:`, its `about:` and its Decided text as first committed.
|
|
17
|
+
- A settled decision keeps its `decided:`, its `about:`, its `parks:`, its `unparks:`, its `order:` and its Decided text as first committed.
|
|
18
18
|
- A resource, once committed, is never removed. A metered resource's `granted`, `per_run` and `unit` change only together
|
|
19
19
|
with `from`, which then names another settled decision that lists the resource. Its `other_use` rows only grow.
|
|
20
20
|
- None of these files is deleted, and none changes its number.
|
|
@@ -140,8 +140,9 @@ def decisions(lab, versions=None, now=None):
|
|
|
140
140
|
return None
|
|
141
141
|
if not isinstance(fm, dict) or fm.get("decided") is None:
|
|
142
142
|
return None
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
ids = lambda v: sorted(str(i) for i in (v if isinstance(v, list) else [v] if v is not None else []))
|
|
144
|
+
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
|
|
145
|
+
return str(fm.get("decided")), ids(fm.get("about")), ids(fm.get("parks")), ids(fm.get("unparks")), order, R.flat(slots.get("Decided", ""))
|
|
145
146
|
|
|
146
147
|
for where, commits in sorted(versions.items()):
|
|
147
148
|
if not DECISION.fullmatch(commits[-1][1]):
|
|
@@ -154,7 +155,7 @@ def decisions(lab, versions=None, now=None):
|
|
|
154
155
|
if was:
|
|
155
156
|
mine = path if path in now[where] else now[where][0]
|
|
156
157
|
if settled(R.read(os.path.join(root, mine))) != was:
|
|
157
|
-
bad(mine, f"was settled in {c[:8]}" + ("" if mine == path else f", as {path}") + ", and its `decided:`, its `about:` or its Decided text has changed since; a change of mind is a new decision")
|
|
158
|
+
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")
|
|
158
159
|
break
|
|
159
160
|
return problems
|
|
160
161
|
|
|
@@ -43,7 +43,7 @@ COLUMNS = {"results.tsv": ("name", "label", "value", "reads", "versus", "command
|
|
|
43
43
|
HASH = 2 # how a folder is hashed in the locks and runs made now; one without the marker was made with the first way
|
|
44
44
|
NUMBER = re.compile(r"[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?")
|
|
45
45
|
LISTS = {"goal": ("see",), "question": ("needs", "see"), "experiment": ("needs", "uses", "see"), "build": ("needs", "commits", "tests", "see"),
|
|
46
|
-
"reading": ("needs", "see"), "decision": ("about", "holds", "see")} # the front matter keys that hold a list
|
|
46
|
+
"reading": ("needs", "see"), "decision": ("about", "holds", "parks", "unparks", "order", "see")} # the front matter keys that hold a list
|
|
47
47
|
TEXTS = ("title", "asks", "from", "replaces", "because", "cost", "waiting_on", "dropped", "answered") # and those that hold one value
|
|
48
48
|
|
|
49
49
|
|
|
@@ -627,7 +627,7 @@ class Lab:
|
|
|
627
627
|
out = []
|
|
628
628
|
for n, path in self._numbered(f"{self.root}/decisions/D*.md", r"/D(\d+)-[^/]+\.md$", {}, "D<n>-<name>.md"):
|
|
629
629
|
fm, slots = self._card(path, "decision")
|
|
630
|
-
d = {"title": f"D{n}", "about": [], "holds": [], "decided": None, "date": "", "see": [], **fm, "id": f"D{n}", "type": "decision", "slots": slots,
|
|
630
|
+
d = {"title": f"D{n}", "about": [], "holds": [], "parks": [], "unparks": [], "order": [], "decided": None, "date": "", "see": [], **fm, "id": f"D{n}", "type": "decision", "slots": slots,
|
|
631
631
|
"path": self.rel(path), "dir": self.rel(os.path.dirname(path))}
|
|
632
632
|
d["state"] = "decided" if d["decided"] else "open"
|
|
633
633
|
out.append(d)
|
|
@@ -679,8 +679,39 @@ class Lab:
|
|
|
679
679
|
return next(g for g in self.goals if g["id"] == q["goal"])
|
|
680
680
|
|
|
681
681
|
def live(self, nodes):
|
|
682
|
-
"""The goals or questions still pursued: what was dropped stays in the record and off the working pages."""
|
|
683
|
-
return [n for n in nodes if n["state"]
|
|
682
|
+
"""The goals or questions still pursued: what was dropped or parked stays in the record and off the working pages."""
|
|
683
|
+
return [n for n in nodes if n["state"] not in ("dropped", "parked")]
|
|
684
|
+
|
|
685
|
+
def pursued(self):
|
|
686
|
+
"""The steps still pursued: under a question that is neither parked nor dropped, of a goal still active. What was
|
|
687
|
+
set aside waits on a decision, not on the work, and is listed apart."""
|
|
688
|
+
keep = {q["id"] for q in self.live(self.questions) if self.nodes[q["goal"]]["state"] == "active"}
|
|
689
|
+
return self.in_order([x for x in self.items if x["question"] in keep])
|
|
690
|
+
|
|
691
|
+
def ordered_by(self):
|
|
692
|
+
"""The settled decision that sets the order of the work, or None: the last settled decision, by number, that
|
|
693
|
+
carries an `order:`. The order is agreed with the operator, so it comes only out of a decision."""
|
|
694
|
+
return next((d for d in reversed(self.decisions) if d["state"] == "decided" and d["order"]), None)
|
|
695
|
+
|
|
696
|
+
def in_order(self, steps):
|
|
697
|
+
"""Steps in the agreed order of the work: each takes the place of its own id in the order, else of its question's,
|
|
698
|
+
else of its goal's; steps that share a place, and those the order does not name, keep the order of the tree,
|
|
699
|
+
the unnamed after the named."""
|
|
700
|
+
d = self.ordered_by()
|
|
701
|
+
if not d:
|
|
702
|
+
return list(steps)
|
|
703
|
+
place = {}
|
|
704
|
+
for i, ident in enumerate(d["order"]):
|
|
705
|
+
place.setdefault(ident, i)
|
|
706
|
+
rank = lambda x: next((place[i] for i in (x["id"], x["question"], x["goal"]) if i in place), len(d["order"]))
|
|
707
|
+
return sorted(steps, key=rank) # a stable sort: what shares a place keeps the order of the tree
|
|
708
|
+
|
|
709
|
+
def set_aside(self):
|
|
710
|
+
"""What was set aside, for the page and the view that list it: parked and dropped questions, and goals that
|
|
711
|
+
were reached or dropped."""
|
|
712
|
+
return {"parked": [q for q in self.questions if q["state"] == "parked"],
|
|
713
|
+
"dropped": [q for q in self.questions if q["state"] == "dropped"],
|
|
714
|
+
"goals": [g for g in self.goals if g["state"] != "active"]}
|
|
684
715
|
|
|
685
716
|
def question_of(self, ident):
|
|
686
717
|
m = re.match(r"(G\d+\.Q\d+)", ident)
|
|
@@ -805,11 +836,22 @@ class Lab:
|
|
|
805
836
|
def replaced_by(self, ident):
|
|
806
837
|
return next((x for x in self.experiments if x.get("replaces") == ident and not x.get("dropped")), None)
|
|
807
838
|
|
|
839
|
+
def parked_by(self, ident):
|
|
840
|
+
"""The settled decision that parked this question, or None. The last settled decision, by number, that parks or
|
|
841
|
+
unparks it has the say: a question is set aside, and brought back, only by a decision."""
|
|
842
|
+
last = None
|
|
843
|
+
for d in self.decisions:
|
|
844
|
+
if d["state"] == "decided" and (ident in d["parks"] or ident in d["unparks"]):
|
|
845
|
+
last = d
|
|
846
|
+
return last if last and ident in last["parks"] else None
|
|
847
|
+
|
|
808
848
|
def _question_state(self, q):
|
|
809
849
|
if q.get("dropped") or self._goal_of(q).get("dropped"):
|
|
810
850
|
return "dropped"
|
|
811
851
|
if q.get("answer") in ("yes", "no"):
|
|
812
852
|
return q["answer"]
|
|
853
|
+
if self.parked_by(q["id"]):
|
|
854
|
+
return "parked"
|
|
813
855
|
return "open" if self.settled(q) else "under discussion"
|
|
814
856
|
|
|
815
857
|
def _reach(self):
|
|
@@ -854,6 +896,8 @@ class Lab:
|
|
|
854
896
|
return f"{g['id']} is {g['state']}"
|
|
855
897
|
if q["state"] == "under discussion":
|
|
856
898
|
return f"the decision {q.get('from') or 'it comes from'} to be settled"
|
|
899
|
+
if q["state"] == "parked":
|
|
900
|
+
return f"{q['id']} is parked by {self.parked_by(q['id'])['id']}: a decision that unparks it comes first"
|
|
857
901
|
if q["state"] != "open":
|
|
858
902
|
return f"{q['id']} is {'answered ' + q['state'] if q['state'] in ('yes', 'no') else q['state']}"
|
|
859
903
|
for need in x.get("needs") or []:
|
|
@@ -982,7 +1026,7 @@ class Lab:
|
|
|
982
1026
|
|
|
983
1027
|
def yours(self):
|
|
984
1028
|
"""Every experiment and build the agent can move now, with what is next on each."""
|
|
985
|
-
return [x for x in self.items if x["mine"]]
|
|
1029
|
+
return self.in_order([x for x in self.items if x["mine"]])
|
|
986
1030
|
|
|
987
1031
|
def since(self, day=None):
|
|
988
1032
|
"""What happened since the last decision was recorded, or since a day."""
|
|
@@ -13,7 +13,7 @@ GENERIC = {"model", "field", "source", "group", "stop", "case", "score", "port",
|
|
|
13
13
|
e = html.escape
|
|
14
14
|
TONES = {"active": "info", "reached": "ok", "under discussion": "warn", "open": "info", "yes": "ok", "no": "warn", "decided": "ok",
|
|
15
15
|
"confirmed": "ok", "refuted": "bad", "unclear": "warn", "running": "info", "waiting": "warn", "in progress": "info", "built": "ok",
|
|
16
|
-
"review failed": "bad", "finished": "ok", "failed": "bad", "pass": "ok", "fail": "bad", "done": "ok"}
|
|
16
|
+
"review failed": "bad", "finished": "ok", "failed": "bad", "pass": "ok", "fail": "bad", "done": "ok", "parked": "plain"}
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def nice(day):
|
|
@@ -433,6 +433,9 @@ def decision_box(lab, T, d, link=True, title=True):
|
|
|
433
433
|
rows = []
|
|
434
434
|
if done:
|
|
435
435
|
rows.append((f'Decided {nice(d["decided"].get("date"))}', block(T, d["slots"].get("Decided", ""))))
|
|
436
|
+
rows += [(verb if done else f"Would {verb.lower()}", "<br>".join(named(lab, i) if i in lab.nodes else e(i) for i in d[key])) for key, verb in (("parks", "Parks"), ("unparks", "Brings back")) if d[key]]
|
|
437
|
+
if d["order"]:
|
|
438
|
+
rows.append(("Orders the work" if done else "Would order the work", "<ol>" + "".join(f"<li>{named(lab, i) if i in lab.nodes else e(i)}</li>" for i in d["order"]) + "</ol>"))
|
|
436
439
|
rows += [(k, block(T, d["slots"][k])) for k in ("Seen", "Options", "Recommendation") if L.flat(d["slots"].get(k, ""))]
|
|
437
440
|
if not done:
|
|
438
441
|
held = lab.held_by(d)
|
|
@@ -596,7 +599,7 @@ def right_now(lab, T):
|
|
|
596
599
|
rows.append(f'<p class="what">{pill("nobody is on it", "warn")} Nothing is running, and no agent has said it is working.</p>'
|
|
597
600
|
f'<p>The next step is the agent\'s: {named(lab, x["id"])}: {T(you(x["next"]))}.</p>')
|
|
598
601
|
else:
|
|
599
|
-
waits = [x for x in lab.
|
|
602
|
+
waits = [x for x in lab.pursued() if x["state"] == "waiting" or (x["state"] == "planned" and x["next"])]
|
|
600
603
|
rows.append(f'<p class="what">{pill("idle", "plain")} Nothing is running and nothing is the agent\'s to move.</p>'
|
|
601
604
|
+ (f'<p>{named(lab, waits[0]["id"])} waits on {T(you(waits[0]["next"]))}.</p>' if waits else ""))
|
|
602
605
|
last = lab.last_record()
|
|
@@ -644,14 +647,16 @@ def home(lab, T):
|
|
|
644
647
|
out.append("<h2>To discuss with you</h2>" + ("".join(talk) or '<p class="muted">Nothing.</p>'))
|
|
645
648
|
busy = lab.doing()["about"] if lab.doing() else None
|
|
646
649
|
nxt = [x for x in lab.yours() if x["id"] != busy]
|
|
647
|
-
held = [x for x in lab.
|
|
650
|
+
held = [x for x in lab.pursued() if x["state"] == "waiting" or (x["state"] == "planned" and not x["mine"] and x["next"])]
|
|
648
651
|
if nxt or held:
|
|
649
|
-
|
|
652
|
+
by = lab.ordered_by()
|
|
653
|
+
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(
|
|
650
654
|
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>")
|
|
651
655
|
out.append("<h2>Where each question stands</h2>")
|
|
652
656
|
for g in lab.live(lab.goals):
|
|
653
657
|
out.append(f'<div class="goalhead">{dot(g)}<a href="/{g["id"]}">{e(g["title"])}</a></div><p class="goalwhy">{T(g["description"])}</p>'
|
|
654
658
|
+ "".join(qcard(lab, T, q) for q in lab.live(g["questions"])))
|
|
659
|
+
out.append(set_aside_html(lab, T))
|
|
655
660
|
latest = happened(lab.lines)[-5:]
|
|
656
661
|
out.append('<h2>Latest</h2>' + log_html(lab, T, latest) + '<p style="font:.85rem var(--sans)"><a href="/log">The whole log</a></p>')
|
|
657
662
|
if lab.resources:
|
|
@@ -659,6 +664,29 @@ def home(lab, T):
|
|
|
659
664
|
return frame(lab, lab.cfg.get("title", lab.cfg["name"]), "".join(out))
|
|
660
665
|
|
|
661
666
|
|
|
667
|
+
def parked_line(lab, T, q):
|
|
668
|
+
d = lab.parked_by(q["id"])
|
|
669
|
+
return f'<p>{named(lab, q["id"])}: parked by {named(lab, d["id"])}. {T(L.first_sentence(L.flat(d["slots"].get("Decided", ""))))}</p>'
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
def set_aside_html(lab, T):
|
|
673
|
+
"""What was set aside, apart from the work: each parked question with the decision that parked it, then what was
|
|
674
|
+
dropped and the goals that were closed, folded."""
|
|
675
|
+
aside = lab.set_aside()
|
|
676
|
+
if not any(aside.values()):
|
|
677
|
+
return ""
|
|
678
|
+
out = ["<h2>Set aside</h2>"]
|
|
679
|
+
if aside["parked"]:
|
|
680
|
+
out.append('<p class="muted" style="font:.84rem var(--sans)">Parked by a decision; each comes back only by another.</p>' + "".join(parked_line(lab, T, q) for q in aside["parked"]))
|
|
681
|
+
if aside["dropped"]:
|
|
682
|
+
out.append(f'<details class="old"><summary>Dropped questions ({len(aside["dropped"])})</summary>' + "".join(
|
|
683
|
+
f'<p>{named(lab, q["id"])}: {T(str(q.get("dropped") or lab.nodes[q["goal"]].get("dropped") or ""))}</p>' for q in aside["dropped"]) + "</details>")
|
|
684
|
+
if aside["goals"]:
|
|
685
|
+
out.append(f'<details class="old"><summary>Closed goals ({len(aside["goals"])})</summary>' + "".join(
|
|
686
|
+
f'<p>{named(lab, g["id"])}: {e(label(g))}{". " + T(str(g["dropped"])) if g.get("dropped") else ""}</p>' for g in aside["goals"]) + "</details>")
|
|
687
|
+
return "".join(out)
|
|
688
|
+
|
|
689
|
+
|
|
662
690
|
def resources_table(lab):
|
|
663
691
|
per = any(isinstance(r.get("per_run"), (int, float)) for r in lab.resources.values() if isinstance(r, dict)) # the column is there only when a resource sets it
|
|
664
692
|
out = ['<table class="t"><tr><th>Resource</th><th>Used</th><th>Granted</th>' + ("<th>One run may use</th>" if per else "") + "</tr>"]
|
|
@@ -689,6 +717,9 @@ def goal_page(lab, T, g):
|
|
|
689
717
|
rows = "".join(f'<tr><td>{e(w["entry"]["term"] if w["entry"] else w["name"])}</td><td>' + (e(w["entry"]["definition"]) + avoid_note(w["entry"]) if w["entry"] else '<span class="muted">not in the glossary</span>') + "</td></tr>" for w in words)
|
|
690
718
|
body.append('<h2>The words this lab uses</h2><table class="t roles"><tr><th>Word</th><th>What it means here, everywhere</th></tr>' + rows + "</table>")
|
|
691
719
|
body.append("<h2>Questions</h2>" + "".join(qcard(lab, T, q) for q in lab.live(g["questions"])))
|
|
720
|
+
parked = [q for q in g["questions"] if q["state"] == "parked"]
|
|
721
|
+
if parked:
|
|
722
|
+
body.append(f'<details class="old"><summary>Parked questions ({len(parked)})</summary>' + "".join(parked_line(lab, T, q) for q in parked) + "</details>")
|
|
692
723
|
gone = [q for q in g["questions"] if q["state"] == "dropped"]
|
|
693
724
|
if gone:
|
|
694
725
|
body.append(f'<details class="old"><summary>Dropped questions ({len(gone)})</summary>' + "".join(f'<p>{named(lab, q["id"])}: {T(str(q.get("dropped") or g.get("dropped") or ""))}</p>' for q in gone) + "</details>")
|
|
@@ -724,6 +755,9 @@ def question_page(lab, T, q):
|
|
|
724
755
|
live = [x for x in q["items"] if x["state"] not in ("replaced", "dropped")]
|
|
725
756
|
gone = [x for x in q["items"] if x["state"] == "dropped" or (x["state"] == "replaced" and not lab.replaced_by(x["id"]))]
|
|
726
757
|
body = [f'<h1>{e(q["title"])}</h1>']
|
|
758
|
+
if q["state"] == "parked":
|
|
759
|
+
d = lab.parked_by(q["id"])
|
|
760
|
+
body.append(f'<div class="box"><b>Parked</b> by {named(lab, d["id"])}: nothing under it moves until a decision brings it back. {T(L.flat(d["slots"].get("Decided", "")))}</div>')
|
|
727
761
|
before = [lab.nodes[i] for i in q["needs"] if i in lab.nodes]
|
|
728
762
|
if before:
|
|
729
763
|
body.append('<div class="slots">' + slot("Where we are coming from", "".join(f'<p>{named(lab, n["id"])} ({e(label(n))}).</p>{block(T, n["slots"].get("So far", ""))}' for n in before), "full") + "</div>")
|
|
@@ -23,6 +23,11 @@ def decision_text(lab, d):
|
|
|
23
23
|
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)
|
|
24
24
|
when = f"decided {d['decided'].get('date')} with {d['decided'].get('with')}" if d["decided"] else "open: to discuss with the operator"
|
|
25
25
|
out = [f"{d['id']} {d['title']} (raised {d.get('date')}, {when})" + (f"\nAbout: {about}" if about else "")]
|
|
26
|
+
for key, verb in (("parks", "Parks"), ("unparks", "Brings back")):
|
|
27
|
+
if d[key]:
|
|
28
|
+
out += [f"{verb}: " + ", ".join(f"{i} {lab.nodes[i]['title']}" if i in lab.nodes else i for i in d[key])]
|
|
29
|
+
if d["order"]:
|
|
30
|
+
out += [("Orders the work" if d["decided"] else "Would order the work") + ", first to last: " + ", ".join(d["order"])]
|
|
26
31
|
out += [f"{slot}. {R.flat(d['slots'][slot])}" for slot in ("Seen", "Options", "Recommendation", "Decided") if R.flat(d["slots"].get(slot, ""))]
|
|
27
32
|
if d["state"] == "open":
|
|
28
33
|
held = lab.held_by(d)
|
|
@@ -68,9 +73,11 @@ def _now(lab):
|
|
|
68
73
|
out += [decision_text(lab, d), ""]
|
|
69
74
|
going = [f"- {x['id']} {x['title']}: {r['id']}, started {r['started']}" for x in lab.experiments for r in x["runs"] + x["trials"] if r["state"] == "running" and not r["orphan"]]
|
|
70
75
|
out += ["" if not waiting else None, "Running"] + (going or ["- nothing"])
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
out += ["", "
|
|
76
|
+
by = lab.ordered_by()
|
|
77
|
+
order = f" (in the order {by['id']} set)" if by else ""
|
|
78
|
+
out += ["", "Yours next" + order] + ([f"- {x['id']} {x['title']} ({x['type']}): {x['next']}" for x in lab.yours()] or ["- nothing"])
|
|
79
|
+
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"])]
|
|
80
|
+
out += ["", "Not yours to move yet" + order] + (held or ["- nothing"])
|
|
74
81
|
out += ["", "Questions"]
|
|
75
82
|
for q in lab.live(lab.questions):
|
|
76
83
|
counts = {}
|
|
@@ -78,6 +85,12 @@ def _now(lab):
|
|
|
78
85
|
key = x["outcome"] if x["state"] == "done" and x.get("outcome") else x["state"]
|
|
79
86
|
counts[key] = counts.get(key, 0) + 1
|
|
80
87
|
out += [f"- {q['id']} ({q['state']}): {q['title']} [{', '.join(f'{n} {k}' for k, n in counts.items()) or 'nothing under it'}]"]
|
|
88
|
+
aside = lab.set_aside()
|
|
89
|
+
if any(aside.values()):
|
|
90
|
+
out += ["", "Set aside"] + [f"- {q['id']} (parked by {lab.parked_by(q['id'])['id']}): {q['title']}" for q in aside["parked"]]
|
|
91
|
+
rest = [f"{len(aside['dropped'])} question{'' if len(aside['dropped']) == 1 else 's'} dropped"] if aside["dropped"] else []
|
|
92
|
+
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 []
|
|
93
|
+
out += [f"- {', '.join(rest)}: lab show <id>"] if rest else []
|
|
81
94
|
if lab.resources:
|
|
82
95
|
out += ["", "Resources"] + [resource_line(lab, name) for name in lab.resources]
|
|
83
96
|
stuck = [f"- {r['id']}: {r['unpublished'].splitlines()[0]}" for r in lab.runs if r["unpublished"]]
|
|
@@ -133,6 +146,8 @@ def _show(lab, ident):
|
|
|
133
146
|
decisions = ["", "Decisions about it"] + [f"- {d['id']} ({d['state']}): {d['title']}" for d in raised] if raised else []
|
|
134
147
|
if n["type"] == "question":
|
|
135
148
|
out = [f"{n['id']} ({n['state']}): {n['title']}", f"Asks: {n['asks']}", n["description"]] + came(n) + [""]
|
|
149
|
+
by = lab.parked_by(n["id"]) if n["state"] == "parked" else None
|
|
150
|
+
out += [f"Parked by {by['id']} {by['title']}: nothing under it moves until a decision brings it back (`unparks:`).", ""] if by else []
|
|
136
151
|
out += [f"{slot}. {lab.fill(R.flat(n['slots'].get(slot, '')))}\n" for slot, _ in R.SLOTS["question"]]
|
|
137
152
|
out += ["Under it"] + ([f"- {x['id']} {x['type']} ({state(x)}): {x['title']}" + (f". Next: {x['next']}" if x["mine"] else "") for x in n["items"]] or ["- nothing yet"])
|
|
138
153
|
out += decisions
|
|
@@ -138,6 +138,8 @@ def new(lab, kind, parent, title, replaces=None, origin=None, about=(), because=
|
|
|
138
138
|
ident, path = f"{p['id']}.Q{n}", f"{p['dir']}/Q{n}-{slug(title)}/question.md"
|
|
139
139
|
text = CARDS["question"].format(title=quoted, origin=origin, asks=f"asks: {json.dumps(R.flat(asks), ensure_ascii=False)}\n" if R.flat(asks) else "")
|
|
140
140
|
elif kind in R.STEPS:
|
|
141
|
+
if p["state"] == "parked": # set aside by a decision: work under it starts again only once a decision brings it back
|
|
142
|
+
stop(f"{p['id']} is parked by {lab.parked_by(p['id'])['id']}: a decision that unparks it (`unparks: [{p['id']}]`) comes first")
|
|
141
143
|
n = 1 + max([int(x["id"].split(".")[-1]) for x in p["items"]] or [0])
|
|
142
144
|
ident, path = f"{p['id']}.{n}", f"{p['dir']}/{n}-{slug(title)}/{kind}.md"
|
|
143
145
|
fill = {"title": quoted, "description": "", "extra": "", "Compares": "", "Arms": "- ", "Cases": "", "Confirmed if": "- ", "Refuted if": "- ", "Outcomes": "", "Limits": ""}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""The order of the work, agreed with the operator: set by a settled decision's `order:`, worked out into the order
|
|
2
|
+
`lab now` and the site list the steps in, and never edited once settled."""
|
|
3
|
+
import glob, re
|
|
4
|
+
|
|
5
|
+
from test_flow import describe, fill, front, git, lab, open_question
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def three_steps(root):
|
|
9
|
+
"""A build under the first question, then a second question with two builds: G1.Q1.1, G1.Q2.1, G1.Q2.2."""
|
|
10
|
+
lab(root, "new", "build", "G1.Q1", "A fair sampler")
|
|
11
|
+
lab(root, "new", "question", "G1", "Does the error fall on a biased coin?", "--from", "D1")
|
|
12
|
+
describe(glob.glob(f"{root}/goals/G1-*/Q2-*/question.md")[0], "The law for a coin that is not fair, which the sampler can also draw.")
|
|
13
|
+
lab(root, "new", "build", "G1.Q2", "A biased sampler")
|
|
14
|
+
lab(root, "new", "build", "G1.Q2", "A weight on heads")
|
|
15
|
+
for card in glob.glob(f"{root}/goals/G1-*/Q*/*/build.md"):
|
|
16
|
+
describe(card, "A sampler the questions need before anything is measured.")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def order(root, ids, title="The order of the work"):
|
|
20
|
+
out = lab(root, "new", "decision", title, "--about", "G1")
|
|
21
|
+
card = sorted(glob.glob(f"{root}/decisions/D*.md"))[-1]
|
|
22
|
+
fill(card, Seen="Both questions have work the agent can move.", Options="(a) The biased coin first. (b) The tree's order.", Recommendation="(a).")
|
|
23
|
+
front(card, order=f"[{', '.join(ids)}]")
|
|
24
|
+
return card, out.split()[1].rstrip(":")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def listed(text, section):
|
|
28
|
+
"""The ids a section of `lab now` lists, in its order."""
|
|
29
|
+
body = text.split(section, 1)[1].split("\n\n", 1)[0]
|
|
30
|
+
return re.findall(r"^- (G\d+\.Q\d+\.\d+) ", body, flags=re.M)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_steps_are_listed_in_the_order_a_settled_decision_sets(tmp_path):
|
|
34
|
+
root = str(tmp_path)
|
|
35
|
+
open_question(root)
|
|
36
|
+
three_steps(root)
|
|
37
|
+
assert listed(lab(root, "now"), "Yours next") == ["G1.Q1.1", "G1.Q2.1", "G1.Q2.2"]
|
|
38
|
+
# a step named on its own takes its own place; its question's place holds the rest of the question
|
|
39
|
+
card, d2 = order(root, ["G1.Q2.2", "G1.Q1", "G1.Q2"])
|
|
40
|
+
assert listed(lab(root, "now"), "Yours next") == ["G1.Q1.1", "G1.Q2.1", "G1.Q2.2"] # an open decision orders nothing yet
|
|
41
|
+
assert "Would order the work, first to last: G1.Q2.2, G1.Q1, G1.Q2" in lab(root, "show", d2)
|
|
42
|
+
lab(root, "decide", d2, "--with", "Ada", "The weight on heads first, then the fair coin, then the rest of the biased coin.")
|
|
43
|
+
now = lab(root, "now")
|
|
44
|
+
assert f"Yours next (in the order {d2} set)" in now
|
|
45
|
+
assert listed(now, "Yours next") == ["G1.Q2.2", "G1.Q1.1", "G1.Q2.1"]
|
|
46
|
+
assert "Orders the work, first to last" in lab(root, "show", d2)
|
|
47
|
+
# the last settled decision that sets an order has the say; what it does not name follows in the tree's order
|
|
48
|
+
_, d3 = order(root, ["G1.Q2.1"], "The biased sampler first")
|
|
49
|
+
lab(root, "decide", d3, "--with", "Ada", "The biased sampler first; the rest as the tree has it.")
|
|
50
|
+
assert listed(lab(root, "now"), "Yours next") == ["G1.Q2.1", "G1.Q1.1", "G1.Q2.2"]
|
|
51
|
+
assert "the record is sound" in lab(root, "check", "--no-rederive")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_the_order_names_what_it_orders_once_and_stays_as_settled(tmp_path):
|
|
55
|
+
root = str(tmp_path)
|
|
56
|
+
open_question(root)
|
|
57
|
+
three_steps(root)
|
|
58
|
+
card, d2 = order(root, ["G1.Q2", "G1.Q9", "G1.Q2", "gpu"])
|
|
59
|
+
out = lab(root, "check", "--no-rederive", ok=False)
|
|
60
|
+
assert "order names 'G1.Q9', which is not a goal, a question or a step" in out and "order names 'gpu'" in out
|
|
61
|
+
assert "order names G1.Q2 more than once" in out
|
|
62
|
+
front(card, order="[G1.Q2, G1.Q1]")
|
|
63
|
+
lab(root, "decide", d2, "--with", "Ada", "The biased coin first.")
|
|
64
|
+
git(root, "init", "-q")
|
|
65
|
+
git(root, "add", ".")
|
|
66
|
+
git(root, "commit", "-qm", "settled")
|
|
67
|
+
front(card, order="[G1.Q1, G1.Q2]") # a settled order is changed by a new decision, not by editing this one
|
|
68
|
+
assert "the order it sets" in lab(root, "check", "--no-rederive", ok=False)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def test_the_site_lists_next_in_the_agreed_order(tmp_path):
|
|
72
|
+
import pytest
|
|
73
|
+
pytest.importorskip("folio.views")
|
|
74
|
+
from lab_kit.site import Provider
|
|
75
|
+
root = str(tmp_path)
|
|
76
|
+
open_question(root)
|
|
77
|
+
three_steps(root)
|
|
78
|
+
_, d2 = order(root, ["G1.Q2.2", "G1.Q1", "G1.Q2"])
|
|
79
|
+
lab(root, "decide", d2, "--with", "Ada", "The weight on heads first, then the fair coin, then the rest of the biased coin.")
|
|
80
|
+
site = Provider(root)
|
|
81
|
+
home = site.get("").main
|
|
82
|
+
nxt = home.split("<h2>Next</h2>", 1)[1].split("</table>", 1)[0]
|
|
83
|
+
assert "In the order of the work set by" in nxt
|
|
84
|
+
assert nxt.index("A weight on heads") < nxt.index("A fair sampler") < nxt.index("A biased sampler")
|
|
85
|
+
assert "Orders the work" in site.get(d2).main
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""A question set aside by a decision: parked, off the working pages, with nothing under it moving until a later
|
|
2
|
+
decision brings it back; and a decision that parks or brings back cannot be edited afterwards."""
|
|
3
|
+
import glob
|
|
4
|
+
|
|
5
|
+
from test_flow import describe, fill, front, git, lab, open_question
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def a_second_question(root):
|
|
9
|
+
lab(root, "new", "question", "G1", "Does the error fall on a biased coin?", "--from", "D1")
|
|
10
|
+
q = glob.glob(f"{root}/goals/G1-*/Q2-*/question.md")[0]
|
|
11
|
+
describe(q, "The law for a coin that is not fair, which the sampler can also draw.")
|
|
12
|
+
lab(root, "new", "build", "G1.Q2", "A biased sampler")
|
|
13
|
+
describe(glob.glob(f"{root}/goals/G1-*/Q2-*/1-*/build.md")[0], "The sampler with a weight on heads.")
|
|
14
|
+
return q
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def park(root, ident, title, decided, key="parks"):
|
|
18
|
+
out = lab(root, "new", "decision", title, "--about", ident)
|
|
19
|
+
card = sorted(glob.glob(f"{root}/decisions/D*.md"))[-1]
|
|
20
|
+
fill(card, Seen="The fair coin answers what the lab needs first.", Options="(a) Set it aside. (b) Keep it.", Recommendation="(a).")
|
|
21
|
+
front(card, **{key: f"[{ident}]"})
|
|
22
|
+
return card, out.split()[1].rstrip(":")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_a_parked_question_leaves_the_work_and_comes_back_only_by_a_decision(tmp_path):
|
|
26
|
+
root = str(tmp_path)
|
|
27
|
+
open_question(root)
|
|
28
|
+
a_second_question(root)
|
|
29
|
+
assert "G1.Q2.1 A biased sampler" in lab(root, "now")
|
|
30
|
+
card, d2 = park(root, "G1.Q2", "Set the biased coin aside", "")
|
|
31
|
+
# an open decision parks nothing yet: the card says what it would park
|
|
32
|
+
assert "(open)" in lab(root, "show", "G1.Q2") and "Parks: G1.Q2" in lab(root, "show", d2)
|
|
33
|
+
lab(root, "decide", d2, "--with", "Ada", "The biased coin is parked: the fair coin answers what the lab needs first. It comes back if the law holds.")
|
|
34
|
+
now = lab(root, "now")
|
|
35
|
+
assert "Set aside" in now and f"G1.Q2 (parked by {d2})" in now and "A biased sampler" not in now.split("Set aside")[0]
|
|
36
|
+
assert f"Parked by {d2}" in lab(root, "show", "G1.Q2")
|
|
37
|
+
refused = lab(root, "new", "reading", "G1.Q2", "What the biased runs said", ok=False)
|
|
38
|
+
assert f"parked by {d2}" in refused and "unparks" in refused and not glob.glob(f"{root}/goals/G1-*/Q2-*/2-*")
|
|
39
|
+
assert "the record is sound" in lab(root, "check", "--no-rederive")
|
|
40
|
+
# a later decision brings it back
|
|
41
|
+
_, d3 = park(root, "G1.Q2", "Bring the biased coin back", "", key="unparks")
|
|
42
|
+
lab(root, "decide", d3, "--with", "Ada", "The law held on the fair coin, so the biased coin comes back.")
|
|
43
|
+
assert "(open)" in lab(root, "show", "G1.Q2") and "Set aside" not in lab(root, "now")
|
|
44
|
+
lab(root, "new", "reading", "G1.Q2", "What the biased runs said")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_the_site_shows_what_was_set_aside_apart_from_the_work(tmp_path):
|
|
48
|
+
import pytest
|
|
49
|
+
pytest.importorskip("folio.views")
|
|
50
|
+
from lab_kit.site import Provider
|
|
51
|
+
root = str(tmp_path)
|
|
52
|
+
open_question(root)
|
|
53
|
+
a_second_question(root)
|
|
54
|
+
_, d2 = park(root, "G1.Q2", "Set the biased coin aside", "")
|
|
55
|
+
lab(root, "decide", d2, "--with", "Ada", "The biased coin is parked: the fair coin answers what the lab needs first. It comes back if the law holds.")
|
|
56
|
+
site = Provider(root)
|
|
57
|
+
home = site.get("").main
|
|
58
|
+
assert "Set aside" in home and "parked by" in home and "The biased coin is parked" in home and "A biased sampler" not in home.split("Set aside")[0]
|
|
59
|
+
assert "Parked questions (1)" in site.get("G1").main
|
|
60
|
+
page = site.get("G1.Q2").main
|
|
61
|
+
assert "<b>Parked</b>" in page and "nothing under it moves" in page
|
|
62
|
+
assert "Parks" in site.get(d2).main
|
|
63
|
+
assert not any("biased coin?" in str(r) for r in site.rail())
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_parking_names_a_question_the_decision_is_about_and_stays_as_settled(tmp_path):
|
|
67
|
+
root = str(tmp_path)
|
|
68
|
+
open_question(root)
|
|
69
|
+
a_second_question(root)
|
|
70
|
+
card, d2 = park(root, "G1.Q2", "Set the biased coin aside", "")
|
|
71
|
+
front(card, parks="[G1.Q2.1, G1.Q1]", unparks="[G1.Q1]")
|
|
72
|
+
out = lab(root, "check", "--no-rederive", ok=False)
|
|
73
|
+
assert "parks names 'G1.Q2.1', which is not a question" in out and "parks names G1.Q1, which is not under `about:`" in out and "both parks and unparks G1.Q1" in out
|
|
74
|
+
front(card, parks="[G1.Q2]", unparks="[]")
|
|
75
|
+
lab(root, "decide", d2, "--with", "Ada", "The biased coin is parked: the fair coin answers what the lab needs first.")
|
|
76
|
+
git(root, "init", "-q")
|
|
77
|
+
git(root, "add", ".")
|
|
78
|
+
git(root, "commit", "-qm", "settled")
|
|
79
|
+
front(card, parks="[]") # what a settled decision parked cannot be taken back by editing it
|
|
80
|
+
assert "and what it parks or brings back, the order it sets, its `decided:`" in lab(root, "check", "--no-rederive", ok=False)
|
|
@@ -190,7 +190,8 @@ def test_a_readings_page_says_it_is_exploratory_and_what_was_dropped_leaves_the_
|
|
|
190
190
|
assert '<span class="kind">reading</span>' in q and "<ol><li><b>The sampler</b> flips a coin 100 times.</li>" in q and "Fix the seed." in q
|
|
191
191
|
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 "<b>The design.</b> Flip, count, compare." in site.get("G1").main
|
|
192
192
|
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
|
|
193
|
-
|
|
193
|
+
home = site.get("").main # off the working part of the front page; listed, folded, among what was set aside
|
|
194
|
+
assert "A side question" not in home.split("<h2>Set aside</h2>")[0] and "Dropped questions (1)" in home.split("<h2>Set aside</h2>")[1] and not any("A side question" in str(r) for r in site.rail()) and site.get("G1.Q2") is not None
|
|
194
195
|
|
|
195
196
|
|
|
196
197
|
def test_an_experiments_page_lists_its_runs_in_order_with_what_changed(tmp_path):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|