robert-github-agent 0.1.0b1__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 (111) hide show
  1. robert_agent/__init__.py +1 -0
  2. robert_agent/acceptance.py +394 -0
  3. robert_agent/acceptance_suite.py +287 -0
  4. robert_agent/audit_result.py +501 -0
  5. robert_agent/authorize.py +117 -0
  6. robert_agent/board.py +538 -0
  7. robert_agent/chat_status.py +338 -0
  8. robert_agent/cli/__init__.py +1 -0
  9. robert_agent/cli/exit_codes.py +5 -0
  10. robert_agent/cli/main.py +535 -0
  11. robert_agent/cli/output.py +20 -0
  12. robert_agent/common.py +6 -0
  13. robert_agent/controlled_e2e_acceptance.py +394 -0
  14. robert_agent/daemon.py +607 -0
  15. robert_agent/daemon_state.py +319 -0
  16. robert_agent/diagnostics.py +119 -0
  17. robert_agent/discover.py +775 -0
  18. robert_agent/dispatch.py +217 -0
  19. robert_agent/doctor.py +94 -0
  20. robert_agent/github_api.py +12 -0
  21. robert_agent/init_config.py +126 -0
  22. robert_agent/integrations/__init__.py +1 -0
  23. robert_agent/integrations/openclaw.py +285 -0
  24. robert_agent/live_discovery_acceptance.py +70 -0
  25. robert_agent/live_worker_acceptance.py +363 -0
  26. robert_agent/live_worktree_acceptance.py +344 -0
  27. robert_agent/loop_engine.py +285 -0
  28. robert_agent/memory_curator.py +105 -0
  29. robert_agent/migrate.py +157 -0
  30. robert_agent/notify.py +74 -0
  31. robert_agent/paths.py +16 -0
  32. robert_agent/production_write_canary.py +254 -0
  33. robert_agent/project_memory.py +503 -0
  34. robert_agent/publish.py +743 -0
  35. robert_agent/publish_dedupe_acceptance.py +270 -0
  36. robert_agent/redaction.py +41 -0
  37. robert_agent/render_prompt.py +544 -0
  38. robert_agent/resource_files.py +8 -0
  39. robert_agent/resources/__init__.py +1 -0
  40. robert_agent/resources/acceptance-matrix.md +120 -0
  41. robert_agent/resources/classifier.md +19 -0
  42. robert_agent/resources/command-matrix.md +38 -0
  43. robert_agent/resources/config.example.yml +20 -0
  44. robert_agent/resources/db/migrations/001_legacy_dd_to_robert.sql +14 -0
  45. robert_agent/resources/db/schema.sql +479 -0
  46. robert_agent/resources/failure-modes.md +36 -0
  47. robert_agent/resources/fixtures/actor-permission.json +1 -0
  48. robert_agent/resources/fixtures/discovery.json +1 -0
  49. robert_agent/resources/fixtures/redaction.json +1 -0
  50. robert_agent/resources/fixtures/review-followup.json +1 -0
  51. robert_agent/resources/fixtures/worker-results.json +1 -0
  52. robert_agent/resources/fixtures/workstreams.json +1 -0
  53. robert_agent/resources/github-events.md +77 -0
  54. robert_agent/resources/kanban-control.md +165 -0
  55. robert_agent/resources/redaction.md +29 -0
  56. robert_agent/resources/result-contract.md +56 -0
  57. robert_agent/resources/routes.yml +82 -0
  58. robert_agent/resources/schemas/config.schema.json +123 -0
  59. robert_agent/resources/schemas/event.schema.json +18 -0
  60. robert_agent/resources/schemas/result.schema.json +99 -0
  61. robert_agent/resources/schemas/route.schema.json +23 -0
  62. robert_agent/resources/schemas/snapshot.schema.json +17 -0
  63. robert_agent/resources/schemas/task.schema.json +15 -0
  64. robert_agent/resources/trust-model.md +16 -0
  65. robert_agent/resources/worker-prompt.md +121 -0
  66. robert_agent/resources/worker-protocol.md +47 -0
  67. robert_agent/resources/workflow.yml +50 -0
  68. robert_agent/resources/workstream-model.md +17 -0
  69. robert_agent/route.py +232 -0
  70. robert_agent/route_config.py +64 -0
  71. robert_agent/run_once.py +5375 -0
  72. robert_agent/runtime_knowledge.py +392 -0
  73. robert_agent/service.py +161 -0
  74. robert_agent/skills.py +28 -0
  75. robert_agent/status.py +1051 -0
  76. robert_agent/storage.py +376 -0
  77. robert_agent/summarize.py +100 -0
  78. robert_agent/supervise.py +72 -0
  79. robert_agent/usage.py +192 -0
  80. robert_agent/validate_config.py +616 -0
  81. robert_agent/wakeup.py +261 -0
  82. robert_agent/web.py +2893 -0
  83. robert_agent/web_assets/board.css +255 -0
  84. robert_agent/web_assets/board.html +165 -0
  85. robert_agent/web_assets/board.js +660 -0
  86. robert_agent/web_assets/github-shell.css +122 -0
  87. robert_agent/web_assets/index.html +103 -0
  88. robert_agent/web_assets/operations.css +168 -0
  89. robert_agent/web_assets/workbench.css +131 -0
  90. robert_agent/web_assets/workbench.js +581 -0
  91. robert_agent/work_items.py +1016 -0
  92. robert_agent/workbench.py +701 -0
  93. robert_agent/worker/__init__.py +1 -0
  94. robert_agent/worker/heartbeat.py +190 -0
  95. robert_agent/worker/result.py +321 -0
  96. robert_agent/worker/snapshot.py +98 -0
  97. robert_agent/worker_adapters/__init__.py +138 -0
  98. robert_agent/worker_adapters/cbc.py +68 -0
  99. robert_agent/worker_adapters/codex.py +56 -0
  100. robert_agent/worker_adapters/command.py +33 -0
  101. robert_agent/worker_adapters/tcodex.py +56 -0
  102. robert_agent/worker_heartbeat.py +6 -0
  103. robert_agent/worker_result.py +6 -0
  104. robert_agent/worker_snapshot.py +6 -0
  105. robert_agent/workstream.py +55 -0
  106. robert_agent/worktree.py +297 -0
  107. robert_github_agent-0.1.0b1.dist-info/METADATA +217 -0
  108. robert_github_agent-0.1.0b1.dist-info/RECORD +111 -0
  109. robert_github_agent-0.1.0b1.dist-info/WHEEL +4 -0
  110. robert_github_agent-0.1.0b1.dist-info/entry_points.txt +2 -0
  111. robert_github_agent-0.1.0b1.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,479 @@
