brindle 0.5.6__tar.gz → 0.5.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. {brindle-0.5.6 → brindle-0.5.8}/PKG-INFO +4 -2
  2. {brindle-0.5.6 → brindle-0.5.8}/README.md +3 -1
  3. {brindle-0.5.6 → brindle-0.5.8}/pyproject.toml +1 -1
  4. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/agents.py +64 -28
  5. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/antigravity.py +16 -3
  6. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/autopilot.py +22 -7
  7. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/bus.py +3 -2
  8. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/check_scope.py +3 -3
  9. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/cli.py +11 -0
  10. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/clone.py +3 -2
  11. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/cloud_login.py +42 -22
  12. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/codemap.py +5 -3
  13. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/codex_hook.py +6 -4
  14. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/company_login.py +5 -6
  15. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/config.py +5 -4
  16. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/cull.py +40 -0
  17. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/daemon/api-schema.json +4 -0
  18. brindle-0.5.8/src/brindle/daemon/app.py +109 -0
  19. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/daemon/auth.py +66 -6
  20. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/daemon/events.py +56 -0
  21. brindle-0.5.8/src/brindle/daemon/health.py +85 -0
  22. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/daemon/lifecycle.py +31 -6
  23. brindle-0.5.8/src/brindle/daemon/pty_view.py +778 -0
  24. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/daemon/routes_actions.py +63 -12
  25. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/daemon/routes_read.py +49 -7
  26. brindle-0.5.8/src/brindle/daemon/session_review.py +910 -0
  27. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/db.py +85 -2
  28. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/detect.py +3 -2
  29. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/doctor.py +8 -4
  30. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/gates.py +77 -9
  31. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/git.py +50 -4
  32. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/keystore.py +11 -4
  33. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/knowledge.py +2 -3
  34. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/learned_rules.py +7 -5
  35. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/mcp_server.py +81 -2
  36. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/model_access.py +7 -4
  37. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/model_availability.py +16 -9
  38. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/native/serve.py +11 -4
  39. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/permission_grants.py +2 -2
  40. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/permissions.py +6 -2
  41. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pipeline.py +59 -6
  42. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pool.py +2 -6
  43. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/managed_models.py +3 -2
  44. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/orgkey.py +3 -2
  45. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/procs.py +6 -3
  46. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/profiles.py +14 -2
  47. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/providers.py +8 -3
  48. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/providers_install.py +4 -5
  49. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/quota.py +3 -3
  50. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/rule_checks.py +145 -14
  51. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/service/errors.py +2 -0
  52. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/service/sessions.py +2 -4
  53. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/services.py +2 -1
  54. brindle-0.5.8/src/brindle/spawn.py +524 -0
  55. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/status_cache.py +35 -12
  56. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/tasks.py +228 -11
  57. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/tmux.py +38 -11
  58. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/upgrade.py +6 -1
  59. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/workspaces.py +20 -15
  60. brindle-0.5.6/src/brindle/daemon/app.py +0 -49
  61. brindle-0.5.6/src/brindle/daemon/session_review.py +0 -470
  62. {brindle-0.5.6 → brindle-0.5.8}/.gitignore +0 -0
  63. {brindle-0.5.6 → brindle-0.5.8}/LICENSE +0 -0
  64. {brindle-0.5.6 → brindle-0.5.8}/SCHEDULE-A +0 -0
  65. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/__init__.py +0 -0
  66. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/__main__.py +0 -0
  67. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/account.py +0 -0
  68. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/airgap.py +0 -0
  69. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/assembler.py +0 -0
  70. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/assets/braid_dark.png +0 -0
  71. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/assets/braid_light.png +0 -0
  72. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/budget.py +0 -0
  73. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/__init__.py +0 -0
  74. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/backend-auditor.md +0 -0
  75. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/coordinator.md +0 -0
  76. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/developer-codex.md +0 -0
  77. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/developer-fable.md +0 -0
  78. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/developer-gemini.md +0 -0
  79. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/developer-heavy.md +0 -0
  80. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/developer-light.md +0 -0
  81. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/developer-local.md +0 -0
  82. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/developer-opencode.md +0 -0
  83. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/developer-sonnet.md +0 -0
  84. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/developer.md +0 -0
  85. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/qa.md +0 -0
  86. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/reviewer-codex.md +0 -0
  87. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/reviewer-gemini.md +0 -0
  88. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/reviewer-local.md +0 -0
  89. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/reviewer-opencode.md +0 -0
  90. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/reviewer.md +0 -0
  91. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/subagent.md +0 -0
  92. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_agents/supervisor.md +0 -0
  93. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_rules/__init__.py +0 -0
  94. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_rules/analysis/doc.md +0 -0
  95. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_rules/security/backend.md +0 -0
  96. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_rules/style/minimal-diff.md +0 -0
  97. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/builtin_rules/tests/only.md +0 -0
  98. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/ci_adapters.py +0 -0
  99. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/ci_client.py +0 -0
  100. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/ci_federation.py +0 -0
  101. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/ci_hosts.py +0 -0
  102. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/cloud_credential.py +0 -0
  103. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/codemap_docs.py +0 -0
  104. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/company_identity.py +0 -0
  105. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/conflicts.py +0 -0
  106. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/connections.py +0 -0
  107. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/coordinator.py +0 -0
  108. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/cost.py +0 -0
  109. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/cost_estimate.py +0 -0
  110. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/daemon/__init__.py +0 -0
  111. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/daemon/holds.py +0 -0
  112. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/daemon/peer.py +0 -0
  113. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/daemon/routes_org_permissions.py +0 -0
  114. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/daemon/schema.py +0 -0
  115. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/daemon/terminal.py +0 -0
  116. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/debuglog.py +0 -0
  117. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/demo.py +0 -0
  118. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/entry.py +0 -0
  119. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/escapes.py +0 -0
  120. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/events.py +0 -0
  121. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/guardrails.py +0 -0
  122. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/history.py +0 -0
  123. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/identity_lock.py +0 -0
  124. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/inbox.py +0 -0
  125. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/kb.py +0 -0
  126. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/key_check.py +0 -0
  127. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/keys_cmds.py +0 -0
  128. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/launch_health.py +0 -0
  129. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/learning.py +0 -0
  130. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/legacy.py +0 -0
  131. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/local_setup.py +0 -0
  132. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/login_pause.py +0 -0
  133. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/native/__init__.py +0 -0
  134. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/native/catalog.py +0 -0
  135. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/native/client.py +0 -0
  136. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/native/loop.py +0 -0
  137. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/native/lsp.py +0 -0
  138. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/native/permissions.py +0 -0
  139. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/native/runner.py +0 -0
  140. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/native/tools.py +0 -0
  141. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/opencode.py +0 -0
  142. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/org_permissions.py +0 -0
  143. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pane_auth.py +0 -0
  144. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/permission_asks.py +0 -0
  145. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/permission_groups.py +0 -0
  146. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/permission_routing.py +0 -0
  147. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/picker.py +0 -0
  148. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/plugins.py +0 -0
  149. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/policy.py +0 -0
  150. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/preflight.py +0 -0
  151. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pricing.py +0 -0
  152. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/__init__.py +0 -0
  153. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/_files.py +0 -0
  154. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/account.py +0 -0
  155. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/analysis_brief.py +0 -0
  156. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/analysis_docs.py +0 -0
  157. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/analysis_imports.py +0 -0
  158. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/analysis_policy.py +0 -0
  159. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/audit_chain.py +0 -0
  160. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/audit_export.py +0 -0
  161. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/auth.py +0 -0
  162. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/brief_learning.py +0 -0
  163. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/cost_centers.py +0 -0
  164. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/credentials.py +0 -0
  165. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/features.py +0 -0
  166. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/keys.py +0 -0
  167. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/learning.py +0 -0
  168. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/license.py +0 -0
  169. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/loopback.py +0 -0
  170. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/org_profiles.py +0 -0
  171. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/rollout.py +0 -0
  172. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/route_health.py +0 -0
  173. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/settings_sync.py +0 -0
  174. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/status.py +0 -0
  175. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/team_events.py +0 -0
  176. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/pro/team_policy.py +0 -0
  177. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/prompt_answer.py +0 -0
  178. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/provider_homes.py +0 -0
  179. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/repo_cmds.py +0 -0
  180. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/repos.py +0 -0
  181. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/rewind.py +0 -0
  182. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/savings.py +0 -0
  183. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/scratch.py +0 -0
  184. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/secrets.py +0 -0
  185. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/self_serve.py +0 -0
  186. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/service/__init__.py +0 -0
  187. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/service/dto.py +0 -0
  188. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/service/inbox.py +0 -0
  189. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/service/permissions.py +0 -0
  190. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/service/routing.py +0 -0
  191. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/sessions.py +0 -0
  192. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/sidebar_follow.py +0 -0
  193. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/sidebar_logo.py +0 -0
  194. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/signin_pause.py +0 -0
  195. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/updates.py +0 -0
  196. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/usage.py +0 -0
  197. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/view.py +0 -0
  198. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/wake.py +0 -0
  199. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/watch.py +0 -0
  200. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/watch_costs.py +0 -0
  201. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/web/__init__.py +0 -0
  202. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/web/chat.py +0 -0
  203. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/web/dashboard.py +0 -0
  204. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/web/diff.py +0 -0
  205. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/web/server.py +0 -0
  206. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/web/static/app.js +0 -0
  207. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/web/static/index.html +0 -0
  208. {brindle-0.5.6 → brindle-0.5.8}/src/brindle/worker_models.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: brindle
