orrin 1.0.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.
Files changed (45) hide show
  1. orrin-1.0.0/LICENSE +21 -0
  2. orrin-1.0.0/PKG-INFO +177 -0
  3. orrin-1.0.0/README.md +156 -0
  4. orrin-1.0.0/orrin/__init__.py +7 -0
  5. orrin-1.0.0/orrin/__main__.py +3 -0
  6. orrin-1.0.0/orrin/board.py +96 -0
  7. orrin-1.0.0/orrin/checkin.py +258 -0
  8. orrin-1.0.0/orrin/cli.py +590 -0
  9. orrin-1.0.0/orrin/config.py +80 -0
  10. orrin-1.0.0/orrin/data.py +126 -0
  11. orrin-1.0.0/orrin/home.py +110 -0
  12. orrin-1.0.0/orrin/jobs.py +319 -0
  13. orrin-1.0.0/orrin/lead.py +78 -0
  14. orrin-1.0.0/orrin/lint.py +120 -0
  15. orrin-1.0.0/orrin/lock.py +183 -0
  16. orrin-1.0.0/orrin/procs.py +245 -0
  17. orrin-1.0.0/orrin/rules.py +188 -0
  18. orrin-1.0.0/orrin/settled.py +102 -0
  19. orrin-1.0.0/orrin/status.py +59 -0
  20. orrin-1.0.0/orrin/stopcheck.py +76 -0
  21. orrin-1.0.0/orrin/tasks.py +298 -0
  22. orrin-1.0.0/orrin/templates/AGENTS.md +9 -0
  23. orrin-1.0.0/orrin/templates/AGENT_RULES.md +21 -0
  24. orrin-1.0.0/orrin/templates/HANDOFF.md +37 -0
  25. orrin-1.0.0/orrin/templates/HEARTBEAT.md +23 -0
  26. orrin-1.0.0/orrin/templates/LEAD_HANDOFF.md +22 -0
  27. orrin-1.0.0/orrin/templates/LESSONS.md +32 -0
  28. orrin-1.0.0/orrin/templates/briefs/README.md +21 -0
  29. orrin-1.0.0/orrin/templates/briefs/finish.md +15 -0
  30. orrin-1.0.0/orrin/templates/briefs/lane-round.md +21 -0
  31. orrin-1.0.0/orrin/templates/briefs/plan-review.md +17 -0
  32. orrin-1.0.0/orrin/templates/briefs/research-round.md +21 -0
  33. orrin-1.0.0/orrin/templates/briefs/review-round.md +20 -0
  34. orrin-1.0.0/orrin/templates/protected_data.json +26 -0
  35. orrin-1.0.0/orrin/tidy.py +62 -0
  36. orrin-1.0.0/orrin/wait.py +48 -0
  37. orrin-1.0.0/orrin.egg-info/PKG-INFO +177 -0
  38. orrin-1.0.0/orrin.egg-info/SOURCES.txt +43 -0
  39. orrin-1.0.0/orrin.egg-info/dependency_links.txt +1 -0
  40. orrin-1.0.0/orrin.egg-info/entry_points.txt +2 -0
  41. orrin-1.0.0/orrin.egg-info/top_level.txt +1 -0
  42. orrin-1.0.0/pyproject.toml +37 -0
  43. orrin-1.0.0/setup.cfg +4 -0
  44. orrin-1.0.0/tests/test_orrin.py +641 -0
  45. orrin-1.0.0/tests/test_skill.py +82 -0
