plotroom 0.1.0__py3-none-any.whl

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 (150) hide show
  1. plotroom/__init__.py +0 -0
  2. plotroom/__main__.py +8 -0
  3. plotroom/_secret_file.py +8 -0
  4. plotroom/adapters/__init__.py +0 -0
  5. plotroom/adapters/claude_desktop.py +219 -0
  6. plotroom/adapters/embedding_http.py +175 -0
  7. plotroom/adapters/github/__init__.py +337 -0
  8. plotroom/adapters/github/app_credential.py +209 -0
  9. plotroom/adapters/github/ci.py +738 -0
  10. plotroom/adapters/github/commit_statuses.py +63 -0
  11. plotroom/adapters/github/deployments.py +213 -0
  12. plotroom/adapters/github/details.py +867 -0
  13. plotroom/adapters/github/issue_details.py +368 -0
  14. plotroom/adapters/github/junit.py +210 -0
  15. plotroom/adapters/github/junit_xml.py +162 -0
  16. plotroom/adapters/github/kodus_review.py +347 -0
  17. plotroom/adapters/github/pr_details.py +192 -0
  18. plotroom/adapters/github/pull_comparison.py +108 -0
  19. plotroom/adapters/github/read.py +530 -0
  20. plotroom/adapters/github/ticket_tree.py +336 -0
  21. plotroom/adapters/mcp/__init__.py +5 -0
  22. plotroom/adapters/mcp/proxy.py +722 -0
  23. plotroom/adapters/mcp/server.py +931 -0
  24. plotroom/adapters/openrouter.py +151 -0
  25. plotroom/adapters/store_sqlite/__init__.py +6 -0
  26. plotroom/adapters/store_sqlite/actions_sql.py +148 -0
  27. plotroom/adapters/store_sqlite/asks_sql.py +153 -0
  28. plotroom/adapters/store_sqlite/backfill_sql.py +138 -0
  29. plotroom/adapters/store_sqlite/budgets_sql.py +102 -0
  30. plotroom/adapters/store_sqlite/checklists_sql.py +77 -0
  31. plotroom/adapters/store_sqlite/claims_sql.py +54 -0
  32. plotroom/adapters/store_sqlite/embedding_sql.py +275 -0
  33. plotroom/adapters/store_sqlite/github_sql.py +331 -0
  34. plotroom/adapters/store_sqlite/goals_sql.py +57 -0
  35. plotroom/adapters/store_sqlite/human_queue_sql.py +60 -0
  36. plotroom/adapters/store_sqlite/items_sql.py +129 -0
  37. plotroom/adapters/store_sqlite/lanes_sql.py +85 -0
  38. plotroom/adapters/store_sqlite/ledger_sql.py +506 -0
  39. plotroom/adapters/store_sqlite/migrate.py +194 -0
  40. plotroom/adapters/store_sqlite/migrations/env.py +36 -0
  41. plotroom/adapters/store_sqlite/migrations/script.py.mako +19 -0
  42. plotroom/adapters/store_sqlite/migrations/versions/0001_project_meta.py +23 -0
  43. plotroom/adapters/store_sqlite/migrations/versions/0002_event_log.py +40 -0
  44. plotroom/adapters/store_sqlite/migrations/versions/0003_next_items.py +49 -0
  45. plotroom/adapters/store_sqlite/migrations/versions/0004_actions.py +28 -0
  46. plotroom/adapters/store_sqlite/migrations/versions/0005_lanes.py +36 -0
  47. plotroom/adapters/store_sqlite/migrations/versions/0006_work_items.py +22 -0
  48. plotroom/adapters/store_sqlite/migrations/versions/0007_item_changes.py +33 -0
  49. plotroom/adapters/store_sqlite/migrations/versions/0008_claude_turn_aliases.py +30 -0
  50. plotroom/adapters/store_sqlite/migrations/versions/0009_github_projection.py +38 -0
  51. plotroom/adapters/store_sqlite/migrations/versions/0010_github_pull_freshness.py +37 -0
  52. plotroom/adapters/store_sqlite/migrations/versions/0011_github_resources.py +27 -0
  53. plotroom/adapters/store_sqlite/migrations/versions/0012_local_triggers_outbox.py +80 -0
  54. plotroom/adapters/store_sqlite/migrations/versions/0013_lane_claims.py +22 -0
  55. plotroom/adapters/store_sqlite/migrations/versions/0015_recurring_triggers.py +45 -0
  56. plotroom/adapters/store_sqlite/migrations/versions/0016_merge_controller.py +28 -0
  57. plotroom/adapters/store_sqlite/migrations/versions/0017_lane_checklists.py +36 -0
  58. plotroom/adapters/store_sqlite/migrations/versions/0018_guardrails.py +33 -0
  59. plotroom/adapters/store_sqlite/migrations/versions/0019_clerk_import_metadata.py +16 -0
  60. plotroom/adapters/store_sqlite/migrations/versions/0020_search.py +30 -0
  61. plotroom/adapters/store_sqlite/migrations/versions/0021_human_queue.py +46 -0
  62. plotroom/adapters/store_sqlite/migrations/versions/0022_search_records.py +77 -0
  63. plotroom/adapters/store_sqlite/migrations/versions/0023_operator_goals.py +25 -0
  64. plotroom/adapters/store_sqlite/migrations/versions/0024_embedding_rejections.py +36 -0
  65. plotroom/adapters/store_sqlite/outbox_sql.py +78 -0
  66. plotroom/adapters/store_sqlite/routes_sql.py +26 -0
  67. plotroom/adapters/store_sqlite/search_sql.py +116 -0
  68. plotroom/adapters/store_sqlite/store.py +623 -0
  69. plotroom/adapters/store_sqlite/triggers_sql.py +111 -0
  70. plotroom/adapters/store_sqlite/work_items_sql.py +36 -0
  71. plotroom/adapters/switchboard.py +152 -0
  72. plotroom/adapters/usage_fixture.py +11 -0
  73. plotroom/adapters/work_items_bmad.py +256 -0
  74. plotroom/adapters/work_items_github_issues.py +323 -0
  75. plotroom/app/__init__.py +0 -0
  76. plotroom/app/bridge.py +162 -0
  77. plotroom/app/clerk_import.py +349 -0
  78. plotroom/app/cli.py +290 -0
  79. plotroom/app/clock.py +12 -0
  80. plotroom/app/config.py +984 -0
  81. plotroom/app/daemon_start.py +453 -0
  82. plotroom/app/lock.py +77 -0
  83. plotroom/app/logging.py +93 -0
  84. plotroom/app/portfile.py +218 -0
  85. plotroom/app/runtime.py +518 -0
  86. plotroom/app/serve.py +671 -0
  87. plotroom/app/session_intake.py +51 -0
  88. plotroom/app/sqlite_floor.py +35 -0
  89. plotroom/app/tokens.py +265 -0
  90. plotroom/core/__init__.py +0 -0
  91. plotroom/core/actions.py +67 -0
  92. plotroom/core/ask_checks.py +124 -0
  93. plotroom/core/asks.py +123 -0
  94. plotroom/core/branch_updates.py +207 -0
  95. plotroom/core/bridge.py +112 -0
  96. plotroom/core/briefs.py +83 -0
  97. plotroom/core/budgets.py +182 -0
  98. plotroom/core/catalog.py +464 -0
  99. plotroom/core/checklists.py +151 -0
  100. plotroom/core/claims.py +296 -0
  101. plotroom/core/clerk_import.py +379 -0
  102. plotroom/core/commands.py +85 -0
  103. plotroom/core/deploy_window.py +21 -0
  104. plotroom/core/envelope.py +20 -0
  105. plotroom/core/events.py +227 -0
  106. plotroom/core/github.py +306 -0
  107. plotroom/core/github_projection.py +310 -0
  108. plotroom/core/goal_language.py +374 -0
  109. plotroom/core/goal_projection.py +146 -0
  110. plotroom/core/human_queue.py +119 -0
  111. plotroom/core/intake.py +106 -0
  112. plotroom/core/kodus_review.py +53 -0
  113. plotroom/core/lanes.py +281 -0
  114. plotroom/core/ledger.py +808 -0
  115. plotroom/core/merge_controller.py +344 -0
  116. plotroom/core/merge_flakes.py +422 -0
  117. plotroom/core/merge_gate.py +724 -0
  118. plotroom/core/merge_lane.py +70 -0
  119. plotroom/core/merge_overlap.py +76 -0
  120. plotroom/core/next_items.py +60 -0
  121. plotroom/core/operator_goals.py +103 -0
  122. plotroom/core/outbox.py +70 -0
  123. plotroom/core/pull_overlaps.py +152 -0
  124. plotroom/core/reports.py +62 -0
  125. plotroom/core/roles.py +100 -0
  126. plotroom/core/routing.py +55 -0
  127. plotroom/core/run_reports.py +53 -0
  128. plotroom/core/search.py +266 -0
  129. plotroom/core/search_sources.py +94 -0
  130. plotroom/core/snapshot.py +204 -0
  131. plotroom/core/trigger_actions.py +89 -0
  132. plotroom/core/triggers.py +550 -0
  133. plotroom/core/unit_of_work.py +541 -0
  134. plotroom/core/watchers.py +35 -0
  135. plotroom/core/work_items.py +23 -0
  136. plotroom/core/writer.py +164 -0
  137. plotroom/ports/__init__.py +6 -0
  138. plotroom/ports/clock.py +12 -0
  139. plotroom/ports/github_write.py +72 -0
  140. plotroom/ports/search.py +197 -0
  141. plotroom/ports/session_reader.py +23 -0
  142. plotroom/ports/store.py +323 -0
  143. plotroom/ports/usage_meter.py +35 -0
  144. plotroom/ports/work_items.py +22 -0
  145. plotroom/py.typed +0 -0
  146. plotroom-0.1.0.dist-info/METADATA +230 -0
  147. plotroom-0.1.0.dist-info/RECORD +150 -0
  148. plotroom-0.1.0.dist-info/WHEEL +4 -0
  149. plotroom-0.1.0.dist-info/entry_points.txt +2 -0
  150. plotroom-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,323 @@