1
+ PRAGMA foreign_keys = ON;
2
+ PRAGMA busy_timeout = 5000;
3
+ PRAGMA journal_mode = WAL;
4
+
5
+ CREATE TABLE IF NOT EXISTS schema_migrations (
6
+ version INTEGER PRIMARY KEY,
7
+ name TEXT NOT NULL UNIQUE,
8
+ checksum TEXT NOT NULL,
9
+ applied_at TEXT NOT NULL
10
+ );
11
+
12
+ CREATE TABLE IF NOT EXISTS repos (
13
+ repo_id TEXT PRIMARY KEY,
14
+ full_name TEXT NOT NULL UNIQUE,
15
+ github_account TEXT NOT NULL,
16
+ default_base_branch TEXT NOT NULL,
17
+ repo_root TEXT NOT NULL,
18
+ worktree_root TEXT NOT NULL,
19
+ enabled INTEGER NOT NULL DEFAULT 1 CHECK (enabled IN (0, 1)),
20
+ metadata_json TEXT NOT NULL DEFAULT '{}'
21
+ );
22
+
23
+ CREATE TABLE IF NOT EXISTS actors (
24
+ actor_id TEXT PRIMARY KEY,
25
+ login TEXT NOT NULL UNIQUE,
26
+ actor_kind TEXT NOT NULL DEFAULT 'user',
27
+ metadata_json TEXT NOT NULL DEFAULT '{}'
28
+ );
29
+
30
+ CREATE TABLE IF NOT EXISTS actor_permissions (
31
+ permission_id TEXT PRIMARY KEY,
32
+ repo_id TEXT NOT NULL REFERENCES repos(repo_id) ON DELETE CASCADE,
33
+ actor_id TEXT NOT NULL REFERENCES actors(actor_id) ON DELETE CASCADE,
34
+ trust_level TEXT NOT NULL CHECK (trust_level IN ('trusted_trigger', 'accepted_context', 'ignored')),
35
+ source TEXT NOT NULL,
36
+ checked_at TEXT NOT NULL,
37
+ metadata_json TEXT NOT NULL DEFAULT '{}',
38
+ UNIQUE(repo_id, actor_id, source)
39
+ );
40
+
41
+ CREATE TABLE IF NOT EXISTS github_sources (
42
+ source_id TEXT PRIMARY KEY,
43
+ repo_id TEXT NOT NULL REFERENCES repos(repo_id) ON DELETE CASCADE,
44
+ source_key TEXT NOT NULL UNIQUE,
45
+ source_type TEXT NOT NULL CHECK (source_type IN ('issue', 'pull_request')),
46
+ number INTEGER NOT NULL,
47
+ html_url TEXT,
48
+ title TEXT NOT NULL DEFAULT '',
49
+ state TEXT NOT NULL DEFAULT 'open',
50
+ author_login TEXT,
51
+ source_updated_at TEXT,
52
+ metadata_json TEXT NOT NULL DEFAULT '{}'
53
+ );
54
+
55
+ CREATE TABLE IF NOT EXISTS github_events (
56
+ event_id TEXT PRIMARY KEY,
57
+ repo_id TEXT NOT NULL REFERENCES repos(repo_id) ON DELETE CASCADE,
58
+ source_id TEXT NOT NULL REFERENCES github_sources(source_id) ON DELETE CASCADE,
59
+ event_fingerprint TEXT NOT NULL UNIQUE,
60
+ event_type TEXT NOT NULL,
61
+ actor_login TEXT,
62
+ author_association TEXT,
63
+ authorization_status TEXT NOT NULL DEFAULT 'pending',
64
+ event_at TEXT NOT NULL,
65
+ payload_json TEXT NOT NULL DEFAULT '{}'
66
+ );
67
+
68
+ CREATE TABLE IF NOT EXISTS workstreams (
69
+ workstream_id TEXT PRIMARY KEY,
70
+ repo_id TEXT NOT NULL REFERENCES repos(repo_id) ON DELETE CASCADE,
71
+ primary_source_id TEXT REFERENCES github_sources(source_id) ON DELETE SET NULL,
72
+ origin_workstream_id TEXT REFERENCES workstreams(workstream_id) ON DELETE SET NULL,
73
+ lifecycle TEXT NOT NULL DEFAULT 'active' CHECK (lifecycle IN ('active', 'completed', 'waiting_for_user', 'failed', 'canceled')),
74
+ active_task_id TEXT,
75
+ created_at TEXT NOT NULL,
76
+ updated_at TEXT NOT NULL,
77
+ metadata_json TEXT NOT NULL DEFAULT '{}'
78
+ );
79
+
80
+ CREATE TABLE IF NOT EXISTS workstream_sources (
81
+ workstream_id TEXT NOT NULL REFERENCES workstreams(workstream_id) ON DELETE CASCADE,
82
+ source_id TEXT NOT NULL REFERENCES github_sources(source_id) ON DELETE CASCADE,
83
+ relationship TEXT NOT NULL CHECK (relationship IN ('primary', 'derived_pr', 'origin_issue', 'related')),
84
+ created_at TEXT NOT NULL,
85
+ PRIMARY KEY(workstream_id, source_id)
86
+ );
87
+
88
+ CREATE TABLE IF NOT EXISTS tasks (
89
+ task_id TEXT PRIMARY KEY,
90
+ workstream_id TEXT NOT NULL REFERENCES workstreams(workstream_id) ON DELETE CASCADE,
91
+ lifecycle TEXT NOT NULL CHECK (lifecycle IN ('detected', 'authorized', 'classified', 'queued', 'running', 'completed', 'waiting_for_user', 'failed', 'canceled', 'ignored')),
92
+ parent_task_id TEXT REFERENCES tasks(task_id) ON DELETE SET NULL,
93
+ priority TEXT NOT NULL DEFAULT 'P2',
94
+ routing_mode TEXT NOT NULL DEFAULT 'auto' CHECK (routing_mode IN ('auto', 'manual')),
95
+ requested_worker TEXT,
96
+ route_id TEXT,
97
+ expected_output TEXT,
98
+ created_at TEXT NOT NULL,
99
+ updated_at TEXT NOT NULL,
100
+ metadata_json TEXT NOT NULL DEFAULT '{}',
101
+ CHECK ((routing_mode = 'auto' AND requested_worker IS NULL)
102
+ OR (routing_mode = 'manual' AND requested_worker IS NOT NULL))
103
+ );
104
+
105
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_workstreams_one_active_task
106
+ ON tasks(workstream_id)
107
+ WHERE lifecycle IN ('detected', 'authorized', 'classified', 'queued', 'running');
108
+
109
+ CREATE TABLE IF NOT EXISTS work_items (
110
+ work_item_id TEXT PRIMARY KEY,
111
+ repo_id TEXT NOT NULL REFERENCES repos(repo_id) ON DELETE CASCADE,
112
+ title TEXT NOT NULL,
113
+ description TEXT NOT NULL DEFAULT '',
114
+ priority TEXT NOT NULL DEFAULT 'P2' CHECK (priority IN ('P0', 'P1', 'P2', 'P3')),
115
+ origin_type TEXT NOT NULL CHECK (origin_type IN ('web', 'github')),
116
+ origin_source_id TEXT REFERENCES github_sources(source_id) ON DELETE SET NULL,
117
+ routing_mode TEXT NOT NULL DEFAULT 'auto' CHECK (routing_mode IN ('auto', 'manual')),
118
+ requested_worker TEXT,
119
+ workstream_id TEXT REFERENCES workstreams(workstream_id) ON DELETE SET NULL,
120
+ creation_idempotency_key TEXT NOT NULL UNIQUE,
121
+ created_by TEXT NOT NULL,
122
+ activated_at TEXT,
123
+ completed_at TEXT,
124
+ canceled_at TEXT,
125
+ version INTEGER NOT NULL DEFAULT 1 CHECK (version >= 1),
126
+ created_at TEXT NOT NULL,
127
+ updated_at TEXT NOT NULL,
128
+ metadata_json TEXT NOT NULL DEFAULT '{}',
129
+ CHECK ((routing_mode = 'auto' AND requested_worker IS NULL)
130
+ OR (routing_mode = 'manual' AND requested_worker IS NOT NULL))
131
+ );
132
+
133
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_work_items_origin_source
134
+ ON work_items(origin_source_id) WHERE origin_source_id IS NOT NULL;
135
+
136
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_work_items_workstream
137
+ ON work_items(workstream_id) WHERE workstream_id IS NOT NULL;
138
+
139
+ CREATE INDEX IF NOT EXISTS idx_work_items_board_order
140
+ ON work_items(updated_at DESC, work_item_id DESC);
141
+
142
+ CREATE INDEX IF NOT EXISTS idx_work_items_repo_updated
143
+ ON work_items(repo_id, updated_at DESC, work_item_id DESC);
144
+
145
+ CREATE TABLE IF NOT EXISTS work_item_events (
146
+ event_id TEXT PRIMARY KEY,
147
+ work_item_id TEXT NOT NULL REFERENCES work_items(work_item_id) ON DELETE CASCADE,
148
+ event_type TEXT NOT NULL,
149
+ actor_kind TEXT NOT NULL,
150
+ actor_identity TEXT NOT NULL,
151
+ body TEXT NOT NULL DEFAULT '',
152
+ resolves_event_id TEXT REFERENCES work_item_events(event_id) ON DELETE SET NULL,
153
+ idempotency_key TEXT NOT NULL,
154
+ created_at TEXT NOT NULL,
155
+ metadata_json TEXT NOT NULL DEFAULT '{}'
156
+ );
157
+
158
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_work_item_events_idempotency
159
+ ON work_item_events(work_item_id, idempotency_key);
160
+
161
+ CREATE INDEX IF NOT EXISTS idx_work_item_events_timeline
162
+ ON work_item_events(work_item_id, created_at DESC, event_id DESC);
163
+
164
+ CREATE INDEX IF NOT EXISTS idx_work_item_events_resolves
165
+ ON work_item_events(resolves_event_id) WHERE resolves_event_id IS NOT NULL;
166
+
167
+ CREATE TABLE IF NOT EXISTS task_events (
168
+ task_id TEXT NOT NULL REFERENCES tasks(task_id) ON DELETE CASCADE,
169
+ event_id TEXT NOT NULL REFERENCES github_events(event_id) ON DELETE CASCADE,
170
+ relationship TEXT NOT NULL CHECK (relationship IN ('trigger', 'pending', 'consumed', 'context')),
171
+ created_at TEXT NOT NULL,
172
+ PRIMARY KEY(task_id, event_id)
173
+ );
174
+
175
+ CREATE TABLE IF NOT EXISTS route_decisions (
176
+ route_decision_id TEXT PRIMARY KEY,
177
+ task_id TEXT NOT NULL REFERENCES tasks(task_id) ON DELETE CASCADE,
178
+ route_id TEXT NOT NULL,
179
+ expected_output TEXT NOT NULL,
180
+ allowed_github_actions_json TEXT NOT NULL DEFAULT '[]',
181
+ required_skills_json TEXT NOT NULL DEFAULT '[]',
182
+ recommended_skills_json TEXT NOT NULL DEFAULT '[]',
183
+ confidence TEXT NOT NULL CHECK (confidence IN ('high', 'medium', 'low')),
184
+ created_at TEXT NOT NULL
185
+ );
186
+
187
+ CREATE TABLE IF NOT EXISTS attempts (
188
+ attempt_id TEXT PRIMARY KEY,
189
+ task_id TEXT NOT NULL REFERENCES tasks(task_id) ON DELETE CASCADE,
190
+ attempt_no INTEGER NOT NULL CHECK (attempt_no >= 1),
191
+ status TEXT NOT NULL CHECK (status IN ('prepared', 'running', 'completed', 'failed', 'stale', 'canceled')),
192
+ worktree_path TEXT,
193
+ branch_name TEXT,
194
+ started_at TEXT,
195
+ heartbeat_at TEXT,
196
+ finished_at TEXT,
197
+ failure_json TEXT,
198
+ metadata_json TEXT NOT NULL DEFAULT '{}',
199
+ UNIQUE(task_id, attempt_no)
200
+ );
201
+
202
+ CREATE TABLE IF NOT EXISTS worker_phases (
203
+ phase_id TEXT PRIMARY KEY,
204
+ attempt_id TEXT NOT NULL REFERENCES attempts(attempt_id) ON DELETE CASCADE,
205
+ phase TEXT NOT NULL CHECK (phase IN ('prepare', 'analyze', 'plan', 'execute', 'verify', 'publish', 'handoff')),
206
+ status TEXT NOT NULL,
207
+ summary TEXT NOT NULL,
208
+ next_step TEXT,
209
+ created_at TEXT NOT NULL,
210
+ metadata_json TEXT NOT NULL DEFAULT '{}'
211
+ );
212
+
213
+ CREATE TABLE IF NOT EXISTS worker_results (
214
+ result_id TEXT PRIMARY KEY,
215
+ task_id TEXT NOT NULL REFERENCES tasks(task_id) ON DELETE CASCADE,
216
+ attempt_id TEXT NOT NULL REFERENCES attempts(attempt_id) ON DELETE CASCADE,
217
+ output_type TEXT NOT NULL,
218
+ consumed_event_fingerprints_json TEXT NOT NULL DEFAULT '[]',
219
+ verification_json TEXT NOT NULL DEFAULT '[]',
220
+ handoff TEXT NOT NULL DEFAULT '',
221
+ created_at TEXT NOT NULL,
222
+ metadata_json TEXT NOT NULL DEFAULT '{}',
223
+ UNIQUE(task_id, attempt_id)
224
+ );
225
+
226
+ CREATE TABLE IF NOT EXISTS github_actions (
227
+ action_id TEXT PRIMARY KEY,
228
+ result_id TEXT REFERENCES worker_results(result_id) ON DELETE SET NULL,
229
+ task_id TEXT NOT NULL REFERENCES tasks(task_id) ON DELETE CASCADE,
230
+ action_type TEXT NOT NULL,
231
+ target_url TEXT,
232
+ external_id TEXT,
233
+ audit_status TEXT NOT NULL DEFAULT 'pending' CHECK (audit_status IN ('pending', 'accepted', 'policy_violation', 'failed')),
234
+ publish_status TEXT NOT NULL DEFAULT 'not_published' CHECK (publish_status IN ('not_published', 'published', 'skipped')),
235
+ created_at TEXT NOT NULL,
236
+ metadata_json TEXT NOT NULL DEFAULT '{}'
237
+ );
238
+
239
+ CREATE TABLE IF NOT EXISTS artifacts (
240
+ artifact_id TEXT PRIMARY KEY,
241
+ task_id TEXT REFERENCES tasks(task_id) ON DELETE CASCADE,
242
+ attempt_id TEXT REFERENCES attempts(attempt_id) ON DELETE SET NULL,
243
+ artifact_type TEXT NOT NULL,
244
+ path TEXT NOT NULL,
245
+ sha256 TEXT,
246
+ bytes INTEGER,
247
+ created_at TEXT NOT NULL,
248
+ metadata_json TEXT NOT NULL DEFAULT '{}'
249
+ );
250
+
251
+ CREATE TABLE IF NOT EXISTS notifications (
252
+ notification_id TEXT PRIMARY KEY,
253
+ task_id TEXT REFERENCES tasks(task_id) ON DELETE SET NULL,
254
+ notification_type TEXT NOT NULL,
255
+ channel TEXT NOT NULL DEFAULT 'local',
256
+ status TEXT NOT NULL,
257
+ created_at TEXT NOT NULL,
258
+ metadata_json TEXT NOT NULL DEFAULT '{}'
259
+ );
260
+
261
+ CREATE TABLE IF NOT EXISTS wakeups (
262
+ wakeup_id TEXT PRIMARY KEY,
263
+ repo_id TEXT NOT NULL REFERENCES repos(repo_id) ON DELETE CASCADE,
264
+ reason TEXT NOT NULL CHECK (reason IN (
265
+ 'worker_result_ready',
266
+ 'queued_capacity_wait',
267
+ 'publish_retry_ready',
268
+ 'stale_attempt_check',
269
+ 'manual_operator_request'
270
+ )),
271
+ dedupe_key TEXT NOT NULL,
272
+ work_item_id TEXT REFERENCES work_items(work_item_id) ON DELETE CASCADE,
273
+ task_id TEXT REFERENCES tasks(task_id) ON DELETE CASCADE,
274
+ attempt_id TEXT REFERENCES attempts(attempt_id) ON DELETE SET NULL,
275
+ result_id TEXT REFERENCES worker_results(result_id) ON DELETE CASCADE,
276
+ source_run_id TEXT REFERENCES agent_runs(run_id) ON DELETE SET NULL,
277
+ consumed_run_id TEXT REFERENCES agent_runs(run_id) ON DELETE SET NULL,
278
+ status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'consumed', 'expired', 'canceled')),
279
+ not_before_at TEXT NOT NULL,
280
+ expires_at TEXT,
281
+ attempt_count INTEGER NOT NULL DEFAULT 0 CHECK (attempt_count >= 0),
282
+ created_at TEXT NOT NULL,
283
+ updated_at TEXT NOT NULL,
284
+ metadata_json TEXT NOT NULL DEFAULT '{}',
285
+ UNIQUE(repo_id, reason, dedupe_key)
286
+ );
287
+
288
+ CREATE INDEX IF NOT EXISTS idx_wakeups_status_due
289
+ ON wakeups(repo_id, status, not_before_at, created_at);
290
+
291
+ CREATE INDEX IF NOT EXISTS idx_wakeups_result
292
+ ON wakeups(result_id);
293
+
294
+ CREATE TABLE IF NOT EXISTS agent_runs (
295
+ run_id TEXT PRIMARY KEY,
296
+ status TEXT NOT NULL CHECK (status IN ('running', 'completed', 'failed', 'skipped')),
297
+ started_at TEXT NOT NULL,
298
+ finished_at TEXT,
299
+ config_path TEXT,
300
+ dry_run INTEGER NOT NULL DEFAULT 0 CHECK (dry_run IN (0, 1)),
301
+ summary_json TEXT NOT NULL DEFAULT '{}',
302
+ error_json TEXT
303
+ );
304
+
305
+ CREATE TABLE IF NOT EXISTS run_steps (
306
+ step_id TEXT PRIMARY KEY,
307
+ run_id TEXT NOT NULL REFERENCES agent_runs(run_id) ON DELETE CASCADE,
308
+ step_key TEXT NOT NULL,
309
+ status TEXT NOT NULL CHECK (status IN ('pending', 'running', 'succeeded', 'failed', 'skipped')),
310
+ started_at TEXT,
311
+ finished_at TEXT,
312
+ output_json TEXT,
313
+ error_json TEXT,
314
+ UNIQUE(run_id, step_key)
315
+ );
316
+
317
+ CREATE TABLE IF NOT EXISTS run_repo_steps (
318
+ step_id TEXT PRIMARY KEY,
319
+ run_id TEXT NOT NULL REFERENCES agent_runs(run_id) ON DELETE CASCADE,
320
+ repo_id TEXT NOT NULL REFERENCES repos(repo_id) ON DELETE CASCADE,
321
+ step_key TEXT NOT NULL,
322
+ status TEXT NOT NULL CHECK (status IN ('pending', 'running', 'succeeded', 'failed', 'skipped')),
323
+ started_at TEXT,
324
+ finished_at TEXT,
325
+ output_json TEXT,
326
+ error_json TEXT,
327
+ UNIQUE(run_id, repo_id, step_key)
328
+ );
329
+
330
+ CREATE TABLE IF NOT EXISTS leases (
331
+ lease_id TEXT PRIMARY KEY,
332
+ resource_type TEXT NOT NULL,
333
+ resource_key TEXT NOT NULL,
334
+ owner_id TEXT NOT NULL,
335
+ status TEXT NOT NULL CHECK (status IN ('active', 'released', 'expired', 'stolen')),
336
+ acquired_at TEXT NOT NULL,
337
+ expires_at TEXT NOT NULL,
338
+ heartbeat_at TEXT NOT NULL,
339
+ released_at TEXT,
340
+ metadata_json TEXT NOT NULL DEFAULT '{}'
341
+ );
342
+
343
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_leases_one_active_resource
344
+ ON leases(resource_type, resource_key)
345
+ WHERE status = 'active';
346
+
347
+ CREATE TABLE IF NOT EXISTS daemon_runs (
348
+ daemon_run_id TEXT PRIMARY KEY,
349
+ status TEXT NOT NULL CHECK (status IN ('running', 'stopped', 'failed', 'replaced')),
350
+ owner_id TEXT NOT NULL,
351
+ config_path TEXT NOT NULL,
352
+ started_at TEXT NOT NULL,
353
+ finished_at TEXT,
354
+ summary_json TEXT NOT NULL DEFAULT '{}',
355
+ error_json TEXT
356
+ );
357
+
358
+ CREATE TABLE IF NOT EXISTS daemon_events (
359
+ daemon_event_id TEXT PRIMARY KEY,
360
+ daemon_run_id TEXT NOT NULL REFERENCES daemon_runs(daemon_run_id) ON DELETE CASCADE,
361
+ event_type TEXT NOT NULL,
362
+ status TEXT NOT NULL,
363
+ created_at TEXT NOT NULL,
364
+ metadata_json TEXT NOT NULL DEFAULT '{}'
365
+ );
366
+
367
+ CREATE INDEX IF NOT EXISTS idx_daemon_events_run_created
368
+ ON daemon_events(daemon_run_id, created_at);
369
+
370
+ CREATE INDEX IF NOT EXISTS idx_daemon_events_type_created
371
+ ON daemon_events(event_type, created_at);
372
+
373
+ CREATE TABLE IF NOT EXISTS audit_events (
374
+ audit_id TEXT PRIMARY KEY,
375
+ repo_id TEXT REFERENCES repos(repo_id) ON DELETE SET NULL,
376
+ workstream_id TEXT REFERENCES workstreams(workstream_id) ON DELETE SET NULL,
377
+ task_id TEXT REFERENCES tasks(task_id) ON DELETE SET NULL,
378
+ event_type TEXT NOT NULL,
379
+ created_at TEXT NOT NULL,
380
+ payload_json TEXT NOT NULL DEFAULT '{}'
381
+ );
382
+
383
+ CREATE TABLE IF NOT EXISTS project_memory_entries (
384
+ memory_id TEXT PRIMARY KEY,
385
+ repo_id TEXT NOT NULL REFERENCES repos(repo_id) ON DELETE CASCADE,
386
+ memory_thread_key TEXT NOT NULL,
387
+ kind TEXT NOT NULL DEFAULT 'context',
388
+ title TEXT NOT NULL,
389
+ short_summary TEXT NOT NULL,
390
+ long_summary TEXT NOT NULL DEFAULT '',
391
+ confidence TEXT NOT NULL DEFAULT 'medium' CHECK (confidence IN ('high', 'medium', 'low')),
392
+ source_task_id TEXT REFERENCES tasks(task_id) ON DELETE SET NULL,
393
+ source_result_id TEXT REFERENCES worker_results(result_id) ON DELETE SET NULL,
394
+ current_revision_id TEXT,
395
+ revision_count INTEGER NOT NULL DEFAULT 0 CHECK (revision_count >= 0),
396
+ created_at TEXT NOT NULL,
397
+ updated_at TEXT NOT NULL,
398
+ last_used_at TEXT,
399
+ metadata_json TEXT NOT NULL DEFAULT '{}',
400
+ UNIQUE(repo_id, memory_thread_key, kind, title)
401
+ );
402
+
403
+ CREATE INDEX IF NOT EXISTS idx_project_memory_entries_repo_updated
404
+ ON project_memory_entries(repo_id, updated_at);
405
+
406
+ CREATE TABLE IF NOT EXISTS project_memory_revisions (
407
+ revision_id TEXT PRIMARY KEY,
408
+ memory_id TEXT NOT NULL REFERENCES project_memory_entries(memory_id) ON DELETE CASCADE,
409
+ repo_id TEXT NOT NULL REFERENCES repos(repo_id) ON DELETE CASCADE,
410
+ result_id TEXT REFERENCES worker_results(result_id) ON DELETE SET NULL,
411
+ task_id TEXT REFERENCES tasks(task_id) ON DELETE SET NULL,
412
+ attempt_id TEXT REFERENCES attempts(attempt_id) ON DELETE SET NULL,
413
+ operation TEXT NOT NULL DEFAULT 'upsert',
414
+ title TEXT NOT NULL,
415
+ short_summary TEXT NOT NULL,
416
+ long_summary TEXT NOT NULL DEFAULT '',
417
+ payload_json TEXT NOT NULL DEFAULT '{}',
418
+ created_at TEXT NOT NULL
419
+ );
420
+
421
+ CREATE INDEX IF NOT EXISTS idx_project_memory_revisions_memory
422
+ ON project_memory_revisions(memory_id, created_at);
423
+
424
+ CREATE TABLE IF NOT EXISTS project_memory_terms (
425
+ memory_id TEXT NOT NULL REFERENCES project_memory_entries(memory_id) ON DELETE CASCADE,
426
+ repo_id TEXT NOT NULL REFERENCES repos(repo_id) ON DELETE CASCADE,
427
+ term_type TEXT NOT NULL,
428
+ term_value TEXT NOT NULL,
429
+ created_at TEXT NOT NULL,
430
+ PRIMARY KEY(memory_id, term_type, term_value)
431
+ );
432
+
433
+ CREATE INDEX IF NOT EXISTS idx_project_memory_terms_lookup
434
+ ON project_memory_terms(repo_id, term_type, term_value);
435
+
436
+ CREATE TABLE IF NOT EXISTS knowledge_candidates (
437
+ candidate_id TEXT PRIMARY KEY,
438
+ repo_id TEXT NOT NULL REFERENCES repos(repo_id) ON DELETE CASCADE,
439
+ title TEXT NOT NULL,
440
+ summary TEXT NOT NULL,
441
+ prompt_text TEXT NOT NULL,
442
+ candidate_type TEXT NOT NULL DEFAULT 'rule' CHECK (candidate_type IN ('rule', 'anti_pattern', 'route_hint', 'verification_hint')),
443
+ source_memory_ids_json TEXT NOT NULL DEFAULT '[]',
444
+ evidence_json TEXT NOT NULL DEFAULT '[]',
445
+ confidence TEXT NOT NULL DEFAULT 'medium' CHECK (confidence IN ('high', 'medium', 'low')),
446
+ status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'approved', 'rejected', 'superseded')),
447
+ created_at TEXT NOT NULL,
448
+ reviewed_at TEXT,
449
+ reviewer TEXT,
450
+ review_note TEXT,
451
+ metadata_json TEXT NOT NULL DEFAULT '{}',
452
+ UNIQUE(repo_id, title, source_memory_ids_json)
453
+ );
454
+
455
+ CREATE INDEX IF NOT EXISTS idx_knowledge_candidates_status
456
+ ON knowledge_candidates(repo_id, status, created_at);
457
+
458
+ CREATE TABLE IF NOT EXISTS runtime_knowledge (
459
+ knowledge_id TEXT PRIMARY KEY,
460
+ candidate_id TEXT REFERENCES knowledge_candidates(candidate_id) ON DELETE SET NULL,
461
+ repo_id TEXT NOT NULL REFERENCES repos(repo_id) ON DELETE CASCADE,
462
+ scope_type TEXT NOT NULL CHECK (scope_type IN ('global', 'route', 'path', 'symbol', 'workstream')),
463
+ scope_value TEXT NOT NULL DEFAULT '',
464
+ title TEXT NOT NULL,
465
+ prompt_text TEXT NOT NULL,
466
+ retrieval_boost_json TEXT NOT NULL DEFAULT '{}',
467
+ active INTEGER NOT NULL DEFAULT 1 CHECK (active IN (0, 1)),
468
+ approved_by TEXT NOT NULL,
469
+ approved_at TEXT NOT NULL,
470
+ created_at TEXT NOT NULL,
471
+ updated_at TEXT NOT NULL,
472
+ metadata_json TEXT NOT NULL DEFAULT '{}'
473
+ );
474
+
475
+ CREATE INDEX IF NOT EXISTS idx_runtime_knowledge_lookup
476
+ ON runtime_knowledge(repo_id, active, scope_type, scope_value);
477
+
478
+ INSERT OR IGNORE INTO schema_migrations(version, name, checksum, applied_at)
479
+ VALUES (1, 'robert-initial-schema', 'stage-3-schema', datetime('now'));
@@ -0,0 +1,36 @@
1
+ # Failure Modes
2
+
3
+ Business lifecycle and technical status are separate.
4
+
5
+ Task lifecycle:
6
+
7
+ ```text
8
+ detected -> authorized -> classified -> queued -> running -> completed
9
+ detected -> ignored
10
+ running -> waiting_for_user
11
+ running -> failed
12
+ running -> canceled
13
+ ```
14
+
15
+ Technical details live in attempt, lease, notification, authorization, and failure fields.
16
+
17
+ Default timeouts:
18
+
19
+ - stale after 20 minutes: warn locally, do not immediately kill
20
+ - hard timeout after 90 minutes: terminate the worker attempt
21
+ - if the stored worker process has already exited and recovery inspection finds
22
+ recoverable progress, prepare a same-task resume attempt even when the
23
+ attempt has crossed the hard-timeout threshold
24
+ - failed-timeout attempts from earlier runs may be resumed by the supervisor
25
+ when they are still the latest attempt for the task and the same dead-process
26
+ plus recoverable-progress checks pass
27
+ - implementation retry default: zero retries unless the route explicitly allows one
28
+ - if the worker process exits but a heartbeat-wrapped command is still writing
29
+ running snapshots, keep the attempt running with `orphaned_command_running`
30
+ metadata instead of starting a duplicate worker
31
+ - if the worker process exits after recoverable progress, such as dirty
32
+ worktree state, command completion evidence, or worker log tails, mark the
33
+ old attempt failed and prepare a same-task resume attempt with a recovery
34
+ context artifact
35
+
36
+ Local environment, permission, script, and network failures normally notify locally instead of posting GitHub comments. Public comments are allowed only after redaction.
@@ -0,0 +1 @@
1
+ {"actors": []}
@@ -0,0 +1 @@
1
+ {"events": []}
@@ -0,0 +1 @@
1
+ {"cases": []}
@@ -0,0 +1 @@
1
+ {"reviews": []}
@@ -0,0 +1 @@
1
+ {"results": []}
@@ -0,0 +1 @@
1
+ {"workstreams": []}
@@ -0,0 +1,77 @@
1
+ # GitHub Events
2
+
3
+ GitHub notifications are polling hints, not canonical task triggers. A
4
+ notification thread can point at an issue, pull request, or commit and its
5
+ reason can change as the same thread receives later activity. Before creating
6
+ or resuming work, the agent must inspect the source issue or PR timeline,
7
+ comments, reviews, and review comments, then normalize the hint to the
8
+ underlying GitHub event.
9
+
10
+ For multi-repo configs, account notifications must first be attributed by the
11
+ notification payload's `repository.full_name`. The agent must ignore
12
+ notifications for unconfigured repositories and must not probe an arbitrary
13
+ configured repository using only the issue or PR number from the notification.
14
+ Preloaded notification hints follow the same rule: if a hint's
15
+ `repo_full_name` does not match the current repo config, ignore it without
16
+ calling the source issue or PR API.
17
+
18
+ ## Canonical Events
19
+
20
+ | Canonical event | GitHub source | Fingerprint | Creates a task? | Notes |
21
+ | --- | --- | --- | --- | --- |
22
+ | `assigned` | Issue or PR timeline `assigned` event | `assigned:<timeline-event-id>` | Yes, only when the assigner is a trusted actor and the assignee is `github_account`. | Assignment discovery may start from assignee search or from a notification hint; both paths must reuse the same timeline event fingerprint and keep timeline-first resolution ahead of later discussion activity. |
23
+ | `comment` | Issue comment, PR conversation comment, or issue/PR body mention lookup | `comment:<comment-id>` or explicit fixture fingerprint | Yes, only when a trusted actor mentions `github_account`; otherwise context only for known workstreams. | Pull requests are issues in the REST API, so PR conversation comments come from issue comment endpoints. |
24
+ | `review` | Pull request review body | `review:<review-id>` | No for new work by itself; accepted as follow-up context in known workstreams. | A review can carry actionable text for an existing DD PR workstream. |
25
+ | `review_comment` | Pull request diff review comment | `review_comment:<comment-id>` | No for new work by itself; accepted as follow-up context in known workstreams. | Diff comments are distinct from issue comments and must stay distinguishable in prompts and evidence. |
26
+ | `review_request` | PR timeline `review_requested` event | `review_request:<timeline-event-id>` | Yes, only when the requester is trusted and the requested reviewer or team matches `github_account`. | Notification reason `review_requested` must be resolved through the PR timeline before authorization. Route to `review-pr` so the worker reviews PR source in a read-only worktree and records a comment-only result. |
27
+ | `notification` | `/notifications` thread | `notification:<thread-id>` only while unresolved | No. | If lookup cannot complete, record pending authorization; if lookup completes without an actionable canonical event, ignore it. |
28
+
29
+ ## Trigger Rules
30
+
31
+ Task triggers:
32
+
33
+ - trusted actor mentions `github_account`
34
+ - trusted actor assigns an issue or PR to `github_account`
35
+ - trusted actor requests review from `github_account`
36
+ - trusted actor replies to a waiting task with a clear command or natural-language decision
37
+
38
+ Follow-up context in a known workstream is accepted from trusted actors and from
39
+ authors with `author_association` equal to `OWNER`, `MEMBER`, or
40
+ `COLLABORATOR`. When `author_association` is absent or `UNKNOWN`, the agent may
41
+ query collaborator permission and accept `admin`, `maintain`, `write`, or
42
+ `triage`.
43
+
44
+ Issue follow-up belongs to the issue mainline. PR follow-up belongs to the PR mainline, even when the PR was created from an issue task. The PR keeps `origin_workstream_id` metadata so the agent can relate it back to the issue without serializing PR repair behind the issue workstream.
45
+
46
+ DD-authored GitHub content never creates a task. It remains available as
47
+ context and audit evidence.
48
+
49
+ Closed issue or PR notification sources do not create follow-up work. Active
50
+ workstreams are reconciled against the remote source state before new discovery
51
+ is routed: closed issues cancel the active task and close the workstream as
52
+ completed or canceled based on `state_reason`; merged PRs cancel any in-flight
53
+ PR update task and mark the PR workstream completed; closed unmerged PRs cancel
54
+ the PR workstream.
55
+
56
+ ## Realistic Collaboration Cases
57
+
58
+ 1. Issue discussion starts work: a trusted actor mentions `github_account` in an
59
+ issue comment, the agent creates an issue workstream task, later issue
60
+ comments on that active workstream are stored as context or pending events.
61
+ 2. Issue work produces a PR: a successful worker result publishes an `open_pr`
62
+ action with `robert-workstream` metadata. The issue workstream can complete, and
63
+ the derived PR workstream is materialized with `origin_workstream_id`
64
+ pointing back to the issue.
65
+ 3. PR discussion fixes the branch: review bodies, issue-style PR comments, and
66
+ diff review comments on the DD-authored PR are routed on the PR workstream.
67
+ They must update the existing PR branch, not reopen or serialize through the
68
+ origin issue workstream.
69
+ 4. Review request asks for DD attention: a notification with reason
70
+ `review_requested` is only a hint. The canonical trigger is the PR timeline
71
+ `review_requested` event whose requester is trusted and whose requested
72
+ reviewer or team matches `github_account`. This creates a `review-pr` source
73
+ review worktree for the PR head and only permits a planned comment action.
74
+ 5. Closed or merged sources stop creating new work: closed issue/PR notification
75
+ hints are ignored during discovery. Active-task reconciliation must query the
76
+ source issue or PR directly, cancel in-flight work when the source is closed,
77
+ and complete a DD PR workstream when the PR was merged.