3
- Version: 0.5.6
3
+ Version: 0.5.8
4
4
  Summary: Run coding agents in parallel, each on its own git branch, with a supervisor that delegates, reviews, and merges
5
5
  Project-URL: Homepage, https://pawdelta.com/brindle/
6
6
  Project-URL: Documentation, https://pawdelta.com/brindle/docs/recommended-use
@@ -130,7 +130,7 @@ signed in. Claude Code is the default for the supervisor, workers and reviewer
130
130
  There's also a free brindle desktop app for macOS and Linux (on Windows, use the CLI inside WSL2). It's a download from the brindle website and runs on the same engine; the CLI keeps working alongside it. `brindle app` opens the app, or prints the download link if it isn't installed. `brindle daemon` runs the local API the app talks to: over a Unix socket by default, or on `--tcp` at 127.0.0.1 for WSL. Over `--tcp` the daemon can't check whether a caller is an agent, so its token is the only gate: keep TCP for the WSL client.
131
131
 
132
132
  `brindle --version` prints the installed version; the tmux status bar of every brindle
133
- session shows it too (`brindle 0.5.6`). A session started before an upgrade keeps
133
+ session shows it too (`brindle 0.5.8`). A session started before an upgrade keeps
134
134
  running the old code, and shows the old number, until you restart it.
135
135
 
136
136
  ## Quick start
@@ -492,6 +492,7 @@ knowing them helps when you tell the supervisor how to work.
492
492
  | `list_agents` / `list_tasks` / `list_agent_profiles` | supervisor | who's running, what's queued, which profiles exist; `list_tasks(full=true)` also shows each task's brief and `done_when` |
493
493
  | `list_repos` | supervisor | the repos attached to the session (brindle Pro); `repo=<alias>` on `assign`/`handoff` puts a worker there |
494
494
  | `cancel_task` | supervisor | cancel a queued task (and its dependents) to re-plan |
495
+ | `start_now` | supervisor | start a worker task that is waiting for room now, despite the load (one forced start at a time) |
495
496
  | `requeue` | supervisor | queue a cancelled task again with the same brief, files and profile; `depends_on` replaces its dependencies |
496
497
  | `workspace_diff` | supervisor | a worker branch's changes against its base |
497
498
  | `request_review` / `submit_review` | supervisor / reviewer | start a reviewer on a branch / record its verdict |
