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,616 @@
1
+ #!/usr/bin/env python3
2
+ import argparse
3
+ from pathlib import Path
4
+
5
+ import yaml
6
+
7
+ from robert_agent import worker_adapters
8
+ from robert_agent.common import emit
9
+ from robert_agent.route_config import (
10
+ load_route_policies,
11
+ resolve_route_config,
12
+ )
13
+
14
+
15
+ def load_config(path):
16
+ config_path = Path(path).expanduser()
17
+ data = yaml.safe_load(config_path.read_text(encoding="utf-8"))
18
+ if not isinstance(data, dict):
19
+ raise ValueError("config root must be a mapping")
20
+ return data
21
+
22
+
23
+ def _normalize_workers(config):
24
+ raw_workers = config.get("workers")
25
+ legacy_fields = {"worker_agent", "worker_command"} & set(config)
26
+ if raw_workers not in (None, "") and legacy_fields:
27
+ raise ValueError(
28
+ "workers cannot be combined with legacy fields: "
29
+ f"{', '.join(sorted(legacy_fields))}"
30
+ )
31
+
32
+ if raw_workers in (None, ""):
33
+ worker_config = worker_adapters.normalize_worker_agent_config(config)
34
+ return [
35
+ {
36
+ "name": "default",
37
+ **worker_config,
38
+ "default_model": "gpt-5.4",
39
+ "default_effort": "high",
40
+ }
41
+ ]
42
+ if isinstance(raw_workers, dict):
43
+ normalized = []
44
+ for name, raw_worker in raw_workers.items():
45
+ if not isinstance(raw_worker, dict):
46
+ raise ValueError(f"workers.{name} must be a mapping")
47
+ unsupported_fields = sorted(
48
+ set(raw_worker)
49
+ - {
50
+ "adapter",
51
+ "command",
52
+ "model",
53
+ "effort",
54
+ "prompt_transport",
55
+ "timeout_seconds",
56
+ "environment_allowlist",
57
+ }
58
+ )
59
+ if unsupported_fields:
60
+ raise ValueError(
61
+ f"workers.{name} contains unsupported fields: "
62
+ f"{', '.join(unsupported_fields)}"
63
+ )
64
+ worker_name = str(name).strip()
65
+ if not worker_name:
66
+ raise ValueError("worker name must not be empty")
67
+ command = raw_worker.get("command", "")
68
+ default_model = str(raw_worker.get("model", "")).strip()
69
+ default_effort = str(raw_worker.get("effort", "")).strip()
70
+ if not str(command).strip():
71
+ raise ValueError(f"workers.{name}.command must not be empty")
72
+ if not default_model:
73
+ raise ValueError(f"workers.{name}.model must not be empty")
74
+ if not default_effort:
75
+ raise ValueError(f"workers.{name}.effort must not be empty")
76
+ worker = worker_adapters.normalize_worker_agent_config(
77
+ {
78
+ "worker_agent": raw_worker.get("adapter", ""),
79
+ "worker_command": command,
80
+ "prompt_transport": raw_worker.get(
81
+ "prompt_transport",
82
+ "stdin",
83
+ ),
84
+ "timeout_seconds": raw_worker.get(
85
+ "timeout_seconds",
86
+ 5400,
87
+ ),
88
+ "environment_allowlist": raw_worker.get(
89
+ "environment_allowlist",
90
+ [],
91
+ ),
92
+ }
93
+ )
94
+ normalized.append(
95
+ {
96
+ "name": worker_name,
97
+ **worker,
98
+ "default_model": default_model,
99
+ "default_effort": default_effort,
100
+ }
101
+ )
102
+ if not normalized:
103
+ raise ValueError("workers must contain at least one named worker")
104
+ return normalized
105
+ if not isinstance(raw_workers, list) or not raw_workers:
106
+ raise ValueError("workers must contain at least one worker")
107
+
108
+ normalized = []
109
+ seen_names = set()
110
+ for index, raw_worker in enumerate(raw_workers):
111
+ if not isinstance(raw_worker, dict):
112
+ raise ValueError(f"workers[{index}] must be a mapping")
113
+ unsupported_fields = sorted(
114
+ set(raw_worker)
115
+ - {
116
+ "name",
117
+ "agent",
118
+ "command",
119
+ "default_model",
120
+ "default_effort",
121
+ "prompt_transport",
122
+ "timeout_seconds",
123
+ "environment_allowlist",
124
+ }
125
+ )
126
+ if unsupported_fields:
127
+ raise ValueError(
128
+ f"workers[{index}] contains unsupported fields: "
129
+ f"{', '.join(unsupported_fields)}"
130
+ )
131
+ name = str(raw_worker.get("name", "")).strip()
132
+ if not name:
133
+ raise ValueError(f"workers[{index}].name must not be empty")
134
+ if name in seen_names:
135
+ raise ValueError(f"duplicate worker name: {name}")
136
+ seen_names.add(name)
137
+
138
+ default_model = str(raw_worker.get("default_model", "")).strip()
139
+ default_effort = str(raw_worker.get("default_effort", "")).strip()
140
+ command = raw_worker.get("command", "")
141
+ if not str(command).strip():
142
+ raise ValueError(f"workers[{index}].command must not be empty")
143
+ if not default_model:
144
+ raise ValueError(f"workers[{index}].default_model must not be empty")
145
+ if not default_effort:
146
+ raise ValueError(f"workers[{index}].default_effort must not be empty")
147
+
148
+ adapter_config = {
149
+ "worker_agent": raw_worker.get("agent", ""),
150
+ "worker_command": command,
151
+ "prompt_transport": raw_worker.get(
152
+ "prompt_transport",
153
+ "stdin",
154
+ ),
155
+ "timeout_seconds": raw_worker.get(
156
+ "timeout_seconds",
157
+ 5400,
158
+ ),
159
+ "environment_allowlist": raw_worker.get(
160
+ "environment_allowlist",
161
+ [],
162
+ ),
163
+ }
164
+ worker_config = worker_adapters.normalize_worker_agent_config(adapter_config)
165
+ normalized.append(
166
+ {
167
+ "name": name,
168
+ **worker_config,
169
+ "default_model": default_model,
170
+ "default_effort": default_effort,
171
+ }
172
+ )
173
+ return normalized
174
+
175
+
176
+ def _normalize_route_worker_models(config, workers):
177
+ raw = config.get("route_worker_models", {})
178
+ if raw in (None, ""):
179
+ return {}
180
+ if not isinstance(raw, dict):
181
+ raise ValueError("route_worker_models must be a mapping of route id to model configuration")
182
+ workers_by_name = {worker["name"]: worker for worker in workers}
183
+ default_worker = workers[0]
184
+ normalized = {}
185
+ for route_id, route_config in raw.items():
186
+ route_id = str(route_id).strip()
187
+ if not route_id:
188
+ raise ValueError("route_worker_models route id must not be empty")
189
+ if not isinstance(route_config, dict):
190
+ raise ValueError(
191
+ f"route_worker_models.{route_id} must be a worker configuration"
192
+ )
193
+ unsupported_fields = sorted(set(route_config) - {"worker", "model", "effort"})
194
+ if unsupported_fields:
195
+ raise ValueError(
196
+ f"route_worker_models.{route_id} contains unsupported fields: "
197
+ f"{', '.join(unsupported_fields)}"
198
+ )
199
+ worker_name = str(route_config.get("worker", default_worker["name"])).strip()
200
+ if not worker_name:
201
+ raise ValueError(f"route_worker_models.{route_id}.worker must not be empty")
202
+ worker = workers_by_name.get(worker_name)
203
+ if worker is None:
204
+ raise ValueError(
205
+ f"route_worker_models.{route_id} references unknown worker: {worker_name}"
206
+ )
207
+ model = str(route_config.get("model", worker["default_model"])).strip()
208
+ effort = str(route_config.get("effort", worker["default_effort"])).strip()
209
+ if not model:
210
+ raise ValueError(f"route_worker_models.{route_id}.model must not be empty")
211
+ if not effort:
212
+ raise ValueError(f"route_worker_models.{route_id}.effort must not be empty")
213
+ normalized[route_id] = {
214
+ "worker": worker_name,
215
+ "model": model,
216
+ "effort": effort,
217
+ }
218
+ return normalized
219
+
220
+
221
+ DAEMON_DEFAULTS = {
222
+ "enabled": True,
223
+ "local_poll_seconds": 5,
224
+ "github_poll_seconds": 300,
225
+ "github_poll_when_full_seconds": 600,
226
+ "rate_limit_cache_seconds": 300,
227
+ "min_search_remaining": 10,
228
+ "min_core_remaining": 500,
229
+ "live_run_timeout_seconds": 300,
230
+ "local_drain_timeout_seconds": 180,
231
+ "event_retention_days": 7,
232
+ "run_on_start": False,
233
+ }
234
+
235
+
236
+ def _normalize_daemon_config(config):
237
+ daemon = {
238
+ "enabled": bool(config.get("daemon_enabled", DAEMON_DEFAULTS["enabled"])),
239
+ "local_poll_seconds": int(config.get("daemon_local_poll_seconds", DAEMON_DEFAULTS["local_poll_seconds"])),
240
+ "github_poll_seconds": int(config.get("daemon_github_poll_seconds", DAEMON_DEFAULTS["github_poll_seconds"])),
241
+ "github_poll_when_full_seconds": int(config.get("daemon_github_poll_when_full_seconds", DAEMON_DEFAULTS["github_poll_when_full_seconds"])),
242
+ "rate_limit_cache_seconds": int(config.get("daemon_rate_limit_cache_seconds", DAEMON_DEFAULTS["rate_limit_cache_seconds"])),
243
+ "min_search_remaining": int(config.get("daemon_min_search_remaining", DAEMON_DEFAULTS["min_search_remaining"])),
244
+ "min_core_remaining": int(config.get("daemon_min_core_remaining", DAEMON_DEFAULTS["min_core_remaining"])),
245
+ "live_run_timeout_seconds": int(config.get("daemon_live_run_timeout_seconds", DAEMON_DEFAULTS["live_run_timeout_seconds"])),
246
+ "local_drain_timeout_seconds": int(config.get("daemon_local_drain_timeout_seconds", DAEMON_DEFAULTS["local_drain_timeout_seconds"])),
247
+ "event_retention_days": int(config.get("daemon_event_retention_days", DAEMON_DEFAULTS["event_retention_days"])),
248
+ "run_on_start": bool(config.get("daemon_run_on_start", DAEMON_DEFAULTS["run_on_start"])),
249
+ }
250
+ for key, value in daemon.items():
251
+ if isinstance(value, bool):
252
+ continue
253
+ if value < 1:
254
+ raise ValueError(f"daemon_{key} must be at least 1")
255
+ return daemon
256
+
257
+
258
+ def _placeholder_fields(repo):
259
+ placeholders = {
260
+ "full_name": {"OWNER/REPO"},
261
+ "github_account": {"robot-user"},
262
+ "repo_root": {"/absolute/path/to/local/repo"},
263
+ "worktree_root": {"/absolute/path/to/local/repo/.worktrees"},
264
+ }
265
+ fields = [
266
+ key
267
+ for key, values in placeholders.items()
268
+ if str(repo.get(key, "")) in values
269
+ ]
270
+ trusted_actors = repo.get("trusted_actors") or []
271
+ if "your-github-login" in trusted_actors:
272
+ fields.append("trusted_actors")
273
+ return fields
274
+
275
+
276
+ def validate_config(config_path, skip_external=False):
277
+ try:
278
+ config = load_config(config_path)
279
+ public_config = "version" in config
280
+ if public_config and config.get("version") != 1:
281
+ raise ValueError("version must be 1")
282
+ github_config = config.get("github")
283
+ if public_config:
284
+ if not isinstance(github_config, dict):
285
+ raise ValueError("github must be a mapping")
286
+ unsupported_github = sorted(
287
+ set(github_config) - {"account", "poll_seconds"}
288
+ )
289
+ if unsupported_github:
290
+ raise ValueError(
291
+ "unsupported github fields: "
292
+ + ", ".join(
293
+ f"github.{name}"
294
+ for name in unsupported_github
295
+ )
296
+ )
297
+ github_account = str(github_config.get("account", "")).strip()
298
+ github_poll_seconds = int(github_config.get("poll_seconds", 300))
299
+ if github_poll_seconds < 1:
300
+ raise ValueError("github.poll_seconds must be at least 1")
301
+ if "github_account" in config:
302
+ raise ValueError(
303
+ "unsupported public config field: github_account"
304
+ )
305
+ else:
306
+ github_account = str(config.get("github_account", "")).strip()
307
+ github_poll_seconds = 300
308
+ data_dir = Path(str(config["data_dir"])).expanduser()
309
+ database = (
310
+ ""
311
+ if config["database"] is None
312
+ else str(config["database"]).strip()
313
+ )
314
+ repos = config["repos"]
315
+ stale_after_minutes = int(config.get("stale_after_minutes", 20))
316
+ hard_timeout_minutes = int(config.get("hard_timeout_minutes", 90))
317
+ worker_startup_grace_seconds = int(config.get("worker_startup_grace_seconds", 300))
318
+ lease_ttl_minutes = int(config.get("lease_ttl_minutes", 9))
319
+ max_concurrency = int(config.get("max_concurrency", 3))
320
+ python_bin_value = config.get("python_bin", "python3")
321
+ python_bin = (
322
+ ""
323
+ if python_bin_value is None
324
+ else str(python_bin_value).strip()
325
+ )
326
+ workers = _normalize_workers(config)
327
+ default_worker = workers[0]
328
+ route_worker_models = _normalize_route_worker_models(config, workers)
329
+ daemon_config = _normalize_daemon_config(config)
330
+ skills_config = config.get("skills", {"search_paths": []})
331
+ if not isinstance(skills_config, dict):
332
+ raise ValueError("skills must be a mapping")
333
+ skill_search_paths = skills_config.get("search_paths", [])
334
+ if not isinstance(skill_search_paths, list):
335
+ raise ValueError("skills.search_paths must be a list")
336
+ routes_config = config.get("routes", {})
337
+ if not isinstance(routes_config, dict):
338
+ raise ValueError("routes must be a mapping")
339
+ except (KeyError, OSError, TypeError, ValueError, yaml.YAMLError) as exc:
340
+ error = str(exc)
341
+ safe_error = (
342
+ error
343
+ if error.startswith(
344
+ (
345
+ "unsupported worker_agent:",
346
+ "worker_agent must ",
347
+ "worker_command must ",
348
+ )
349
+ )
350
+ else f"invalid config: {error}"
351
+ )
352
+ return {
353
+ "ok": False,
354
+ "status": "failed_config",
355
+ "safe_error": safe_error,
356
+ }
357
+
358
+ worker_agent_config = {
359
+ "agent": default_worker["agent"],
360
+ "command": default_worker["command"],
361
+ "command_argv": default_worker["command_argv"],
362
+ }
363
+ worker_agent = default_worker["agent"]
364
+ worker_command = default_worker["command"]
365
+
366
+ if not python_bin:
367
+ return {
368
+ "ok": False,
369
+ "status": "failed_config",
370
+ "safe_error": "python_bin must not be empty",
371
+ }
372
+ if not database:
373
+ return {
374
+ "ok": False,
375
+ "status": "failed_config",
376
+ "safe_error": "database must not be empty",
377
+ }
378
+ if Path(database).name != database:
379
+ return {
380
+ "ok": False,
381
+ "status": "failed_config",
382
+ "safe_error": f"database must be a filename, not a path: {database}",
383
+ }
384
+ if data_dir.exists() and not data_dir.is_dir():
385
+ return {
386
+ "ok": False,
387
+ "status": "failed_config",
388
+ "safe_error": f"data_dir is not a directory: {data_dir}",
389
+ }
390
+ positive_integer_fields = {
391
+ "max_concurrency": max_concurrency,
392
+ "stale_after_minutes": stale_after_minutes,
393
+ "hard_timeout_minutes": hard_timeout_minutes,
394
+ "worker_startup_grace_seconds": worker_startup_grace_seconds,
395
+ "lease_ttl_minutes": lease_ttl_minutes,
396
+ }
397
+ for field, value in positive_integer_fields.items():
398
+ if value < 1:
399
+ return {
400
+ "ok": False,
401
+ "status": "failed_config",
402
+ "safe_error": f"{field} must be at least 1",
403
+ }
404
+
405
+ if not isinstance(repos, list) or not repos:
406
+ return {
407
+ "ok": False,
408
+ "status": "failed_config",
409
+ "safe_error": "repos must contain at least one repository",
410
+ }
411
+
412
+ seen_repo_names = set()
413
+ normalized_repos = []
414
+ for index, repo in enumerate(repos):
415
+ if not isinstance(repo, dict):
416
+ return {
417
+ "ok": False,
418
+ "status": "failed_config",
419
+ "safe_error": f"repos[{index}] must be a mapping",
420
+ }
421
+ repo_full_name = str(repo.get("full_name", "")).strip()
422
+ if repo_full_name in seen_repo_names:
423
+ return {
424
+ "ok": False,
425
+ "status": "failed_config",
426
+ "safe_error": f"duplicate repo full_name: {repo_full_name}",
427
+ }
428
+ if repo_full_name:
429
+ seen_repo_names.add(repo_full_name)
430
+
431
+ effective_github_account = str(repo.get("github_account") or github_account).strip()
432
+ if not effective_github_account:
433
+ return {
434
+ "ok": False,
435
+ "status": "failed_config",
436
+ "safe_error": f"repos[{index}].github_account must not be empty",
437
+ }
438
+ if public_config:
439
+ unsupported_repo_fields = sorted(
440
+ set(repo)
441
+ & {
442
+ "repo_root",
443
+ "worktree_root",
444
+ "default_base_branch",
445
+ }
446
+ )
447
+ if unsupported_repo_fields:
448
+ raise ValueError(
449
+ f"repos[{index}] contains unsupported public fields: "
450
+ f"{', '.join(unsupported_repo_fields)}"
451
+ )
452
+ repo = {
453
+ **repo,
454
+ "full_name": repo_full_name,
455
+ "github_account": effective_github_account,
456
+ "repo_root": repo.get("checkout"),
457
+ "worktree_root": repo.get("worktrees"),
458
+ "default_base_branch": repo.get("default_branch"),
459
+ }
460
+ else:
461
+ repo = {
462
+ **repo,
463
+ "full_name": repo_full_name,
464
+ "github_account": effective_github_account,
465
+ "repo_root": repo.get("repo_root", repo.get("checkout")),
466
+ "worktree_root": repo.get(
467
+ "worktree_root",
468
+ repo.get("worktrees"),
469
+ ),
470
+ "default_base_branch": repo.get(
471
+ "default_base_branch",
472
+ repo.get("default_branch"),
473
+ ),
474
+ }
475
+ trusted_actors = repo.get("trusted_actors")
476
+ if not trusted_actors:
477
+ return {
478
+ "ok": False,
479
+ "status": "failed_config",
480
+ "safe_error": f"repos[{index}].trusted_actors must not be empty",
481
+ }
482
+ required_keys = [
483
+ "full_name",
484
+ "github_account",
485
+ "default_base_branch",
486
+ "repo_root",
487
+ "worktree_root",
488
+ ]
489
+ missing = [key for key in required_keys if not repo.get(key)]
490
+ if missing:
491
+ return {
492
+ "ok": False,
493
+ "status": "failed_config",
494
+ "safe_error": f"repos[{index}] missing required keys: {', '.join(missing)}",
495
+ }
496
+
497
+ placeholder_fields = _placeholder_fields(repo)
498
+ if placeholder_fields:
499
+ return {
500
+ "ok": False,
501
+ "status": "failed_config",
502
+ "safe_error": (
503
+ f"repos[{index}] contains placeholder values: "
504
+ f"{', '.join(placeholder_fields)}"
505
+ ),
506
+ }
507
+
508
+ repo_root = Path(str(repo["repo_root"])).expanduser()
509
+ if not repo_root.exists() or not (repo_root / ".git").exists():
510
+ return {
511
+ "ok": False,
512
+ "status": "failed_config",
513
+ "safe_error": f"repos[{index}].repo_root is not a git checkout: {repo_root}",
514
+ }
515
+
516
+ worktree_root = Path(str(repo["worktree_root"])).expanduser()
517
+ repo_max_concurrency = repo.get("max_concurrency", max_concurrency)
518
+ if (
519
+ isinstance(repo_max_concurrency, bool)
520
+ or not isinstance(repo_max_concurrency, int)
521
+ or repo_max_concurrency < 1
522
+ or repo_max_concurrency > max_concurrency
523
+ ):
524
+ return {
525
+ "ok": False,
526
+ "status": "failed_config",
527
+ "safe_error": (
528
+ f"repos[{index}].max_concurrency must be an integer between "
529
+ f"1 and global max_concurrency ({max_concurrency})"
530
+ ),
531
+ }
532
+ normalized_repos.append(
533
+ {
534
+ **repo,
535
+ "trusted_actors": list(trusted_actors),
536
+ "repo_root": str(repo_root),
537
+ "worktree_root": str(worktree_root),
538
+ "max_concurrency": repo_max_concurrency,
539
+ }
540
+ )
541
+
542
+ route_validation_config = {
543
+ "workers": workers,
544
+ "routes": routes_config,
545
+ }
546
+ try:
547
+ for repo in normalized_repos:
548
+ for policy in load_route_policies():
549
+ route_config = resolve_route_config(
550
+ route_validation_config,
551
+ repo,
552
+ policy,
553
+ )
554
+ if route_config["worker"] not in {
555
+ worker["name"]
556
+ for worker in workers
557
+ }:
558
+ raise ValueError(
559
+ f"route {route_config['id']} references unknown "
560
+ f"worker: {route_config['worker']}"
561
+ )
562
+ except ValueError as exc:
563
+ return {
564
+ "ok": False,
565
+ "status": "failed_config",
566
+ "safe_error": f"invalid config: {exc}",
567
+ }
568
+
569
+ return {
570
+ "ok": True,
571
+ "status": "valid",
572
+ "config_path": str(Path(config_path)),
573
+ "data_dir": str(data_dir),
574
+ "db_path": str(data_dir / database),
575
+ "version": config.get("version"),
576
+ "github": {
577
+ "account": github_account,
578
+ "poll_seconds": github_poll_seconds,
579
+ },
580
+ "github_account": github_account,
581
+ "repos": normalized_repos,
582
+ "stale_after_minutes": stale_after_minutes,
583
+ "hard_timeout_minutes": hard_timeout_minutes,
584
+ "worker_startup_grace_seconds": worker_startup_grace_seconds,
585
+ "lease_ttl_minutes": lease_ttl_minutes,
586
+ "max_concurrency": max_concurrency,
587
+ "python_bin": python_bin,
588
+ "worker_agent": worker_agent,
589
+ "worker_command": worker_command,
590
+ "worker_agent_config": worker_agent_config,
591
+ "workers": workers,
592
+ "default_worker": default_worker,
593
+ "route_worker_models": route_worker_models,
594
+ "routes": routes_config,
595
+ "skills": {
596
+ "search_paths": [
597
+ str(Path(path).expanduser())
598
+ for path in skill_search_paths
599
+ ],
600
+ },
601
+ "daemon": daemon_config,
602
+ "skip_external": bool(skip_external),
603
+ }
604
+
605
+
606
+ def main(argv=None):
607
+ parser = argparse.ArgumentParser()
608
+ parser.add_argument("--config", required=True)
609
+ parser.add_argument("--skip-external", action="store_true")
610
+ args = parser.parse_args(argv)
611
+ result = validate_config(args.config, skip_external=args.skip_external)
612
+ return emit(result, 0 if result["ok"] else 3)
613
+
614
+
615
+ if __name__ == "__main__":
616
+ raise SystemExit(main())