lab-kit-cli 1.4.0__tar.gz → 1.5.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.4.0 → lab_kit_cli-1.5.0}/CHANGELOG.md +15 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/PKG-INFO +1 -1
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/docs/model.md +21 -13
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/pyproject.toml +1 -1
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/skills/lab-mission/SKILL.md +8 -3
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/src/lab_kit/__init__.py +1 -1
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/src/lab_kit/checks.py +5 -3
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/src/lab_kit/cli.py +9 -6
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/src/lab_kit/record.py +9 -6
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/src/lab_kit/views.py +11 -7
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/src/lab_kit/write.py +19 -6
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/tests/test_mission.py +46 -8
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/.github/workflows/ci.yml +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/.github/workflows/policy.yml +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/.github/workflows/release.yml +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/.gitignore +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/AGENTS.md +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/CLAUDE.md +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/CONTRIBUTING.md +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/LICENSE +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/README.md +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/agents/reviewer.md +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/method/METHOD.md +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/skills/lab-review/SKILL.md +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/skills/lab-set-up/SKILL.md +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/skills/lab-talk/SKILL.md +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/skills/lab-work/SKILL.md +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/src/lab_kit/history.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/src/lab_kit/runs.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/src/lab_kit/site.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/src/lab_kit/supervise.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/tests/test_flow.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/tests/test_held.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/tests/test_integrity.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/tests/test_needs.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/tests/test_order.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/tests/test_parked.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/tests/test_refusals.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/tests/test_site.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/tests/test_vocabulary.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/tests/test_wording.py +0 -0
- {lab_kit_cli-1.4.0 → lab_kit_cli-1.5.0}/tools/import_run.py +0 -0
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.5.0
|
|
4
|
+
|
|
5
|
+
A closed mission is kept. In 1.4.0 `lab mission close` removed the mission's file, and with it the only account of
|
|
6
|
+
how its decision was carried out: which sessions started, what stalled, what was restarted. The skill `lab-mission`
|
|
7
|
+
changed: run `lab init` in a lab after upgrading, and add `status: next` (or `status: current`, for one already
|
|
8
|
+
launched) under the `title:` of every mission 1.4.0 wrote, or `lab check` reports it.
|
|
9
|
+
|
|
10
|
+
- **`status:`** on a mission, written by the commands: `next` when saved, `current` when launched, `done` or
|
|
11
|
+
`stopped` when closed. `lab check` asks for it. A file 1.4.0 wrote is still read (current once its log says
|
|
12
|
+
`launched`), and `lab check` asks for the status to be written.
|
|
13
|
+
- **`lab mission close [<id>] [--stopped] "<what>"`** sets the status, adds a last line to the mission's log, writes
|
|
14
|
+
one line about the decision in `log.md` (`Mission done:` or `Mission stopped:`), and keeps the file.
|
|
15
|
+
- **`lab mission`** lists the open missions and counts the closed; `--all` lists them all. `lab now` names only the
|
|
16
|
+
open ones.
|
|
17
|
+
|
|
3
18
|
## 1.4.0
|
|
4
19
|
|
|
5
20
|
Missions: a working note for carrying out a settled decision across many sessions. Before, starting or restarting
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: lab-kit-cli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.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
|
|
@@ -333,9 +333,11 @@ It copies nothing the decision or the record holds: not the steps, the order or
|
|
|
333
333
|
works out, such as which runs are going or which machine is free.
|
|
334
334
|
|
|
335
335
|
Each mission is a file, `missions/M<n>-<slug>.md`, numbered as decisions are. `lab mission new` gives the next
|
|
336
|
-
number after every mission in `missions/` and every one whose close `log.md` records; a file removed by hand
|
|
337
|
-
|
|
338
|
-
|
|
336
|
+
number after every mission in `missions/` and every one whose close `log.md` records; a file removed by hand
|
|
337
|
+
leaves no trace, and its number may be given again. Its `status:` says where it is: **next** from when it is saved,
|
|
338
|
+
**current** once it is launched, and **done** or **stopped** once it is closed. A closed mission stays in
|
|
339
|
+
`missions/`: its log is the one account of how its decision was carried out (which sessions started, what stalled,
|
|
340
|
+
what was restarted), which neither the decision nor the lab's log holds. Several may be current at once, each carrying its own decision or its own part of one;
|
|
339
341
|
they share the lab's resources, so each one's rules say what it takes, and a session reads the other current
|
|
340
342
|
missions before it takes a machine.
|
|
341
343
|
|
|
@@ -343,14 +345,16 @@ missions before it takes a machine.
|
|
|
343
345
|
- `lab mission launch [<mission>]` makes one current: the one named, or with no id the one saved last. It refuses
|
|
344
346
|
while the decision it carries is open, and while the mission does not say what it is for.
|
|
345
347
|
- `lab mission log [<mission>] "<what happened>"` adds a line to a current mission's log. Lines are only added.
|
|
346
|
-
- `lab mission close [<mission>] "<what it did, or why it stopped>"` ends a current mission:
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
348
|
+
- `lab mission close [<mission>] [--stopped] "<what it did, or why it stopped>"` ends a current mission: its status
|
|
349
|
+
becomes done (stopped, with `--stopped`, when it ended before its work did), its log ends with that line, and one
|
|
350
|
+
`agent` line about the decision it carried goes into `log.md`, `Mission done: M<n> <title>` (or `Mission stopped:`).
|
|
351
|
+
The file is kept.
|
|
352
|
+
- `lab mission` lists the open missions, next and current, in a line each, and counts the closed; `--all` lists
|
|
353
|
+
those too. `lab mission <mission>` shows one whole, with the steps its decision orders and where each stands now,
|
|
354
|
+
and the other current missions.
|
|
351
355
|
|
|
352
356
|
`log` and `close` may leave out the mission while only one is current, and refuse to guess when several are.
|
|
353
|
-
`lab now` names every mission under **Right now**. A mission is not part of the record: `lab check` checks its
|
|
357
|
+
`lab now` names every open mission under **Right now**. A mission is not part of the record: `lab check` checks its
|
|
354
358
|
form (section 9) and that it carries a decision, and does not hold it against history; the site does not draw
|
|
355
359
|
it; its log is not the lab's log. The lab-mission skill says what to do on each step.
|
|
356
360
|
|
|
@@ -404,7 +408,7 @@ written, and only one of them writes at a time.
|
|
|
404
408
|
```
|
|
405
409
|
lab.toml AGENTS.md GLOSSARY.md resources.toml log.md
|
|
406
410
|
decisions/D1-<slug>.md what was discussed and decided
|
|
407
|
-
missions/M1-<slug>.md a mission: how a settled decision is
|
|
411
|
+
missions/M1-<slug>.md a mission: how a settled decision is carried out, and once closed, how it was
|
|
408
412
|
goals/G1-<slug>/
|
|
409
413
|
goal.md
|
|
410
414
|
Q1-<slug>/
|
|
@@ -732,7 +736,8 @@ in UTC. The file holds no other heading, and a line no other `|`. The kinds are
|
|
|
732
736
|
`decision` lines, each with the opening of what was decided. A `doing` line holds what the agent is
|
|
733
737
|
starting on and why now. A line written before the kit kept the time has none.
|
|
734
738
|
A line is about a goal, a question or a step, and a `decision` line about its decision. The one other line
|
|
735
|
-
about a decision is the `agent` line `lab mission close` writes when a mission that carried it ends
|
|
739
|
+
about a decision is the `agent` line `lab mission close` writes when a mission that carried it ends (`Mission done:`
|
|
740
|
+
or `Mission stopped:`, and `Mission closed:` as 1.4.0 wrote it).
|
|
736
741
|
`lab log` ends a line with no space, even when the so what is empty. Spaces at the end of a log line
|
|
737
742
|
are not part of it: `lab check` compares the committed lines of `log.md` with those spaces left out,
|
|
738
743
|
so removing or adding them changes no committed line.
|
|
@@ -742,6 +747,7 @@ so removing or adding them changes no committed line.
|
|
|
742
747
|
```
|
|
743
748
|
---
|
|
744
749
|
title: "The first wave"
|
|
750
|
+
status: current
|
|
745
751
|
carries: D4
|
|
746
752
|
---
|
|
747
753
|
|
|
@@ -757,9 +763,11 @@ What the mission is for, in a sentence or two (80 words).
|
|
|
757
763
|
- 2026-11-15 09:40 | launched
|
|
758
764
|
```
|
|
759
765
|
|
|
760
|
-
The front matter holds `title
|
|
766
|
+
The front matter holds `title:`, `status:` (next, current, done or stopped, which the commands write) and `carries:`
|
|
767
|
+
(a decision), and nothing else. Rules is a list, each rule a line
|
|
761
768
|
`- <rule>`, possibly empty (200 words). Log is the last slot, and each line is `- <date> <time> | <what happened>` in UTC, holding no other
|
|
762
|
-
`|`. No other file sits in `missions/`. A
|
|
769
|
+
`|`. No other file sits in `missions/`. A file 1.4.0 wrote has no `status:`; it is read as current when its log
|
|
770
|
+
holds the line `launched`, else next, and `lab check` asks for the status to be written. `lab check`
|
|
763
771
|
reports a mission that breaks any of this, one whose `carries:` is not a decision, and a current mission whose
|
|
764
772
|
decision is still open.
|
|
765
773
|
|
|
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
|
|
|
5
5
|
[project]
|
|
6
6
|
dynamic = ["readme"]
|
|
7
7
|
name = "lab-kit-cli"
|
|
8
|
-
version = "1.
|
|
8
|
+
version = "1.5.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" }]
|
|
@@ -17,7 +17,10 @@ session reads to pick the work up where the last one stopped, so the operator ne
|
|
|
17
17
|
a long prompt to start or restart the work.
|
|
18
18
|
|
|
19
19
|
A mission is a file, `missions/M<n>-<name>.md`. It is **next** from when it is saved, and
|
|
20
|
-
**current** once it is launched
|
|
20
|
+
**current** once it is launched, and **done** or **stopped** once it is closed; its `status:` says
|
|
21
|
+
which, and the commands write it. A closed mission stays in `missions/`: its log is the only account
|
|
22
|
+
of how the decision was carried out. Several may be current at once. `lab mission` lists the open
|
|
23
|
+
ones (`--all` the closed too), and
|
|
21
24
|
`lab mission <id>` shows one whole: what it is for, its rules, the steps its decision orders with
|
|
22
25
|
where each stands now, the other current missions, and its log.
|
|
23
26
|
|
|
@@ -82,8 +85,10 @@ When asked how it is going, answer from `lab mission <id>` and `lab now`, as lab
|
|
|
82
85
|
## Close: when every step is finished, or the operator stops it
|
|
83
86
|
|
|
84
87
|
1. Check `lab mission <id>`: every step it lists is finished, or the operator said to stop.
|
|
85
|
-
2. `lab mission close <id> "<what it did
|
|
86
|
-
`
|
|
88
|
+
2. `lab mission close <id> "<what it did>"`, or `lab mission close <id> --stopped "<why it
|
|
89
|
+
stopped>"` when the operator ended it before its work was done. Its status becomes done or
|
|
90
|
+
stopped, its log gets a last line, and the lab's `log.md` one line about the decision. The file
|
|
91
|
+
stays: never remove it.
|
|
87
92
|
3. Commit, and tell the operator in a sentence what was carried out. If another mission is next,
|
|
88
93
|
say so; it is launched when they say to.
|
|
89
94
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""lab-kit: a research lab's record, its method, and the command that keeps both."""
|
|
2
|
-
__version__ = "1.
|
|
2
|
+
__version__ = "1.5.0"
|
|
@@ -299,7 +299,7 @@ def run(lab, rederive=True):
|
|
|
299
299
|
kind = nodes.get(l["about"], {}).get("type")
|
|
300
300
|
if l["kind"] == "doing" and not l["so"]:
|
|
301
301
|
bad("log", where, "a `doing` line says why now, after what the agent is starting on")
|
|
302
|
-
closes = l["kind"] == "agent" and kind == "decision" and l["what"].startswith("Mission closed: ") # written by `lab mission close`
|
|
302
|
+
closes = l["kind"] == "agent" and kind == "decision" and l["what"].startswith(("Mission closed: ", "Mission done: ", "Mission stopped: ")) # written by `lab mission close`
|
|
303
303
|
if kind is None or ((kind == "decision") != (l["kind"] == "decision") and not closes):
|
|
304
304
|
bad("log", where, f"is about {l['about']!r}: a decision line is about its decision, as is the line that closes a mission, any other about a goal, a question, an experiment, a build or a reading")
|
|
305
305
|
|
|
@@ -310,8 +310,10 @@ def run(lab, rederive=True):
|
|
|
310
310
|
bad("missions", where, b)
|
|
311
311
|
if m["bad"]:
|
|
312
312
|
continue
|
|
313
|
-
for key in sorted({str(k) for k in m["fm"]} - {"title", "carries"}):
|
|
314
|
-
bad("missions", where, f"`{key}:` is not something a mission holds: only `title:` and `carries:`")
|
|
313
|
+
for key in sorted({str(k) for k in m["fm"]} - {"title", "status", "carries"}):
|
|
314
|
+
bad("missions", where, f"`{key}:` is not something a mission holds: only `title:`, `status:` and `carries:`")
|
|
315
|
+
if str(m["fm"].get("status") or "") not in R.MISSION_STATES:
|
|
316
|
+
bad("missions", where, f"`status:` is one of {', '.join(R.MISSION_STATES)}; it is {m['fm'].get('status')!r}")
|
|
315
317
|
if not m["title"]:
|
|
316
318
|
bad("missions", where, "has no title")
|
|
317
319
|
d = nodes.get(m["carries"])
|
|
@@ -22,11 +22,11 @@ To write
|
|
|
22
22
|
lab log <id> agent|result|stuck "<what happened>" ["<so what>"]
|
|
23
23
|
lab answer <question> yes|no "<what the answer rests on>"
|
|
24
24
|
To carry out a decision
|
|
25
|
-
lab mission [<mission>]
|
|
25
|
+
lab mission [<mission>] [--all] the open missions (--all: the closed too), or one whole: its rules, its steps, its log
|
|
26
26
|
lab mission new "<title>" --carries <decision> save a mission; it is next until launched
|
|
27
27
|
lab mission launch [<mission>] make it current; with no id, the one saved last. Several may be current
|
|
28
28
|
lab mission log [<mission>] "<what happened>" a line in a current mission's log
|
|
29
|
-
lab mission close [<mission>] "<what it did, or why it stopped>" one line in log.md
|
|
29
|
+
lab mission close [<mission>] [--stopped] "<what it did, or why it stopped>" done (or stopped), one line in log.md; the file is kept
|
|
30
30
|
For evidence
|
|
31
31
|
lab lock <experiment>
|
|
32
32
|
lab run <experiment> [--trial] [--wait] [--changed "<what changed since the last run, and why>"] -- <command>
|
|
@@ -60,7 +60,8 @@ def main(argv=None):
|
|
|
60
60
|
i = rest.index("--")
|
|
61
61
|
rest, command = rest[:i], rest[i + 1:]
|
|
62
62
|
held = None
|
|
63
|
-
|
|
63
|
+
bare = [r for r in rest if r != "--all"]
|
|
64
|
+
looks = cmd == "mission" and len(bare) <= 1 and (not bare or re.fullmatch(r"M\d+", bare[0]) is not None) # `lab mission [<id>]` only reads
|
|
64
65
|
if cmd in ("new", "log", "decide", "answer", "lock", "review") or (cmd == "mission" and not looks): # one writer at a time, on the lab as it then is
|
|
65
66
|
held = runs.exclusive(find_root())
|
|
66
67
|
held.__enter__()
|
|
@@ -101,10 +102,12 @@ def main(argv=None):
|
|
|
101
102
|
raise SystemExit(USAGE)
|
|
102
103
|
print(f"made {ident}: {path}")
|
|
103
104
|
elif cmd == "mission":
|
|
104
|
-
carries = flag("--carries")
|
|
105
|
+
carries, everything, stopped = flag("--carries"), flag("--all", switch=True), flag("--stopped", switch=True)
|
|
106
|
+
if not rest and not looks or (stopped and rest[:1] != ["close"]) or (everything and not looks) or "--all" in rest:
|
|
107
|
+
raise SystemExit(USAGE)
|
|
105
108
|
ident = lambda: rest.pop(1) if len(rest) == 3 or (rest[0] == "launch" and len(rest) == 2) else None
|
|
106
109
|
if looks:
|
|
107
|
-
print(views.mission(lab, rest[0] if rest else None))
|
|
110
|
+
print(views.mission(lab, rest[0] if rest else None, everything))
|
|
108
111
|
elif rest[0] == "new" and len(rest) == 2:
|
|
109
112
|
made, path = write.mission_new(lab, rest[1], carries)
|
|
110
113
|
print(f"saved {made}: {path}. Say what it is for under the front matter, and its rules")
|
|
@@ -118,7 +121,7 @@ def main(argv=None):
|
|
|
118
121
|
print(f"added to {write.mission_log(lab, m, rest[1])}")
|
|
119
122
|
elif rest[0] == "close" and len(rest) in (2, 3):
|
|
120
123
|
m = ident()
|
|
121
|
-
print(f"closed: {write.mission_close(lab, m, rest[1])}")
|
|
124
|
+
print(f"closed: {write.mission_close(lab, m, rest[1], stopped)}")
|
|
122
125
|
else:
|
|
123
126
|
raise SystemExit(USAGE)
|
|
124
127
|
elif cmd == "log":
|
|
@@ -29,6 +29,7 @@ DECIDED = 150 # the word budget of what a decision says was decided and why, wh
|
|
|
29
29
|
DESCRIPTION = {"goal": 70, "question": 150, "experiment": 80, "build": 60, "reading": 70}
|
|
30
30
|
MISSION_LINE = re.compile(r"^- (\d{4}-\d\d-\d\d) (\d\d:\d\d) \| ([^|]+)$") # a line of a mission's log
|
|
31
31
|
MISSION_BUDGET = {"description": 80, "Rules": 200}
|
|
32
|
+
MISSION_STATES = ("next", "current", "done", "stopped") # a mission's `status:`; done and stopped are closed, and the file is kept
|
|
32
33
|
STEPS = ("experiment", "build", "reading") # what sits under a question: a locked comparison, something made, a look at what already exists
|
|
33
34
|
READS = ("", "percent", "points") # how a result's value reads on a page
|
|
34
35
|
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
|
|
@@ -639,9 +640,9 @@ class Lab:
|
|
|
639
640
|
return out
|
|
640
641
|
|
|
641
642
|
def _missions(self):
|
|
642
|
-
"""Every mission, by number: `missions/M<n>-<name>.md
|
|
643
|
-
|
|
644
|
-
`lab check` checks only its form."""
|
|
643
|
+
"""Every mission, by number: `missions/M<n>-<name>.md`, with its `status:` (next, current, done, stopped), which
|
|
644
|
+
the commands write. A file written by 1.4.0 has none: it is current once its log says it was launched, else next.
|
|
645
|
+
A mission is a working note, not part of the record: `lab check` checks only its form."""
|
|
645
646
|
out = []
|
|
646
647
|
for n, path in self._numbered(f"{self.root}/missions/*.md", r"/M(\d+)-[^/]+\.md$", {}, "M<n>-<name>.md"):
|
|
647
648
|
m = {"id": f"M{n}", "n": n, "path": self.rel(path), "title": "", "carries": "", "fm": {}, "slots": {}, "description": "", "log": [], "bad": [], "last_slot": ""}
|
|
@@ -661,7 +662,8 @@ class Lab:
|
|
|
661
662
|
if raw.strip():
|
|
662
663
|
hit = MISSION_LINE.match(raw.rstrip())
|
|
663
664
|
m["log"].append({"day": hit.group(1), "time": hit.group(2), "what": hit.group(3).strip()} if hit else {"bad": raw.strip()})
|
|
664
|
-
|
|
665
|
+
status = flat(fm.get("status") or "")
|
|
666
|
+
m["state"] = status if status in MISSION_STATES else ("current" if any(l.get("what") == "launched" for l in m["log"]) else "next")
|
|
665
667
|
out.append(m)
|
|
666
668
|
return out
|
|
667
669
|
|
|
@@ -669,8 +671,9 @@ class Lab:
|
|
|
669
671
|
return next((m for m in self.missions if m["id"] == ident), None)
|
|
670
672
|
|
|
671
673
|
def mission_numbers(self):
|
|
672
|
-
"""Every number a mission has had: those
|
|
673
|
-
|
|
674
|
+
"""Every number a mission has had: those in `missions/`, closed ones included, and those whose close the lab's
|
|
675
|
+
log records (a mission closed by 1.4.0 had its file removed)."""
|
|
676
|
+
closed = [int(m.group(1)) for l in self.lines if l["kind"] == "agent" for m in [re.match(r"Mission (?:closed|done|stopped): M(\d+)\b", l["what"])] if m]
|
|
674
677
|
return [m["n"] for m in self.missions] + closed
|
|
675
678
|
|
|
676
679
|
def mission_steps(self, mission):
|
|
@@ -67,7 +67,7 @@ def _now(lab):
|
|
|
67
67
|
out += ["", "Right now, as the operator sees it"]
|
|
68
68
|
out += [f"- on {d['about']} {lab.nodes[d['about']]['title']} since {d['day']} {d['time']}: {d['what']} Why now: {d['so']}"] if d else ["- no `doing` line is open: the site says nobody is on anything. When you start: lab log <id> doing \"<what>\" \"<why now>\""]
|
|
69
69
|
out += [f"- last recorded activity: {last.strftime('%Y-%m-%d %H:%M')} UTC"] if last else []
|
|
70
|
-
out += [mission_line(lab, m).replace("- M", "- mission M", 1) for m in lab.missions]
|
|
70
|
+
out += [mission_line(lab, m).replace("- M", "- mission M", 1) for m in lab.missions if m["state"] in ("next", "current")]
|
|
71
71
|
waiting = lab.open_decisions()
|
|
72
72
|
out += ["", "To discuss with the operator"] + (["- nothing"] if not waiting else [])
|
|
73
73
|
for d in waiting:
|
|
@@ -114,13 +114,15 @@ def mission_line(lab, m):
|
|
|
114
114
|
return f"- {m['id']} ({m['state']}): {m['title'] or m['path']}, {carries}{tail}"
|
|
115
115
|
|
|
116
116
|
|
|
117
|
-
def mission(lab, ident=None):
|
|
117
|
+
def mission(lab, ident=None, everything=False):
|
|
118
118
|
"""Every mission in a line each, or one whole: what it is for, its rules, the steps its decision orders, its log."""
|
|
119
119
|
if ident is None:
|
|
120
|
-
lines = [mission_line(lab, m) for m in lab.missions]
|
|
120
|
+
lines = [mission_line(lab, m) for m in lab.missions if everything or m["state"] in ("next", "current")]
|
|
121
|
+
closed = sum(m["state"] in ("done", "stopped") for m in lab.missions)
|
|
122
|
+
more = [] if everything or not closed else [f"{closed} closed mission{'' if closed == 1 else 's'}: lab mission --all"]
|
|
121
123
|
if not lines:
|
|
122
|
-
return 'no mission: save one with lab mission new "<title>" --carries <decision>'
|
|
123
|
-
return "\n".join(lines + ["", "More: lab mission <id>"])
|
|
124
|
+
return "\n".join(['no open mission: save one with lab mission new "<title>" --carries <decision>'] + more)
|
|
125
|
+
return "\n".join(lines + more + ["", "More: lab mission <id>"])
|
|
124
126
|
m = lab.mission(ident)
|
|
125
127
|
if not m:
|
|
126
128
|
return f"no mission {ident}: `lab mission` lists them"
|
|
@@ -137,7 +139,7 @@ def mission(lab, ident=None):
|
|
|
137
139
|
out += [f"Decided. {R.flat(d['slots']['Decided'])}"]
|
|
138
140
|
if R.flat(m["slots"].get("Rules", "")):
|
|
139
141
|
out += ["", "Rules of this mission", m["slots"]["Rules"].strip()]
|
|
140
|
-
others = [o for o in lab.missions if o["state"] == "current" and o["id"] != m["id"]]
|
|
142
|
+
others = [] if m["state"] in ("done", "stopped") else [o for o in lab.missions if o["state"] == "current" and o["id"] != m["id"]]
|
|
141
143
|
if others:
|
|
142
144
|
out += ["", "Also current (read their rules before taking a machine)"] + [mission_line(lab, o) for o in others]
|
|
143
145
|
if d and d["type"] == "decision":
|
|
@@ -153,7 +155,9 @@ def mission(lab, ident=None):
|
|
|
153
155
|
out += [] if open_ else ["- every step is finished: close the mission"]
|
|
154
156
|
out += ["", "Log"] + ([f"- {l['day']} {l['time']} {l['what']}" if "what" in l else f"- (not a log line) {l['bad']}" for l in m["log"]] or ["- nothing yet"])
|
|
155
157
|
if m["state"] == "current":
|
|
156
|
-
out += ["", f'To add a line: lab mission log {m["id"]} "<what happened>" To end it: lab mission close {m["id"]} "<what it did>"']
|
|
158
|
+
out += ["", f'To add a line: lab mission log {m["id"]} "<what happened>" To end it: lab mission close {m["id"]} [--stopped] "<what it did>"']
|
|
159
|
+
elif m["state"] in ("done", "stopped"):
|
|
160
|
+
out += ["", f"Closed ({m['state']}): its log above is the record of how {m['carries']} was carried out."]
|
|
157
161
|
else:
|
|
158
162
|
out += ["", f"To launch it: lab mission launch {m['id']}"]
|
|
159
163
|
return R.bare("\n".join(out))
|
|
@@ -364,7 +364,7 @@ def rederive(lab, only=None):
|
|
|
364
364
|
|
|
365
365
|
# ---------------------------------------------------------------- missions: carrying out a settled decision
|
|
366
366
|
|
|
367
|
-
MISSION = "---\ntitle: {title}\ncarries: {carries}\n---\n\n\n\n## Rules\n\n\n## Log\n\n{line}\n"
|
|
367
|
+
MISSION = "---\ntitle: {title}\nstatus: next\ncarries: {carries}\n---\n\n\n\n## Rules\n\n\n## Log\n\n{line}\n"
|
|
368
368
|
|
|
369
369
|
|
|
370
370
|
def _mission_line(what):
|
|
@@ -384,6 +384,14 @@ def _mission_append(lab, m, line):
|
|
|
384
384
|
f.write(("" if text.endswith("\n") else "\n") + line + "\n")
|
|
385
385
|
|
|
386
386
|
|
|
387
|
+
def _mission_status(lab, m, status):
|
|
388
|
+
"""Write a mission's `status:` in its front matter, in place of the one there, or as its second line."""
|
|
389
|
+
path = os.path.join(lab.root, m["path"])
|
|
390
|
+
fm, body = R.split(R.read(path))
|
|
391
|
+
fm = re.sub(r"^status:.*\n", f"status: {status}\n", fm, flags=re.M) if re.search(r"^status:", fm, flags=re.M) else re.sub(r"^(title:.*\n)", rf"\1status: {status}\n", fm, count=1, flags=re.M) if re.search(r"^title:", fm, flags=re.M) else f"status: {status}\n" + fm
|
|
392
|
+
open(path, "w").write(R.join(fm, body))
|
|
393
|
+
|
|
394
|
+
|
|
387
395
|
def pick_mission(lab, ident, state):
|
|
388
396
|
"""The mission a command acts on: the one named, or, with no name, the only one in that state."""
|
|
389
397
|
if ident:
|
|
@@ -430,6 +438,7 @@ def mission_launch(lab, ident=None):
|
|
|
430
438
|
if not m["description"]:
|
|
431
439
|
stop(f"{m['path']}: say what the mission is for, in the paragraph under the front matter")
|
|
432
440
|
_mission_append(lab, m, _mission_line("launched"))
|
|
441
|
+
_mission_status(lab, m, "current")
|
|
433
442
|
return m["id"], m["path"]
|
|
434
443
|
|
|
435
444
|
|
|
@@ -439,8 +448,9 @@ def mission_log(lab, ident, what):
|
|
|
439
448
|
return m["path"]
|
|
440
449
|
|
|
441
450
|
|
|
442
|
-
def mission_close(lab, ident, what):
|
|
443
|
-
"""End a current mission:
|
|
451
|
+
def mission_close(lab, ident, what, stopped=False):
|
|
452
|
+
"""End a current mission: its status becomes done (or stopped), a last line in its log, and one line in the lab's
|
|
453
|
+
log about the decision it carried. The file is kept: its log is the record of how the decision was carried out."""
|
|
444
454
|
m = pick_mission(lab, ident, "current")
|
|
445
455
|
if lab.nodes.get(m["carries"], {}).get("type") != "decision":
|
|
446
456
|
stop(f"{m['path']}: `carries:` names no decision; fix it before closing, so the lab's log says what was carried out")
|
|
@@ -448,7 +458,10 @@ def mission_close(lab, ident, what):
|
|
|
448
458
|
if not what or "|" in what:
|
|
449
459
|
stop("say what the mission did, or why it stopped, with no |")
|
|
450
460
|
title = (m["title"] or "untitled").replace("|", "/")
|
|
451
|
-
|
|
452
|
-
|
|
461
|
+
status = "stopped" if stopped else "done"
|
|
462
|
+
line = log_line(lab, m["carries"], "agent", f"Mission {status}: {m['id']} {title}", what, _mission=True) # validated before anything is written
|
|
463
|
+
mine = _mission_line(f"{status}: {what}")
|
|
464
|
+
_mission_append(lab, m, mine) # refuses a file it cannot add to, before anything is written
|
|
465
|
+
_mission_status(lab, m, status)
|
|
453
466
|
log(lab, m["carries"], "agent", *line, _mission=True)
|
|
454
|
-
return f"
|
|
467
|
+
return f"{m['path']} ({status}, kept), and log.md"
|
|
@@ -24,7 +24,7 @@ def test_a_mission_is_saved_launched_logged_and_closed(tmp_path):
|
|
|
24
24
|
open_question(root)
|
|
25
25
|
three_steps(root)
|
|
26
26
|
card, d2 = order(root, ["G1.Q2.2", "G1.Q1", "G1.Q2"])
|
|
27
|
-
assert "no mission" in lab(root, "mission")
|
|
27
|
+
assert "no open mission" in lab(root, "mission")
|
|
28
28
|
# a mission carries a decision; it may be saved while the decision is open, and not launched until it is settled
|
|
29
29
|
assert "is not one" in lab(root, "mission", "new", "Nothing", "--carries", "G1.Q1", ok=False)
|
|
30
30
|
m1, path = saved(root, "The weight first", d2)
|
|
@@ -47,8 +47,14 @@ def test_a_mission_is_saved_launched_logged_and_closed(tmp_path):
|
|
|
47
47
|
assert "holds no |" in lab(root, "mission", "log", "a | b", ok=False)
|
|
48
48
|
assert "the record is sound" in lab(root, "check", "--no-rederive")
|
|
49
49
|
out = lab(root, "mission", "close", "M1", "The weight on heads is built; the rest moved to the next mission.")
|
|
50
|
-
assert "
|
|
51
|
-
assert f"| {d2} | agent | Mission
|
|
50
|
+
assert "missions/M1-the-weight-first.md (done, kept)" in out and os.path.exists(path)
|
|
51
|
+
assert f"| {d2} | agent | Mission done: M1 The weight first | The weight on heads is built" in open(f"{root}/log.md").read()
|
|
52
|
+
kept = open(path).read()
|
|
53
|
+
assert "status: done" in kept and "| done: The weight on heads is built" in kept and "| launched" in kept
|
|
54
|
+
assert "M1" not in lab(root, "mission").split("\n")[0] and "1 closed mission: lab mission --all" in lab(root, "mission")
|
|
55
|
+
assert "M1 (done): The weight first" in lab(root, "mission", "--all") and "mission M1" not in lab(root, "now")
|
|
56
|
+
assert "Closed (done)" in lab(root, "mission", "M1")
|
|
57
|
+
assert "M1 is done, not current" in lab(root, "mission", "log", "M1", "more", ok=False)
|
|
52
58
|
assert "the record is sound" in lab(root, "check", "--no-rederive")
|
|
53
59
|
# a number is never given twice, even once its file is gone
|
|
54
60
|
assert saved(root, "The rest", d2)[0] == "M2"
|
|
@@ -77,11 +83,11 @@ def test_lab_check_holds_a_missions_form(tmp_path):
|
|
|
77
83
|
open_question(root)
|
|
78
84
|
_, path = saved(root, "A mission", "D1")
|
|
79
85
|
assert "the record is sound" in lab(root, "check", "--no-rederive")
|
|
80
|
-
front(path, carries="D9",
|
|
86
|
+
front(path, carries="D9", phase="active")
|
|
81
87
|
open(path, "a").write("not a line\n")
|
|
82
88
|
open(f"{root}/missions/notes.txt", "w").write("x")
|
|
83
89
|
out = lab(root, "check", "--no-rederive", ok=False)
|
|
84
|
-
assert "`
|
|
90
|
+
assert "`phase:` is not something a mission holds" in out
|
|
85
91
|
assert "'D9' is not one" in out
|
|
86
92
|
assert "is not `- <date> <time> | <what happened>`" in out
|
|
87
93
|
assert "missions/notes.txt: missions/ holds only the missions" in out
|
|
@@ -90,7 +96,7 @@ def test_lab_check_holds_a_missions_form(tmp_path):
|
|
|
90
96
|
os.remove(f"{root}/missions/notes.txt")
|
|
91
97
|
lab(root, "new", "decision", "Another", "--about", "G1")
|
|
92
98
|
fill(sorted(glob.glob(f"{root}/decisions/D2-*.md"))[0], Seen="Something to discuss.")
|
|
93
|
-
text = open(path).read().replace("
|
|
99
|
+
text = open(path).read().replace("phase: active\n", "").replace("status: next", "status: current").replace("not a line\n", "- 2026-01-02 09:40 | launched\n")
|
|
94
100
|
open(path, "w").write(text)
|
|
95
101
|
assert "is current and carries D2, which is still open" in lab(root, "check", "--no-rederive", ok=False)
|
|
96
102
|
|
|
@@ -105,7 +111,7 @@ def test_the_site_draws_the_line_that_closes_a_mission(tmp_path):
|
|
|
105
111
|
lab(root, "mission", "launch")
|
|
106
112
|
lab(root, "mission", "close", "The first question is open and its work has started.")
|
|
107
113
|
site = Provider(root)
|
|
108
|
-
assert "Mission
|
|
114
|
+
assert "Mission done: M1 A mission" in site.get("D1").main + site.get("log").main
|
|
109
115
|
|
|
110
116
|
|
|
111
117
|
def test_the_refusals_a_mission_command_holds(tmp_path):
|
|
@@ -120,7 +126,10 @@ def test_the_refusals_a_mission_command_holds(tmp_path):
|
|
|
120
126
|
# an id with no message is not taken as the message
|
|
121
127
|
assert 'say what happened after the mission: lab mission close M1 "<what>"' in lab(root, "mission", "close", "M1", ok=False)
|
|
122
128
|
assert "say what happened after the mission" in lab(root, "mission", "log", "M1", ok=False)
|
|
123
|
-
assert os.path.exists(path) and "Mission
|
|
129
|
+
assert os.path.exists(path) and "Mission done" not in open(f"{root}/log.md").read()
|
|
130
|
+
# a mission ended before its work is stopped, not done
|
|
131
|
+
lab(root, "mission", "close", "--stopped", "The operator ended it to free the machines.")
|
|
132
|
+
assert "status: stopped" in open(path).read() and "Mission stopped: M1" in open(f"{root}/log.md").read()
|
|
124
133
|
|
|
125
134
|
|
|
126
135
|
def test_lab_check_holds_a_missions_slots(tmp_path):
|
|
@@ -140,3 +149,32 @@ def test_lab_check_holds_a_missions_slots(tmp_path):
|
|
|
140
149
|
assert "cannot be read" in lab(root, "mission")
|
|
141
150
|
open(path, "w").write("---\ntitle: Short\ncarries: D1\n---\n\nFor the first question.\n\n## Log\n\n- 2026-01-02 09:30 | saved, carrying D1\n")
|
|
142
151
|
assert "missing slot Rules" in lab(root, "check", "--no-rederive", ok=False)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def test_a_mission_has_a_status_and_one_written_by_the_last_kit_is_still_read(tmp_path):
|
|
155
|
+
root = str(tmp_path)
|
|
156
|
+
open_question(root)
|
|
157
|
+
_, path = saved(root, "A mission", "D1")
|
|
158
|
+
assert "status: next" in open(path).read()
|
|
159
|
+
lab(root, "mission", "launch")
|
|
160
|
+
assert "status: current" in open(path).read()
|
|
161
|
+
front(path, status="paused")
|
|
162
|
+
assert "`status:` is one of next, current, done, stopped; it is 'paused'" in lab(root, "check", "--no-rederive", ok=False)
|
|
163
|
+
# a file 1.4.0 wrote has no status: read as current from its log, and the check asks for the status
|
|
164
|
+
text = open(path).read().replace("status: paused\n", "")
|
|
165
|
+
open(path, "w").write(text)
|
|
166
|
+
assert "M1 (current)" in lab(root, "mission")
|
|
167
|
+
assert "`status:` is one of" in lab(root, "check", "--no-rederive", ok=False)
|
|
168
|
+
lab(root, "mission", "close", "Done.")
|
|
169
|
+
assert "status: done" in open(path).read() and "the record is sound" in lab(root, "check", "--no-rederive")
|
|
170
|
+
# numbers count the closed missions, kept and removed alike
|
|
171
|
+
assert saved(root, "Another", "D1")[0] == "M2"
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def test_the_mission_switches_go_only_where_they_mean_something(tmp_path):
|
|
175
|
+
root = str(tmp_path)
|
|
176
|
+
open_question(root)
|
|
177
|
+
saved(root, "A mission", "D1")
|
|
178
|
+
for args in (["--stopped"], ["log", "--stopped", "x"], ["new", "B", "--carries", "D1", "--all"], ["--all", "--all"]):
|
|
179
|
+
assert "To look" in lab(root, "mission", *args, ok=False) # refused with the usage, nothing written
|
|
180
|
+
assert len(glob.glob(f"{root}/missions/*.md")) == 1
|
|
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
|
|
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
|