@@ -707,6 +708,7 @@ Goal driving, merge gates and cleanup:
707
708
  | `pre_commit` | `true` | run [pre-commit](https://pre-commit.com) over the branch, if the repo uses it |
708
709
  | `max_agents` | `4` | workers running at once per session (`0`: no cap) |
709
710
  | `check_timeout` | `900` | seconds each check may take |
711
+ | `wait_for_room` | `true` | a new worker or check run waits while the machine is busy; `false` starts it at once. While it waits, the supervisor can start a worker anyway with `start_now` |
710
712
  | `check_concurrency` | half the logical cores, at least 2, at most 6 and 2 GB of RAM per run | check runs at once on this machine, across branches; the rest wait their turn (`0`: no cap). A run far past its last duration is reported to the supervisor |
711
713
  | `fable_escalation` | on, unless the worker runs on a cloud account (Bedrock, Vertex or Foundry) | retry a failed heavy task once on `developer-heavy` before handing it to you; `true` turns it on for a cloud account, `false` off |
712
714
  | `usage_limit` | `90` | brindle stops pushing on at this % of your Claude usage limit |
@@ -98,7 +98,7 @@ signed in. Claude Code is the default for the supervisor, workers and reviewer
98
98
  There's also a free brindle desktop app for macOS and Linux (on Windows, use the CLI inside WSL2). It's a download from the brindle website and runs on the same engine; the CLI keeps working alongside it. `brindle app` opens the app, or prints the download link if it isn't installed. `brindle daemon` runs the local API the app talks to: over a Unix socket by default, or on `--tcp` at 127.0.0.1 for WSL. Over `--tcp` the daemon can't check whether a caller is an agent, so its token is the only gate: keep TCP for the WSL client.
99
99
 
100
100
  `brindle --version` prints the installed version; the tmux status bar of every brindle
101
- session shows it too (`brindle 0.5.6`). A session started before an upgrade keeps
101
+ session shows it too (`brindle 0.5.8`). A session started before an upgrade keeps
102
102
  running the old code, and shows the old number, until you restart it.
103
103
 
104
104
  ## Quick start
@@ -460,6 +460,7 @@ knowing them helps when you tell the supervisor how to work.
460
460
  | `list_agents` / `list_tasks` / `list_agent_profiles` | supervisor | who's running, what's queued, which profiles exist; `list_tasks(full=true)` also shows each task's brief and `done_when` |
461
461
  | `list_repos` | supervisor | the repos attached to the session (brindle Pro); `repo=<alias>` on `assign`/`handoff` puts a worker there |
462
462
  | `cancel_task` | supervisor | cancel a queued task (and its dependents) to re-plan |
463
+ | `start_now` | supervisor | start a worker task that is waiting for room now, despite the load (one forced start at a time) |
463
464
  | `requeue` | supervisor | queue a cancelled task again with the same brief, files and profile; `depends_on` replaces its dependencies |
464
465
  | `workspace_diff` | supervisor | a worker branch's changes against its base |
465
466
  | `request_review` / `submit_review` | supervisor / reviewer | start a reviewer on a branch / record its verdict |
@@ -675,6 +676,7 @@ Goal driving, merge gates and cleanup:
675
676
  | `pre_commit` | `true` | run [pre-commit](https://pre-commit.com) over the branch, if the repo uses it |
676
677
  | `max_agents` | `4` | workers running at once per session (`0`: no cap) |
677
678
  | `check_timeout` | `900` | seconds each check may take |
679
+ | `wait_for_room` | `true` | a new worker or check run waits while the machine is busy; `false` starts it at once. While it waits, the supervisor can start a worker anyway with `start_now` |
678
680
  | `check_concurrency` | half the logical cores, at least 2, at most 6 and 2 GB of RAM per run | check runs at once on this machine, across branches; the rest wait their turn (`0`: no cap). A run far past its last duration is reported to the supervisor |
679
681
  | `fable_escalation` | on, unless the worker runs on a cloud account (Bedrock, Vertex or Foundry) | retry a failed heavy task once on `developer-heavy` before handing it to you; `true` turns it on for a cloud account, `false` off |
680
682
  | `usage_limit` | `90` | brindle stops pushing on at this % of your Claude usage limit |
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "brindle"
3
- version = "0.5.6"
3
+ version = "0.5.8"
4
4
  description = "Run coding agents in parallel, each on its own git branch, with a supervisor that delegates, reviews, and merges"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -24,6 +24,7 @@ from contextlib import ExitStack, contextmanager
24
24
  from types import SimpleNamespace
25
25
 
26
26
  from brindle import bus, cloud_credential, company_identity, company_login, git, keystore, knowledge, pane_auth, providers, secrets, tmux, upgrade, workspaces
27
+ from brindle import spawn as processes # this module's own spawn() starts an agent
27
28
  from brindle.assembler import DECISIONS, DOCUMENT_CHUNKS, OTHER_SESSIONS, TASK_AND_RULES, Block, assemble
28
29
  from brindle.config import RepoConfig
29
30
  from brindle.db import DB, Agent, Workspace
@@ -386,8 +387,12 @@ def spawn(
386
387
  files: list[str] | None = None,
387
388
  weight: str | None = None,
388
389
  analysis_doc: bool = False,
390
+ detached: bool = False,
389
391
  ) -> Agent:
390
- """Start an agent in ``ws``. ``weight`` is the weight its task was routed
392
+ """Start an agent in ``ws``. ``detached``: a handoff nobody waits on (a
393
+ queued one) is recorded as 'handoff_detached' from the start, so a
394
+ result it reports at once is forwarded; it is briefed as a handoff.
395
+ ``weight`` is the weight its task was routed
391
396
  as, kept on the agent so the owner's per-kind effort and instructions apply
392
397
  from the first launch. Workers (handoff/assign) given a ``done_when``
393
398
  finish line run it as a Claude Code ``/goal``; their brief carries the
@@ -464,7 +469,8 @@ def spawn(
464
469
  raise PreflightBlocked([off])
465
470
  agent = Agent(
466
471
  id=agent_id, workspace_id=ws.id, profile=profile.name, provider=provider.name,
467
- parent_id=parent_id, mode=mode, status="starting", tmux_window="",
472
+ parent_id=parent_id, mode="handoff_detached" if detached and mode == "handoff" else mode,
473
+ status="starting", tmux_window="",
468
474
  result=None, created_at=time.time(), task=raw_task, headless=int(headless) or None,
469
475
  done_when=done_when, review_sha=review_sha,
470
476
  # Its CLI's config home, decided once here: every later check, its
@@ -856,8 +862,7 @@ def quit_later(root_id: str) -> None:
856
862
  prompt back. Runs detached, since pausing closes the sidebar asking."""
857
863
  from brindle.providers import brindle_invocation
858
864
 
859
- subprocess.Popen([*brindle_invocation(), "_quit", root_id], start_new_session=True,
860
- stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
865
+ processes.detach([*brindle_invocation(), "_quit", root_id])
861
866
 
862
867
 
863
868
  def dismiss_sidebar(db: DB, pane: str | None) -> None:
@@ -1217,7 +1222,7 @@ def _launch_resolved(db: DB, agent: Agent, ws: Workspace, *, prompt: str | None,
1217
1222
  # Without this process's own Claude Code inbox, if it has one: the
1218
1223
  # helper marks the agent ready, and must not take that inbox for it.
1219
1224
  base = {k: v for k, v in os.environ.items() if k not in (inbox.SOCKET_VAR, inbox.TOKEN_VAR)}
1220
- subprocess.Popen(
1225
+ processes.start(
1221
1226
  [*brindle_invocation(), "_after-launch", agent.id, *launch_health.helper_token(agent)],
1222
1227
  start_new_session=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
1223
1228
  env={**base, **agent_env(ws, agent.id)},
@@ -1585,6 +1590,12 @@ def resume(db: DB, root_id: str, *, watch_pane: bool = True,
1585
1590
  resumed.append(a)
1586
1591
  if any(a.id == root_id for a in resumed):
1587
1592
  knowledge.note(db, root_id, knowledge.RESUME)
1593
+ from brindle import tasks
1594
+
1595
+ try:
1596
+ tasks.on_resumed(db, root_id) # queued tasks the pause held back
1597
+ except Exception: # noqa: BLE001 - a queued task must never keep the session from resuming
1598
+ log.exception("brindle: starting %s's queued tasks on resume failed", root_id)
1588
1599
  ap = db.get_autopilot(root_id)
1589
1600
  failed_still = [a for a in candidates if db.get_agent(a.id) and db.get_agent(a.id).status == "failed"]
1590
1601
  if ap and ap.state == "blocked" and resumed and not failed_still:
@@ -2368,8 +2379,7 @@ def warm_checks(ws: Workspace) -> None:
2368
2379
 
2369
2380
  def _detach(args: list[str]) -> None:
2370
2381
  """Start a brindle helper that outlives this process."""
2371
- subprocess.Popen(args, start_new_session=True, stdin=subprocess.DEVNULL,
2372
- stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
2382
+ processes.detach(args)
2373
2383
 
2374
2384
 
2375
2385
  # A shell that starts the command after it in the background and exits, so the
@@ -2382,9 +2392,7 @@ def _detach_orphan(args: list[str]) -> None:
2382
2392
  shell starts it in the background and exits, so it is nobody's child.
2383
2393
  Stopping an agent stops every process descended from its MCP server
2384
2394
  (brindle.procs), a helper ``_detach`` started there included."""
2385
- subprocess.run([*ORPHANED, *args],
2386
- start_new_session=True, stdin=subprocess.DEVNULL,
2387
- stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=False)
2395
+ processes.detach([*ORPHANED, *args]).wait()
2388
2396
 
2389
2397
 
2390
2398
  def wait_for_result(db: DB, agent_id: str, timeout: float, poll: float = 2.0) -> str:
@@ -2577,18 +2585,18 @@ def close_later(agent_id: str, delay: float = 5.0) -> None:
2577
2585
  tool call, which must return before its CLI goes away."""
2578
2586
  from brindle.providers import brindle_invocation
2579
2587
 
2580
- subprocess.Popen(
2581
- [*brindle_invocation(), "_close", agent_id, "--delay", str(delay)],
2582
- start_new_session=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
2583
- )
2588
+ processes.detach([*brindle_invocation(), "_close", agent_id, "--delay", str(delay)])
2584
2589
 
2585
2590
 
2586
2591
  def _stop(db: DB, agent: Agent) -> None:
2587
2592
  """Stop an agent: its window, and every process of its that outlives the
2588
2593
  window (Claude Code's daemon can host the real session; see brindle.procs).
2589
2594
  A pane id a newer agent has since been given is left alone (see owns_pane)."""
2590
- from brindle import procs
2595
+ from brindle import procs, spawn
2591
2596
 
2597
+ # Refused past a request's deadline, before anything is touched; otherwise the
2598
+ # stop (sidebar rescue, window, processes, bookkeeping) runs to its end, client or not.
2599
+ spawn.begin_write()
2592
2600
  # Only a window on the server brindle is using: another server's pane
2593
2601
  # ids mean other panes here (see same_server).
2594
2602
  window = agent.tmux_window if same_server(agent) and owns_pane(db, agent) else ""
@@ -2673,6 +2681,28 @@ def _branch_from_task(profile: str, task: str, agent_hint: str) -> str:
2673
2681
  return f"brindle/{profile}/{'-'.join(words)[:40].strip('-') or 'task'}-{agent_hint}"
2674
2682
 
2675
2683
 
2684
+ class NoRoom(AgentError):
2685
+ """The machine has no room for another worker (``brindle.spawn.no_room``,
2686
+ the reason is the message); nothing was started or created. Callers
2687
+ queue the start instead (``tasks.enqueue(waiting=...)``)."""
2688
+
2689
+
2690
+ def admission(profile: str, repo_root: str) -> str | None:
2691
+ """Why a worker on ``profile`` must wait for room before it starts, or
2692
+ None. A subagent profile starts no process of brindle's: never held."""
2693
+ from brindle import spawn as gate
2694
+ from brindle.providers import PROVIDERS
2695
+
2696
+ busy = gate.no_room(repo_root)
2697
+ if busy is None:
2698
+ return None
2699
+ try:
2700
+ provider = PROVIDERS.get(load_profile(profile, repo_root).provider)
2701
+ except Exception: # noqa: BLE001 - an unloadable profile fails at its start, with its reason
2702
+ return busy
2703
+ return busy if provider is None or provider.launches_process else None
2704
+
2705
+
2676
2706
  def delegate(
2677
2707
  db: DB,
2678
2708
  caller: Agent | None,
@@ -2689,8 +2719,12 @@ def delegate(
2689
2719
  files: list[str] | None = None,
2690
2720
  weight: str | None = None,
2691
2721
  analysis_doc: bool = False,
2722
+ admit: bool = True,
2723
+ detached: bool = False,
2692
2724
  ) -> tuple[Agent, Workspace]:
2693
- """Start a worker. ``weight`` is the weight its task was routed as;
2725
+ """Start a worker, or raise ``NoRoom`` (nothing created) when the machine
2726
+ has no room for it (``admission``); ``admit`` False skips that, for a
2727
+ caller that has just looked. ``detached``: see ``spawn``. ``weight`` is the weight its task was routed as;
2694
2728
  ``analysis_doc`` asks for an analysis doc whatever the weight.
2695
2729
  ``plan_first`` (None: the repo's ``plan_first`` config)
2696
2730
  makes it get a plan approved before it may edit; ``files`` picks the
@@ -2718,6 +2752,9 @@ def delegate(
2718
2752
  why = model_problem(profile, caller_ws)
2719
2753
  if why:
2720
2754
  raise AgentError(why)
2755
+ busy = admission(profile, caller_ws.repo_root) if admit else None
2756
+ if busy:
2757
+ raise NoRoom(busy)
2721
2758
  def start_worker(ws: Workspace) -> Agent:
2722
2759
  # Startup dialogs are handled by the detached _after-launch helper, so
2723
2760
  # handoff/assign return as soon as the window exists instead of polling
@@ -2725,7 +2762,7 @@ def delegate(
2725
2762
  return spawn(
2726
2763
  db, ws, profile, prompt=task, parent_id=caller.id if caller else None, mode=mode,
2727
2764
  done_when=done_when, background_setup=True, plan_first=bool(plan_first), files=files,
2728
- weight=weight, analysis_doc=analysis_doc,
2765
+ weight=weight, analysis_doc=analysis_doc, **({"detached": True} if detached else {}),
2729
2766
  )
2730
2767
 
2731
2768
  if isolate:
@@ -3114,11 +3151,16 @@ def review_after_checks(db: DB, caller_id: str | None, ws: Workspace, profile: s
3114
3151
  second=second, slot=slot)
3115
3152
 
3116
3153
 
3117
- def review_dispatch_lock(workspace_id: str):
3118
- """Share the dispatch lock with recovery's read of the failed agent."""
3154
+ def review_dispatch_lock(workspace_id: str, *, timeout: float | None = None):
3155
+ """Share dispatch with recovery; optionally bound acquisition for a request.
3156
+
3157
+ Nested dispatches in the same thread reuse the lock. Background callers
3158
+ omit ``timeout`` and keep waiting until the current dispatcher finishes.
3159
+ """
3119
3160
  from brindle import pipeline
3120
3161
 
3121
- return pipeline._reentrant_lock("review-dispatch-" + hashlib.sha1(workspace_id.encode()).hexdigest()[:16])
3162
+ return pipeline._reentrant_lock("review-dispatch-" + hashlib.sha1(workspace_id.encode()).hexdigest()[:16],
3163
+ timeout=timeout)
3122
3164
 
3123
3165
 
3124
3166
  def request_review(db: DB, caller: Agent | None, ws: Workspace, profile: str | None = None,
@@ -4138,16 +4180,10 @@ def handle_hook(db: DB, agent_id: str, event: str, payload: dict) -> dict | None
4138
4180
  elif db.pending_count(agent_id) and not agent.headless:
4139
4181
  # Claude Code hasn't drawn its input box yet; deliver shortly after,
4140
4182
  # from a detached process so this hook returns immediately.
4141
- import subprocess
4142
-
4143
4183
  from brindle.providers import brindle_invocation
4144
4184
 
4145
- subprocess.Popen(
4146
- [*brindle_invocation(), "_flush", agent_id, "--delay",
4147
- str(get_provider(agent.provider).ready_delay)],
4148
- start_new_session=True,
4149
- stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
4150
- )
4185
+ processes.detach([*brindle_invocation(), "_flush", agent_id, "--delay",
4186
+ str(get_provider(agent.provider).ready_delay)])
4151
4187
  elif event == "prompt-submit":
4152
4188
  db.set_status(agent_id, "processing")
4153
4189
  from brindle import launch_health
@@ -130,7 +130,18 @@ def tool_names() -> list[str]:
130
130
 
131
131
 
132
132
  def _git(args: list[str], cwd: str) -> subprocess.CompletedProcess:
133
- return subprocess.run(["git", *args], cwd=cwd, capture_output=True, text=True)
133
+ from brindle import spawn
134
+
135
+ return spawn.read(["git", *args], cwd=cwd) # rev-parse, ls-files: reads
136
+
137
+
138
+ def _begin_write() -> None:
139
+ """Refused (spawn.Busy, nothing written) once the request's deadline has
140
+ passed or it was stopped; otherwise the request commits, so the file
141
+ write and the exclude after it run to their end (brindle.spawn)."""
142
+ from brindle import spawn
143
+
144
+ spawn.begin_write()
134
145
 
135
146
 
136
147
  def _exclude(workspace: str, rel: Path) -> None:
@@ -172,6 +183,7 @@ def _merge_json(workspace: str, rel: Path, section: str, key: str, value: object
172
183
  )
173
184
  created = not path.exists()
174
185
  target[key] = value
186
+ _begin_write() # past here the write and its exclude run to their end
175
187
  path.parent.mkdir(parents=True, exist_ok=True)
176
188
  path.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8")
177
189
  if created:
@@ -222,6 +234,7 @@ def install(workspace: str, permission_policy: bool = False, strict: bool = Fals
222
234
  rule = Path(workspace) / AGENTS_DIR / "rules" / "brindle.md"
223
235
  if not rule.exists() or rule.read_text(encoding="utf-8") != RULE:
224
236
  created = not rule.exists()
237
+ _begin_write()
225
238
  rule.parent.mkdir(parents=True, exist_ok=True)
226
239
  rule.write_text(RULE, encoding="utf-8")
227
240
  if created:
@@ -390,10 +403,10 @@ def _tell_parent_stopped_on_error(db, agent, error_type: str) -> None:
390
403
 
391
404
  def _flush_soon(agent_id: str, delay: float = 1.5) -> None:
392
405
  """Type the agent's next queued message once agy has finished stopping."""
406
+ from brindle import spawn
393
407
  from brindle.providers import brindle_invocation
394
408
 
395
- subprocess.Popen([*brindle_invocation(), "_flush", agent_id, "--delay", str(delay)],
396
- start_new_session=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
409
+ spawn.detach([*brindle_invocation(), "_flush", agent_id, "--delay", str(delay)])
397
410
 
398
411
 
399
412
  def pre_tool_decision(db, agent_id: str | None, payload: object, strict: bool = False) -> dict:
@@ -48,7 +48,7 @@ from dataclasses import dataclass
48
48
  from pathlib import Path
49
49
 
50
50
  from brindle.config import CONFIG_DIR, WEIGHTS, RepoConfig, config_root, load_repo_config, workspace_config
51
- from brindle import bus, escapes, knowledge
51
+ from brindle import bus, escapes, knowledge, spawn
52
52
  from brindle.db import DB, Agent, Autopilot, Milestone, Workspace, check_state
53
53
  from brindle.profiles import load_profile
54
54
 
@@ -1225,12 +1225,13 @@ CANCEL_POLL = 1.0 # seconds between looks at ``cancel`` while a check runs
1225
1225
 
1226
1226
 
1227
1227
  def run_check(cmd: str, cwd: str, env: dict[str, str], timeout: int,
1228
- cancel=None) -> tuple[bool, str]:
1228
+ cancel=None, background: bool = False) -> tuple[bool, str]:
1229
1229
  """Run one check command. Returns (passed, the tail of its output).
1230
1230
  ``cancel``, if given, is polled while the command runs; when it turns
1231
- true the command is killed and ``CheckCancelled`` is raised."""
1232
- proc = subprocess.Popen(
1233
- cmd, shell=True, cwd=cwd, env={**os.environ, **env}, stdout=subprocess.PIPE,
1231
+ true the command is killed and ``CheckCancelled`` is raised.
1232
+ ``background``: at background priority (``spawn._background``)."""
1233
+ proc = spawn.start(
1234
+ spawn._background(["/bin/sh", "-c", cmd], force=True) if background else cmd, shell=not background, cwd=cwd, env={**os.environ, **env}, stdout=subprocess.PIPE,
1234
1235
  stderr=subprocess.PIPE, text=True, stdin=subprocess.DEVNULL, start_new_session=True,
1235
1236
  )
1236
1237
  if cancel is None:
@@ -1284,8 +1285,7 @@ def checking(ap: Autopilot, timeout: float = 900.0) -> bool:
1284
1285
 
1285
1286
  def _detach(args: list[str]) -> None:
1286
1287
  """Start a brindle helper that outlives this process."""
1287
- subprocess.Popen(args, start_new_session=True, stdin=subprocess.DEVNULL,
1288
- stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
1288
+ spawn.detach(args)
1289
1289
 
1290
1290
 
1291
1291
  def check_in_background(db: DB, root_id: str, ws: Workspace, position: int | None,
@@ -2103,6 +2103,21 @@ def on_stop(db: DB, agent: Agent, payload: dict) -> dict | None:
2103
2103
  if any(agents.runs_process(a) for a in working
2104
2104
  if getattr(a, "plan_state", None) != "proposed"):
2105
2105
  return None # their results arrive as messages and wake it up
2106
+ from brindle import tasks
2107
+
2108
+ if waiting := tasks.waiting_for_room(db, agent.id):
2109
+ # Workers queued until the machine has room start on their own, and the
2110
+ # start message wakes the supervisor. Not a stall, so no nudge is counted;
2111
+ # but once per step it is told which wait on it, so it decides rather than forgets.
2112
+ now = time.time()
2113
+ if ap.nudged_at == ap.progress and ap.nudged_time is not None and now - ap.nudged_time < NUDGE_BACKOFF:
2114
+ return None
2115
+ db.update_autopilot(agent.id, nudged_at=ap.progress, nudged_time=now)
2116
+ listing = "\n".join(f"- {t.id}: {t.task_text[:80]}" for t in waiting)
2117
+ return {"decision": "block", "reason": (
2118
+ f"{NUDGE_HEAD}\nThese workers are waiting for room on the machine "
2119
+ f"({tasks.load_note(db)}):\n{listing}\nThey start on their own when there's room. "
2120
+ "Wait, call start_now(task_id) to start one despite the load, or cancel_task to give it up.")}
2106
2121
  if (db.outstanding(agent.id, NUDGE_HEAD) or db.outstanding(agent.id, WAIT_ENDED_HEAD)
2107
2122
  or db.outstanding(agent.id, QUESTION_REMINDER_HEAD)):
2108
2123
  return None # (#209) the last reminder is still queued or unread: never pile up another
@@ -125,11 +125,12 @@ def _rollup(c, cutoff: float) -> None:
125
125
  old = c.execute("SELECT samples FROM stage_timings WHERE day=? AND repo_root=? AND stage=?",
126
126
  (day, repo, stage)).fetchone()
127
127
  values = (json.loads(old["samples"]) if old else []) + new
128
- c.execute("INSERT OR REPLACE INTO stage_timings VALUES (?, ?, ?, ?, ?, ?, ?)",
128
+ c.execute("INSERT OR REPLACE INTO stage_timings (day, repo_root, stage, n, median_s, p90_s, samples)"
129
+ " VALUES (?, ?, ?, ?, ?, ?, ?)",
129
130
  (day, repo, stage, len(values), statistics.median(values),
130
131
  _percentile(sorted(values), 0.9), json.dumps(values)))
131
132
  c.execute("DELETE FROM stage_open")
132
- c.executemany("INSERT INTO stage_open VALUES (?, ?, ?, ?)",
133
+ c.executemany("INSERT INTO stage_open (workspace_id, stage, who, ts) VALUES (?, ?, ?, ?)",
133
134
  [(*k, v) for k, v in open_at.items()])
134
135
 
135
136
 
@@ -40,7 +40,7 @@ from fnmatch import fnmatch
40
40
  from pathlib import Path, PurePosixPath
41
41
  from typing import TYPE_CHECKING
42
42
 
43
- from brindle import git
43
+ from brindle import git, spawn
44
44
 
45
45
  if TYPE_CHECKING:
46
46
  from brindle.db import DB, Workspace
@@ -406,8 +406,8 @@ def affected_tests(graph: Path, node_id: str, cwd: str) -> set[str] | None:
406
406
  """The test files ``graphify affected`` lists for ``node_id``; None when
407
407
  the lookup itself failed (not the same as reaching no test)."""
408
408
  try:
409
- proc = subprocess.run(["graphify", "affected", node_id, "--graph", str(graph)], cwd=cwd,
410
- capture_output=True, text=True, timeout=GRAPHIFY_SECONDS)
409
+ proc = spawn.read(["graphify", "affected", node_id, "--graph", str(graph)], cwd=cwd,
410
+ timeout=GRAPHIFY_SECONDS)
411
411
  except (OSError, subprocess.TimeoutExpired):
412
412
  return None
413
413
  if proc.returncode != 0:
@@ -3129,6 +3129,17 @@ def finish_review_cmd(reviewer_id: str, workspace_id: str) -> None:
3129
3129
  agents.finish_review(_helper_db(), reviewer_id, workspace_id)
3130
3130
 
3131
3131
 
3132
+ @app.command("_start-when-room", hidden=True)
3133
+ def start_when_room_cmd(task_id: str) -> None:
3134
+ """Start a task queued for room on the machine once there is (detached)."""
3135
+ import signal
3136
+
3137
+ from brindle import tasks
3138
+
3139
+ signal.signal(signal.SIGHUP, signal.SIG_IGN)
3140
+ tasks.start_when_room(_helper_db(), task_id)
3141
+
3142
+
3132
3143
  @app.command("_statusline", hidden=True)
3133
3144
  def statusline_cmd() -> None:
3134
3145
  from brindle.providers import status_line
@@ -11,6 +11,7 @@ from collections.abc import Callable
11
11
  from pathlib import Path
12
12
  from urllib.parse import urlsplit
13
13
 
14
+ from brindle import spawn
14
15
  from brindle.service.errors import ServiceError
15
16
 
16
17
  # Tests only: lets a file:// URL (a local bare repo) through. Production refuses it.
@@ -61,8 +62,8 @@ def clone(url: str, dest: Path, on_line: Callable[[str], None]) -> str:
61
62
  (git ends them with CR or LF) to ``on_line``. Returns the path; a failure
62
63
  raises a ServiceError carrying git's own message."""
63
64
  env = {**os.environ, "GIT_TERMINAL_PROMPT": "0"} # no prompt to hang on: fail with git's message
64
- proc = subprocess.Popen(["git", "clone", "--progress", "--", url, str(dest)], stdin=subprocess.DEVNULL,
65
- stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, env=env)
65
+ proc = spawn.start(["git", "clone", "--progress", "--", url, str(dest)], stdin=subprocess.DEVNULL,
66
+ stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, env=env)
66
67
  lines: list[str] = []
67
68
  buf = b""
68
69
  assert proc.stderr is not None
@@ -21,6 +21,7 @@ import shlex
21
21
  import signal
22
22
  import subprocess
23
23
  import sys
24
+ import threading
24
25
  import time
25
26
  import urllib.parse
26
27
  import urllib.request
@@ -29,7 +30,7 @@ from datetime import datetime, timezone
29
30
  from pathlib import Path
30
31
  from typing import Mapping
31
32
 
32
- from brindle import model_access
33
+ from brindle import model_access, spawn
33
34
 
34
35
  CLI_TIMEOUT = 15.0
35
36
  # A sign-in tab this old is dead: AWS and Azure device codes and Google's
@@ -326,26 +327,13 @@ def _aws(env: Mapping[str, str], home: Path, now: float) -> LoginStatus:
326
327
 
327
328
  def run_bounded(argv: list[str], *, capture_output: bool = True, text: bool = True,
328
329
  timeout: float = CLI_TIMEOUT, env=None) -> subprocess.CompletedProcess:
329
- """``subprocess.run`` for a cloud CLI that leaves nothing behind: the CLI
330
- gets no terminal and its own process group, and a timeout ends the whole
331
- group (gcloud is a wrapper around python, which may hold a local auth
332
- server and its port), not just the wrapper."""
333
- with subprocess.Popen(argv, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
334
- stderr=subprocess.PIPE, text=text, env=env,
335
- start_new_session=True) as proc:
336
- try:
337
- out, err = proc.communicate(timeout=timeout)
338
- except BaseException:
339
- try:
340
- os.killpg(proc.pid, signal.SIGKILL)
341
- except OSError:
342
- proc.kill()
343
- raise # Popen's exit reaps the wrapper
344
- try: # a server the CLI left running (trade-off: the group id could in theory
345
- os.killpg(proc.pid, signal.SIGKILL) # be reused once the group is empty)
346
- except OSError:
347
- pass
348
- return subprocess.CompletedProcess(argv, proc.returncode, out, err)
330
+ """A cloud CLI probe that leaves nothing behind, as a brindle.spawn read:
331
+ the CLI gets no terminal and its own process group; ``timeout`` (raising
332
+ TimeoutExpired), the request's deadline or its stop (raising spawn.Busy)
333
+ ends the whole group (gcloud is a wrapper around python, which may hold a
334
+ local auth server and its port), not just the wrapper, and so does the
335
+ wrapper's exit. Past the deadline it never starts."""
336
+ return spawn.read(argv, env=env, text=text, timeout=timeout, reap=True)
349
337
 
350
338
 
351
339
  def _full_env(env: Mapping[str, str] | None) -> dict[str, str] | None:
@@ -418,9 +406,40 @@ def tokeninfo_expiry(token: str, timeout: float = CLI_TIMEOUT) -> float | None:
418
406
  return None
419
407
 
420
408
 
409
+ _GOOGLE_TOKEN_MARGIN = 300.0
410
+ # Expiry (epoch seconds) of the access token gcloud last minted, by the env that
411
+ # selects the account. Only the expiry is kept, never the token.
412
+ _google_expiry_cache: dict[tuple, float] = {}
413
+ _google_locks: dict[tuple, threading.Lock] = {}
414
+ _google_locks_guard = threading.Lock()
415
+
416
+
417
+ def _google_cache_key(full: Mapping[str, str]) -> tuple:
418
+ adc = Path(full.get("GOOGLE_APPLICATION_CREDENTIALS") or _gcloud_adc_file(full))
419
+ try:
420
+ stamp = adc.stat().st_mtime_ns # a new sign-in rewrites the file
421
+ except OSError:
422
+ stamp = None
423
+ names = ("CLOUDSDK_CONFIG", "GOOGLE_APPLICATION_CREDENTIALS", "CLOUDSDK_CORE_ACCOUNT",
424
+ "CLOUDSDK_AUTH_IMPERSONATE_SERVICE_ACCOUNT", "CLOUDSDK_ACTIVE_CONFIG_NAME", "HOME")
425
+ return (*(full.get(n) for n in names), stamp)
426
+
427
+
421
428
  def _google(run, env, now: float, expiry) -> LoginStatus:
422
429
  full = {**os.environ, **(env or {})}
423
430
  refresh = "gcloud auth application-default login" if _google_browser_login(full) else ""
431
+ key = _google_cache_key(full)
432
+ with _google_locks_guard:
433
+ lock = _google_locks.setdefault(key, threading.Lock())
434
+ with lock: # one gcloud call per identity; the others wait, then reuse its result
435
+ cached = _google_expiry_cache.get(key)
436
+ if cached is not None and cached - now > _GOOGLE_TOKEN_MARGIN:
437
+ return _from_expiry(cached, refresh, now, "")
438
+ _google_expiry_cache.pop(key, None)
439
+ return _google_mint(run, env, now, expiry, key, refresh)
440
+
441
+
442
+ def _google_mint(run, env, now: float, expiry, key: tuple, refresh: str) -> LoginStatus:
424
443
  try:
425
444
  proc = run(["gcloud", "auth", "application-default", "print-access-token"],
426
445
  capture_output=True, text=True, timeout=CLI_TIMEOUT, env=_full_env(env))
@@ -433,6 +452,7 @@ def _google(run, env, now: float, expiry) -> LoginStatus:
433
452
  left = expiry(token)
434
453
  if left is None:
435
454
  return LoginStatus(True, None, refresh, "logged in; token expiry unknown")
455
+ _google_expiry_cache[key] = now + left
436
456
  return _from_expiry(now + left, refresh, now, "")
437
457
  if model_access.expired_login(f"{proc.stdout or ''}\n{proc.stderr or ''}") is not None:
438
458
  return LoginStatus(False, None, refresh, "login expired (invalid_grant)", expired=True)
@@ -740,7 +760,7 @@ def sign_in(provider: str | None = None, *, env: Mapping[str, str] | None = None
740
760
  try:
741
761
  # The child inherits the locked descriptor: the lock is held until
742
762
  # the sign-in exits, however long the person takes.
743
- proc = (popen or subprocess.Popen)(
763
+ proc = (popen or spawn.start)(
744
764
  shlex.split(s.refresh_cmd), env=child_env, stdin=subprocess.DEVNULL,
745
765
  stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
746
766
  start_new_session=True, pass_fds=(fd,))
@@ -38,10 +38,12 @@ import time
38
38
  from pathlib import Path
39
39
  from typing import TYPE_CHECKING, Callable
40
40
 
41
+ from brindle import spawn
42
+
41
43
  if TYPE_CHECKING:
42
44
  from brindle.db import Workspace
43
45
 
44
- GRAPH = Path("graphify-out") / "graph.json"
46
+ GRAPH =Path("graphify-out") / "graph.json"
45
47
  # Read-only graphify commands, pre-approved for Claude agents.
46
48
  ALLOWED_TOOLS = ["Bash(graphify query:*)", "Bash(graphify explain:*)", "Bash(graphify path:*)",
47
49
  "Bash(graphify affected:*)"]
@@ -377,7 +379,7 @@ def _request_refresh(checkout: str, repo_root: str | None, *, background: bool)
377
379
 
378
380
  log = brindle_home() / "graphify.log"
379
381
  with log.open("a", encoding="utf-8") as out:
380
- subprocess.Popen(
382
+ spawn.start(
381
383
  [sys.executable, "-P", "-c",
382
384
  "import sys; from brindle.codemap import _run_refresh; "
383
385
  "_run_refresh(sys.argv[1], sys.argv[2] or None, int(sys.argv[3]))",
@@ -451,7 +453,7 @@ def _start_refresh(checkout: str, repo_root: str | None, lock_fd: int) -> Callab
451
453
  log = brindle_home() / "graphify.log"
452
454
  log.parent.mkdir(parents=True, exist_ok=True)
453
455
  with open(log, "a", encoding="utf-8") as out:
454
- proc = subprocess.Popen(
456
+ proc = spawn.start(
455
457
  ["nice", "-n", "10", "graphify", "update", checkout, "--force"],
456
458
  cwd=checkout,
457
459
  start_new_session=True,
@@ -47,6 +47,8 @@ import time
47
47
  from dataclasses import dataclass
48
48
  from pathlib import Path
49
49
 
50
+ from brindle import spawn
51
+
50
52
  EVENT = "codex-permission-request"
51
53
  # Seconds Codex gives the hook: room for the default permission_hold_seconds
52
54
  # (a day) plus agents.HOOK_SLACK. Codex caps only SessionEnd hooks' timeouts
@@ -297,10 +299,10 @@ class _AppServer:
297
299
  def __init__(self, binary: str, flags: list[str], timeout: float = 30.0):
298
300
  self.timeout = timeout
299
301
  try:
300
- self.proc = subprocess.Popen([binary, "app-server", *flags], stdin=subprocess.PIPE,
301
- stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True,
302
- start_new_session=True,
303
- env={**os.environ, "CODEX_HOME": str(codex_home())})
302
+ self.proc = spawn.start([binary, "app-server", *flags], stdin=subprocess.PIPE,
303
+ stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True,
304
+ start_new_session=True,
305
+ env={**os.environ, "CODEX_HOME": str(codex_home())})
304
306
  except OSError as e:
305
307
  raise CodexHookError(f"couldn't run {binary}: {e}") from e
306
308
  self.lines: queue.Queue = queue.Queue()