1
+ """The ``Store`` port: what core needs from a project's storage."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Mapping
6
+ from contextlib import AbstractAsyncContextManager
7
+ from typing import TYPE_CHECKING, Any, Protocol
8
+
9
+ from plotroom.core.actions import Action, QueuedAction
10
+ from plotroom.core.claims import Claim
11
+ from plotroom.core.events import Event
12
+ from plotroom.core.github import FetchCursor, FetchRetry, GitHubSummary, PullRequest
13
+ from plotroom.core.github_projection import GitHubResource
14
+ from plotroom.core.lanes import Lane
15
+ from plotroom.core.next_items import Item
16
+ from plotroom.ports.work_items import WorkItem
17
+
18
+ if TYPE_CHECKING:
19
+ from plotroom.core.ask_checks import Ask, IssueComment
20
+ from plotroom.core.budgets import Budget
21
+ from plotroom.core.checklists import Checklist
22
+ from plotroom.core.goal_projection import GoalFacts, StoredGoal
23
+ from plotroom.core.human_queue import Decision
24
+ from plotroom.core.merge_gate import GateSnapshot
25
+ from plotroom.core.outbox import OutboxLease, OutboxMessage, OutboxReadiness
26
+ from plotroom.core.triggers import Trigger
27
+
28
+ type Board = tuple[int, list[Item], dict[str, int], list[Lane]]
29
+
30
+
31
+ class Transaction(Protocol):
32
+ """One open writer transaction (AD-14): all of it commits or rolls back together."""
33
+
34
+ async def find_event(self, source: str, kind: str, upstream_id: str) -> Event | None:
35
+ """The stored event with this identity, or ``None``."""
36
+ ...
37
+
38
+ async def latest_event(
39
+ self,
40
+ kind: str,
41
+ *,
42
+ fields: Mapping[str, str | bool] | None = None,
43
+ after: int = 0,
44
+ ) -> Event | None: ...
45
+
46
+ async def latest_run_report(self, run_id: str) -> Event | None: ...
47
+
48
+ async def lane_activity(self, lane: str) -> Event | None: ...
49
+
50
+ async def insert_event(self, event: Event) -> None:
51
+ """Store a new event whose ``seq`` came from ``allocate_seq`` in this transaction."""
52
+ ...
53
+
54
+ async def insert_decision(self, decision: Decision) -> None: ...
55
+
56
+ async def find_claude_turn(self, session: str, aliases: tuple[str, ...]) -> Event | None: ...
57
+
58
+ async def bind_claude_turn(
59
+ self, session: str, aliases: tuple[str, ...], event: str
60
+ ) -> None: ...
61
+
62
+ async def allocate_seq(self) -> int:
63
+ """The project's next integer ``seq`` (AD-9). Rolled back with the transaction."""
64
+ ...
65
+
66
+ async def find_noop_receipt(self, command: str, key: str) -> dict[str, Any] | None: ...
67
+
68
+ async def ask_for_comment(self, repository: str, comment_id: int) -> Ask | None: ...
69
+
70
+ async def find_ask(self, ask_id: str) -> Ask | None: ...
71
+
72
+ async def save_ask(self, ask: Ask) -> None: ...
73
+
74
+ async def save_goal(self, goal: StoredGoal) -> None: ...
75
+
76
+ async def goals_use_blockers(self) -> bool: ...
77
+
78
+ async def unsettled_asks(self, repository: str) -> list[Ask]: ...
79
+
80
+ async def ask_comments(
81
+ self, repository: str, issues: set[int]
82
+ ) -> dict[int, list[IssueComment]]: ...
83
+
84
+ async def ask_comment_histories(
85
+ self, repository: str, issues: set[int]
86
+ ) -> dict[int, tuple[str, frozenset[int]]]: ...
87
+
88
+ async def insert_noop_receipt(
89
+ self, command: str, key: str, receipt: dict[str, Any]
90
+ ) -> None: ...
91
+
92
+ async def active_item_subjects(self, kind: str) -> set[str]: ...
93
+
94
+ async def find_item(self, item_id: str) -> Item | None: ...
95
+ async def active_item(self, key: str) -> Item | None: ...
96
+ async def save_item(self, item: Item) -> None: ...
97
+
98
+ async def insert_action(self, action: Action) -> None: ...
99
+
100
+ async def update_action(self, action: Action) -> None: ...
101
+
102
+ async def bridge_action(
103
+ self, workers: tuple[str, ...], now: str, act_id: str | None
104
+ ) -> Action | None: ...
105
+
106
+ async def insert_outbox(self, message: OutboxMessage) -> None: ...
107
+
108
+ async def lease_outbox(
109
+ self, lease_id: str, now: str, expires_at: str
110
+ ) -> OutboxLease | None: ...
111
+
112
+ async def complete_outbox(self, lease_id: str, now: str) -> str | None: ...
113
+
114
+ async def retire_stale_outbox(self, now: str) -> None: ...
115
+
116
+ async def find_trigger(self, trigger_id: str) -> Trigger | None: ...
117
+
118
+ async def open_triggers(self) -> list[Trigger]: ...
119
+
120
+ async def save_trigger(self, trigger: Trigger) -> None: ...
121
+
122
+ async def first_matching_pull(self, repository: str, pattern: str) -> int | None: ...
123
+
124
+ async def find_lane(self, lane_id: str) -> Lane | None: ...
125
+
126
+ async def find_budget(self, run: str) -> Budget | None: ...
127
+
128
+ async def insert_budget(self, budget: Budget) -> None: ...
129
+
130
+ async def reserve_openrouter_key(self, reservation: str, run: str) -> bool: ...
131
+
132
+ async def update_budget_spend(self, budget: Budget) -> None: ...
133
+
134
+ async def has_routes(self) -> bool: ...
135
+
136
+ async def find_route(self, action_kind: str) -> str | None: ...
137
+
138
+ async def save_route(self, action_kind: str, lane: str) -> None: ...
139
+
140
+ async def worker_lane(self, worker: str) -> Lane | None: ...
141
+
142
+ async def branch_lane(self, branch: str) -> Lane | None: ...
143
+
144
+ async def branch_lanes(self, branch: str) -> list[Lane]: ...
145
+
146
+ async def active_lanes(self) -> list[Lane]: ...
147
+
148
+ async def save_lane(self, lane: Lane) -> None: ...
149
+
150
+ async def find_checklist(self, lane: str) -> Checklist | None: ...
151
+
152
+ async def save_checklist(self, checklist: Checklist) -> None: ...
153
+
154
+ async def set_checklist_step_completion(
155
+ self, lane: str, version: int, step: str, completion_ref: str
156
+ ) -> bool:
157
+ """Update an open step of the lane's active checklist at the given version."""
158
+ ...
159
+
160
+ async def lane_claims(self, lane: str | None = None) -> list[Claim]: ...
161
+
162
+ async def save_claims(self, claims: list[Claim]) -> None: ...
163
+
164
+ async def delete_claims(self, lane: str, globs: list[str] | None) -> None: ...
165
+
166
+ async def ready_work_items(self) -> tuple[WorkItem, ...]: ...
167
+
168
+ async def replace_work_items(self, items: tuple[WorkItem, ...]) -> None: ...
169
+
170
+ async def claimed_work_items(self) -> set[str]: ...
171
+
172
+ async def pull_request(self, repository: str, number: int) -> PullRequest | None: ...
173
+
174
+ async def open_branch_pull(self, repository: str, branch: str) -> PullRequest | None: ...
175
+
176
+ async def latest_merge_verdict(self, repository: str, number: int) -> Event | None: ...
177
+
178
+ async def save_merge_verdict(self, repository: str, number: int, seq: int) -> None: ...
179
+
180
+ async def deploy_freeze(self) -> str | None: ...
181
+
182
+ async def set_deploy_freeze(self, reason: str | None) -> None: ...
183
+
184
+ async def open_pulls(self, repository: str) -> tuple[PullRequest, ...]: ...
185
+
186
+ async def detail_capacity_exceeded(self, repository: str) -> bool: ...
187
+
188
+ async def save_github_resource(
189
+ self, repository: str, resource: str, scope: str, result: GitHubResource
190
+ ) -> None: ...
191
+
192
+ async def save_pull_request(self, pull: PullRequest) -> None: ...
193
+
194
+ async def github_resource(
195
+ self, repository: str, resource: str, scope: str = ""
196
+ ) -> GitHubResource | None: ...
197
+
198
+ async def fetch_cursor(self, repository: str, resource: str) -> FetchCursor | None: ...
199
+
200
+ async def save_fetch_cursor(
201
+ self, repository: str, resource: str, cursor: FetchCursor
202
+ ) -> None: ...
203
+
204
+ async def save_fetch_retry(
205
+ self, repository: str, resource: str, retry: FetchRetry | None
206
+ ) -> None: ...
207
+
208
+
209
+ class Store(Protocol):
210
+ async def github_pull_targets(self, repository: str) -> tuple[PullRequest, ...]: ...
211
+
212
+ async def github_pending_merge_shas(
213
+ self, repository: str, as_of: str, limit: int
214
+ ) -> tuple[PullRequest, ...]: ...
215
+
216
+ """One project's ledger storage (AD-4: a store is opened for exactly one project)."""
217
+
218
+ @property
219
+ def project_id(self) -> str: ...
220
+
221
+ async def revision(self) -> str | None:
222
+ """The schema revision the project file is at, or ``None`` for an unmigrated file."""
223
+ ...
224
+
225
+ def transaction(self) -> AbstractAsyncContextManager[Transaction]:
226
+ """Open the project's one writer transaction.
227
+
228
+ Commits when the block exits normally and rolls back on any exception. Only the project
229
+ writer calls this (AD-3); a second concurrent entry raises ``RuntimeError``.
230
+ """
231
+ ...
232
+
233
+ async def head_seq(self) -> int:
234
+ """The last allocated ``seq`` (0 when nothing has been written). Reads committed state."""
235
+ ...
236
+
237
+ async def events_after(self, seq: int, limit: int = 100) -> list[Event]:
238
+ """Committed events above ``seq``, ascending, at most ``limit``; none when it is below 1."""
239
+ ...
240
+
241
+ async def read_board(self, role: str) -> Board: ...
242
+
243
+ async def read_snapshot(
244
+ self,
245
+ role: str,
246
+ repository: str | None,
247
+ *,
248
+ checklist_lane: str | None = None,
249
+ include_github_health: bool = False,
250
+ ) -> tuple[
251
+ Board, GitHubSummary | None, dict[str, int], int, str | None, FetchCursor | None
252
+ ]: ...
253
+
254
+ async def read_claims(
255
+ self, role: str, lane: str | None, offset: int, limit: int
256
+ ) -> tuple[int, list[Claim]]: ...
257
+
258
+ async def read_brief_claims(self, worker: str) -> tuple[str | None, list[Claim]]:
259
+ """Read the worker's current lane and all active claims in one snapshot."""
260
+ ...
261
+
262
+ async def read_overlaps(
263
+ self, role: str, lane: str | None, pr: int | None, offset: int, limit: int
264
+ ) -> tuple[int, list[Item]]: ...
265
+
266
+ async def list_triggers(self, lane: str | None) -> list[Trigger]: ...
267
+
268
+ async def read_budgets(self, run: str | None) -> list[Budget]: ...
269
+
270
+ async def read_merge_gate(self, repository: str | None, number: int) -> GateSnapshot: ...
271
+
272
+ async def list_decisions(self, governs: str | None) -> list[Decision]: ...
273
+
274
+ async def list_asks(self, stale_only: bool) -> list[Ask]: ...
275
+
276
+ async def goals_use_blockers(self) -> bool: ...
277
+
278
+ async def read_goals(
279
+ self,
280
+ name: str | None,
281
+ repository: str | None,
282
+ human_login: str | None,
283
+ ) -> tuple[list[StoredGoal], GoalFacts | None]: ...
284
+
285
+ async def pending_ask_issues(self, repository: str) -> set[int]: ...
286
+
287
+ async def pull_request(self, repository: str, number: int) -> PullRequest | None: ...
288
+
289
+ async def github_resource(
290
+ self, repository: str, resource: str, scope: str = ""
291
+ ) -> GitHubResource | None: ...
292
+
293
+ async def fetch_cursor(self, repository: str, resource: str) -> FetchCursor | None: ...
294
+
295
+ async def fetch_retry(self, repository: str, resource: str) -> FetchRetry | None: ...
296
+
297
+ async def read_next(self, role: str, offset: int, limit: int) -> tuple[int, list[Item]]: ...
298
+
299
+ async def read_open_item(self, role: str, item_id: str) -> Item | None: ...
300
+
301
+ async def first_item_change(
302
+ self, role: str, cursor: int
303
+ ) -> tuple[int, dict[str, Any] | None]: ...
304
+
305
+ async def pending_action(self) -> Action | None: ...
306
+
307
+ async def pending_actions(
308
+ self,
309
+ *,
310
+ after: int,
311
+ limit: int,
312
+ skip_branch_updates: bool = False,
313
+ skip_controller_merges: bool = False,
314
+ skip_bridge_workers: tuple[str, ...] | None = None,
315
+ ) -> tuple[QueuedAction, ...]: ...
316
+
317
+ async def outbox_readiness(self, now: str) -> OutboxReadiness: ...
318
+
319
+ async def bridge_readiness(self, workers: tuple[str, ...], now: str) -> OutboxReadiness: ...
320
+
321
+ async def ready_work_items(self) -> tuple[WorkItem, ...]: ...
322
+
323
+ async def close(self) -> None: ...
@@ -0,0 +1,35 @@
1
+ """The read-only port for a project's cumulative usage observations."""
2
+
3
+ from dataclasses import dataclass
4
+ from datetime import UTC, datetime
5
+ from math import isfinite
6
+ from typing import Protocol
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class UsageObservation:
11
+ """Cumulative spend through as_of, eligible for the ledger when complete."""
12
+
13
+ meter: str
14
+ run: str
15
+ spent_usd: float
16
+ as_of: datetime
17
+ complete: bool = True
18
+
19
+ def __post_init__(self) -> None:
20
+ try:
21
+ spend = float(self.spent_usd)
22
+ except OverflowError:
23
+ raise ValueError("meter spend must be finite and nonnegative") from None
24
+ if isinstance(self.spent_usd, bool) or not isfinite(spend) or spend < 0:
25
+ raise ValueError("meter spend must be finite and nonnegative")
26
+ if self.as_of.utcoffset() is None:
27
+ raise ValueError("meter timestamps must include a time zone")
28
+ object.__setattr__(self, "spent_usd", spend)
29
+ object.__setattr__(self, "as_of", self.as_of.astimezone(UTC))
30
+
31
+
32
+ class UsageMeter(Protocol):
33
+ async def observations(self) -> tuple[UsageObservation, ...]:
34
+ """Return a snapshot of cumulative readings, marking incomplete samples explicitly."""
35
+ ...
@@ -0,0 +1,22 @@
1
+ """A read-only source of ready work (AD-17)."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Protocol
5
+
6
+ MAX_WORK_ITEM_BODY_BYTES = 512 * 1024
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class WorkItem:
11
+ ref: str
12
+ title: str
13
+
14
+
15
+ class WorkItemSource(Protocol):
16
+ async def ready_items(self) -> tuple[WorkItem, ...]:
17
+ """Read ready work in source order, or raise if the source cannot be read."""
18
+ ...
19
+
20
+ async def body(self, ref: str) -> str | None:
21
+ """Read the full text of a source reference, or None when it is absent."""
22
+ ...
plotroom/py.typed ADDED
File without changes
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.5
2
+ Name: plotroom
3
+ Version: 0.1.0
4
+ Summary: Orchestration control plane for multi-session coding work
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.14
8
+ Requires-Dist: aiosqlite==0.22.1
9
+ Requires-Dist: alembic==1.20.1
10
+ Requires-Dist: cryptography
11
+ Requires-Dist: httpx==0.28.1
12
+ Requires-Dist: mcp<3,>=2.3.0
13
+ Requires-Dist: pyyaml<7,>=6.0.2
14
+ Requires-Dist: sqlalchemy[asyncio]==2.1.9
15
+ Requires-Dist: sqlite-vec==0.1.9
16
+ Requires-Dist: uvicorn==0.54.0
17
+ Description-Content-Type: text/markdown
18
+
19
+ # Plotroom
20
+
21
+ **One shared ledger for every coding agent on your project.**
22
+
23
+ Plotroom is an MCP server that your Claude Code and Codex sessions all connect to. It records who
24
+ owns each piece of work, which files each agent plans to touch, what you decided, and what still
25
+ has to happen after a PR merges. A new chat, a compacted chat or a second agent can pick up where
26
+ the last one left off by asking the server, not by scrolling back through chat history.
27
+
28
+ ## Why
29
+
30
+ Run three or four agents at once and the coordination ends up in chat. Who owns this branch? Is
31
+ anyone else editing the shared fixture? Did someone check CI on main after that merge? What did
32
+ the human actually say? A fresh chat starts blind, and a compacted one forgets. Two agents edit
33
+ the same file and find out when the PR conflicts.
34
+
35
+ Plotroom moves that state out of the conversation and into a ledger every session can read:
36
+
37
+ - **Lanes with owners.** The orchestrator gives each worker a lane (a branch and its work items)
38
+ with `lane_start`. `snapshot()` summarizes the board and pages through lane details.
39
+ - **File claims that catch collisions early.** Workers `claim` the paths they plan to change, with
40
+ a reason. Overlapping claims, and PRs that touch another lane's claims, become items for the
41
+ orchestrator before the work collides.
42
+ - **One attention queue.** `next()` pages through ranked items visible to your role, including
43
+ overlaps, lanes waiting on someone, PRs ready to merge, stale questions and missing action routes.
44
+ `wait()` blocks until a visible change or a timeout. On timeout, `data.item` is `null`;
45
+ pass `data.cursor` to the next `wait()` call to keep watching.
46
+ - **Merge readiness you can check.** `merge_gate(pr)` returns an advisory verdict for the exact PR
47
+ head using checks, review threads, main's CI, base freshness and closing keywords. The controller
48
+ separately routes actionable refusals to the owning worker or, for an unowned PR, the orchestrator.
49
+ A person or a clerk session does the merge.
50
+ - **Post-merge steps that stay on the board.** `lane_ready` attaches a checklist to a PR and its
51
+ head. After that head merges, the lane stays open until every step is recorded.
52
+ - **Briefs written from the ticket.** `brief` drafts a worker's handoff from the ticket's full text
53
+ and the paths other lanes have claimed.
54
+ - **Your words, kept exactly.** `decide` records a decision word for word, with where you said it.
55
+ `ask` tracks questions tied to an existing GitHub issue comment and flags stale ones. `goal`
56
+ checks a rule such as "every open issue in milestone 1 has an owner" against projected GitHub data.
57
+ - **Triggers.** `trigger` can fire once or recur when a condition becomes true, such as a PR
58
+ merging or main going green with its images built. It can message a worker, notify the
59
+ orchestrator, mark a lane or propose archiving it.
60
+ - **Budget thresholds.** `budget_open` records a run's cap. With usage meter readings, Plotroom
61
+ raises orchestrator items at 50%, 80%, and 100%. At 100% it queues a stop request for an active
62
+ lane. Delivery depends on its route. Bridged lane-pinned stops surface as failed actions for
63
+ operator attention. OpenRouter is the first live usage meter.
64
+ - **Search.** `search` covers messages, turn reports, decisions, asks, issue comments and PR bodies,
65
+ with full-text search by default and search by meaning when you configure an embedding endpoint.
66
+
67
+ Local Claude Code and Codex clients reach Plotroom through `plotroom connect --stdio`. Hosted
68
+ instances serve MCP over HTTP. Workers on a Switchboard relay reach it through `plotroom bridge`.
69
+
70
+ ## What it looks like
71
+
72
+ An orchestrator starts two lanes, and both workers decide to touch the same fixture.
73
+ Use the orchestrator token to start the lanes and each worker's token to claim paths.
74
+ [Run your own](#run-your-own) shows how to issue all three tokens.
75
+
76
+ ```text
77
+ orchestrator lane_start(lane="api", worker="agent", branch="feat/api", work_items=[], request_id="r1")
78
+ orchestrator lane_start(lane="tests", worker="tester", branch="feat/tests", work_items=[], request_id="r2")
79
+ agent claim(lane="api", globs=["src/api/**", "tests/fixtures/user.json"], reason="API change", request_id="r3")
80
+ tester claim(lane="tests", globs=["tests/fixtures/*.json"], reason="test update", request_id="r4")
81
+
82
+ orchestrator next()
83
+ → { "ok": true, "data": { "items": [
84
+ { "kind": "claim_overlap", "subject_ref": "[\"api\", \"tests\"]", "state": "open",
85
+ "context": { "lanes": ["api", "tests"], "claims": [...], ... }, ... } ] } }
86
+ ```
87
+
88
+ Reuse the same `request_id` to retry a command for the same role. The orchestrator can settle
89
+ who owns the fixture before either PR exists. If a chat is compacted or replaced,
90
+ `snapshot(lane="api")` recovers that lane and what it is waiting on, and
91
+ `claims(lane="api")` lists its path claims.
92
+
93
+ Every token is bound to one project and one role: `orchestrator`, `clerk`, `worker:<name>`,
94
+ `drain` or `bridge`. Each command declares which roles may call it, and anything undeclared is
95
+ refused. A worker that tries to start a lane, or to claim paths in another worker's lane, gets
96
+ `forbidden`.
97
+
98
+ ## Status
99
+
100
+ Plotroom is usable from a checkout today. Start sessions in Claude Code or Codex,
101
+ then connect them to a local Plotroom daemon to assign lanes, record claims and
102
+ decisions, and track follow-up work. Start with the credential-free tour below, or
103
+ [connect your own sessions](#run-your-own).
104
+
105
+ - **Verified so far.** The GitHub poller was exercised against a dedicated live test
106
+ repository ([#29](https://github.com/mgd43b/plotroom/issues/29)). A local daemon
107
+ refreshed a GitHub App installation token using a mounted key
108
+ ([#39](https://github.com/mgd43b/plotroom/issues/39)). The local daemon, isolated
109
+ Docker Compose run, and available integrated CI checks passed
110
+ ([#46](https://github.com/mgd43b/plotroom/issues/46)). CI also exercises the Helm
111
+ chart on disposable kind clusters, where Claude Code and Codex connections
112
+ have also been verified ([#123](https://github.com/mgd43b/plotroom/issues/123)).
113
+ - **Live acceptance still open.** Hosted GitHub App refresh, hosted Switchboard
114
+ bridge delivery, and live deployment evidence remain in
115
+ [Epic #2](https://github.com/mgd43b/plotroom/issues/2). The live pilot for
116
+ coordinating Plotroom's own development is deferred
117
+ ([#110](https://github.com/mgd43b/plotroom/issues/110)).
118
+ - **Publishing still open.** The first public release to PyPI and GHCR
119
+ ([#25](https://github.com/mgd43b/plotroom/issues/25)) and the published Helm chart
120
+ ([#125](https://github.com/mgd43b/plotroom/issues/125)) are pending.
121
+
122
+ ## Try it in a minute
123
+
124
+ On macOS or Linux, with Git and uv 0.13.8 or newer. The tests play the orchestrator and the
125
+ workers against temporary local daemons, so no credentials, agents or live repository are needed.
126
+
127
+ ```sh
128
+ git clone https://github.com/mgd43b/plotroom.git
129
+ cd plotroom
130
+ uv sync --locked --python 3.14
131
+ uv run --locked --python 3.14 python -m pytest -v \
132
+ tests/test_lanes.py::test_local_lane_smoke \
133
+ tests/test_claims_e2e.py::test_conflicting_claim_reported_when_made \
134
+ tests/test_epic6_e2e.py
135
+ ```
136
+
137
+ You should see **7 passed**:
138
+ - [The lane smoke test](tests/test_lanes.py): a worker marks its lane as waiting, and the
139
+ orchestrator recovers that state after a daemon restart.
140
+ - [The claims test](tests/test_claims_e2e.py): an overlap opens, then clears as the workers change
141
+ scope.
142
+ - [The brief and checklist tests](tests/test_epic6_e2e.py): a handoff that lists other lanes'
143
+ claims, and a merge that keeps its lane open until the post-merge check is recorded.
144
+
145
+ ## Run your own
146
+
147
+ Save this two-worker config next to the checkout as `plotroom.toml`:
148
+
149
+ ```toml
150
+ data_dir = "plotroom-data"
151
+
152
+ [projects.example.workers.agent]
153
+ [projects.example.workers.tester]
154
+ ```
155
+
156
+ Start the daemon from the checkout. It runs in the foreground:
157
+
158
+ ```sh
159
+ uv run --locked plotroom serve --config ../plotroom.toml
160
+ ```
161
+
162
+ In a second terminal, from the same checkout, issue a token for each role:
163
+
164
+ ```sh
165
+ uv run --locked plotroom token issue --config ../plotroom.toml --project example --role orchestrator
166
+ uv run --locked plotroom token issue --config ../plotroom.toml --project example --role worker:agent
167
+ uv run --locked plotroom token issue --config ../plotroom.toml --project example --role worker:tester
168
+ ```
169
+
170
+ Configure each MCP client to launch the stdio proxy. Set `--directory` to the absolute checkout
171
+ path so uv finds the project even when the client starts elsewhere. Set `--config` to the absolute
172
+ TOML path and replace `YOUR_TOKEN_ID` with the ID for that client's role.
173
+
174
+ ```sh
175
+ uv --directory /path/to/plotroom run --locked plotroom connect --stdio \
176
+ --config /path/to/plotroom.toml --token-id YOUR_TOKEN_ID
177
+ ```
178
+
179
+ Call `snapshot()` in each connected MCP client. The response should show
180
+ `data.project` as `example`. The token commands generate the credentials locally. Use
181
+ the returned `token_id` in the client command and keep the bearer `token` private.
182
+
183
+ ### Track OpenRouter spend
184
+
185
+ Add a binding for the exact run ID you will pass to `budget_open`. Use a dedicated inference
186
+ key with a positive, non-resetting OpenRouter USD cap and shared OpenRouter billing. Use a
187
+ new key per run and keep inference for that run on that key for its lifetime.
188
+
189
+ ```toml
190
+ [projects.example.openrouter.trial]
191
+ key_file = "/run/secrets/openrouter-trial"
192
+ key_sha256 = "<SHA-256 of the trimmed mounted key>"
193
+ ```
194
+
195
+ Compute the SHA-256 from the key text after trimming surrounding whitespace, without printing
196
+ the key. Keep the digest in private configuration and the key in an owner-controlled mounted
197
+ file. Relative paths are based on the configuration file. Keep the binding and key dedicated
198
+ to the same run across restarts. A replacement key requires a new run ID. A changed file
199
+ fails the configured digest check. Plotroom keeps an opaque reservation in the project ledger
200
+ to prevent reassigning an existing budget or reusing its key for a different run in the same
201
+ daemon data directory, including inactive projects. Across separate data directories, keep the
202
+ key dedicated to its original run.
203
+
204
+ Open a budget for `run="trial"` with `provider="openrouter"`, the active lane,
205
+ a `cap_usd` at least as high as the provider cap, and a `key_scope` of `staging`
206
+ or `production`. Budget registration checks the mounted key and provider cap before reserving
207
+ the key. The daemon reads lifetime `data.usage` in USD on the project tick.
208
+ `budget_status(run="trial")` shows accepted spend and when Plotroom saw it.
209
+ Provider accounting may lag. Equal, lower, incomplete, and BYOK readings preserve the previous
210
+ spend and as-of. The provider key cap supplies the spend boundary during reporting delay.
211
+ After a lane archives, its budgets can reconcile for two minutes. The key remains reserved
212
+ when polling stops.
213
+ [OpenRouter current-key API](https://openrouter.ai/docs/api/api-reference/api-keys/get-current-key)
214
+
215
+ - [Running Plotroom](docs/running.md): the local daemon, Docker Compose, the Helm chart on kind, and
216
+ the Switchboard bridge.
217
+ - [Features and configuration](docs/features.md): GitHub reads, the merge gate, briefs, checklists,
218
+ operator goals and search.
219
+
220
+ ## How it's built
221
+
222
+ One daemon owns a data directory and holds a lock on it. Each project is its own SQLite file,
223
+ holding an append-only event log. Commands are checked against the writer-rule table, and every
224
+ retried call is idempotent. GitHub is read by polling, so no public webhook endpoint is needed. The
225
+ same build runs on a laptop over stdio and hosted in Docker or Kubernetes, with several projects
226
+ per instance.
227
+
228
+ - [Architecture](_bmad-output/initiative-orchestration-control-plane/architecture-orchestration-control-plane/architecture-orchestration-control-plane.md)
229
+ - [The plan: initiative and epics](_bmad-output/initiative-orchestration-control-plane/initiative-orchestration-control-plane.md)
230
+ - [How this repository coordinates its own development](coordination/README.md)