teaimforge 0.19.0__tar.gz → 0.20.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.
- teaimforge-0.20.0/CHANGELOG.md +54 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/PKG-INFO +1 -1
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/__init__.py +1 -1
- teaimforge-0.20.0/src/teaimforge/autonomy.py +329 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/backup.py +1 -1
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/cli.py +244 -1
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/config.py +10 -2
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/domain.py +16 -0
- teaimforge-0.20.0/src/teaimforge/escalations.py +260 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/events.py +4 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/identity.py +6 -2
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/items.py +77 -2
- teaimforge-0.20.0/src/teaimforge/runs.py +440 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/walls.py +34 -2
- teaimforge-0.20.0/tests/test_autonomy.py +474 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_backup.py +1 -1
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_cli.py +94 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_config.py +4 -0
- teaimforge-0.19.0/CHANGELOG.md +0 -26
- {teaimforge-0.19.0 → teaimforge-0.20.0}/.gitignore +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/LICENSE +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/NOTICE +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/README.md +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/pyproject.toml +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/archive.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/errors.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/findings.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/gates.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/index.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/insights.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/ledger.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/messages.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/migrate.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/output.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/paths.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/py.typed +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/schema.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/ulid.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/upgrade.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/versions.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/views.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/src/teaimforge/workflow.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/conftest.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_archive.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_basics.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_events.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_findings.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_gates.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_identity.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_index.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_items.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_ledger.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_messages.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_migrate.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_parents.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_walls.py +0 -0
- {teaimforge-0.19.0 → teaimforge-0.20.0}/tests/test_workflow.py +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
|
|
5
|
+
[Semantic Versioning](https://semver.org/). Until 1.0, a minor version may
|
|
6
|
+
change the API; team plugins should pin one (`teaimforge>=0.19,<0.20`).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.20.0] - 2026-12-03
|
|
11
|
+
|
|
12
|
+
Teams can now run on their own at a level the operator chooses, and say when
|
|
13
|
+
they are blocked. No migration is needed; existing projects stay at `gated`.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- Autonomy levels: `supervised`, `gated` (default), `delegated` and
|
|
18
|
+
`unattended`, per project, with items held lower. Lowering is immediate;
|
|
19
|
+
only the operator raises, at the desk. `autonomy show`, `autonomy set`.
|
|
20
|
+
- Go-aheads: at `supervised`, a move needs the operator's `go ID`. A move
|
|
21
|
+
without one is refused and escalated once.
|
|
22
|
+
- Runs: `run start` parks items whose escalations went unanswered and returns
|
|
23
|
+
the work plan; `run status`; `run end` with an outcome.
|
|
24
|
+
- Budgets: tool calls and minutes per run (counted by the lane-guard hook),
|
|
25
|
+
and self-reported tokens per item (`budget report`). By default they warn
|
|
26
|
+
and work goes on. With `limits.budget_mode: enforce`, a run past its budget
|
|
27
|
+
refuses further tool calls from team roles (the orchestrator can still
|
|
28
|
+
report and end the run), and an item past its tokens cannot be moved by the
|
|
29
|
+
team until the operator raises the limit. The operator is never stopped.
|
|
30
|
+
- Retry limits: a domain maps states to `build_attempts` or `verify_cycles`;
|
|
31
|
+
a move past the limit is refused and escalated (`Domain.entry_limits`).
|
|
32
|
+
- Escalations, said once per subject: `escalation raise`, `escalation
|
|
33
|
+
resolve`, and `inbox` for everything waiting on the operator. An
|
|
34
|
+
escalation left unanswered past `escalation.park_after` parks its item.
|
|
35
|
+
- Config: `limits.run_minutes`, `limits.run_tool_calls`,
|
|
36
|
+
`limits.budget_mode`, `escalation.park_after`. Events: `run`, `autonomy`, `go`, `escalation`.
|
|
37
|
+
|
|
38
|
+
## [0.19.0] - 2026-12-02
|
|
39
|
+
|
|
40
|
+
First public release. Earlier versions were carried inside each team plugin as
|
|
41
|
+
a vendored copy; team plugins now depend on this package instead.
|
|
42
|
+
|
|
43
|
+
### Included
|
|
44
|
+
|
|
45
|
+
- Event log: append-only, hash-chained, locked and fsynced, with `verify`,
|
|
46
|
+
upgrade on read and `migrate` for schema changes.
|
|
47
|
+
- Strict, team-extensible configuration and project discovery.
|
|
48
|
+
- A command-line engine teams extend with their own commands and options.
|
|
49
|
+
- Pinned role identity and a lane-guard hook; walls that limit reads and writes
|
|
50
|
+
by role, by item state and by the content an item points at.
|
|
51
|
+
- Items with parents, workflows with named checks (including `children_in`),
|
|
52
|
+
gates with per-kind rulings, findings, insights and relayed messages.
|
|
53
|
+
- A SQLite index, a generated ledger, archives that keep non-text files beside
|
|
54
|
+
the rollup, and age-encrypted backups with verified restores.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: teaimforge
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.20.0
|
|
4
4
|
Summary: The core for AI team plugins for Claude Code: event log, workflows, gates, roles and walls
|
|
5
5
|
Project-URL: Repository, https://github.com/jknyght9/teaimforge
|
|
6
6
|
Project-URL: Issues, https://github.com/jknyght9/teaimforge/issues
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""Autonomy: how much the team does without asking.
|
|
3
|
+
|
|
4
|
+
| Level | The team… |
|
|
5
|
+
|---|---|
|
|
6
|
+
| ``supervised`` | asks before every workflow move: a move needs the operator's go-ahead |
|
|
7
|
+
| ``gated`` | works freely between gates; the operator rules every gate |
|
|
8
|
+
| ``delegated`` | gated, plus standing approvals for routine decisions (to come) |
|
|
9
|
+
| ``unattended`` | delegated, and wakes on a schedule or a signal (to come) |
|
|
10
|
+
|
|
11
|
+
The project's level starts as ``config.yaml``'s ``autonomy`` and changes with
|
|
12
|
+
``autonomy`` events. An item may be held lower than the project, never higher.
|
|
13
|
+
Three rules hold at every level:
|
|
14
|
+
|
|
15
|
+
- Some decisions never delegate: gates are always the operator's, and desk-only
|
|
16
|
+
gates and item types stay at the desk.
|
|
17
|
+
- Lowering is immediate (the operator or the orchestrator); raising is the
|
|
18
|
+
operator's alone, and only at the desk.
|
|
19
|
+
- Silence is never consent: a move waiting on a go-ahead is escalated, and an
|
|
20
|
+
escalation left unanswered parks the item (escalations.py).
|
|
21
|
+
|
|
22
|
+
Moves to ``PARKED`` and the operator's own moves never need a go-ahead.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
from collections.abc import Iterable, Mapping
|
|
28
|
+
from dataclasses import dataclass
|
|
29
|
+
from typing import TYPE_CHECKING, Any
|
|
30
|
+
|
|
31
|
+
from .domain import OPERATOR, ORCHESTRATOR, Domain
|
|
32
|
+
from .errors import ExitCode, ForgeError
|
|
33
|
+
from .escalations import close_in, fold_escalations, raise_in
|
|
34
|
+
from .events import EventStore, Transaction
|
|
35
|
+
from .identity import Identity
|
|
36
|
+
from .paths import Layout
|
|
37
|
+
|
|
38
|
+
if TYPE_CHECKING:
|
|
39
|
+
from .items import Item
|
|
40
|
+
|
|
41
|
+
LEVELS: tuple[str, ...] = ("supervised", "gated", "delegated", "unattended")
|
|
42
|
+
SUPERVISED = "supervised"
|
|
43
|
+
INHERIT = "inherit"
|
|
44
|
+
MAX_NOTE = 500
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def rank(level: str) -> int:
|
|
48
|
+
return LEVELS.index(level)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@dataclass(frozen=True)
|
|
52
|
+
class Level:
|
|
53
|
+
"""An item's (or the project's) autonomy, and where it comes from."""
|
|
54
|
+
|
|
55
|
+
level: str
|
|
56
|
+
project: str
|
|
57
|
+
held: str | None = None # the item's own, lower level, if any
|
|
58
|
+
|
|
59
|
+
def as_dict(self) -> dict[str, Any]:
|
|
60
|
+
return {"level": self.level, "project": self.project, "held": self.held}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def project_level(events: Iterable[Mapping[str, Any]], config: Mapping[str, Any]) -> str:
|
|
64
|
+
"""The project's level: the last change, or ``config.yaml``'s ``autonomy``."""
|
|
65
|
+
level = str(config.get("autonomy") or "gated")
|
|
66
|
+
for event in events:
|
|
67
|
+
if event.get("type") == "autonomy" and "item" not in event:
|
|
68
|
+
level = event["data"]["level"]
|
|
69
|
+
return level
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def item_holds(events: Iterable[Mapping[str, Any]]) -> dict[str, str]:
|
|
73
|
+
"""Items held below the project, and at what level."""
|
|
74
|
+
held: dict[str, str] = {}
|
|
75
|
+
for event in events:
|
|
76
|
+
if event.get("type") == "autonomy" and "item" in event:
|
|
77
|
+
level = event["data"]["level"]
|
|
78
|
+
if level == INHERIT:
|
|
79
|
+
held.pop(event["item"], None)
|
|
80
|
+
else:
|
|
81
|
+
held[event["item"]] = level
|
|
82
|
+
return held
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def level_of(
|
|
86
|
+
events: Iterable[Mapping[str, Any]], config: Mapping[str, Any], item_id: str | None = None
|
|
87
|
+
) -> Level:
|
|
88
|
+
"""The level that applies: the project's, or the item's if it is held lower."""
|
|
89
|
+
seen = list(events)
|
|
90
|
+
project = project_level(seen, config)
|
|
91
|
+
if item_id is None:
|
|
92
|
+
return Level(project, project)
|
|
93
|
+
held = item_holds(seen).get(item_id)
|
|
94
|
+
if held is None or rank(held) >= rank(project):
|
|
95
|
+
return Level(project, project, held)
|
|
96
|
+
return Level(held, project, held)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def pending_go(events: Iterable[Mapping[str, Any]], item_id: str, target: str) -> str | None:
|
|
100
|
+
"""The unspent go-ahead for this move, if any: one given since the item last moved."""
|
|
101
|
+
found: str | None = None
|
|
102
|
+
for event in events:
|
|
103
|
+
if event.get("item") != item_id:
|
|
104
|
+
continue
|
|
105
|
+
if event.get("type") == "state":
|
|
106
|
+
found = None
|
|
107
|
+
elif event.get("type") == "go":
|
|
108
|
+
wanted = event["data"].get("to")
|
|
109
|
+
if wanted in (None, target):
|
|
110
|
+
found = event["id"]
|
|
111
|
+
return found
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def require_go( # noqa: PLR0913, PLR0917 - the move being checked, inside a held transaction
|
|
115
|
+
tx: Transaction,
|
|
116
|
+
events: list[dict[str, Any]],
|
|
117
|
+
config: Mapping[str, Any],
|
|
118
|
+
who: Identity,
|
|
119
|
+
item: Item,
|
|
120
|
+
target: str,
|
|
121
|
+
) -> str | None:
|
|
122
|
+
"""The go-ahead a move uses; ``None`` if it needs none.
|
|
123
|
+
|
|
124
|
+
A supervised move without one is escalated (once) and refused.
|
|
125
|
+
"""
|
|
126
|
+
from .workflow import PARKED # noqa: PLC0415 - workflow imports domain only
|
|
127
|
+
|
|
128
|
+
if who.role == OPERATOR or target == PARKED:
|
|
129
|
+
return None
|
|
130
|
+
level = level_of(events, config, item.id)
|
|
131
|
+
if level.level != SUPERVISED:
|
|
132
|
+
return None
|
|
133
|
+
go = pending_go(events, item.id, target)
|
|
134
|
+
if go is not None:
|
|
135
|
+
return go
|
|
136
|
+
esc = raise_in(
|
|
137
|
+
tx,
|
|
138
|
+
events,
|
|
139
|
+
who,
|
|
140
|
+
f"go:{item.id}",
|
|
141
|
+
f"ready to move {item.id} from {item.state} to {target}; waiting on your go-ahead",
|
|
142
|
+
item,
|
|
143
|
+
)
|
|
144
|
+
raise ForgeError(
|
|
145
|
+
ExitCode.REFUSED,
|
|
146
|
+
"needs_go_ahead",
|
|
147
|
+
f"{item.label()} is supervised: {item.state} → {target} needs the operator's "
|
|
148
|
+
f"go-ahead ({esc.id} is waiting on them). Carry on with other work.",
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class Autonomy:
|
|
153
|
+
"""Change autonomy and give go-aheads, as one pinned identity."""
|
|
154
|
+
|
|
155
|
+
def __init__(
|
|
156
|
+
self,
|
|
157
|
+
layout: Layout,
|
|
158
|
+
domain: Domain,
|
|
159
|
+
identity: Identity | None = None,
|
|
160
|
+
config: Mapping[str, Any] | None = None,
|
|
161
|
+
) -> None:
|
|
162
|
+
self.layout = layout
|
|
163
|
+
self.domain = domain
|
|
164
|
+
self.identity = identity
|
|
165
|
+
self.config: Mapping[str, Any] = config or {}
|
|
166
|
+
self.store = EventStore(layout, domain)
|
|
167
|
+
|
|
168
|
+
def _who(self) -> Identity:
|
|
169
|
+
if self.identity is None:
|
|
170
|
+
raise ForgeError(ExitCode.INTERNAL, "no_identity", "autonomy writes need an identity")
|
|
171
|
+
return self.identity
|
|
172
|
+
|
|
173
|
+
def level(self, item_id: str | None = None) -> Level:
|
|
174
|
+
return level_of(self.store.events(), self.config, item_id)
|
|
175
|
+
|
|
176
|
+
def held(self) -> dict[str, str]:
|
|
177
|
+
return item_holds(self.store.events())
|
|
178
|
+
|
|
179
|
+
def set(
|
|
180
|
+
self,
|
|
181
|
+
level: str,
|
|
182
|
+
*,
|
|
183
|
+
item_id: str | None = None,
|
|
184
|
+
channel: str = "console",
|
|
185
|
+
note: str | None = None,
|
|
186
|
+
) -> Level:
|
|
187
|
+
"""Change the project's level, or hold an item lower (``inherit`` releases it)."""
|
|
188
|
+
from .gates import LOCAL_CHANNELS, REMOTE_CHANNELS # noqa: PLC0415 - gates imports items
|
|
189
|
+
from .items import fold # noqa: PLC0415 - items imports this module
|
|
190
|
+
|
|
191
|
+
who = self._who()
|
|
192
|
+
if who.role not in (OPERATOR, ORCHESTRATOR):
|
|
193
|
+
raise ForgeError(
|
|
194
|
+
ExitCode.REFUSED,
|
|
195
|
+
"autonomy_not_yours",
|
|
196
|
+
f"only the operator or the orchestrator changes autonomy; this call runs as "
|
|
197
|
+
f"{who.role}",
|
|
198
|
+
)
|
|
199
|
+
choices = (*LEVELS, INHERIT) if item_id else LEVELS
|
|
200
|
+
if level not in choices:
|
|
201
|
+
raise ForgeError(
|
|
202
|
+
ExitCode.USAGE, "invalid_level", f"autonomy is one of {', '.join(choices)}"
|
|
203
|
+
)
|
|
204
|
+
if channel not in (*LOCAL_CHANNELS, *REMOTE_CHANNELS):
|
|
205
|
+
raise ForgeError(ExitCode.USAGE, "invalid_channel", f"no channel {channel!r}")
|
|
206
|
+
text = note.strip() if note else None
|
|
207
|
+
if text is not None and (not text or len(text) > MAX_NOTE):
|
|
208
|
+
raise ForgeError(ExitCode.USAGE, "invalid_note", f"notes are 1-{MAX_NOTE} characters")
|
|
209
|
+
with self.store.transaction() as tx:
|
|
210
|
+
events = list(tx.events())
|
|
211
|
+
item: Item | None = None
|
|
212
|
+
if item_id is not None:
|
|
213
|
+
item = fold(events, self.domain).get(item_id)
|
|
214
|
+
if item is None:
|
|
215
|
+
raise ForgeError(ExitCode.NOT_FOUND, "item_not_found", f"no item {item_id}")
|
|
216
|
+
before = level_of(events, self.config, item_id)
|
|
217
|
+
project = before.project
|
|
218
|
+
if item is not None and level not in (INHERIT, project) and rank(level) > rank(project):
|
|
219
|
+
raise ForgeError(
|
|
220
|
+
ExitCode.USAGE,
|
|
221
|
+
"above_project",
|
|
222
|
+
f"an item can be held below the project ({project}), not above it",
|
|
223
|
+
)
|
|
224
|
+
after = project if level == INHERIT else level
|
|
225
|
+
if item is not None:
|
|
226
|
+
after = min(after, project, key=rank)
|
|
227
|
+
raising = rank(after) > rank(before.level)
|
|
228
|
+
if raising and who.role != OPERATOR:
|
|
229
|
+
raise ForgeError(
|
|
230
|
+
ExitCode.REFUSED,
|
|
231
|
+
"operator_raises",
|
|
232
|
+
f"lowering is immediate, but only the operator raises autonomy "
|
|
233
|
+
f"({before.level} → {after})",
|
|
234
|
+
)
|
|
235
|
+
if raising and channel in REMOTE_CHANNELS:
|
|
236
|
+
raise ForgeError(
|
|
237
|
+
ExitCode.REFUSED,
|
|
238
|
+
"desk_only",
|
|
239
|
+
f"raising autonomy is decided at your desk (tui or console), not from "
|
|
240
|
+
f"{channel}",
|
|
241
|
+
)
|
|
242
|
+
data: dict[str, Any] = {"level": level, "from": before.level, "channel": channel}
|
|
243
|
+
if text:
|
|
244
|
+
data["note"] = text
|
|
245
|
+
tx.append(
|
|
246
|
+
"autonomy",
|
|
247
|
+
actor=who.role,
|
|
248
|
+
session=who.session,
|
|
249
|
+
data=data,
|
|
250
|
+
item=item.id if item else None,
|
|
251
|
+
title=item.title if item else None,
|
|
252
|
+
)
|
|
253
|
+
if raising and before.level == SUPERVISED:
|
|
254
|
+
self._release_waits(tx, who, events, item_id, after)
|
|
255
|
+
return level_of(self.store.events(), self.config, item_id)
|
|
256
|
+
|
|
257
|
+
def _release_waits(
|
|
258
|
+
self,
|
|
259
|
+
tx: Transaction,
|
|
260
|
+
who: Identity,
|
|
261
|
+
events: list[dict[str, Any]],
|
|
262
|
+
item_id: str | None,
|
|
263
|
+
level: str,
|
|
264
|
+
) -> None:
|
|
265
|
+
"""Close go-ahead escalations that no longer apply once autonomy rises."""
|
|
266
|
+
for esc in fold_escalations(events).values():
|
|
267
|
+
if not (esc.is_open and esc.subject.startswith("go:")):
|
|
268
|
+
continue
|
|
269
|
+
if item_id is not None and esc.item != item_id:
|
|
270
|
+
continue
|
|
271
|
+
if item_id is None and esc.item in item_holds(events):
|
|
272
|
+
continue
|
|
273
|
+
close_in(tx, who, esc, "resolved", f"autonomy raised to {level}; no go-ahead needed")
|
|
274
|
+
|
|
275
|
+
def go(
|
|
276
|
+
self,
|
|
277
|
+
item_id: str,
|
|
278
|
+
*,
|
|
279
|
+
to: str | None = None,
|
|
280
|
+
channel: str = "console",
|
|
281
|
+
note: str | None = None,
|
|
282
|
+
) -> dict[str, Any]:
|
|
283
|
+
"""The operator lets a supervised item make its next move (to ``to``, or any)."""
|
|
284
|
+
from .gates import LOCAL_CHANNELS, REMOTE_CHANNELS # noqa: PLC0415 - gates imports items
|
|
285
|
+
from .items import fold # noqa: PLC0415 - items imports this module
|
|
286
|
+
|
|
287
|
+
who = self._who()
|
|
288
|
+
if who.role != OPERATOR:
|
|
289
|
+
raise ForgeError(
|
|
290
|
+
ExitCode.REFUSED,
|
|
291
|
+
"operator_only",
|
|
292
|
+
f"only the operator gives go-aheads; this call runs as {who.role}",
|
|
293
|
+
)
|
|
294
|
+
if channel not in (*LOCAL_CHANNELS, *REMOTE_CHANNELS):
|
|
295
|
+
raise ForgeError(ExitCode.USAGE, "invalid_channel", f"no channel {channel!r}")
|
|
296
|
+
text = note.strip() if note else None
|
|
297
|
+
if text is not None and (not text or len(text) > MAX_NOTE):
|
|
298
|
+
raise ForgeError(ExitCode.USAGE, "invalid_note", f"notes are 1-{MAX_NOTE} characters")
|
|
299
|
+
with self.store.transaction() as tx:
|
|
300
|
+
events = list(tx.events())
|
|
301
|
+
item = fold(events, self.domain).get(item_id)
|
|
302
|
+
if item is None:
|
|
303
|
+
raise ForgeError(ExitCode.NOT_FOUND, "item_not_found", f"no item {item_id}")
|
|
304
|
+
if item.archived:
|
|
305
|
+
raise ForgeError(ExitCode.REFUSED, "item_archived", f"{item.label()} is archived")
|
|
306
|
+
if item.type in self.domain.desk_only_item_types and channel in REMOTE_CHANNELS:
|
|
307
|
+
raise ForgeError(
|
|
308
|
+
ExitCode.REFUSED,
|
|
309
|
+
"desk_only",
|
|
310
|
+
f"{item.type} items are decided at your desk (tui or console), not from "
|
|
311
|
+
f"{channel}",
|
|
312
|
+
)
|
|
313
|
+
data: dict[str, Any] = {"channel": channel}
|
|
314
|
+
if to:
|
|
315
|
+
data["to"] = to
|
|
316
|
+
if text:
|
|
317
|
+
data["note"] = text
|
|
318
|
+
event = tx.append(
|
|
319
|
+
"go",
|
|
320
|
+
actor=who.role,
|
|
321
|
+
session=who.session,
|
|
322
|
+
data=data,
|
|
323
|
+
item=item.id,
|
|
324
|
+
title=item.title,
|
|
325
|
+
)
|
|
326
|
+
for esc in fold_escalations(events).values():
|
|
327
|
+
if esc.is_open and esc.subject == f"go:{item.id}":
|
|
328
|
+
close_in(tx, who, esc, "resolved", "go-ahead given")
|
|
329
|
+
return {"go": event["id"], "item": item.id, "title": item.title, "to": to}
|
|
@@ -43,7 +43,7 @@ MANIFEST = "BACKUP.json"
|
|
|
43
43
|
PREFIX = "state"
|
|
44
44
|
SUFFIX = ".tar.gz.age"
|
|
45
45
|
#: Not backed up: the lock, the index cache, and interrupted atomic writes.
|
|
46
|
-
SKIPPED = (".lock", ".index.sqlite")
|
|
46
|
+
SKIPPED = (".lock", ".index.sqlite", ".run.json")
|
|
47
47
|
_RECIPIENT_PREFIXES = ("age1", "ssh-ed25519 ", "ssh-rsa ")
|
|
48
48
|
|
|
49
49
|
|