hubkit-cli 0.4.1__tar.gz → 0.6.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.
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/CHANGELOG.md +31 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/PKG-INFO +4 -2
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/README.md +2 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/SKILL.md +12 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/config.example.toml +10 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/docs/architecture.md +25 -1
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/docs/commands.md +12 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/docs/configuration.md +15 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/pyproject.toml +2 -2
- hubkit_cli-0.6.0/scripts/hubcore/checkup.py +239 -0
- hubkit_cli-0.6.0/scripts/hubcore/claims.py +333 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/cli.py +65 -9
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/compat.py +14 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/config.py +10 -3
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/gate.py +62 -4
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/hooks.py +75 -9
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/inbound.py +27 -7
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/lessons.py +27 -1
- hubkit_cli-0.6.0/scripts/hubcore/logwatch.py +92 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/orders.py +258 -64
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/playbooks.py +20 -1
- hubkit_cli-0.6.0/scripts/hubcore/priority.py +318 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/redact.py +19 -15
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/replies.py +1 -1
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/routed.py +14 -4
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/slow.py +3 -3
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/status.py +37 -10
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/store.py +33 -1
- hubkit_cli-0.6.0/scripts/hubcore/tasks.py +827 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/watcher.py +4 -2
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/run_reverts.py +68 -0
- hubkit_cli-0.6.0/tests/test_auto_open.py +57 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_blockers.py +1 -1
- hubkit_cli-0.6.0/tests/test_checkup.py +202 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_hubkit.py +29 -14
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_learning_rules.py +11 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_lessons.py +8 -0
- hubkit_cli-0.6.0/tests/test_mistakes_1116.py +584 -0
- hubkit_cli-0.6.0/tests/test_priority.py +356 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_replies.py +1 -1
- hubkit_cli-0.6.0/tests/test_tasks.py +722 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_watcher.py +1 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/.github/workflows/ci.yml +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/.gitignore +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/CLAUDE.md +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/CONTRIBUTING.md +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/LICENSE +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/SECURITY.md +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/docs/troubleshooting.md +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/intents.example.toml +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/llms.txt +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/references/design-sources.md +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/references/research.md +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/__init__.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/agentio.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/eodclock.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/gatectl.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/guardwatch.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/install.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/learnings.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/ledger.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/lifecycle.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/mergestate.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/nopr.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/owed.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/preroute.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/reportcheck.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/reviewdebt.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/reviewreport.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/roster.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/stale.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/standing.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/standrules.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/sweeps.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/threads.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubcore/trust.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/hubkit +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/scripts/learn.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/skills/hub-mep/SKILL.md +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/skills/hubkit-setup/SKILL.md +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/conftest.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/ghkit.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_agent_cli.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_compat.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_eodclock.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_gate_strength.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_guards2.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_inbound.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_install.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_intake_learning.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_ledger.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_lifecycle.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_mergestate.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_own_work.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_peer_reports.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_playbooks.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_preroute.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_redact_inplace.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_reportcheck.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_requests.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_review_chain.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_reviewdebt.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_roster.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_slow.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_stale_nopr.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_standrules.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_state_rules.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_threads.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_tool_guards.py +0 -0
- {hubkit_cli-0.4.1 → hubkit_cli-0.6.0}/tests/test_tool_routing_guards.py +0 -0
|
@@ -2,6 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
4
4
|
|
|
5
|
+
## [0.6.0] - 2026-11-25
|
|
6
|
+
|
|
7
|
+
Brings in everything the live hub had that the public package lacked, so a switch-over loses nothing. One implementation each where task tracking and priority tracking overlapped: `tasks.py` owns tasks; `priority.py` and `checkup.py` keep only the non-task rows.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Priority items (`priority.py`): urgent words and "check msgs" asks open a priority item that leads every prompt and blocks the stop until a first action is recorded (`hubkit work act ID --note ".." [--inbox-read]`).
|
|
11
|
+
- `hubkit checkup [done]` and `checkup interval [min]`: read-only view of open tasks, routed and active rows and live peers, with one nudge each; `interval` is the same setting as `hubkit tasks interval`.
|
|
12
|
+
- Claims check (`claims.py`): never-ask and batch-recipient warnings, `claims` and `never-ask` stop-gate checks.
|
|
13
|
+
- Release-log watcher (`logwatch.py`): `hubkit log ls|ack`, `[watcher] log_globs` and `log_max_age_h`.
|
|
14
|
+
- `hubkit inbound scan`, review-ask items marked `REVIEW ASK`, `unordered-act`, `inbox-watch`, `checkup`, `logwatch` and `urgent` stop-gate checks, `doctor` warning while `auto_open` is on, playbook `act` steps, ETA holds in routed work.
|
|
15
|
+
- Awake-time clock (`store.awake_min`): task and check-up intervals skip the time the machine was off.
|
|
16
|
+
- Config `[priority] inbox_tools` (default `gmail`, `zulip`, `slack`, `chat`): name parts of MCP tools whose read counts as an inbox read.
|
|
17
|
+
- Config: `[checkup]` is still read as the legacy name of `[tasks] interval_min` and `eta_default_min`; `batch_to`.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- "don't mark W1 finished" (any `n't` form) no longer closes W1: the negation guard now covers contractions.
|
|
21
|
+
- `hubkit status` shows at most three REGRESSED lines and folds the rest into one, so routed work is not pushed out of the capped block.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Stored state masks a bare 40-hex or 32-hex id unless it sits under a head field (`head`, `heads`, `old`, `new`, `commit`, `oid`, `verdict_acked`), as the live hub always did; `hubkit doctor` counts it the same way. `redact()` on plain text still keeps such ids in prose.
|
|
25
|
+
- A scan of stored watcher output that finds nothing new no longer writes `work.json`; review-ask reply lines read `reply W1 REVIEW ASK name`, and `status` lists replies before routed work.
|
|
26
|
+
- Build backend pinned to `hatchling==1.27.0`: newer hatchling writes Metadata-Version 2.5, which twine 6.2 rejects.
|
|
27
|
+
|
|
28
|
+
## [0.5.0] - 2026-11-25
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
- Tasks (`tasks.py`): when the user's typed prompt gives tasks ("tasks:", "todo" and typos, a numbered list introduced as tasks, "new task ..."), the prompt hook opens one priority item per task and opens no order. A question, a status ask, peer or harness text, pasted or quoted text and filenames open nothing. A task is open until the user's typed word names it ("mark W5 finished") or, once it has a done-when criterion (`hubkit work criterion ID --done-when ".."`, or "done when ..." in the prompt; after a `;` it covers every task of the line), `hubkit work done ID --evidence <merged PR URL|file:path>` proves it: a file must exist and postdate the task, a PR must be merged on GitHub, any other page is refused. With no criterion and no word `work done` is refused (exit 3). A criterion the hub wrote is marked as the hub's.
|
|
32
|
+
- Each task lists its workers (`hubkit work assign`, or a SendMessage/Agent brief that names the task id, its PR or clearly its title) and says so when it has none. `hubkit tasks` lists open tasks (no worker first) with the nudge; `hubkit tasks interval N` and `[tasks] interval_min` (15) set the check interval, `hubkit work every ID --minutes N` one task's; the watch exits with `TASK CHECK DUE` when one is due; `hubkit tasks done` restarts the clocks and a missed nudge becomes a re-brief to another owner. hubkit sends nothing.
|
|
33
|
+
- Stop-gate check `task`: while a task is open the turn may end only if each has a live worker inside its ETA, an `ask` item naming it, or a named blocker (`hubkit work block ID --on .. --fix .. --holder ..`), and a watch runs; the same reason blocks at most twice per turn. The user's "stop" holds every open task and says so; "stop W5" or "pause the login bug" holds that one; "resume" frees them.
|
|
34
|
+
- Fast track means first in every list, a shorter clock, an earlier re-brief and never queued behind other work; it never bypasses a guard, a permission prompt, a denial or any deploy, merge or message rule. New `[tasks]` keys.
|
|
35
|
+
|
|
5
36
|
## [0.4.1] - 2026-11-12
|
|
6
37
|
|
|
7
38
|
First release since 0.2.4; versions 0.3.0 and 0.4.0 were not published separately. This one holds both: the new trackers and checks, and the lifecycle table with the agent-friendly CLI.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: hubkit-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Session supervisor for Claude Code: hooks-based multi-agent orchestration with order clocks, routed-work tracking, a watchdog and a stop gate, standard library only.
|
|
5
5
|
Project-URL: Repository, https://github.com/ankitkpandey1/hubkit
|
|
6
6
|
Project-URL: Documentation, https://github.com/ankitkpandey1/hubkit/tree/main/docs
|
|
@@ -67,6 +67,7 @@ In a live hub, the prompt hook opens that order itself from your sentence, and t
|
|
|
67
67
|
- **Routed-work tracking.** A hook on `SendMessage` and `Agent` records what the hub asked of whom, one item per (owner, PR). It follows last heard-from, moved heads and GitHub reviews at the PR head.
|
|
68
68
|
- **Standing rules, review debt, stale items.** `hubkit standing add` saves what you said to do every time ("when peer-b approves, merge it"; "route review asks to the reviewer") with your quote; when it fires hubkit opens the order or item and prints the exact NEXT, and the hub does the action. `hubkit mine` also shows the re-reviews you owe and marks open items whose PR is already merged or closed. `report.eod_time` makes the tick write the end-of-day review itself.
|
|
69
69
|
- **Peer roster and pre-route checks.** `hubkit peers` shows each peer's role and free/busy state, learned from its own messages, with its record (jobs done, median time, late). The routed hook warns when work goes to a busy or wrong-role peer while a fitting one is free, when the PR is already merged, closed or reviewed at its head, and when a brief to a role lacks a line the config requires.
|
|
70
|
+
- **Tasks.** Say "tasks: 1. ... 2. ..." (or "todo") and each task becomes a priority item that stays open until you mark it finished or its done-when criterion is proven with evidence (a merged PR, or a file made after the task). Each lists who works on it, is checked every 15 minutes (or as you set), and holds the Stop gate until a live worker, a question to you or a named blocker covers it. `hubkit tasks` shows them. A task authorises no merge, release, deploy or message.
|
|
70
71
|
- **Watchdog and wake-up.** `hubkit tick` (cron) and `hubkit watch` (a background process) raise alerts with back-off; a watch exit wakes an idle hub.
|
|
71
72
|
- **Stop gate.** The Stop hook refuses to let the turn end while the hub owes something (no watch running, a stalled item, an unbacked verdict, a question to you that blocks nothing, a "tests pass" claim with no command run, a PR number with no link, an approval on red CI, a PR called ready to merge while GitHub shows changes requested or a block, a merged PR reported while a person who asked about it is not yet answered, built work not pushed).
|
|
72
73
|
- **Tool guards.** An optional warn-only PreToolUse hook (`hubkit hooks --merge-guard`) warns about an unordered merge, a post without your typed yes (typed after the draft it approves) or from the wrong account, a banned command, stopping an agent, an unmarked decision card, the hub editing files itself, two agents on one host and a review nobody asked for. It never denies.
|
|
@@ -172,6 +173,7 @@ Every key is documented in [docs/configuration.md](docs/configuration.md).
|
|
|
172
173
|
| A final message longer than `report.max_lines` or with a code block longer than `report.max_code_lines` (off until set) | Warning only |
|
|
173
174
|
| A Stop-gate check that you mark a false alarm 3 times (`hubkit gate false-alarm ID --why ..`) and that is 30% of its fires in 14 days downgrades itself from blocking to a next-prompt warning; a correction soon after restores it. `verdict`, `ci` and `merge-state` never downgrade. | Adaptive (`hubkit gate ls`) |
|
|
174
175
|
| A typed "from now on ..." style rule: the prompt hook says to save it with `learn.py add --class standing-rule` | Warning only |
|
|
176
|
+
| A task closes only on your word or evidence of its done-when; an open task with no live worker, no question to you and no named blocker holds the turn (twice per reason, then the turn may end with a note) | Enforced |
|
|
175
177
|
| An order closes only with the evidence its kind requires | Enforced (the close is refused) |
|
|
176
178
|
| A learned class counts as fixed only if a rule for it exists (and, with `--check`, its command passes) | Enforced (the address is refused) |
|
|
177
179
|
| A merge order closes only with the merge commit sha | Enforced (the close is refused) |
|
|
@@ -53,6 +53,7 @@ In a live hub, the prompt hook opens that order itself from your sentence, and t
|
|
|
53
53
|
- **Routed-work tracking.** A hook on `SendMessage` and `Agent` records what the hub asked of whom, one item per (owner, PR). It follows last heard-from, moved heads and GitHub reviews at the PR head.
|
|
54
54
|
- **Standing rules, review debt, stale items.** `hubkit standing add` saves what you said to do every time ("when peer-b approves, merge it"; "route review asks to the reviewer") with your quote; when it fires hubkit opens the order or item and prints the exact NEXT, and the hub does the action. `hubkit mine` also shows the re-reviews you owe and marks open items whose PR is already merged or closed. `report.eod_time` makes the tick write the end-of-day review itself.
|
|
55
55
|
- **Peer roster and pre-route checks.** `hubkit peers` shows each peer's role and free/busy state, learned from its own messages, with its record (jobs done, median time, late). The routed hook warns when work goes to a busy or wrong-role peer while a fitting one is free, when the PR is already merged, closed or reviewed at its head, and when a brief to a role lacks a line the config requires.
|
|
56
|
+
- **Tasks.** Say "tasks: 1. ... 2. ..." (or "todo") and each task becomes a priority item that stays open until you mark it finished or its done-when criterion is proven with evidence (a merged PR, or a file made after the task). Each lists who works on it, is checked every 15 minutes (or as you set), and holds the Stop gate until a live worker, a question to you or a named blocker covers it. `hubkit tasks` shows them. A task authorises no merge, release, deploy or message.
|
|
56
57
|
- **Watchdog and wake-up.** `hubkit tick` (cron) and `hubkit watch` (a background process) raise alerts with back-off; a watch exit wakes an idle hub.
|
|
57
58
|
- **Stop gate.** The Stop hook refuses to let the turn end while the hub owes something (no watch running, a stalled item, an unbacked verdict, a question to you that blocks nothing, a "tests pass" claim with no command run, a PR number with no link, an approval on red CI, a PR called ready to merge while GitHub shows changes requested or a block, a merged PR reported while a person who asked about it is not yet answered, built work not pushed).
|
|
58
59
|
- **Tool guards.** An optional warn-only PreToolUse hook (`hubkit hooks --merge-guard`) warns about an unordered merge, a post without your typed yes (typed after the draft it approves) or from the wrong account, a banned command, stopping an agent, an unmarked decision card, the hub editing files itself, two agents on one host and a review nobody asked for. It never denies.
|
|
@@ -158,6 +159,7 @@ Every key is documented in [docs/configuration.md](docs/configuration.md).
|
|
|
158
159
|
| A final message longer than `report.max_lines` or with a code block longer than `report.max_code_lines` (off until set) | Warning only |
|
|
159
160
|
| A Stop-gate check that you mark a false alarm 3 times (`hubkit gate false-alarm ID --why ..`) and that is 30% of its fires in 14 days downgrades itself from blocking to a next-prompt warning; a correction soon after restores it. `verdict`, `ci` and `merge-state` never downgrade. | Adaptive (`hubkit gate ls`) |
|
|
160
161
|
| A typed "from now on ..." style rule: the prompt hook says to save it with `learn.py add --class standing-rule` | Warning only |
|
|
162
|
+
| A task closes only on your word or evidence of its done-when; an open task with no live worker, no question to you and no named blocker holds the turn (twice per reason, then the turn may end with a note) | Enforced |
|
|
161
163
|
| An order closes only with the evidence its kind requires | Enforced (the close is refused) |
|
|
162
164
|
| A learned class counts as fixed only if a rule for it exists (and, with `--check`, its command passes) | Enforced (the address is refused) |
|
|
163
165
|
| A merge order closes only with the merge commit sha | Enforced (the close is refused) |
|
|
@@ -54,6 +54,8 @@ A human prompt containing an order word (words come from `intents.toml`; hotfix,
|
|
|
54
54
|
- **(d) Before saying something is gone or absent, read the code that writes it.** A missing file, row or log line is proof of nothing until you know what produces it and when. *Checked in code:* a final message that says something is gone, lost or absent, with no lookup in that turn, is held the same way.
|
|
55
55
|
- **(e) A brief must not forbid the one action that clears the blocker.** Before sending a brief, check its banned-command list against the step the order needs. *Checked in code:* the routed hook warns when a brief's "do not / never" line shares a key word with an open order's blocker or fix.
|
|
56
56
|
|
|
57
|
+
**His urgent words lead (enforced in code, class `priority-not-applied`).** A prompt with "urgent", "code red", "top priority", "asap" (or a typo) opens one priority work item quoting him, and a "check msgs" ask needs an inbox read first. Until `hubkit work act <id> --note ".."` (`--inbox-read` for a messages ask) the hooks lead with it and fold old STALLED/OVERDUE lines under it. It is not an order and authorises no merge, release, deploy or message. After a sleep gap (no heartbeat for 30 min) stall clocks do not count the gap.
|
|
58
|
+
|
|
57
59
|
## 4. Live status and routed work
|
|
58
60
|
|
|
59
61
|
`hubkit work add --kind active|tracked|priority --title "..." [--owner X]`, `hubkit work done <id> --note "..."`, `hubkit work ls`. The work file holds only live items; finished ones move to `archive/archive_<day>.jsonl`. `hubkit status` rebuilds the block. Before saying anything is pending on the user, section 5 applies.
|
|
@@ -81,6 +83,16 @@ Silence on routed work past `stall_min` (reviews: `review_stall_min`, hard `OVER
|
|
|
81
83
|
|
|
82
84
|
`hubkit doctor` prints the bind, heartbeat ages (`seen/cron` is touched by every `tick`, so it tells a dead cron from an idle one), hook errors and a count of secret-shaped strings in state (never the strings).
|
|
83
85
|
|
|
86
|
+
### Tasks the user gives
|
|
87
|
+
|
|
88
|
+
When the user's typed prompt gives tasks ("tasks:", "todo", a numbered list introduced as tasks, "new task ..."), the prompt hook opens one priority item per task (a list is split; a prompt that names none makes one item quoting it; a question, "what tasks are running?", peer or harness text, pasted content and filenames open nothing). A task is priority: first in every list, never queued behind other work, open until it is finished. It authorises no merge, release, deploy or message, and the prompt opens no order.
|
|
89
|
+
|
|
90
|
+
- **Finish.** The user's typed word naming it ("mark W5 finished", "the login fix is done"; never a question or a peer's text), or `hubkit work done ID --evidence <merged PR URL|file:path>` once a criterion exists (`hubkit work criterion ID --done-when "..."`, or "done when ..." in the prompt; after a `;` it covers every task of the line, inside one task it covers that task). A file must exist and postdate the task; a PR must be merged on GitHub; any other page is refused (save the proof to a file). With no criterion and no word, `work done` is refused (exit 3). A criterion you wrote is marked as yours.
|
|
91
|
+
- **Workers.** `hubkit work assign ID --owner X`; a SendMessage or Agent brief that names the task id, its PR number or clearly its title records its recipient as a worker. A task with no worker says so.
|
|
92
|
+
- **Clock.** Every `[tasks] interval_min` (15) minutes: `hubkit tasks interval N`, per task `hubkit work every ID --minutes N`. The watch exits with `TASK CHECK DUE`; `hubkit tasks` lists them (no worker first) with the nudge; send it or re-brief, then `hubkit tasks done`. hubkit sends nothing.
|
|
93
|
+
- **Stop gate (check `task`).** The turn may end only if each open task has a live worker inside its ETA, or waits on the user (an `ask` item naming it), or on a named blocker (`hubkit work block ID --on .. --fix .. --holder ..`), and a watch runs. After two blocks for the same reason in one turn the stop is allowed with a line saying what is open. "stop" holds every open task (and says so), "stop W5" or "pause the login bug" holds that one; "resume" frees them.
|
|
94
|
+
- **Fast track** ("by hook or crook") means first in every list, a shorter clock, a re-brief to another owner after one missed nudge, and never queued behind other work. It never bypasses a guard, a permission prompt, a denial or any deploy, merge or message rule.
|
|
95
|
+
|
|
84
96
|
## 7. Reporting
|
|
85
97
|
|
|
86
98
|
- At most 15 lines. Lead with what changed or what the user must decide. Tag claims verified / read / inferred. Full URLs. Times in the user's zone.
|
|
@@ -34,6 +34,7 @@ timeout_s = 30 # default 30
|
|
|
34
34
|
|
|
35
35
|
[watchdog]
|
|
36
36
|
transcript_scan_hours = 24
|
|
37
|
+
hook_error_window_h = 6 # only hook failures newer than this alert
|
|
37
38
|
|
|
38
39
|
[stop_guard]
|
|
39
40
|
# Log only. A final message ending in "?" or containing one of these, while an order is open,
|
|
@@ -77,6 +78,15 @@ floor_min = 2 # never SLOW under this many minutes
|
|
|
77
78
|
tool_min = 2 # a tool running this long is named in the why
|
|
78
79
|
scan_kb = 2048 # tail of a transcript read for the why
|
|
79
80
|
|
|
81
|
+
[tasks]
|
|
82
|
+
# interval_min = 15 # minutes between checks of a task you gave; `hubkit tasks interval N` overrides
|
|
83
|
+
# eta_default_min = 30 # a task worker's ETA when its brief stated none
|
|
84
|
+
|
|
85
|
+
[checkup]
|
|
86
|
+
# interval_min = 30 # minutes between check-ups of the rows that are not tasks
|
|
87
|
+
# task_interval_min = 15 # legacy name of [tasks] interval_min; still read when [tasks] does not set it
|
|
88
|
+
# task_eta_default_min = 30 # legacy name of [tasks] eta_default_min
|
|
89
|
+
|
|
80
90
|
[watcher]
|
|
81
91
|
stuck_min = 30 # hub busy this long with live jobs = stuck
|
|
82
92
|
unhandled_min = 10 # an alert this old and no hub heartbeat since = unhandled
|
|
@@ -62,6 +62,26 @@ An order is a row family in `orders.jsonl` (`open`, `move`, `hold`, `resume`, `c
|
|
|
62
62
|
- **Chases.** A short prompt matching `intake.chase` while an order is open is recorded as a chase. Three chases print a stop-loss line.
|
|
63
63
|
- **Close.** `order close` requires every evidence name the kind's `done_when` lists; `file:<path>` evidence must exist and be newer than the order. Evidence names in the kind's `sha_evidence` (the merge kind's `merged`) must hold a commit sha. A closed order is archived under `archive/archive_<day>.jsonl`.
|
|
64
64
|
|
|
65
|
+
## Priority intake (`priority.py`)
|
|
66
|
+
|
|
67
|
+
Class `priority-not-applied`: what he says is urgent must lead, in code.
|
|
68
|
+
|
|
69
|
+
- **Intake.** A typed prompt with an urgent word ("urgent", "asap", "code red", "top/high priority", and typos such as "urgnt", "priotity") opens one `lead` work item (kind `priority`) quoting him; later prompts within 10 minutes, or while it has no first action, update it instead of adding a row. It is NOT an order: it authorises no merge, release, deploy or message, and `auto_open = false` for orders is unchanged.
|
|
70
|
+
- **Inbox ask.** "check msgs", "read msg", "is X msg done?" make the item need an inbox read as its first action. `work act --inbox-read` or an inbox-reading tool call after the ask (an `mep` command, an agent briefed on the inbox, a mail or chat read tool) clears it; a plain `work act` does not.
|
|
71
|
+
- **Lead.** While a lead item has no first action, the prompt hook and the stop hook print its `hubkit PRIORITY` line first (the stop hook blocks on it), and every `hubkit STALLED`/`OVERDUE` line is folded into one count line under it. The watchdog alerts after 5 minutes. A routed `SendMessage`/`Agent` is the first action of a plain item.
|
|
72
|
+
- **Gaps.** Every heartbeat (`touch_seen`) first checks the newest file in `seen/`; older than 30 minutes, the quiet spell goes to `gaps.jsonl`, and routed stall/overdue clocks and order clocks subtract it (`store.awake_min`). Not yet applied to `slow.py` estimates.
|
|
73
|
+
|
|
74
|
+
## Tasks he gives (`priority.py` tasks section, `checkup.py`, `gate.task_reasons`)
|
|
75
|
+
|
|
76
|
+
`priority.parse_tasks` reads his typed prompt (the hook has already dropped peer, harness and pasted text) and `task_intake` opens one `kind: priority` item with `task: true`, `workers`, `done_when`, optional `every_min`, `blocker`, `held`. Old items lack these keys and behave as before (legacy priority items are never gated as tasks). `status.work_done` routes a task through `priority.done_proof`: his word, or evidence of the criterion. `checkup.task_rows` lists tasks first; `task_alerts` feeds the watchdog when a task's own interval passed; `checkup done` restarts the clocks and counts missed nudges (one miss means re-brief). `gate.task_reasons` blocks the stop for a task with no live worker inside its ETA, no ask and no blocker; `limit_task_repeats` lets the turn end after two blocks of the same reason. Fast track orders lists and clocks only; it never bypasses a guard, permission prompt, denial or the deploy, merge and message rules.
|
|
77
|
+
|
|
78
|
+
## Check-ups, ETA and stored review asks (`checkup.py`, `routed.eta_holds`, `inbound.scan_stored`)
|
|
79
|
+
|
|
80
|
+
- **Check-up.** `hubkit checkup` lists items and peers with live session state; `due_line` goes in the prompt and stop hooks and as a `checkup:due` watchdog alert while 30 awake minutes passed since `checkup done` and an item is not reported-within-ETA. Hubkit sends nothing.
|
|
81
|
+
- **ETA.** A routed item whose estimate was stated (not defaulted by the hook) has no stall level until that many awake minutes passed since the ask, so no STALLED line and no re-brief step before then.
|
|
82
|
+
- **Session names.** `store.norm_name` drops a trailing `[ref]`, so a session named `peer [93f867]` matches the owner `peer` everywhere `slow.holder_session` is used (the "no live session of that name" false alarm).
|
|
83
|
+
- **Review asks.** Lines in `mep_watch*.out` that hold a review or re-review word and a PR become `REVIEW ASK` reply items, once per message id, shown in the status block until `work done`. Only stored text is read; a thread that is not in stored state needs the inbox, which hubkit does not read.
|
|
84
|
+
|
|
65
85
|
## Routed work (`routed.py`)
|
|
66
86
|
|
|
67
87
|
A routed item is one outcome per (owner, PR number), or per owner when no PR is named, in `work.json`.
|
|
@@ -102,7 +122,11 @@ One piece of work is up to four records: the user's ask (an order or a request),
|
|
|
102
122
|
- **Closing.** When the last member of a live root is closed (a routed item archived on evidence, a reply sent), the tick alerts `<root> "<title>": every step under it is closed (...). NEXT: hubkit req done|order close ...` (the order form prefilled with the evidence names, the PR URL and the sha found in the members' notes), and `work done` prints it at once. Closing a root with members still open prints a warning naming them; it does not refuse. A reply is marked due by `replies.note_states` as before; the thread shows it as owed to the person.
|
|
103
123
|
- **Declared check for work with no PR.** A line `Done-when: <text>` in a non-review brief (`routed.done_when_markers`) is stored as `done_when`. When the owner reports done the nudge names it, and `work done` on that item without `--note` is refused (exit 3). A non-review brief with no PR and no such line gets a warn-only hook line (`routed.require_done_when`).
|
|
104
124
|
|
|
105
|
-
##
|
|
125
|
+
## Tasks the user gives (`tasks.py`)
|
|
126
|
+
|
|
127
|
+
`tasks.parse_tasks` reads a typed human prompt (the hook has dropped peer, harness and pasted text) and `task_intake` opens one `kind: priority` item with `task: true`, `workers`, `done_when`, optional `every_min`, `blocker`, `held`. Other priority items lack these keys and are never gated as tasks. A prompt that opens tasks opens no order and no request. `done_proof` closes a task on the user's word, or on evidence of its criterion (a merged PR read from GitHub, or a file that exists and postdates the task). `note_workers` (the routed hook) records a brief's recipient as a worker when the brief names the task. `task_rows` gives each task a state (reported-within-ETA, no-worker, idle, overdue, waiting on a prompt); `alerts` feeds the watchdog when a task's own interval passed; `check_done` restarts the clocks and counts a missed nudge (one miss means re-brief). The Stop-gate check `task` blocks a task with no live worker inside its ETA, no ask naming it and no named blocker; the same reason blocks at most twice per turn, then the Stop hook lets the turn end with a `systemMessage` naming what is open. Minutes are wall-clock. Fast track orders lists and clocks only; it never bypasses a guard, permission prompt, denial or the deploy, merge and message rules.
|
|
128
|
+
|
|
129
|
+
## Watchdog (`status.py`)## Watchdog (`status.py`)
|
|
106
130
|
|
|
107
131
|
`hubkit tick` evaluates: no first action, no movement, passed deadline, unconfirmed expiry, a hold longer than `held_review_min`, routed-item ladders, hook failures found by scanning transcripts for failures of hubkit's own hooks, and extension checks. It repairs half-archived orders, rewrites `status.json`, appends `alerts.jsonl` with back-off (one alert per condition per order, repeats at 10, 20, 30 minutes) and runs `tools.notify_cmd`. It runs from cron (`--if-bound`) and inside `hubkit watch`.
|
|
108
132
|
|
|
@@ -27,6 +27,14 @@
|
|
|
27
27
|
| `order open\|confirm\|move\|block\|result\|hold\|resume\|cancel\|close` | Change an order | write | no |
|
|
28
28
|
| `order metrics` | A day's orders and chases | read | always JSON |
|
|
29
29
|
| `work ls` | Live work items | read | yes: `{"work": [...]}` |
|
|
30
|
+
| `tasks [ls\|check]` | Open tasks the user gave (no worker first): state, who holds each, done-when and the nudge. Read-only; hubkit sends nothing. | read | no |
|
|
31
|
+
| `tasks done` | Record that the tasks were checked now (restarts their clocks; an uncovered task counts a missed nudge, and the next nudge is a re-brief). | write | no |
|
|
32
|
+
| `tasks interval [N]` | Show or set the minutes between checks of tasks (default `[tasks] interval_min`, 15). | write | no |
|
|
33
|
+
| `work criterion ID --done-when ".."` | Task: what finished means, in words evidence can prove. | write | no |
|
|
34
|
+
| `work assign ID --owner X` | Task: record the agent or peer that holds it (a brief naming the task does this by itself). | write | no |
|
|
35
|
+
| `work every ID --minutes N` | Task: its own check interval (0 clears). | write | no |
|
|
36
|
+
| `work block ID --on .. --fix .. --holder ..` | For a task: a named blocker needs all three. | write | no |
|
|
37
|
+
| `work done ID --evidence <merged PR URL\|file:path>` | For a task: close it with evidence of its done-when (it also closes on the user's typed word). Refused with exit 3 otherwise. | write | no |
|
|
30
38
|
| `work add\|done\|estimate\|block\|verify` | Change work items | write | no |
|
|
31
39
|
| `req ls` | Open requests (with parts); `--learned`: the verbs intake muted and why | read | yes: `{"requests": [...]}`; `--learned`: `{"muted", "keys", "misses"}` |
|
|
32
40
|
| `req show ID` | The full record: text, parts, notes, chases, age | read | yes: `{"request": {...}}` |
|
|
@@ -74,6 +82,10 @@
|
|
|
74
82
|
| `hubkit mine` | Read only: everything open, grouped by whose court it is in (the user, the hub, peers and agents, other people), one line each with id, age, title and link. Under the user it lists the PRs they owe a re-review on (`[review_debt]`); under the hub, standing rules that fired and are not yet acted on; an item whose every named PR is merged or closed ends with ` — PR merged 2d ago, probably stale; last activity 5d ago` (`[stale]`, at most `stale.max_reads` gh reads, warn only). |
|
|
75
83
|
| `hubkit standing ls` / `add --on approved\|inbound --quote ".." --action ".." [--repo OWNER/NAME] [--pr URL] [--from PERSON] [--word WORD] [--kind ORDERKIND] [--cmd "CMD"] [--until DATE]` / `drop ID --quote ".."` | Standing rules: what the user said to do every time something happens. `add` is refused without the user's quote and an action; `drop` without their words. `approved` fires on a counting non-author approval at the current head of a PR hubkit tracks (routed, reply or order PRs, or the rule's `--pr`); `inbound` fires on a new ask from `inbound ingest`, scoped by `--from` and/or `--word`. A firing opens an order (the action names an order kind such as merge, or `--kind`) or an `active` work item, prints one line with the user's quote and the exact NEXT (for a merge: `standing.approved_cmd` with the head sha, `--match-head-commit <sha>`; `--cmd` replaces it; CI red or pending turns it into a hold), once per PR head or message. hubkit never runs the action. `--until` takes `2026-12-01` or `2026-12-01 18:00` in the user's zone; an expired rule does not fire. |
|
|
76
84
|
| `hubkit asks ls [--since 12h]` | The user's recent prompts (from `recent-prompts.jsonl`), one line each, newest last. Marks the asks as re-read for the Stop gate. |
|
|
85
|
+
| `hubkit work act ID --note "..." [--inbox-read]` | Record the first action on a priority item the prompt hook opened from the user's urgent words or a "check msgs" ask. An item with no first action leads every prompt and blocks the stop. |
|
|
86
|
+
| `hubkit checkup [done]` / `checkup interval [min]` | Read-only view of every open task, routed or active item and each recent live peer, with its live session state and the one nudge; `done` records that the hub sent the nudges. `interval` shows or sets the task check interval (the same setting as `hubkit tasks interval`). |
|
|
87
|
+
| `hubkit inbound scan` | Open a reply item for each review or re-review ask already in the stored watcher output (`mep_watch*.out` in the state dir). It never reads the chat itself. |
|
|
88
|
+
| `hubkit log ls` / `ack KEY` | Release-log lines that need a person (`[watcher] log_globs`); `ack` records that one was reported. |
|
|
77
89
|
| `hubkit order block ID --on "..." [--fix "..."] [--holder who]` | Record what blocks an order and the fix running now (a second call with the same `--on` adds the fix). No fix, or a fix older than `blocker_fix_min` with no result, alerts and holds the Stop gate. |
|
|
78
90
|
| `hubkit order result ID --note "..."` | Record the result of an action: movement, clears the blocker and any STOP-LOSS. Notes from `order move` do neither. |
|
|
79
91
|
| `hubkit order hold ID --quote "..."` / `resume ID` | Hold (with the user's words) and resume. |
|
|
@@ -61,6 +61,7 @@ Other environment variables: `HUBKIT_SESSIONS` (directory of Claude Code session
|
|
|
61
61
|
| Key | Default | Meaning |
|
|
62
62
|
|---|---|---|
|
|
63
63
|
| `transcript_scan_hours` | `24` | How far back to scan transcripts for hubkit hook failures. |
|
|
64
|
+
| `hook_error_window_h` | `6` | A hook failure older than this (by its own timestamp) is not counted or alerted. |
|
|
64
65
|
| `cron_stale_min` | `15` | `doctor` flags `seen/cron` as stale when the crontab runs hubkit and the file is older than this. |
|
|
65
66
|
|
|
66
67
|
### `[requests]`
|
|
@@ -81,6 +82,14 @@ Estimates and the slowness check (hub-internal, see architecture).
|
|
|
81
82
|
| `tool_min` | `2` | A tool running this long is named in the why. |
|
|
82
83
|
| `scan_kb` | `2048` | Tail of a transcript read for the why (tool names and queue operations only). |
|
|
83
84
|
|
|
85
|
+
### `[priority]`
|
|
86
|
+
|
|
87
|
+
`inbox_tools` (`["gmail", "zulip", "slack", "chat"]`): name parts that make an MCP tool a chat or mail reader, so a read through it counts as the first action on an inbox item. Add the name of your own chat product.
|
|
88
|
+
|
|
89
|
+
### `[checkup]`
|
|
90
|
+
|
|
91
|
+
`interval_min` (30): minutes between check-ups of routed, active and peer rows. `task_interval_min` (15): minutes between checks of tasks he gave; `hubkit checkup interval <min>` overrides it per state dir. `task_eta_default_min` (30): a task worker's ETA when no estimate was given.
|
|
92
|
+
|
|
84
93
|
### `[watcher]`
|
|
85
94
|
|
|
86
95
|
| Key | Default | Meaning |
|
|
@@ -136,6 +145,12 @@ Estimates and the slowness check (hub-internal, see architecture).
|
|
|
136
145
|
| `max_reads` | `8` | gh reads per run. |
|
|
137
146
|
| `gh_timeout_s` | `5` | Timeout of each read. |
|
|
138
147
|
|
|
148
|
+
### `[tasks]` (tasks the user gives)
|
|
149
|
+
| Key | Default | Meaning |
|
|
150
|
+
|---|---|---|
|
|
151
|
+
| `interval_min` | `15` | Minutes between checks of a task; `hubkit tasks interval N` overrides it for a state dir, `hubkit work every ID --minutes N` for one task. |
|
|
152
|
+
| `eta_default_min` | `30` | A task worker's ETA when its brief stated no estimate. |
|
|
153
|
+
|
|
139
154
|
### `[gate]`
|
|
140
155
|
| Key | Default | Meaning |
|
|
141
156
|
|---|---|---|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["hatchling"]
|
|
2
|
+
requires = ["hatchling==1.27.0"] # newer hatchling writes Metadata-Version 2.5, which twine 6.2 rejects
|
|
3
3
|
build-backend = "hatchling.build"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "hubkit-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.6.0"
|
|
8
8
|
description = "Session supervisor for Claude Code: hooks-based multi-agent orchestration with order clocks, routed-work tracking, a watchdog and a stop gate, standard library only."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.14"
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"""Worker check-ups (class `workers-not-nudged`): every open routed or active item and every recent peer, with its live
|
|
2
|
+
session state, sorted into reported-within-ETA / idle / overdue / waiting-on-permission-prompt / free.
|
|
3
|
+
|
|
4
|
+
TASKS he gave (priority.py) are listed first and checked on their own, shorter interval ([checkup] task_interval_min, default
|
|
5
|
+
15; `hubkit checkup interval <min>`; per task `hubkit work every <id> --minutes N`). Other rows keep EVERY_MIN (30).
|
|
6
|
+
A task's row says who holds it, whether that worker is live and inside its ETA, and the nudge; a task past one nudge is
|
|
7
|
+
re-briefed to another owner at once (fast track). Fast track never bypasses a guard, a permission prompt, a denial or a
|
|
8
|
+
deploy/merge/message rule: it only orders the lists and shortens the clocks.
|
|
9
|
+
|
|
10
|
+
Read-only. hubkit never sends a message: the hub reads the view and sends the nudges, then runs `hubkit checkup done`.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import time
|
|
16
|
+
|
|
17
|
+
from . import routed, status, store, tasks
|
|
18
|
+
|
|
19
|
+
EVERY_MIN = 30
|
|
20
|
+
NOWORKER = "no-worker"
|
|
21
|
+
OVERRIDE_FILE = "checkup.json"
|
|
22
|
+
WITHIN, IDLE, OVERDUE, WAITING, FREE = (
|
|
23
|
+
"reported-within-ETA",
|
|
24
|
+
"idle",
|
|
25
|
+
"overdue",
|
|
26
|
+
"waiting-on-permission-prompt",
|
|
27
|
+
"free",
|
|
28
|
+
)
|
|
29
|
+
WAITING_STATES = ("waiting", "blocked", "needs_input", "permission")
|
|
30
|
+
PEER_RECENT_H = 24
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def every_min(cfg: dict) -> float:
|
|
34
|
+
"""Minutes between check-ups of the non-task rows."""
|
|
35
|
+
return float(cfg.get("checkup", {}).get("interval_min", EVERY_MIN))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def set_interval(cfg: dict, minutes: int) -> str:
|
|
39
|
+
"""Set the task check interval for this state dir (tasks.py owns it)."""
|
|
40
|
+
tasks.set_interval(cfg, minutes)
|
|
41
|
+
return f"task check interval is {minutes} min (non-task rows: {int(every_min(cfg))} min)"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _routed_state(cfg: dict, i: dict, ss: dict, now: float) -> tuple[str, str]:
|
|
45
|
+
if ss.get("waiting"):
|
|
46
|
+
return WAITING, "answer its prompt in that session, or re-brief"
|
|
47
|
+
base = routed.base(cfg, i)
|
|
48
|
+
heard = (
|
|
49
|
+
f"heard {int(store.awake_min(cfg, i['last_heard'], now))}m ago"
|
|
50
|
+
if i.get("last_heard")
|
|
51
|
+
else "never heard"
|
|
52
|
+
)
|
|
53
|
+
if routed.eta_holds(cfg, i, now):
|
|
54
|
+
left = int(
|
|
55
|
+
float(i["estimate_min"])
|
|
56
|
+
- store.awake_min(cfg, routed.started_at(cfg, i), now)
|
|
57
|
+
)
|
|
58
|
+
return WITHIN, f"{heard}; its ETA has {left}m left"
|
|
59
|
+
est = i.get("estimate_min")
|
|
60
|
+
late = routed.overdue(cfg, i, now) is not None or (
|
|
61
|
+
est is not None
|
|
62
|
+
and store.awake_min(cfg, routed.started_at(cfg, i), now) > float(est)
|
|
63
|
+
)
|
|
64
|
+
if store.awake_min(cfg, base, now) <= routed.limit(cfg, i) and not late:
|
|
65
|
+
return WITHIN, heard
|
|
66
|
+
return (
|
|
67
|
+
(OVERDUE if late else IDLE),
|
|
68
|
+
f"{heard}; silent {int(store.awake_min(cfg, base, now))}m (limit {int(routed.limit(cfg, i))})",
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _own_state(i: dict, now: float) -> tuple[str, str]:
|
|
73
|
+
est = i.get("estimate_min")
|
|
74
|
+
spent = (now - float(i["added"])) / 60
|
|
75
|
+
if est is None:
|
|
76
|
+
return IDLE, f"no estimate, {int(spent)}m spent"
|
|
77
|
+
return (
|
|
78
|
+
(WITHIN, f"{int(spent)}m of {float(est):g}m")
|
|
79
|
+
if spent <= float(est)
|
|
80
|
+
else (OVERDUE, f"{int(spent)}m spent, estimate {float(est):g}m")
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _nudged(cfg: dict, i: dict, now: float) -> bool:
|
|
85
|
+
"""The hub already chased this owner: at the current silence step, or within the last EVERY_MIN minutes."""
|
|
86
|
+
lvl = routed.eff_level(cfg, i, now)
|
|
87
|
+
at_step = lvl is not None and i.get("chased_level") is not None and i["chased_level"] >= lvl
|
|
88
|
+
return at_step or any(store.awake_min(cfg, float(t), now) < every_min(cfg) for t in i.get("addressed", []))
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def rows(cfg: dict, now: float) -> list[dict]:
|
|
92
|
+
"""Tasks first, then one row per open routed or active item, then one per recent live peer holding nothing (free)."""
|
|
93
|
+
out: list[dict] = tasks.task_rows(cfg, now)
|
|
94
|
+
owners: set[str] = set()
|
|
95
|
+
for i in routed.items(cfg):
|
|
96
|
+
ss = tasks.session_state(cfg, i["owner"])
|
|
97
|
+
state, why = _routed_state(cfg, i, ss, now)
|
|
98
|
+
owners.add(store.norm_name(i["owner"]))
|
|
99
|
+
out.append(
|
|
100
|
+
{
|
|
101
|
+
"id": i["id"],
|
|
102
|
+
"who": i["owner"],
|
|
103
|
+
"item": i["title"][:50],
|
|
104
|
+
"state": state,
|
|
105
|
+
"why": why,
|
|
106
|
+
"session": ss["text"],
|
|
107
|
+
"socket": ss.get("socket"),
|
|
108
|
+
"nudged": _nudged(cfg, i, now),
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
for i in status.work_load(store.state(cfg)):
|
|
112
|
+
if i.get("kind") == "active" and not i["title"].startswith("draft: "):
|
|
113
|
+
state, why = _own_state(i, now)
|
|
114
|
+
out.append(
|
|
115
|
+
{
|
|
116
|
+
"id": i["id"],
|
|
117
|
+
"who": "hub",
|
|
118
|
+
"item": i["title"][:50],
|
|
119
|
+
"state": state,
|
|
120
|
+
"why": why,
|
|
121
|
+
"session": "this session",
|
|
122
|
+
"socket": None,
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
for name, ts in sorted(routed.peers(cfg).items(), key=lambda kv: -float(kv[1])):
|
|
126
|
+
if store.norm_name(name) in owners or now - float(ts) > PEER_RECENT_H * 3600:
|
|
127
|
+
continue
|
|
128
|
+
ss = tasks.session_state(cfg, name)
|
|
129
|
+
if ss["live"]:
|
|
130
|
+
out.append(
|
|
131
|
+
{
|
|
132
|
+
"id": "-",
|
|
133
|
+
"who": name,
|
|
134
|
+
"item": "",
|
|
135
|
+
"state": WAITING if ss["waiting"] else FREE,
|
|
136
|
+
"why": f"last wrote {int((now - float(ts)) / 60)}m ago",
|
|
137
|
+
"session": ss["text"],
|
|
138
|
+
"socket": ss.get("socket"),
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
return out
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def nudge(r: dict) -> str:
|
|
145
|
+
"""The one action for a row. The hub sends it; hubkit never does."""
|
|
146
|
+
if r.get("task"):
|
|
147
|
+
return tasks.task_nudge(r["task_item"], r["state"])
|
|
148
|
+
if r["state"] == WAITING:
|
|
149
|
+
return f"ask the user to answer {r['who']}'s prompt, or re-brief {r['id']}"
|
|
150
|
+
if r["state"] in (IDLE, OVERDUE):
|
|
151
|
+
return (
|
|
152
|
+
f"SendMessage {r['who']}: one-line state and a new ETA for {r['id']}"
|
|
153
|
+
if r["who"] != "hub"
|
|
154
|
+
else f"finish {r['id']} or re-estimate it"
|
|
155
|
+
)
|
|
156
|
+
return ""
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def last_done(cfg: dict) -> float:
|
|
160
|
+
rs = store.read_rows(store.state(cfg, create=False) / "checkups.jsonl")[0]
|
|
161
|
+
return max((float(r["ts"]) for r in rs), default=0.0)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def render(cfg: dict, now: float | None = None) -> list[str]:
|
|
165
|
+
now = now or time.time()
|
|
166
|
+
rs = rows(cfg, now)
|
|
167
|
+
last = last_done(cfg)
|
|
168
|
+
out = [
|
|
169
|
+
f"checkup: {len(rs)} row(s); last checkup {'never' if not last else str(int(store.awake_min(cfg, last, now))) + ' min ago (awake)'}; "
|
|
170
|
+
f"tasks every {int(tasks.task_interval_min(cfg))} min, other rows every {int(every_min(cfg))} min; hubkit sends nothing, you do"
|
|
171
|
+
]
|
|
172
|
+
for r in rs:
|
|
173
|
+
sock = (
|
|
174
|
+
""
|
|
175
|
+
if r["socket"] is None
|
|
176
|
+
else (", socket ok" if r["socket"] else ", no socket")
|
|
177
|
+
)
|
|
178
|
+
out.append(
|
|
179
|
+
f" {r['id']:<6} {r['who'][:22]:<22} {r['state']:<28} {r['item']} | {r['why']} | session: {r['session']}{sock}"
|
|
180
|
+
+ (f" | TASK, done-when: {r['done_when']}" if r.get("task") else "")
|
|
181
|
+
)
|
|
182
|
+
if n := nudge(r):
|
|
183
|
+
out.append(f" NEXT: {n}")
|
|
184
|
+
return out
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def done(cfg: dict) -> str:
|
|
188
|
+
"""Record that the check-up was done now (the hub has sent its nudges)."""
|
|
189
|
+
now = time.time()
|
|
190
|
+
rs = rows(cfg, now)
|
|
191
|
+
store.append_row(
|
|
192
|
+
store.state(cfg) / "checkups.jsonl",
|
|
193
|
+
{
|
|
194
|
+
"items": len([r for r in rs if r["id"] != "-"]),
|
|
195
|
+
"not_within": len(
|
|
196
|
+
[r for r in rs if r["id"] != "-" and r["state"] != WITHIN]
|
|
197
|
+
),
|
|
198
|
+
},
|
|
199
|
+
)
|
|
200
|
+
late = {r["id"]: r["state"] != WITHIN and tasks.task_cover(cfg, r["task_item"], now) is not None for r in rs if r.get("task")} # covered by an ask or a blocker is not a missed nudge
|
|
201
|
+
sd = store.state(cfg)
|
|
202
|
+
with store.locked(sd / "work.lock"):
|
|
203
|
+
items = status.work_load(sd)
|
|
204
|
+
for i in items:
|
|
205
|
+
if i.get("task") and i["id"] in late:
|
|
206
|
+
i["checked"] = now
|
|
207
|
+
i["nudges"] = int(i.get("nudges", 0)) + 1 if late[i["id"]] else 0
|
|
208
|
+
status.work_save(sd, items)
|
|
209
|
+
return f"checkup recorded; next due in {int(every_min(cfg))} min (tasks: {int(tasks.task_interval_min(cfg))} min)"
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def due_line(cfg: dict, now: float) -> str:
|
|
213
|
+
"""A line when EVERY_MIN awake minutes passed without a checkup and any item is not reported-within-ETA, else empty."""
|
|
214
|
+
last = last_done(cfg)
|
|
215
|
+
if last and store.awake_min(cfg, last, now) < every_min(cfg):
|
|
216
|
+
return ""
|
|
217
|
+
bad = [r for r in rows(cfg, now) if r["id"] != "-" and not r.get("task") and r["state"] != WITHIN and not r.get("nudged")]
|
|
218
|
+
if not bad:
|
|
219
|
+
return ""
|
|
220
|
+
names = ", ".join(r["id"] for r in bad[:8])
|
|
221
|
+
return (
|
|
222
|
+
f"hubkit CHECKUP DUE: {len(bad)} item(s) not reported within ETA: {names}, last checkup "
|
|
223
|
+
f"{'never' if not last else str(int(store.awake_min(cfg, last, now))) + ' min ago'}. NEXT: hubkit checkup, SendMessage each idle or overdue "
|
|
224
|
+
"owner for a one-line state and an ETA (the hub sends; hubkit never does), then: hubkit checkup done"
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def alerts(cfg: dict, now: float) -> list[dict]:
|
|
229
|
+
"""Watchdog: the same line, so the watch wakes the hub when a checkup is due."""
|
|
230
|
+
line = due_line(cfg, now)
|
|
231
|
+
return [{"key": "checkup:due", "msg": line}] if line else [] # task check alerts come from tasks.alerts (watcher.checks)
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def interval_of(cfg: dict, task: dict) -> float:
|
|
235
|
+
return tasks.interval_of(cfg, task)
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def task_interval_min(cfg: dict) -> float:
|
|
239
|
+
return tasks.task_interval_min(cfg)
|