orrin-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 snehoza
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
orrin-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,177 @@
1
+ Metadata-Version: 2.4
2
+ Name: orrin
3
+ Version: 1.0.0
4
+ Summary: Run several coding agents on one machine: detached jobs with completion markers, a fair machine lock, short waits, a lane board, status, tidy and protected data.
5
+ Author: snehoza
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/snehoza/orrin
8
+ Project-URL: Issues, https://github.com/snehoza/orrin/issues
9
+ Project-URL: Changelog, https://github.com/snehoza/orrin/blob/main/CHANGELOG.md
10
+ Keywords: agents,ai-agents,coding-agents,job-queue,lock,worktree,orchestration
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Software Development
16
+ Classifier: Topic :: System :: Distributed Computing
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Dynamic: license-file
21
+
22
+ # orrin
23
+
24
+ Keep a coding agent working on a project around the clock, alone or with a team of worker agents, without it drifting from what you want.
25
+
26
+ What makes that work isn't a fixed rule set. It is a small loop:
27
+ - **An anchor:** a status file that is always true.
28
+ - **A heartbeat:** a check-in on a regular beat that looks at usage, jobs and workers, then acts.
29
+ - **Rules from corrections:** each correction becomes a dated rule the same day, and the rule it replaces is superseded.
30
+ - **A decision boundary:** what the agent decides alone, and what needs you.
31
+ - **Independent verification** of every result.
32
+
33
+ The kit gives you that loop and the tools that grew out of running it:
34
+
35
+ - **`orrin checkin`**: the heartbeat. Usage from any provider, failed or stalled jobs, quiet workers, a status file that fell behind the commits.
36
+ - **A memory layer for the lead:** `WORKING_WITH_USER.md` (how this user wants to be worked with, built from their corrections with `rule add --for coordinator`), `LEAD_HANDOFF.md` (the lead's own state, flagged when stale), `SETTLED.md` (ideas already measured, so nobody retries them; the check-in flags lookalike tasks) and the check-in prompt's own history.
37
+ - **Agents from your harness:** `agents_command` wraps any harness's agent list. The check-in then sees agents that never post: quiet ones, ones with too large a context, and two strong models on one account.
38
+ - **`orrin lint`** keeps instructions from making agents rigid: it flags token budgets, capitalised `MUST`/`NEVER`, rules without a reason, rules tied to one case, and too many rules. It also lists rules worth reviewing, because they hurt or their failure came back. Skills and rules say plainly that the user's current request comes first.
39
+ - **`orrin stop-check`** for a harness stop hook: the lead keeps going when it still has work it can do (at most three short items, capped, never for things that need you), instead of idling until the next beat.
40
+ - **`orrin task`**: a task list where "done" needs a passing check or a completed job as evidence, so agents can't declare victory early. Failures from before the work don't count against it (`task baseline`), and a check that was quietly changed is refused.
41
+ - **`orrin rule add/retire`**: rules that evolve, with your words, the date and their history. Rendered into the agents' rules file along with the decision boundary and model policy from `orrin.json`. `rule outcome` logs whether a rule helped, hurt, or let its failure come back.
42
+ - **Detached jobs** survive the agent that started them, and their completion markers can't lie. **Short blocking waits** keep agents cheap and still able to hear messages.
43
+ - **A fair machine lock,** first come first served, with an exclusive mode for heavy work and a shared mode for tests. It is safe when a holder crashes.
44
+ - **A lane board, one status screen, and tidy,** which repairs stale state without losing data.
45
+ - **A protected-data registry:** cleanup only ever archives.
46
+ - **Two [Agent Skills](https://agentskills.io):** one for the lead session, one for workers. Plus brief and handoff templates, and a list of lessons to adopt when their problem shows up.
47
+
48
+ Standard-library Python 3.11+, no daemon, state in plain files. Linux, macOS and Windows.
49
+
50
+ Why it works is in [the write-up](https://github.com/snehoza/orrin/blob/main/docs/WRITEUP.md). The failures behind each tool are in [the notes](https://github.com/snehoza/orrin/blob/main/docs/NOTES.md).
51
+
52
+ ## Install
53
+
54
+ pip install orrin
55
+
56
+ This gives you the `orrin` command (`python -m orrin` works too).
57
+
58
+ ## Thirty seconds of it
59
+
60
+ ```sh
61
+ # run a long job detached, holding the machine lock (exclusive by default)
62
+ orrin jobs launch --name lane1-tests --min-free-mb 2000 -- python -m pytest -q
63
+
64
+ # wait up to 3 minutes; exit 0 done, 1 failed, 3 still running (call again)
65
+ orrin wait lane1-tests
66
+
67
+ # a short command that must not run beside heavy jobs
68
+ orrin lock run --shared -- python scripts/check.py
69
+
70
+ # who is doing what
71
+ orrin board set --lane lane1 --worktree ../proj-lane1 --activity "speed round" --next "timing run" --eta 15:30
72
+ orrin status
73
+ ```
74
+
75
+ What `status` looks like:
76
+
77
+ ```
78
+ MACHINE: 16 CPUs | available 6120 MiB | load 38%
79
+ LOCK machine: held by lane2-gate (exclusive, 12m)
80
+ queued: lane1-timing (exclusive, waiting 3m)
81
+ JOBS (3 active or recent):
82
+ lane2-gate: running [lane2] 41/99 eta 17m
83
+ lane1-timing: waiting-lock [lane1]
84
+ lane3-smoke: done [lane3]
85
+ LANE BOARD (information only; decisions go through the coordinator)
86
+ lane1: live | gpt-x | speed round | next timing run eta 15:30 | updated 4m ago
87
+ ```
88
+
89
+ ## Jobs
90
+
91
+ `orrin jobs launch --name N -- CMD` starts CMD detached, so it survives the agent's turn, terminal and session. Its files go in `~/.orrin/jobs/N/`:
92
+
93
+ | File | Contents |
94
+ |---|---|
95
+ | `N.log` | Everything CMD prints |
96
+ | `N.pid` | The runner's PID and process start time |
97
+ | `N.done` | `EXIT=<code> COMPLETE=<0|1> REASON=<ok|failed|fail-fast|stopped|lock-timeout|ram-guard|...> <time>` |
98
+
99
+ A job is accepted only with `COMPLETE=1` in the marker **and** `JOB_COMPLETE N` in the log.
100
+
101
+ Before CMD runs, the runner:
102
+ - waits for the machine lock (`--lock exclusive|shared|none`);
103
+ - waits for free memory (`--min-free-mb`).
104
+
105
+ While CMD runs:
106
+ - a line starting `ERROR `, `FATAL ` or `JOB_FATAL ` stops it at once;
107
+ - `PROGRESS n/N` lines feed the ETA;
108
+ - `--smoke 1` sets `ORRIN_SMOKE=1`, so a batch job can run one item first.
109
+
110
+ `orrin jobs stop N` stops CMD's whole process tree.
111
+
112
+ ## The lock
113
+
114
+ `exclusive` holders run alone. `shared` holders run together, but never beside an exclusive holder and never ahead of an exclusive ticket that is already waiting. Waiters are served in arrival order. Holders that die are noticed by PID and start time, and dropped. Nesting is refused, because it would deadlock.
115
+
116
+ From Python:
117
+
118
+ ```python
119
+ from orrin.lock import FairLock
120
+
121
+ with FairLock(label="benchmark", timeout=600):
122
+ run_benchmark()
123
+ ```
124
+
125
+ ## Set up the loop
126
+
127
+ ```sh
128
+ orrin init # orrin.json + docs/agents/
129
+ ```
130
+
131
+ `orrin init` writes:
132
+ - `orrin.json`: settings as data:
133
+ - the status file;
134
+ - the heartbeat (beat, quiet-lane minutes, status drift);
135
+ - `usage_commands`;
136
+ - the decision `boundary` (`decide` and `ask`);
137
+ - `models` (roles, fallback order, checkpoint threshold).
138
+ - `docs/agents/AGENT_RULES.md`: a short frame plus a generated block (decision boundary, models and budget, live rules). Point your `AGENTS.md` or `CLAUDE.md` at it.
139
+ - `docs/agents/HEARTBEAT.md`: the check-in prompt. Schedule it with your harness's loop or cron.
140
+ - `docs/agents/LESSONS.md`: rules from a real project, each tied to the symptom that calls for it. Adopt one when you see its symptom, not on day one.
141
+ - `docs/agents/briefs/` (lane, research, review/judging, finish), `HANDOFF.md`, and an example `protected_data.json`.
142
+
143
+ Then the coordinator records corrections as they come:
144
+
145
+ ```sh
146
+ orrin rule add "Wait in 3-minute blocking calls" --why "long waits left agents deaf for 10 min" --supersedes R4
147
+ orrin rule list --all
148
+ orrin checkin --quiet
149
+ ```
150
+
151
+ The skills in [`skills/`](https://github.com/snehoza/orrin/tree/main/skills) follow the open Agent Skills format:
152
+ - `orrin` is for the lead session: anchor, heartbeat, corrections, workers, verification.
153
+ - `orrin-lane` is for workers: jobs, waits, the lock, the board, handoffs.
154
+
155
+ To install them, copy the folders into your agent's skills directory, e.g. `.claude/skills/` for Claude Code; other agents document where skills live. They need only a shell and Python. Every command is listed in [`COMMANDS.md`](https://github.com/snehoza/orrin/blob/main/skills/orrin/references/COMMANDS.md).
156
+
157
+ ## Protected data
158
+
159
+ ```sh
160
+ orrin data --registry protected_data.json check # sources exist; goldens are self-contained
161
+ orrin data --registry protected_data.json scan ./outputs # size, age, and why each folder is kept
162
+ orrin data --registry protected_data.json archive ./outputs/old-run --to ../archive --apply
163
+ ```
164
+
165
+ `archive` moves folders and logs each move. It refuses sources, goldens, their inputs and any folder that contains one. Nothing is ever deleted.
166
+
167
+ ## State
168
+
169
+ Shared state lives in `~/.orrin`. Set `ORRIN_HOME` or `--home` to put it elsewhere. Every agent on the machine must use the same location, so the default is per user, not per repository. On Windows with WSL, pick one side for jobs and locks: a Windows process and a Linux process do not see each other's PIDs.
170
+
171
+ ## Related
172
+
173
+ [speedloop](https://github.com/snehoza/speedloop) does noise-aware speed measurement. It came out of the same project, and works well inside `orrin jobs`.
174
+
175
+ ## License
176
+
177
+ MIT
orrin-1.0.0/README.md ADDED
@@ -0,0 +1,156 @@
1
+ # orrin
2
+
3
+ Keep a coding agent working on a project around the clock, alone or with a team of worker agents, without it drifting from what you want.
4
+
5
+ What makes that work isn't a fixed rule set. It is a small loop:
6
+ - **An anchor:** a status file that is always true.
7
+ - **A heartbeat:** a check-in on a regular beat that looks at usage, jobs and workers, then acts.
8
+ - **Rules from corrections:** each correction becomes a dated rule the same day, and the rule it replaces is superseded.
9
+ - **A decision boundary:** what the agent decides alone, and what needs you.
10
+ - **Independent verification** of every result.
11
+
12
+ The kit gives you that loop and the tools that grew out of running it:
13
+
14
+ - **`orrin checkin`**: the heartbeat. Usage from any provider, failed or stalled jobs, quiet workers, a status file that fell behind the commits.
15
+ - **A memory layer for the lead:** `WORKING_WITH_USER.md` (how this user wants to be worked with, built from their corrections with `rule add --for coordinator`), `LEAD_HANDOFF.md` (the lead's own state, flagged when stale), `SETTLED.md` (ideas already measured, so nobody retries them; the check-in flags lookalike tasks) and the check-in prompt's own history.
16
+ - **Agents from your harness:** `agents_command` wraps any harness's agent list. The check-in then sees agents that never post: quiet ones, ones with too large a context, and two strong models on one account.
17
+ - **`orrin lint`** keeps instructions from making agents rigid: it flags token budgets, capitalised `MUST`/`NEVER`, rules without a reason, rules tied to one case, and too many rules. It also lists rules worth reviewing, because they hurt or their failure came back. Skills and rules say plainly that the user's current request comes first.
18
+ - **`orrin stop-check`** for a harness stop hook: the lead keeps going when it still has work it can do (at most three short items, capped, never for things that need you), instead of idling until the next beat.
19
+ - **`orrin task`**: a task list where "done" needs a passing check or a completed job as evidence, so agents can't declare victory early. Failures from before the work don't count against it (`task baseline`), and a check that was quietly changed is refused.
20
+ - **`orrin rule add/retire`**: rules that evolve, with your words, the date and their history. Rendered into the agents' rules file along with the decision boundary and model policy from `orrin.json`. `rule outcome` logs whether a rule helped, hurt, or let its failure come back.
21
+ - **Detached jobs** survive the agent that started them, and their completion markers can't lie. **Short blocking waits** keep agents cheap and still able to hear messages.
22
+ - **A fair machine lock,** first come first served, with an exclusive mode for heavy work and a shared mode for tests. It is safe when a holder crashes.
23
+ - **A lane board, one status screen, and tidy,** which repairs stale state without losing data.
24
+ - **A protected-data registry:** cleanup only ever archives.
25
+ - **Two [Agent Skills](https://agentskills.io):** one for the lead session, one for workers. Plus brief and handoff templates, and a list of lessons to adopt when their problem shows up.
26
+
27
+ Standard-library Python 3.11+, no daemon, state in plain files. Linux, macOS and Windows.
28
+
29
+ Why it works is in [the write-up](https://github.com/snehoza/orrin/blob/main/docs/WRITEUP.md). The failures behind each tool are in [the notes](https://github.com/snehoza/orrin/blob/main/docs/NOTES.md).
30
+
31
+ ## Install
32
+
33
+ pip install orrin
34
+
35
+ This gives you the `orrin` command (`python -m orrin` works too).
36
+
37
+ ## Thirty seconds of it
38
+
39
+ ```sh
40
+ # run a long job detached, holding the machine lock (exclusive by default)
41
+ orrin jobs launch --name lane1-tests --min-free-mb 2000 -- python -m pytest -q
42
+
43
+ # wait up to 3 minutes; exit 0 done, 1 failed, 3 still running (call again)
44
+ orrin wait lane1-tests
45
+
46
+ # a short command that must not run beside heavy jobs
47
+ orrin lock run --shared -- python scripts/check.py
48
+
49
+ # who is doing what
50
+ orrin board set --lane lane1 --worktree ../proj-lane1 --activity "speed round" --next "timing run" --eta 15:30
51
+ orrin status
52
+ ```
53
+
54
+ What `status` looks like:
55
+
56
+ ```
57
+ MACHINE: 16 CPUs | available 6120 MiB | load 38%
58
+ LOCK machine: held by lane2-gate (exclusive, 12m)
59
+ queued: lane1-timing (exclusive, waiting 3m)
60
+ JOBS (3 active or recent):
61
+ lane2-gate: running [lane2] 41/99 eta 17m
62
+ lane1-timing: waiting-lock [lane1]
63
+ lane3-smoke: done [lane3]
64
+ LANE BOARD (information only; decisions go through the coordinator)
65
+ lane1: live | gpt-x | speed round | next timing run eta 15:30 | updated 4m ago
66
+ ```
67
+
68
+ ## Jobs
69
+
70
+ `orrin jobs launch --name N -- CMD` starts CMD detached, so it survives the agent's turn, terminal and session. Its files go in `~/.orrin/jobs/N/`:
71
+
72
+ | File | Contents |
73
+ |---|---|
74
+ | `N.log` | Everything CMD prints |
75
+ | `N.pid` | The runner's PID and process start time |
76
+ | `N.done` | `EXIT=<code> COMPLETE=<0|1> REASON=<ok|failed|fail-fast|stopped|lock-timeout|ram-guard|...> <time>` |
77
+
78
+ A job is accepted only with `COMPLETE=1` in the marker **and** `JOB_COMPLETE N` in the log.
79
+
80
+ Before CMD runs, the runner:
81
+ - waits for the machine lock (`--lock exclusive|shared|none`);
82
+ - waits for free memory (`--min-free-mb`).
83
+
84
+ While CMD runs:
85
+ - a line starting `ERROR `, `FATAL ` or `JOB_FATAL ` stops it at once;
86
+ - `PROGRESS n/N` lines feed the ETA;
87
+ - `--smoke 1` sets `ORRIN_SMOKE=1`, so a batch job can run one item first.
88
+
89
+ `orrin jobs stop N` stops CMD's whole process tree.
90
+
91
+ ## The lock
92
+
93
+ `exclusive` holders run alone. `shared` holders run together, but never beside an exclusive holder and never ahead of an exclusive ticket that is already waiting. Waiters are served in arrival order. Holders that die are noticed by PID and start time, and dropped. Nesting is refused, because it would deadlock.
94
+
95
+ From Python:
96
+
97
+ ```python
98
+ from orrin.lock import FairLock
99
+
100
+ with FairLock(label="benchmark", timeout=600):
101
+ run_benchmark()
102
+ ```
103
+
104
+ ## Set up the loop
105
+
106
+ ```sh
107
+ orrin init # orrin.json + docs/agents/
108
+ ```
109
+
110
+ `orrin init` writes:
111
+ - `orrin.json`: settings as data:
112
+ - the status file;
113
+ - the heartbeat (beat, quiet-lane minutes, status drift);
114
+ - `usage_commands`;
115
+ - the decision `boundary` (`decide` and `ask`);
116
+ - `models` (roles, fallback order, checkpoint threshold).
117
+ - `docs/agents/AGENT_RULES.md`: a short frame plus a generated block (decision boundary, models and budget, live rules). Point your `AGENTS.md` or `CLAUDE.md` at it.
118
+ - `docs/agents/HEARTBEAT.md`: the check-in prompt. Schedule it with your harness's loop or cron.
119
+ - `docs/agents/LESSONS.md`: rules from a real project, each tied to the symptom that calls for it. Adopt one when you see its symptom, not on day one.
120
+ - `docs/agents/briefs/` (lane, research, review/judging, finish), `HANDOFF.md`, and an example `protected_data.json`.
121
+
122
+ Then the coordinator records corrections as they come:
123
+
124
+ ```sh
125
+ orrin rule add "Wait in 3-minute blocking calls" --why "long waits left agents deaf for 10 min" --supersedes R4
126
+ orrin rule list --all
127
+ orrin checkin --quiet
128
+ ```
129
+
130
+ The skills in [`skills/`](https://github.com/snehoza/orrin/tree/main/skills) follow the open Agent Skills format:
131
+ - `orrin` is for the lead session: anchor, heartbeat, corrections, workers, verification.
132
+ - `orrin-lane` is for workers: jobs, waits, the lock, the board, handoffs.
133
+
134
+ To install them, copy the folders into your agent's skills directory, e.g. `.claude/skills/` for Claude Code; other agents document where skills live. They need only a shell and Python. Every command is listed in [`COMMANDS.md`](https://github.com/snehoza/orrin/blob/main/skills/orrin/references/COMMANDS.md).
135
+
136
+ ## Protected data
137
+
138
+ ```sh
139
+ orrin data --registry protected_data.json check # sources exist; goldens are self-contained
140
+ orrin data --registry protected_data.json scan ./outputs # size, age, and why each folder is kept
141
+ orrin data --registry protected_data.json archive ./outputs/old-run --to ../archive --apply
142
+ ```
143
+
144
+ `archive` moves folders and logs each move. It refuses sources, goldens, their inputs and any folder that contains one. Nothing is ever deleted.
145
+
146
+ ## State
147
+
148
+ Shared state lives in `~/.orrin`. Set `ORRIN_HOME` or `--home` to put it elsewhere. Every agent on the machine must use the same location, so the default is per user, not per repository. On Windows with WSL, pick one side for jobs and locks: a Windows process and a Linux process do not see each other's PIDs.
149
+
150
+ ## Related
151
+
152
+ [speedloop](https://github.com/snehoza/speedloop) does noise-aware speed measurement. It came out of the same project, and works well inside `orrin jobs`.
153
+
154
+ ## License
155
+
156
+ MIT
@@ -0,0 +1,7 @@
1
+ """orrin: run several coding agents on one machine without them tripping over each other.
2
+
3
+ Detached jobs with completion markers, a fair machine lock, short blocking waits, a lane board,
4
+ a one-screen status, state tidying and a protected-data registry. Standard library only.
5
+ """
6
+
7
+ __version__ = "1.0.0"
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ raise SystemExit(main())
@@ -0,0 +1,96 @@
1
+ """The lane board: who is working where, on what, and what heavy job comes next.
2
+
3
+ Information only. A board entry never blocks anyone and grants nothing; decisions and approvals go
4
+ through the coordinator. Entries go stale (and are ignored) when they are older than ``stale_h``
5
+ hours, their PID is gone, or the job they are bound to has finished.
6
+
7
+ One JSON file per lane under ``<home>/board/``; ``done`` moves the file to ``board/archive/``.
8
+ """
9
+ from __future__ import annotations
10
+
11
+ import time
12
+ from pathlib import Path
13
+
14
+ from . import jobs, procs
15
+ from .home import check_name, home, human_age, mutex, read_json, write_json
16
+
17
+ FIELDS = ("worktree", "branch", "model", "activity", "next", "eta", "job")
18
+
19
+
20
+ def board_dir(root=None) -> Path:
21
+ path = home(root) / "board"
22
+ path.mkdir(parents=True, exist_ok=True)
23
+ return path
24
+
25
+
26
+ def update(lane: str, fields: dict | None = None, note: str | None = None, pid: int | None = None, root=None) -> dict:
27
+ check_name(lane, "lane")
28
+ base = board_dir(root)
29
+ with mutex(base / ".mutex"):
30
+ path = base / f"{lane}.json"
31
+ row = read_json(path) or {"lane": lane, "notes": [], "started": time.time()}
32
+ row.update({k: v for k, v in (fields or {}).items() if v is not None})
33
+ if pid:
34
+ row["pid"], row["pid_ident"] = pid, procs.identity(pid)
35
+ if note:
36
+ row["notes"].append({"time": time.time(), "text": note})
37
+ row["notes"] = row["notes"][-50:]
38
+ row["updated"] = time.time()
39
+ write_json(path, row)
40
+ return row
41
+
42
+
43
+ def done(lane: str, root=None) -> Path | None:
44
+ check_name(lane, "lane")
45
+ base = board_dir(root)
46
+ with mutex(base / ".mutex"):
47
+ path = base / f"{lane}.json"
48
+ if not path.exists():
49
+ return None
50
+ (base / "archive").mkdir(exist_ok=True)
51
+ target = base / "archive" / f"{lane}-{time.strftime('%Y%m%d-%H%M%S')}.json"
52
+ path.replace(target)
53
+ return target
54
+
55
+
56
+ def read(root=None, stale_h: float = 2.0, jobs_out=None, now: float | None = None) -> list[dict]:
57
+ now = now or time.time()
58
+ rows = []
59
+ for path in sorted(board_dir(root).glob("*.json")):
60
+ row = read_json(path)
61
+ if not isinstance(row, dict):
62
+ continue
63
+ reasons = []
64
+ if now - row.get("updated", 0) > stale_h * 3600:
65
+ reasons.append(f"not updated for {human_age(now - row.get('updated', 0))}")
66
+ if row.get("pid") and not procs.alive(row["pid"], row.get("pid_ident")):
67
+ reasons.append("process gone")
68
+ if row.get("job"):
69
+ try:
70
+ state = jobs.status(jobs.resolve(row["job"], jobs_out, root))["state"]
71
+ except ValueError:
72
+ state = "missing"
73
+ if state not in ("running", "waiting-lock", "waiting-ram", "starting"):
74
+ reasons.append(f"bound job {state}")
75
+ rows.append(dict(row, stale=bool(reasons), stale_reasons=reasons))
76
+ return rows
77
+
78
+
79
+ def render(rows: list[dict], now: float | None = None) -> str:
80
+ now = now or time.time()
81
+ if not rows:
82
+ return "LANE BOARD: empty"
83
+ out = ["LANE BOARD (information only; decisions go through the coordinator)"]
84
+ for row in rows:
85
+ bits = [row.get("model", "?"), row.get("activity", "-")]
86
+ if row.get("next"):
87
+ bits.append(f"next {row['next']}" + (f" eta {row['eta']}" if row.get("eta") else ""))
88
+ out.append(f"{row['lane']}: {'STALE' if row['stale'] else 'live'} | " + " | ".join(bits)
89
+ + f" | updated {human_age(now - row.get('updated', now))} ago")
90
+ if row.get("worktree"):
91
+ out.append(f" worktree {row['worktree']}" + (f" ({row['branch']})" if row.get("branch") else ""))
92
+ if row["stale"]:
93
+ out.append(" stale: " + ", ".join(row["stale_reasons"]))
94
+ for note in row.get("notes", [])[-3:]:
95
+ out.append(f" note {time.strftime('%m-%d %H:%M', time.localtime(note['time']))}: {note['text']}")
96
+ return "\n".join(out)