code-coordinator 0.5.415__py3-none-any.whl → 0.5.417__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.
- {code_coordinator-0.5.415.dist-info → code_coordinator-0.5.417.dist-info}/METADATA +1 -1
- {code_coordinator-0.5.415.dist-info → code_coordinator-0.5.417.dist-info}/RECORD +14 -14
- coord/auto_loop.py +65 -38
- coord/commands/plan_followup.py +137 -10
- coord/diagnose.py +87 -2
- coord/dispatch.py +129 -1
- coord/interactive.py +28 -2
- coord/issue_store.py +20 -28
- coord/review.py +12 -3
- coord/state.py +123 -0
- {code_coordinator-0.5.415.dist-info → code_coordinator-0.5.417.dist-info}/WHEEL +0 -0
- {code_coordinator-0.5.415.dist-info → code_coordinator-0.5.417.dist-info}/entry_points.txt +0 -0
- {code_coordinator-0.5.415.dist-info → code_coordinator-0.5.417.dist-info}/licenses/LICENSE +0 -0
- {code_coordinator-0.5.415.dist-info → code_coordinator-0.5.417.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
code_coordinator-0.5.
|
|
1
|
+
code_coordinator-0.5.417.dist-info/licenses/LICENSE,sha256=851BVZZwf_pEv2ydSlMmcZrwnwSS5YJ98wdLze7lyL8,4212
|
|
2
2
|
coord/__init__.py,sha256=3FN2qrrxtW87xSsSD557YcMwHLDahnFK8LvqQI7Wlf4,9783
|
|
3
3
|
coord/_board_mapping.py,sha256=5FTW-8Dg5SzHvszdFj9MuAirpe2KmRqgipZWBAhgUJI,11627
|
|
4
4
|
coord/acceptance.py,sha256=oAec-wQbrcR5PPfI9NW8JJYipfQ9-3EDpmMmxrP3pQM,90211
|
|
@@ -8,7 +8,7 @@ coord/agent_app.py,sha256=ZYdY1HHkB4MFPfR-jbEewb4hOCSr0ygtaj7ccPGTGl8,99206
|
|
|
8
8
|
coord/agent_update.py,sha256=51ySDSoHT5kTB82nO46uwBwymvbCS2ncLAQ1E7fsAcI,37489
|
|
9
9
|
coord/approved_work.py,sha256=wSoxJe2KeapPtDTfrM7mcCy-BrS6DhRvjnQr48Rnsh0,19207
|
|
10
10
|
coord/audit.py,sha256=PHbwmojBaXpJjk1CVzHygkXKVe-wy6AJGrKsL7yod8I,19451
|
|
11
|
-
coord/auto_loop.py,sha256=
|
|
11
|
+
coord/auto_loop.py,sha256=OsUlWAj0Y2kvHbC7ibWEWbH0MH3QQyvRa04DPmPDqkA,79660
|
|
12
12
|
coord/backup.py,sha256=9mkHgsdnMXQ40Uyi_CUAi_4kZEZFCGB1_Rtz0Yh6FAk,37981
|
|
13
13
|
coord/block_log.py,sha256=8_3pvOFBkPl9FWZ7pg0XrINiOE61X1ZXqRkoUZjVvLA,56714
|
|
14
14
|
coord/board_schema.py,sha256=_8x8wU37IcFZlQ6klZohL0X_m8qvnQjMbqlOU7nmBwE,15203
|
|
@@ -39,8 +39,8 @@ coord/deploy_manifest.py,sha256=X-deE_n6oRfDQDRSqcnLCEiLUMXbgKqgBUaoU1MD1hg,8103
|
|
|
39
39
|
coord/deploy_units.py,sha256=ZfFueMPXKW4u8geOMEHhmgyseUPuKWNub77NDjMNrHA,24097
|
|
40
40
|
coord/deprecation_telemetry.py,sha256=ZK6wmN3qzF2-Ic1iVpYSC8Y4gw1sA0sJnerErzgKAI8,4149
|
|
41
41
|
coord/deps.py,sha256=WnV5u_zYw_f3oMr88Qy7EUVeb3vBj5cTq8Ts1oGAR2s,3770
|
|
42
|
-
coord/diagnose.py,sha256=
|
|
43
|
-
coord/dispatch.py,sha256=
|
|
42
|
+
coord/diagnose.py,sha256=VCLUvNCQeZ-80uTUSiq8u6FqkSZFN0IdVioKlj2D77I,104544
|
|
43
|
+
coord/dispatch.py,sha256=UkAtoZy0pjGzTk06k6zPaSqXIMgf6RCrcMIW6H6aQJg,64745
|
|
44
44
|
coord/dist_name.py,sha256=XDhumYscJahwcaKjmSw135HYsnXQjwGGxRo0Qv4b0xM,5583
|
|
45
45
|
coord/dr_promote.py,sha256=xS9fFvzrY-EjSEj1XMSwD7RtjbBhhXZT76XFLnddDng,60329
|
|
46
46
|
coord/dr_verify.py,sha256=sIRNLFkDZFEv_kY2Z-shsoGiPIbeE17sccnoJG2-7mI,44757
|
|
@@ -64,8 +64,8 @@ coord/goal.py,sha256=URYTwPHFU2zpCjrDYoKoItZiNCb8EMaOzMTOfY51dSs,5198
|
|
|
64
64
|
coord/graph_health.py,sha256=VN9Eg3uTMlcQ3Hm-tNUhW0-LjMsBp7To_jd5-avdfkI,29823
|
|
65
65
|
coord/hooks.py,sha256=fdEwUf1zGF7xFm9TqlTda94EmtH2Tl8NNVeD-JfpkvA,3968
|
|
66
66
|
coord/housekeeping.py,sha256=mHCyewO8w-XWesEFSn3GUuVeSP2Jz7uSHAOoLoll2nY,10510
|
|
67
|
-
coord/interactive.py,sha256=
|
|
68
|
-
coord/issue_store.py,sha256=
|
|
67
|
+
coord/interactive.py,sha256=L8wMrKV-ykh--TGjVLLZFa5S0KKdiVN8Q28wpMfTVio,220556
|
|
68
|
+
coord/issue_store.py,sha256=T9vp_TpD6v7cjsZkEnVQYt9hSJwZcoksRq7hQsMwN_I,74000
|
|
69
69
|
coord/issues_sync_status.py,sha256=_6ucx7oW3TUGZZvs93wRbzR_SUQcNlz-7RptOzr4alo,9262
|
|
70
70
|
coord/liveness_auditor.py,sha256=sf_xBklt37DUnrIEeD4fVp4_gWPDaXbydZgfuWAPFRE,12478
|
|
71
71
|
coord/machine_metrics.py,sha256=paWqBTZgeIi7w1pgH5QSJL59UxwetxE8bXblzzcspSI,16300
|
|
@@ -111,7 +111,7 @@ coord/repo_onboard.py,sha256=HRm-SALgUNcp6h0Zr5B1kR-4RH-6jBucpTZ3-BCL6wY,94132
|
|
|
111
111
|
coord/reports.py,sha256=7pAdEGUjWyKTqZ3EKeeg6_jrtOTC7WMKbOvonirFRsQ,170794
|
|
112
112
|
coord/rest_schema.py,sha256=RymD01eTPN8ckVZEyMlDXlcc5riKjQeCnAtFzuLOuWs,12063
|
|
113
113
|
coord/revalidate.py,sha256=fQaYCvObqUawSZWMEOkVWFtYswz9PQQwSMApAyP5zeA,66266
|
|
114
|
-
coord/review.py,sha256=
|
|
114
|
+
coord/review.py,sha256=_-jWVtySdXROojobPynssAbJF4SyK1Y97xaaE1V9fYE,236013
|
|
115
115
|
coord/scorecard.py,sha256=axe_doBJBBFWtN21JZDRSijwDI0xaZrt2oVYbwJPW7U,20211
|
|
116
116
|
coord/self_health.py,sha256=9PLVdaEReFLUY6y2QXMGVd6U1CdHAh9_8MzduwBOzAY,10651
|
|
117
117
|
coord/serve_app.py,sha256=WxyeNtwiqxpVbI344vC7zarpe993cZnFsPCPpicnfKc,540068
|
|
@@ -120,7 +120,7 @@ coord/spend_ceiling.py,sha256=hfuiXlnD4or7Wqoqf6BHcOMT2CXd92FBZuVdnQVlI2M,13573
|
|
|
120
120
|
coord/split_work.py,sha256=Gp_cNtYBe7nDxBN7cDRs8CJG3V_Y0C1QUi35fHGcvnY,8502
|
|
121
121
|
coord/sql.py,sha256=wOXKh4b5cJT1KYi4GTp6USBnAQOuFt4S08x0DINkaS0,62734
|
|
122
122
|
coord/stage_projection.py,sha256=BtVNqOOnv5mttJbdoSBC8QES5Nh-bzkkdWBlrFuT-D8,52012
|
|
123
|
-
coord/state.py,sha256=
|
|
123
|
+
coord/state.py,sha256=88tqlQoWek_YJvH6u4uGccSWtfLSjo2IqgDs2zFAFPM,351674
|
|
124
124
|
coord/store_migrate.py,sha256=NFB7BT41OkedR9oGl8br2xGKlBKJVVwaLhmyfgEc0Rg,39163
|
|
125
125
|
coord/store_parity.py,sha256=wCmGUSYXZPtEhYMaw4H-JpY3QdcKL-op9m81nNSfM3Q,20111
|
|
126
126
|
coord/test_author.py,sha256=CCLMyEDpLE1bjancrmiqvemzBJD-JToINMSSov4vY2o,60120
|
|
@@ -156,7 +156,7 @@ coord/commands/lifecycle.py,sha256=M-SvlBT6k7yhO5TCSGCXs-w2JlnWRwicuI-9YScpvCg,2
|
|
|
156
156
|
coord/commands/machine.py,sha256=cVW7Bb1eO5ovCQm5K4loWW0xrHyEcf70Mqp84--c1p4,21851
|
|
157
157
|
coord/commands/merge.py,sha256=x9jzvnDGD_N46xiK1EF9rlRTsqFwVfnkKlsPtiDH6uI,138076
|
|
158
158
|
coord/commands/milestone.py,sha256=SlTZwESFz07pHb0ZW2gA03h0M8hTONnK4vbYLIj8cL4,83165
|
|
159
|
-
coord/commands/plan_followup.py,sha256=
|
|
159
|
+
coord/commands/plan_followup.py,sha256=V9vw6LVKfB9cyrO7Y9Bnc3LTxtbXVLChoaSFn61RPhk,67199
|
|
160
160
|
coord/commands/plans.py,sha256=OxcMyDWIhFFiA13lbxOGOscLXckgZqEy6FfzRSRrm00,5408
|
|
161
161
|
coord/commands/portal.py,sha256=RLUD_tfJ9pH3DplHAa8n3BY58k02870Afa7ayJyNE8E,111522
|
|
162
162
|
coord/commands/pr.py,sha256=J-8wMjymkT50bQdWP6KoHcX5PdfA-ChJuvym6t1byZc,19966
|
|
@@ -267,8 +267,8 @@ coord/skills/review-verdict-recovery/SKILL.md,sha256=Grg8GWkJLK20ct2YiigbTFfNOki
|
|
|
267
267
|
coord/skills/tui-quadraui-workflow/SKILL.md,sha256=4hUZza9wSSnPhf0eRAOh2r_MQZxK2pXYO5g-kxmJq-U,3832
|
|
268
268
|
coord/skills/update-issue/SKILL.md,sha256=VrPinEmLZrCSNDrnz96hQomyO403o5c4i0RdsnUnWA0,3642
|
|
269
269
|
coord/templates/deploy-cloudflare.node.yml,sha256=icsTiWn2ziQJnpZODhhFKYlnqjt2xAXsbwlQufdxhuM,2078
|
|
270
|
-
code_coordinator-0.5.
|
|
271
|
-
code_coordinator-0.5.
|
|
272
|
-
code_coordinator-0.5.
|
|
273
|
-
code_coordinator-0.5.
|
|
274
|
-
code_coordinator-0.5.
|
|
270
|
+
code_coordinator-0.5.417.dist-info/METADATA,sha256=Oxog8zR661_fXHSWqE8SI3dwrxK-of5sLYps5Ulw5Rs,27178
|
|
271
|
+
code_coordinator-0.5.417.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
272
|
+
code_coordinator-0.5.417.dist-info/entry_points.txt,sha256=o-Hq8pvG7ReGePvN_4iOKjLNqiq-MJ43HbPurqjNPZo,41
|
|
273
|
+
code_coordinator-0.5.417.dist-info/top_level.txt,sha256=w5sTrXesTCebhXyYv2qufOZGo0PoD1Lxgn0Q3MAXjh4,6
|
|
274
|
+
code_coordinator-0.5.417.dist-info/RECORD,,
|
coord/auto_loop.py
CHANGED
|
@@ -9,7 +9,12 @@ creating a closed loop.
|
|
|
9
9
|
The loop terminates when:
|
|
10
10
|
- A review approves the changes (verdict = ``approve``)
|
|
11
11
|
- The iteration count hits ``pipeline.max_review_iterations``
|
|
12
|
-
- A fix worker fails to dispatch
|
|
12
|
+
- A fix worker fails to dispatch — no configured machine is both capable
|
|
13
|
+
of the repo and actually reachable right now (#3208: an unreachable
|
|
14
|
+
ORIGINAL worker machine alone no longer stops this — see
|
|
15
|
+
``coord.dispatch.select_fix_machine``, which falls back to another
|
|
16
|
+
capable, reachable machine first and names every machine it tried when
|
|
17
|
+
none is usable)
|
|
13
18
|
|
|
14
19
|
Config (coordinator.yml)::
|
|
15
20
|
|
|
@@ -268,9 +273,15 @@ def process_review_completion(
|
|
|
268
273
|
http_client: httpx.Client | None = None,
|
|
269
274
|
terminal_cache: dict | None = None,
|
|
270
275
|
dispatch_fixes: bool = True,
|
|
276
|
+
override_machine: str | None = None,
|
|
271
277
|
) -> list[LoopAction]:
|
|
272
278
|
"""Process a completed review assignment through the auto-loop.
|
|
273
279
|
|
|
280
|
+
*override_machine* (#3208, from ``coord fix --machine``) is forwarded to
|
|
281
|
+
:func:`_dispatch_fix_for_review` when a fix is dispatched; it has no
|
|
282
|
+
effect on any other outcome (approve, max-iterations, terminal-skip,
|
|
283
|
+
...).
|
|
284
|
+
|
|
274
285
|
Parses the reviewer's verdict (local log or agent HTTP fallback when
|
|
275
286
|
*machine_host* is supplied), then either:
|
|
276
287
|
|
|
@@ -438,6 +449,7 @@ def process_review_completion(
|
|
|
438
449
|
return _dispatch_fix_for_review(
|
|
439
450
|
review, findings, board, config,
|
|
440
451
|
http_client=http_client, terminal_cache=terminal_cache,
|
|
452
|
+
override_machine=override_machine,
|
|
441
453
|
)
|
|
442
454
|
|
|
443
455
|
|
|
@@ -805,8 +817,13 @@ def _dispatch_fix_for_review(
|
|
|
805
817
|
*,
|
|
806
818
|
http_client: httpx.Client | None = None,
|
|
807
819
|
terminal_cache: dict | None = None,
|
|
820
|
+
override_machine: str | None = None,
|
|
808
821
|
) -> list[LoopAction]:
|
|
809
|
-
"""Find the reviewed work assignment and dispatch a fix worker for it.
|
|
822
|
+
"""Find the reviewed work assignment and dispatch a fix worker for it.
|
|
823
|
+
|
|
824
|
+
*override_machine* (#3208, from ``coord fix --machine``) is forwarded
|
|
825
|
+
straight to :func:`_dispatch_fix` — see its docstring.
|
|
826
|
+
"""
|
|
810
827
|
# Locate the work assignment that was reviewed.
|
|
811
828
|
work: Assignment | None = None
|
|
812
829
|
if review.review_of_assignment_id:
|
|
@@ -903,16 +920,26 @@ def _dispatch_fix_for_review(
|
|
|
903
920
|
work, merged_findings, next_iteration, max_iter
|
|
904
921
|
)
|
|
905
922
|
model = _fix_model_for_iteration(config, next_iteration)
|
|
923
|
+
fix_failure: list[str] = []
|
|
906
924
|
fix = _dispatch_fix(
|
|
907
925
|
work, briefing, board, config, next_iteration,
|
|
908
926
|
model=model, http_client=http_client,
|
|
927
|
+
override_machine=override_machine, failure_detail=fix_failure,
|
|
909
928
|
)
|
|
910
929
|
|
|
911
930
|
if fix is None:
|
|
931
|
+
# #3208: name the machine(s) actually tried and why, when
|
|
932
|
+
# `_dispatch_fix` could produce one — falls back to the old generic
|
|
933
|
+
# line only for a failure mode it can't attribute to a machine (e.g.
|
|
934
|
+
# persistent DB contention recording the dispatched assignment).
|
|
935
|
+
detail = (
|
|
936
|
+
fix_failure[0] if fix_failure
|
|
937
|
+
else "fix worker dispatch failed (agent unreachable or no capable machine)"
|
|
938
|
+
)
|
|
912
939
|
return [LoopAction(
|
|
913
940
|
kind="no_work_found",
|
|
914
941
|
assignment_id=review.assignment_id,
|
|
915
|
-
detail=
|
|
942
|
+
detail=detail,
|
|
916
943
|
)]
|
|
917
944
|
|
|
918
945
|
log.info(
|
|
@@ -1158,11 +1185,25 @@ def _dispatch_fix(
|
|
|
1158
1185
|
model: str | None = None,
|
|
1159
1186
|
http_client: httpx.Client | None = None,
|
|
1160
1187
|
remote_branch_checker=None,
|
|
1188
|
+
override_machine: str | None = None,
|
|
1189
|
+
status_fetcher=None,
|
|
1190
|
+
failure_detail: list[str] | None = None,
|
|
1161
1191
|
) -> Assignment | None:
|
|
1162
1192
|
"""POST a fix assignment to the agent server.
|
|
1163
1193
|
|
|
1164
1194
|
Prefers the same machine as the original worker (the branch is already
|
|
1165
|
-
checked out there).
|
|
1195
|
+
checked out there). Falls back to any OTHER capable machine that is
|
|
1196
|
+
actually reachable right now (#3208) — see
|
|
1197
|
+
:func:`coord.dispatch.select_fix_machine`, the one function both doors
|
|
1198
|
+
onto ``coord fix`` use to answer "which machine" (#2096).
|
|
1199
|
+
|
|
1200
|
+
*override_machine* — from ``coord fix --machine`` — pins the dispatch to
|
|
1201
|
+
exactly that machine (no fallback). *status_fetcher* is forwarded to
|
|
1202
|
+
:func:`coord.dispatch.select_fix_machine` for test injection. When the
|
|
1203
|
+
caller passes a *failure_detail* list, a human-readable reason (naming
|
|
1204
|
+
the machine(s) tried and why) is appended to it whenever this returns
|
|
1205
|
+
``None`` for lack of a usable machine — the #3208 fix for a bare
|
|
1206
|
+
"dispatch failed: timed out" with no named cause.
|
|
1166
1207
|
|
|
1167
1208
|
#1176/#2302: the dispatched type mirrors ``work.type`` for any
|
|
1168
1209
|
:data:`coord.models.SEALED_PATH_AUTHOR_TYPES` member (``"test-author"``,
|
|
@@ -1180,41 +1221,27 @@ def _dispatch_fix(
|
|
|
1180
1221
|
Returns the new Assignment (already added to ``board.active``), or None
|
|
1181
1222
|
on failure.
|
|
1182
1223
|
"""
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1224
|
+
from coord.dispatch import describe_fix_machine_failure, select_fix_machine
|
|
1225
|
+
|
|
1226
|
+
selection = select_fix_machine(
|
|
1227
|
+
original_machine_name=work.machine_name,
|
|
1228
|
+
repo_name=work.repo_name,
|
|
1229
|
+
machines=config.machines,
|
|
1230
|
+
override_machine_name=override_machine,
|
|
1231
|
+
status_fetcher=status_fetcher,
|
|
1186
1232
|
)
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
or not machine.can_work_on(work.repo_name)
|
|
1200
|
-
or machine.repo_path(work.repo_name) is None
|
|
1201
|
-
or machine.name in paused
|
|
1202
|
-
):
|
|
1203
|
-
# Fallback: any machine capable of working on this repo, minus
|
|
1204
|
-
# any the user has paused via `coord pause` (routing-pause).
|
|
1205
|
-
candidates = [
|
|
1206
|
-
m for m in config.machines
|
|
1207
|
-
if m.can_work_on(work.repo_name)
|
|
1208
|
-
and m.repo_path(work.repo_name) is not None
|
|
1209
|
-
and m.name not in paused
|
|
1210
|
-
]
|
|
1211
|
-
if not candidates:
|
|
1212
|
-
log.warning(
|
|
1213
|
-
"auto_loop: no machine can handle repo %r (paused=%r)",
|
|
1214
|
-
work.repo_name, sorted(paused)
|
|
1215
|
-
)
|
|
1216
|
-
return None
|
|
1217
|
-
machine = candidates[0]
|
|
1233
|
+
machine = selection.machine
|
|
1234
|
+
if machine is None:
|
|
1235
|
+
reason = describe_fix_machine_failure(
|
|
1236
|
+
work.machine_name, selection, override_machine_name=override_machine,
|
|
1237
|
+
)
|
|
1238
|
+
log.warning(
|
|
1239
|
+
"auto_loop: fix dispatch for %s declined: %s",
|
|
1240
|
+
work.assignment_id, reason,
|
|
1241
|
+
)
|
|
1242
|
+
if failure_detail is not None:
|
|
1243
|
+
failure_detail.append(reason)
|
|
1244
|
+
return None
|
|
1218
1245
|
|
|
1219
1246
|
# #586: if we ended up routing to a different machine than the original
|
|
1220
1247
|
# worker, the branch must exist on the remote so the fix worker can fetch
|
coord/commands/plan_followup.py
CHANGED
|
@@ -106,6 +106,7 @@ def _dispatch_followup(
|
|
|
106
106
|
type: str = "work",
|
|
107
107
|
files_likely: list[str] | None = None,
|
|
108
108
|
inherit_branch: bool = True,
|
|
109
|
+
machine_name: str | None = None,
|
|
109
110
|
) -> str:
|
|
110
111
|
"""Dispatch a follow-up assignment for an existing assignment. Returns assignment ID.
|
|
111
112
|
|
|
@@ -125,6 +126,14 @@ def _dispatch_followup(
|
|
|
125
126
|
PLAN assignment: a plan never pushes, its recorded branch is a
|
|
126
127
|
throwaway worktree name (sometimes a stale/wrong capture), and the
|
|
127
128
|
work it spawns must start a FRESH branch derived from the issue.
|
|
129
|
+
|
|
130
|
+
*machine_name* (#3208) overrides which machine the follow-up is
|
|
131
|
+
dispatched to — defaults to ``original.machine_name``, same as before
|
|
132
|
+
this parameter existed. A same-branch fix caller that has already
|
|
133
|
+
resolved a live, capable machine via
|
|
134
|
+
:func:`coord.dispatch.select_fix_machine` (because the original worker's
|
|
135
|
+
machine turned out to be unreachable) passes that resolved name here
|
|
136
|
+
instead of unconditionally re-aiming at the original.
|
|
128
137
|
"""
|
|
129
138
|
from coord.board_service import read_board, write_board
|
|
130
139
|
from coord.dispatch import dispatch, post_briefing, compute_do_not_touch
|
|
@@ -137,7 +146,7 @@ def _dispatch_followup(
|
|
|
137
146
|
|
|
138
147
|
proposal = Proposal(
|
|
139
148
|
id=0,
|
|
140
|
-
machine_name=original.machine_name,
|
|
149
|
+
machine_name=machine_name or original.machine_name,
|
|
141
150
|
repo_name=original.repo_name,
|
|
142
151
|
issue_number=original.issue_number,
|
|
143
152
|
issue_title=original.issue_title,
|
|
@@ -633,6 +642,7 @@ def _fix_from_review(
|
|
|
633
642
|
*,
|
|
634
643
|
guidance: str,
|
|
635
644
|
force: bool,
|
|
645
|
+
machine_override: str | None = None,
|
|
636
646
|
) -> None:
|
|
637
647
|
"""#1622: dispatch a HEADLESS fix round for a request-changes review.
|
|
638
648
|
|
|
@@ -727,6 +737,7 @@ def _fix_from_review(
|
|
|
727
737
|
before = {a.assignment_id for a in board.active}
|
|
728
738
|
actions = auto_loop.process_review_completion(
|
|
729
739
|
review, board, cfg, log_path=log_path, machine_host=machine_host,
|
|
740
|
+
override_machine=machine_override,
|
|
730
741
|
)
|
|
731
742
|
|
|
732
743
|
# `process_review_completion` mutates the board and leaves persistence to
|
|
@@ -813,7 +824,24 @@ def _fix_from_review(
|
|
|
813
824
|
"max_review_iterations or the #522 terminal-work guard."
|
|
814
825
|
),
|
|
815
826
|
)
|
|
816
|
-
|
|
827
|
+
@click.option(
|
|
828
|
+
"--machine",
|
|
829
|
+
"machine_override",
|
|
830
|
+
default=None,
|
|
831
|
+
help=(
|
|
832
|
+
"Redirect this same-branch fix to a specific machine instead of the "
|
|
833
|
+
"original worker's (#3208) — e.g. when `coord status` shows the "
|
|
834
|
+
"original asleep/unreachable. The branch is fetched from the remote, "
|
|
835
|
+
"so any machine configured for this repo works. Without this flag, "
|
|
836
|
+
"an unreachable original now falls back to another capable, reachable "
|
|
837
|
+
"machine automatically; this flag only matters when you want a "
|
|
838
|
+
"SPECIFIC one, or every automatic fallback was also unreachable."
|
|
839
|
+
),
|
|
840
|
+
)
|
|
841
|
+
def fix(
|
|
842
|
+
assignment_id: str, config_path: Path, guidance: str, force: bool,
|
|
843
|
+
machine_override: str | None,
|
|
844
|
+
) -> None:
|
|
817
845
|
from coord.board_service import read_board
|
|
818
846
|
from coord.state import COORD_DIR
|
|
819
847
|
|
|
@@ -829,7 +857,10 @@ def fix(assignment_id: str, config_path: Path, guidance: str, force: bool) -> No
|
|
|
829
857
|
# `coord.auto_loop`, which owns same-branch fix dispatch — this command
|
|
830
858
|
# deliberately does not grow a second implementation of it.
|
|
831
859
|
if assignment.type == "review":
|
|
832
|
-
_fix_from_review(
|
|
860
|
+
_fix_from_review(
|
|
861
|
+
cfg, board, assignment, guidance=guidance, force=force,
|
|
862
|
+
machine_override=machine_override,
|
|
863
|
+
)
|
|
833
864
|
return
|
|
834
865
|
|
|
835
866
|
# #1384: gate on the canonical `test_state` with the legacy `smoke_test`
|
|
@@ -853,6 +884,16 @@ def fix(assignment_id: str, config_path: Path, guidance: str, force: bool) -> No
|
|
|
853
884
|
# #2282, observed live 2026-08-17).
|
|
854
885
|
acceptance_failed = assignment.acceptance_state == "failed"
|
|
855
886
|
|
|
887
|
+
# #3208: a failed human/customer UAT verdict (`coord uat --failed` or a
|
|
888
|
+
# customer portal `preview.changes_requested`, #2687/#3188) is a FIFTH
|
|
889
|
+
# door — distinct from the four above, so it does NOT by itself skip the
|
|
890
|
+
# `--force` gate below (nothing here has independently confirmed the PR
|
|
891
|
+
# is red the way a test/CI/acceptance failure does). What it DOES supply
|
|
892
|
+
# is evidence to brief the fix worker with: `uat_reason` already holds
|
|
893
|
+
# the full write-up of what's wrong, so a caller forcing a fix for a UAT
|
|
894
|
+
# failure should not have to retype it via `--guidance`.
|
|
895
|
+
uat_failed = assignment.uat_state == "failed"
|
|
896
|
+
|
|
856
897
|
# #1622 (part 3): red CI is the third trigger. Only consulted when the
|
|
857
898
|
# local test gate has NOT already failed, so the cheap in-DB path stays
|
|
858
899
|
# zero-I/O and the existing failure story keeps priority. #2344: same
|
|
@@ -937,14 +978,26 @@ def fix(assignment_id: str, config_path: Path, guidance: str, force: bool) -> No
|
|
|
937
978
|
err=True,
|
|
938
979
|
)
|
|
939
980
|
sys.exit(1)
|
|
981
|
+
if not guidance and uat_failed and assignment.uat_reason:
|
|
982
|
+
# #3208: the board already holds a full write-up of what's
|
|
983
|
+
# broken (`uat_reason` — the Gate-A/preview divergence detail a
|
|
984
|
+
# customer or operator recorded via `coord uat --failed`) — don't
|
|
985
|
+
# make the caller retype it.
|
|
986
|
+
guidance = assignment.uat_reason
|
|
987
|
+
click.echo(
|
|
988
|
+
f" guidance: defaulted to uat_reason (#3208, {len(guidance)} "
|
|
989
|
+
"chars) — pass --guidance explicitly to override",
|
|
990
|
+
)
|
|
940
991
|
if not guidance:
|
|
941
|
-
# There's no failed verdict, CI read, or test-output
|
|
942
|
-
# brief the fix worker with — `--force` alone would
|
|
943
|
-
# blind. Require the caller to say what's actually
|
|
992
|
+
# There's no failed verdict, CI read, uat_reason, or test-output
|
|
993
|
+
# file to brief the fix worker with — `--force` alone would
|
|
994
|
+
# dispatch it blind. Require the caller to say what's actually
|
|
995
|
+
# broken.
|
|
944
996
|
click.echo(
|
|
945
997
|
f"error: --force on assignment {assignment_id} also needs "
|
|
946
|
-
"--guidance — there's no failed test verdict
|
|
947
|
-
"brief the fix worker with, so say what's
|
|
998
|
+
"--guidance — there's no failed test verdict, CI read, or "
|
|
999
|
+
"UAT reason to brief the fix worker with, so say what's "
|
|
1000
|
+
"actually broken.",
|
|
948
1001
|
err=True,
|
|
949
1002
|
)
|
|
950
1003
|
sys.exit(1)
|
|
@@ -970,6 +1023,10 @@ def fix(assignment_id: str, config_path: Path, guidance: str, force: bool) -> No
|
|
|
970
1023
|
# smoke/test-reason fallbacks below apply here: this door fires
|
|
971
1024
|
# precisely when Test/CI are NOT what's red.
|
|
972
1025
|
test_output = assignment.acceptance_reason or ""
|
|
1026
|
+
elif uat_failed and not test_failed and assignment.uat_reason:
|
|
1027
|
+
# #3208: same shape as the acceptance-trust-gate branch above — a
|
|
1028
|
+
# UAT failure's own recorded reason IS the evidence for this door.
|
|
1029
|
+
test_output = assignment.uat_reason
|
|
973
1030
|
elif test_output_file.exists():
|
|
974
1031
|
test_output = test_output_file.read_text()
|
|
975
1032
|
elif assignment.smoke_test_reason or assignment.test_reason:
|
|
@@ -988,7 +1045,13 @@ def fix(assignment_id: str, config_path: Path, guidance: str, force: bool) -> No
|
|
|
988
1045
|
)
|
|
989
1046
|
|
|
990
1047
|
guidance_text = guidance or "Fix the failing tests and push."
|
|
991
|
-
if forced_without_evidence:
|
|
1048
|
+
if forced_without_evidence and uat_failed and assignment.uat_reason:
|
|
1049
|
+
# #3208: a real, board-recorded UAT failure — not the caller merely
|
|
1050
|
+
# attesting the PR is red — so give it its own heading rather than
|
|
1051
|
+
# the generic "unverified" one below.
|
|
1052
|
+
_what = f"a failed UAT verdict ({assignment.uat_actor or 'operator'}, #2687/#3208)"
|
|
1053
|
+
_failure_heading = "UAT failure"
|
|
1054
|
+
elif forced_without_evidence:
|
|
992
1055
|
_what = (
|
|
993
1056
|
"a reported failure (--force: neither a failed test verdict nor "
|
|
994
1057
|
"an automated CI read found one — the caller attests the PR is "
|
|
@@ -1020,6 +1083,67 @@ def fix(assignment_id: str, config_path: Path, guidance: str, force: bool) -> No
|
|
|
1020
1083
|
f"- Commit your fixes and push with git push origin HEAD"
|
|
1021
1084
|
)
|
|
1022
1085
|
|
|
1086
|
+
# #3208: pick a machine to run the fix on BEFORE ever POSTing — same
|
|
1087
|
+
# selector the review-verdict door uses (`coord.dispatch.
|
|
1088
|
+
# select_fix_machine`), so the two doors onto `coord fix` can never
|
|
1089
|
+
# disagree about "which machine" (#2096). Prefers the original worker's
|
|
1090
|
+
# machine, but a live reachability probe (not just config capability)
|
|
1091
|
+
# skips it — and falls through to another capable, reachable machine —
|
|
1092
|
+
# the moment it's asleep/offline, instead of the previous unconditional
|
|
1093
|
+
# re-aim that surfaced only as a bare `dispatch failed: timed out` with
|
|
1094
|
+
# no named cause (format-converter#6 / #3208).
|
|
1095
|
+
from coord.dispatch import describe_fix_machine_failure, select_fix_machine
|
|
1096
|
+
|
|
1097
|
+
selection = select_fix_machine(
|
|
1098
|
+
original_machine_name=assignment.machine_name,
|
|
1099
|
+
repo_name=assignment.repo_name,
|
|
1100
|
+
machines=cfg.machines,
|
|
1101
|
+
override_machine_name=machine_override,
|
|
1102
|
+
)
|
|
1103
|
+
if selection.machine is None:
|
|
1104
|
+
click.echo(
|
|
1105
|
+
f"error: cannot dispatch fix for assignment {assignment_id}: "
|
|
1106
|
+
+ describe_fix_machine_failure(
|
|
1107
|
+
assignment.machine_name, selection,
|
|
1108
|
+
override_machine_name=machine_override,
|
|
1109
|
+
),
|
|
1110
|
+
err=True,
|
|
1111
|
+
)
|
|
1112
|
+
sys.exit(1)
|
|
1113
|
+
if selection.machine.name != assignment.machine_name:
|
|
1114
|
+
# #586 (mirrored from `coord.auto_loop._dispatch_fix`): routing to a
|
|
1115
|
+
# DIFFERENT machine than the original worker only works if the
|
|
1116
|
+
# branch actually exists on the remote for the new machine to fetch
|
|
1117
|
+
# — otherwise the fix worker starts from an empty checkout with no
|
|
1118
|
+
# commits and no clear error. A WORK assignment reaching this arm of
|
|
1119
|
+
# `coord fix` has normally already cleared Test/Review (both of
|
|
1120
|
+
# which require a pushed branch), but check rather than assume.
|
|
1121
|
+
from coord import github_ops # noqa: PLC0415
|
|
1122
|
+
|
|
1123
|
+
repo_for_check = cfg.repo(assignment.repo_name)
|
|
1124
|
+
if (
|
|
1125
|
+
repo_for_check is not None
|
|
1126
|
+
and assignment.branch
|
|
1127
|
+
and not github_ops.branch_exists_on_remote(
|
|
1128
|
+
repo_for_check.github, assignment.branch
|
|
1129
|
+
)
|
|
1130
|
+
):
|
|
1131
|
+
click.echo(
|
|
1132
|
+
f"error: cannot redirect fix for {assignment_id} to "
|
|
1133
|
+
f"{selection.machine.name!r} — branch {assignment.branch!r} "
|
|
1134
|
+
f"is not on the remote, so a different machine cannot fetch "
|
|
1135
|
+
f"it. The original machine {assignment.machine_name!r} must "
|
|
1136
|
+
"push it first, or dispatch from that machine once it's "
|
|
1137
|
+
"reachable again.",
|
|
1138
|
+
err=True,
|
|
1139
|
+
)
|
|
1140
|
+
sys.exit(1)
|
|
1141
|
+
click.echo(
|
|
1142
|
+
f" redirecting: original machine {assignment.machine_name!r} "
|
|
1143
|
+
f"unusable — dispatching to {selection.machine.name!r} instead "
|
|
1144
|
+
"(#3208; the branch is fetched from the remote)",
|
|
1145
|
+
)
|
|
1146
|
+
|
|
1023
1147
|
# Determine escalated model for the fix-up.
|
|
1024
1148
|
original_model = assignment.model or cfg.models.default
|
|
1025
1149
|
escalated = cfg.models.next_model(original_model)
|
|
@@ -1027,7 +1151,10 @@ def fix(assignment_id: str, config_path: Path, guidance: str, force: bool) -> No
|
|
|
1027
1151
|
click.echo(f" escalating model: {original_model} → {escalated}")
|
|
1028
1152
|
|
|
1029
1153
|
try:
|
|
1030
|
-
new_id = _dispatch_followup(
|
|
1154
|
+
new_id = _dispatch_followup(
|
|
1155
|
+
cfg, assignment, briefing, model=escalated,
|
|
1156
|
+
machine_name=selection.machine.name,
|
|
1157
|
+
)
|
|
1031
1158
|
except httpx.HTTPError as e:
|
|
1032
1159
|
click.echo(f"error: dispatch failed: {e}", err=True)
|
|
1033
1160
|
sys.exit(1)
|
coord/diagnose.py
CHANGED
|
@@ -709,7 +709,56 @@ def diagnose_stage(
|
|
|
709
709
|
def _recover_review(
|
|
710
710
|
board, config, latest, state, res: DiagnoseResult, *, dry_run: bool
|
|
711
711
|
) -> None:
|
|
712
|
-
from coord.state import load_assignment_review_findings # noqa: PLC0415
|
|
712
|
+
from coord.state import has_review_claim, load_assignment_review_findings # noqa: PLC0415
|
|
713
|
+
|
|
714
|
+
# #3206: a review row that has no live session left (status is already
|
|
715
|
+
# terminal — the `running`/`pending` + machine-unconfigured phantom case
|
|
716
|
+
# above already returned before reaching here, and #1180's "resolve the
|
|
717
|
+
# reviewed id" comment on `_do_reset` explains why `review_of_assignment_
|
|
718
|
+
# id` is the FK to check) but whose work assignment's `review_claims` row
|
|
719
|
+
# is STILL held is permanently wedged: every future `dispatch_review` for
|
|
720
|
+
# that work assignment loses `claim_review_dispatch` forever and denies
|
|
721
|
+
# with the misleading #3113 "lost the atomic dispatch-claim race" reason
|
|
722
|
+
# — even though nothing is racing. `latest.status not in ("running",
|
|
723
|
+
# "pending")` is a positive disproof that anything is still in flight to
|
|
724
|
+
# release it itself, so this is checked FIRST, before any of the
|
|
725
|
+
# per-shape branches below: none of the "healthy"/"recovered" outcomes
|
|
726
|
+
# they report are actually dispatchable while the claim is held (this is
|
|
727
|
+
# exactly the coord-tui#49 repro — a SIGKILLed review that reached
|
|
728
|
+
# `status=failed` and then reported "review stage looks healthy").
|
|
729
|
+
# #3206 fix-review note: there is a narrow, real false-positive window
|
|
730
|
+
# here on a legitimate re-review. `dispatch_review` (review.py) takes
|
|
731
|
+
# `claim_review_dispatch` BEFORE it ever inserts the new review's
|
|
732
|
+
# `assignments` row. If this function runs in that gap, `latest` above
|
|
733
|
+
# still resolves to the *previous* terminal review row, `has_review_claim`
|
|
734
|
+
# is now True (it's the new, in-flight dispatch's claim, not a leak), and
|
|
735
|
+
# this would misreport a leaked claim — with `--reset` then releasing a
|
|
736
|
+
# claim a live dispatch still needs. No known way to distinguish the two
|
|
737
|
+
# cases from this read alone (both look like "terminal review row +
|
|
738
|
+
# live claim"); flagged here rather than fixed, since fixing it would
|
|
739
|
+
# need `dispatch_review` to expose in-flight state this function can
|
|
740
|
+
# check first.
|
|
741
|
+
work_assignment_id = (
|
|
742
|
+
latest.review_of_assignment_id
|
|
743
|
+
if latest.type == "review" and latest.review_of_assignment_id
|
|
744
|
+
else latest.assignment_id
|
|
745
|
+
)
|
|
746
|
+
if (
|
|
747
|
+
latest.status not in ("running", "pending")
|
|
748
|
+
and work_assignment_id
|
|
749
|
+
and has_review_claim(work_assignment_id)
|
|
750
|
+
):
|
|
751
|
+
res.findings.append(
|
|
752
|
+
f"review stage is terminal (status={latest.status!r}) but its "
|
|
753
|
+
f"review-dispatch claim for work assignment {work_assignment_id} "
|
|
754
|
+
"is still held (leaked review_claims row, #3206) — every future "
|
|
755
|
+
"dispatch_review for this work assignment will deny with the "
|
|
756
|
+
"misleading #3113 'lost the atomic dispatch-claim race' reason "
|
|
757
|
+
"until it is released. Re-run with --reset to release it."
|
|
758
|
+
)
|
|
759
|
+
res.recovered = False
|
|
760
|
+
res.needs_reset = True
|
|
761
|
+
return
|
|
713
762
|
|
|
714
763
|
has_findings = False
|
|
715
764
|
if latest.assignment_id:
|
|
@@ -1408,7 +1457,43 @@ def _reset_review_stage(
|
|
|
1408
1457
|
repo_name, issue_number, types=("review",),
|
|
1409
1458
|
review_of_assignment_id=assignment_id,
|
|
1410
1459
|
)
|
|
1411
|
-
|
|
1460
|
+
# #3206: VERIFY the delete actually persisted before reporting it as an
|
|
1461
|
+
# action taken — `delete_assignments_for_issue`'s own `cur.rowcount`
|
|
1462
|
+
# only proves the DELETE statement was issued and committed on ITS
|
|
1463
|
+
# connection; it is not proof the row is gone from the canonical board
|
|
1464
|
+
# (the coord-tui#49 `--reset` run reported "deleted 1 review row(s)"
|
|
1465
|
+
# while `f00d5e20670c` was still present, unchanged, on the daemon's
|
|
1466
|
+
# board immediately afterward). A re-read against the same predicate,
|
|
1467
|
+
# taken AFTER the write, is the observation #2096 requires before a
|
|
1468
|
+
# success line is trustworthy — the claim-release and review_state
|
|
1469
|
+
# writes below already get exactly this scrutiny implicitly, since
|
|
1470
|
+
# their own callers read the board fresh next; the delete's rowcount
|
|
1471
|
+
# was the one unverified "success" in this function.
|
|
1472
|
+
#
|
|
1473
|
+
# Scope note: this re-read uses the same `get_connection()` singleton,
|
|
1474
|
+
# in the same process, immediately after `conn.commit()` — within a
|
|
1475
|
+
# single connection it cannot observe a delete that "didn't stick" the
|
|
1476
|
+
# way the original coord-tui#49 evidence looked (the daemon's board
|
|
1477
|
+
# still showing the row afterward implies a *different* connection/
|
|
1478
|
+
# process saw stale state, not this one). What this DOES still catch:
|
|
1479
|
+
# a genuine concurrent insert/delete race from another connection or
|
|
1480
|
+
# process, and any future predicate mismatch between the delete and
|
|
1481
|
+
# this re-read. It is narrower than "verify the delete actually
|
|
1482
|
+
# persisted" sounds, but it's a real gate, not a tautology — see
|
|
1483
|
+
# `tests/test_diagnose.py`'s coverage that mocks
|
|
1484
|
+
# `delete_assignments_for_issue`'s rowcount to exercise the failure path.
|
|
1485
|
+
still_present = state.count_review_rows_for_reset(
|
|
1486
|
+
repo_name, issue_number, review_of_assignment_id=assignment_id
|
|
1487
|
+
)
|
|
1488
|
+
if still_present:
|
|
1489
|
+
res.actions_taken.append(
|
|
1490
|
+
f"delete requested for {deleted} review row(s), but "
|
|
1491
|
+
f"{still_present} still present on re-read — the row delete did "
|
|
1492
|
+
"NOT persist (#3206); stage grey/re-reviewable status below "
|
|
1493
|
+
"does not depend on this delete having landed"
|
|
1494
|
+
)
|
|
1495
|
+
else:
|
|
1496
|
+
res.actions_taken.append(f"deleted {deleted} review row(s) → stage grey")
|
|
1412
1497
|
# #3113: the raw DELETE above never goes through
|
|
1413
1498
|
# ``coord.issue_store._update_local_state`` — the ONLY other seam that
|
|
1414
1499
|
# releases a ``review_claims`` row (on a review assignment's own
|
coord/dispatch.py
CHANGED
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import logging
|
|
6
6
|
import time
|
|
7
|
+
from dataclasses import dataclass
|
|
7
8
|
from typing import Iterable
|
|
8
9
|
|
|
9
10
|
import httpx
|
|
@@ -18,7 +19,7 @@ from coord.comments import (
|
|
|
18
19
|
format_refused_premise,
|
|
19
20
|
)
|
|
20
21
|
from coord.config import Config
|
|
21
|
-
from coord.models import EPIC_DECOMPOSE_TYPE, Proposal, Repo, coordinator_owned_docs
|
|
22
|
+
from coord.models import EPIC_DECOMPOSE_TYPE, Machine, Proposal, Repo, coordinator_owned_docs
|
|
22
23
|
|
|
23
24
|
AGENT_PORT = 7433
|
|
24
25
|
|
|
@@ -1052,6 +1053,133 @@ def dispatch_with_retry(
|
|
|
1052
1053
|
raise last_exc # unreachable, but satisfies type checker
|
|
1053
1054
|
|
|
1054
1055
|
|
|
1056
|
+
@dataclass
|
|
1057
|
+
class FixMachineSelection:
|
|
1058
|
+
"""Outcome of picking a machine for a same-branch fix dispatch (#3208).
|
|
1059
|
+
|
|
1060
|
+
Same-branch fix dispatch (``coord fix``) used to aim unconditionally at
|
|
1061
|
+
the ORIGINAL worker's machine and, when that machine was merely asleep
|
|
1062
|
+
or powered off, surface nothing but a bare ``dispatch failed: timed
|
|
1063
|
+
out`` — no machine name, no hint that reachability was even the
|
|
1064
|
+
problem, no way to redirect. This is the ONE place that answers "which
|
|
1065
|
+
machine should a same-branch fix run on" for both doors onto ``coord
|
|
1066
|
+
fix`` — the failed-test/CI/acceptance/UAT door
|
|
1067
|
+
(``coord.commands.plan_followup._dispatch_followup``) and the
|
|
1068
|
+
request-changes-review door (``coord.auto_loop._dispatch_fix``) — so
|
|
1069
|
+
the two can never again drift into disagreeing answers for the same
|
|
1070
|
+
question (#2096, "one question, one answer").
|
|
1071
|
+
|
|
1072
|
+
``machine`` is the chosen target, or ``None`` if nothing capable is
|
|
1073
|
+
reachable right now. ``tried`` lists every candidate actually
|
|
1074
|
+
considered, in the order tried, paired with why it was skipped
|
|
1075
|
+
(unreachable — with the classified network reason — not capable, or
|
|
1076
|
+
paused) so a refusal can name names instead of leaving the operator to
|
|
1077
|
+
guess which piece of infrastructure is at fault.
|
|
1078
|
+
"""
|
|
1079
|
+
|
|
1080
|
+
machine: Machine | None
|
|
1081
|
+
tried: list[tuple[str, str]]
|
|
1082
|
+
|
|
1083
|
+
|
|
1084
|
+
def select_fix_machine(
|
|
1085
|
+
*,
|
|
1086
|
+
original_machine_name: str,
|
|
1087
|
+
repo_name: str,
|
|
1088
|
+
machines: list[Machine],
|
|
1089
|
+
override_machine_name: str | None = None,
|
|
1090
|
+
status_fetcher=None,
|
|
1091
|
+
) -> FixMachineSelection:
|
|
1092
|
+
"""Pick a machine for a same-branch fix dispatch (#3208).
|
|
1093
|
+
|
|
1094
|
+
Prefers *original_machine_name* — the branch is already checked out
|
|
1095
|
+
there — but skips it, and falls through to any other machine configured
|
|
1096
|
+
for *repo_name* (in ``machines`` order), the moment it fails a LIVE
|
|
1097
|
+
reachability probe, not just a config-capability check. Before this, an
|
|
1098
|
+
original machine that was merely asleep/offline stalled the whole
|
|
1099
|
+
dispatch instead of routing around it, even though the branch lives on
|
|
1100
|
+
the remote and a fresh worktree can be built anywhere (#3208).
|
|
1101
|
+
|
|
1102
|
+
*override_machine_name* — from ``coord fix --machine`` — restricts the
|
|
1103
|
+
candidate list to exactly that machine: the caller is asserting where
|
|
1104
|
+
to send it, so no further fallback is attempted. An unreachable or
|
|
1105
|
+
incapable override still comes back through ``.tried``, named, rather
|
|
1106
|
+
than silently falling through to somewhere the caller didn't ask for.
|
|
1107
|
+
|
|
1108
|
+
*status_fetcher* defaults to :func:`coord.network.fetch_status` — the
|
|
1109
|
+
same liveness probe ``coord status`` already uses — and is injectable
|
|
1110
|
+
so tests never make a real network call.
|
|
1111
|
+
"""
|
|
1112
|
+
from coord.machine_pause import follow_on_paused_set
|
|
1113
|
+
from coord.network import fetch_status as _fetch_status
|
|
1114
|
+
|
|
1115
|
+
fetch = status_fetcher or _fetch_status
|
|
1116
|
+
# #2240: the same follow-on cordon `_dispatch_fix` has always used — a
|
|
1117
|
+
# fix leg is the tail of already-running work, not new work, so an
|
|
1118
|
+
# explicit release pause (not a routing-only `coord pause`) must not
|
|
1119
|
+
# filter its host out.
|
|
1120
|
+
paused = follow_on_paused_set(machines)
|
|
1121
|
+
|
|
1122
|
+
def _capable(m: Machine) -> bool:
|
|
1123
|
+
return m.can_work_on(repo_name) and m.repo_path(repo_name) is not None
|
|
1124
|
+
|
|
1125
|
+
tried: list[tuple[str, str]] = []
|
|
1126
|
+
|
|
1127
|
+
if override_machine_name is not None:
|
|
1128
|
+
m = next((mm for mm in machines if mm.name == override_machine_name), None)
|
|
1129
|
+
if m is None:
|
|
1130
|
+
tried.append((override_machine_name, "not configured in coordinator.yml"))
|
|
1131
|
+
return FixMachineSelection(None, tried)
|
|
1132
|
+
candidates = [m]
|
|
1133
|
+
else:
|
|
1134
|
+
original = next(
|
|
1135
|
+
(m for m in machines if m.name == original_machine_name), None
|
|
1136
|
+
)
|
|
1137
|
+
if original is None:
|
|
1138
|
+
tried.append((original_machine_name, "not configured in coordinator.yml"))
|
|
1139
|
+
candidates = ([original] if original is not None else []) + [
|
|
1140
|
+
m for m in machines if m.name != original_machine_name
|
|
1141
|
+
]
|
|
1142
|
+
|
|
1143
|
+
for m in candidates:
|
|
1144
|
+
if m.name in paused:
|
|
1145
|
+
tried.append((m.name, "paused via `coord pause`"))
|
|
1146
|
+
continue
|
|
1147
|
+
if not _capable(m):
|
|
1148
|
+
tried.append((m.name, f"cannot work on repo {repo_name!r}"))
|
|
1149
|
+
continue
|
|
1150
|
+
result = fetch(m)
|
|
1151
|
+
if result.ok:
|
|
1152
|
+
return FixMachineSelection(m, tried)
|
|
1153
|
+
tried.append((m.name, result.error or "unreachable"))
|
|
1154
|
+
|
|
1155
|
+
return FixMachineSelection(None, tried)
|
|
1156
|
+
|
|
1157
|
+
|
|
1158
|
+
def describe_fix_machine_failure(
|
|
1159
|
+
original_machine_name: str,
|
|
1160
|
+
selection: FixMachineSelection,
|
|
1161
|
+
*,
|
|
1162
|
+
override_machine_name: str | None = None,
|
|
1163
|
+
) -> str:
|
|
1164
|
+
"""Render :class:`FixMachineSelection`'s ``tried`` list into one
|
|
1165
|
+
actionable line (#3208) — names every machine actually considered and
|
|
1166
|
+
why, instead of a bare ``dispatch failed: timed out``.
|
|
1167
|
+
"""
|
|
1168
|
+
if not selection.tried:
|
|
1169
|
+
return (
|
|
1170
|
+
"no machine is configured to work on this repo (original "
|
|
1171
|
+
f"worker machine was {original_machine_name!r})"
|
|
1172
|
+
)
|
|
1173
|
+
detail = "; ".join(f"{name} ({why})" for name, why in selection.tried)
|
|
1174
|
+
if override_machine_name is not None:
|
|
1175
|
+
return f"--machine {override_machine_name!r} refused: {detail}"
|
|
1176
|
+
return (
|
|
1177
|
+
f"original machine {original_machine_name!r} and every capable "
|
|
1178
|
+
f"fallback are unusable right now: {detail}. Redirect with `coord "
|
|
1179
|
+
"fix ... --machine <name>` once `coord status` shows one up."
|
|
1180
|
+
)
|
|
1181
|
+
|
|
1182
|
+
|
|
1055
1183
|
def compute_do_not_touch(
|
|
1056
1184
|
proposal: Proposal,
|
|
1057
1185
|
peers: Iterable[Proposal],
|
coord/interactive.py
CHANGED
|
@@ -4362,7 +4362,11 @@ def reap_stale_interactive_sessions(
|
|
|
4362
4362
|
return []
|
|
4363
4363
|
|
|
4364
4364
|
from coord import sql # noqa: PLC0415
|
|
4365
|
-
from coord.state import
|
|
4365
|
+
from coord.state import ( # noqa: PLC0415
|
|
4366
|
+
COORD_DIR,
|
|
4367
|
+
get_connection,
|
|
4368
|
+
release_review_claim_if_row_is_review,
|
|
4369
|
+
)
|
|
4366
4370
|
|
|
4367
4371
|
if worktrees_dir is None:
|
|
4368
4372
|
worktrees_dir = COORD_DIR / "worktrees"
|
|
@@ -4488,6 +4492,18 @@ def reap_stale_interactive_sessions(
|
|
|
4488
4492
|
(terminal_status, now, a.assignment_id),
|
|
4489
4493
|
)
|
|
4490
4494
|
conn.commit()
|
|
4495
|
+
# #3206: this raw SQL terminal-status write bypasses
|
|
4496
|
+
# `coord.issue_store._update_local_state`, so an interactively
|
|
4497
|
+
# dispatched (`provider_name="claude-pty"`) type="review" leg
|
|
4498
|
+
# reaped here (the Work→Review handoff and the `coord review
|
|
4499
|
+
# <id>` escape hatch both dispatch one, per review.py:3789-3795)
|
|
4500
|
+
# would otherwise leak its `review_claims` row exactly like the
|
|
4501
|
+
# headless reaper path did before #3206 — wedging every later
|
|
4502
|
+
# `dispatch_review` for the same work assignment behind the
|
|
4503
|
+
# misleading #3113 "lost the atomic dispatch-claim race" denial.
|
|
4504
|
+
# Safe to call unconditionally: it's a no-op for any row whose
|
|
4505
|
+
# type isn't "review".
|
|
4506
|
+
release_review_claim_if_row_is_review(a.assignment_id)
|
|
4491
4507
|
except Exception: # noqa: BLE001
|
|
4492
4508
|
pass # non-fatal — the board update below still releases the claim
|
|
4493
4509
|
|
|
@@ -4568,7 +4584,10 @@ def _mark_stale_reap_in_db(assignment_id: str, status: str, finished_at: float)
|
|
|
4568
4584
|
"""
|
|
4569
4585
|
try:
|
|
4570
4586
|
from coord import sql # noqa: PLC0415
|
|
4571
|
-
from coord.state import
|
|
4587
|
+
from coord.state import ( # noqa: PLC0415
|
|
4588
|
+
get_connection,
|
|
4589
|
+
release_review_claim_if_row_is_review,
|
|
4590
|
+
)
|
|
4572
4591
|
conn = get_connection()
|
|
4573
4592
|
sql.execute(
|
|
4574
4593
|
conn,
|
|
@@ -4577,6 +4596,13 @@ def _mark_stale_reap_in_db(assignment_id: str, status: str, finished_at: float)
|
|
|
4577
4596
|
(status, finished_at, assignment_id),
|
|
4578
4597
|
)
|
|
4579
4598
|
conn.commit()
|
|
4599
|
+
# #3206: this raw SQL terminal-status write is the remote-fallback
|
|
4600
|
+
# sibling of reap_stale_interactive_sessions's DB update above and
|
|
4601
|
+
# bypasses `coord.issue_store._update_local_state` the same way —
|
|
4602
|
+
# release the review-dispatch claim here too so a reaped remote
|
|
4603
|
+
# interactive review doesn't leak its `review_claims` row. No-op
|
|
4604
|
+
# for any row whose type isn't "review".
|
|
4605
|
+
release_review_claim_if_row_is_review(assignment_id)
|
|
4580
4606
|
except Exception: # noqa: BLE001
|
|
4581
4607
|
pass
|
|
4582
4608
|
|
coord/issue_store.py
CHANGED
|
@@ -287,36 +287,28 @@ def _update_local_state(
|
|
|
287
287
|
)
|
|
288
288
|
conn.commit()
|
|
289
289
|
|
|
290
|
-
# #3113: this is the generic chokepoint where ANY assignment
|
|
291
|
-
# smoke, work, ...) transitions to a terminal status — the same
|
|
292
|
-
# `coord.claim.has_active_followup` starts reporting "not in
|
|
293
|
-
# (board partitioning keys off exactly this status, #
|
|
294
|
-
# _ACTIVE_STATUSES). A `type="review"` row leaving the active
|
|
295
|
-
# therefore exactly when its dispatch-time claim (coord.state.
|
|
290
|
+
# #3113/#3206: this is the generic chokepoint where ANY assignment
|
|
291
|
+
# (review, smoke, work, ...) transitions to a terminal status — the same
|
|
292
|
+
# moment `coord.claim.has_active_followup` starts reporting "not in
|
|
293
|
+
# flight" (board partitioning keys off exactly this status, #_board_
|
|
294
|
+
# mapping._ACTIVE_STATUSES). A `type="review"` row leaving the active
|
|
295
|
+
# state is therefore exactly when its dispatch-time claim (coord.state.
|
|
296
296
|
# claim_review_dispatch) must be released — otherwise a legitimate later
|
|
297
297
|
# re-review of the same work assignment (the `coord review <id>` escape
|
|
298
|
-
# hatch) would find the claim still held forever.
|
|
299
|
-
#
|
|
300
|
-
#
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if row_type == "review" and row_of_id:
|
|
313
|
-
from coord.state import ( # noqa: PLC0415
|
|
314
|
-
_release_review_dispatch_claim_local,
|
|
315
|
-
)
|
|
316
|
-
|
|
317
|
-
_release_review_dispatch_claim_local(row_of_id)
|
|
318
|
-
except Exception: # noqa: BLE001 — best-effort; never break the status write
|
|
319
|
-
pass
|
|
298
|
+
# hatch) would find the claim still held forever.
|
|
299
|
+
#
|
|
300
|
+
# #3206: the type/review_of_assignment_id check + release used to be
|
|
301
|
+
# duplicated inline here AND, independently, missing entirely from
|
|
302
|
+
# `coord.state._mark_notified_local` (the `coord notify` polling path a
|
|
303
|
+
# reaper-killed headless review's terminal write goes through when no
|
|
304
|
+
# daemon reconcile tick got there first) — the exact "two surfaces, two
|
|
305
|
+
# implementations" split-brain #2096 warns about, and how a SIGKILLed
|
|
306
|
+
# review's claim leaked forever (coord-tui#49). Both seams now call the
|
|
307
|
+
# same `coord.state.release_review_claim_if_row_is_review` — one
|
|
308
|
+
# question, one answer.
|
|
309
|
+
from coord.state import release_review_claim_if_row_is_review # noqa: PLC0415
|
|
310
|
+
|
|
311
|
+
release_review_claim_if_row_is_review(assignment_id)
|
|
320
312
|
|
|
321
313
|
|
|
322
314
|
def _record_notification(
|
coord/review.py
CHANGED
|
@@ -2870,9 +2870,18 @@ def dispatch_review(
|
|
|
2870
2870
|
# `completed.assignment_id`; the loser denies here, before spending
|
|
2871
2871
|
# anything on a candidate machine. Released by every subsequent
|
|
2872
2872
|
# `_deny(...)` call in this function (see `_claim_held` above) and, once
|
|
2873
|
-
# this call succeeds through to a real dispatch, by
|
|
2874
|
-
# assignment's own terminal
|
|
2875
|
-
#
|
|
2873
|
+
# this call succeeds through to a real dispatch, by every seam that can
|
|
2874
|
+
# write the review assignment's own terminal status — all of which now
|
|
2875
|
+
# route through the single `coord.state.
|
|
2876
|
+
# release_review_claim_if_row_is_review` check (#3206):
|
|
2877
|
+
# `coord.issue_store._update_local_state` (worker self-report / git-floor
|
|
2878
|
+
# backstop), `coord.state._mark_notified_local` (the `coord notify`
|
|
2879
|
+
# polling path a headless reap's SIGKILL lands through), and
|
|
2880
|
+
# `coord.interactive.reap_stale_interactive_sessions` /
|
|
2881
|
+
# `_mark_stale_reap_in_db` (the local/remote interactive-session
|
|
2882
|
+
# reapers — dispatch_review is also reachable for a `provider_name=
|
|
2883
|
+
# "claude-pty"` type="review" leg, see the Work→Review handoff below).
|
|
2884
|
+
# Never left permanently held by any of them.
|
|
2876
2885
|
from coord.state import claim_review_dispatch # noqa: PLC0415
|
|
2877
2886
|
|
|
2878
2887
|
if not claim_review_dispatch(completed.assignment_id):
|
coord/state.py
CHANGED
|
@@ -2109,6 +2109,18 @@ def _mark_notified_local(
|
|
|
2109
2109
|
)
|
|
2110
2110
|
conn.commit()
|
|
2111
2111
|
|
|
2112
|
+
# #3206: this write can be the FIRST (and, absent a daemon reconcile
|
|
2113
|
+
# tick, only) place a review assignment's terminal status ever lands —
|
|
2114
|
+
# e.g. a headless review reaped by `AgentServer._reap`'s 7200s max-wait
|
|
2115
|
+
# SIGKILL, observed here via `coord notify`'s own agent poll rather than
|
|
2116
|
+
# the daemon's passive reconcile tick. Release its review-dispatch claim
|
|
2117
|
+
# the same way `coord.issue_store._update_local_state` does for every
|
|
2118
|
+
# other terminal-status seam — `release_review_claim_if_row_is_review`
|
|
2119
|
+
# is a no-op for the composite `f"{aid}:stuck"`-style keys the four
|
|
2120
|
+
# override events above pass (no row matches that string), so this is
|
|
2121
|
+
# safe to call unconditionally.
|
|
2122
|
+
release_review_claim_if_row_is_review(assignment_id)
|
|
2123
|
+
|
|
2112
2124
|
# #1036: this is the single funnel every notify.py call site (completion,
|
|
2113
2125
|
# failure, advisory, stuck, needs-attention, stalled, liveness) reaches —
|
|
2114
2126
|
# hook here rather than at each of the ~10 mark_notified() call sites.
|
|
@@ -2316,6 +2328,39 @@ def _claim_review_dispatch_local(of_assignment_id: str) -> bool:
|
|
|
2316
2328
|
return (cur.rowcount or 0) > 0
|
|
2317
2329
|
|
|
2318
2330
|
|
|
2331
|
+
def has_review_claim(of_assignment_id: str) -> bool:
|
|
2332
|
+
"""True when *of_assignment_id* still holds a live ``review_claims`` row
|
|
2333
|
+
(#3206) — the read side of :func:`claim_review_dispatch`/
|
|
2334
|
+
:func:`release_review_dispatch_claim`, used by ``coord diagnose --stage
|
|
2335
|
+
review`` to cross-check a review row's own terminal ``status`` against
|
|
2336
|
+
the claim table, so a leaked claim (one whose releasing write went
|
|
2337
|
+
through a seam other than :func:`release_review_claim_if_row_is_review`)
|
|
2338
|
+
is reported as an unhealthy, undispatchable stage instead of silently
|
|
2339
|
+
passing.
|
|
2340
|
+
|
|
2341
|
+
**Local-DB read only** — unlike ``claim_review_dispatch``/
|
|
2342
|
+
``release_review_dispatch_claim``, this does NOT route to the daemon via
|
|
2343
|
+
``board_service``. ``review_claims`` lives on the canonical board (the
|
|
2344
|
+
``coord serve`` daemon's DB, per this function's own module docs above);
|
|
2345
|
+
a thin client's local ``~/.coord/coord.db`` copy is empty/stale for this
|
|
2346
|
+
table exactly like it is for `build_board()` (`#615`,
|
|
2347
|
+
`_thin_client_local_board_guard`). Giving this its own daemon-routed GET
|
|
2348
|
+
endpoint is tracked separately — see the #3206 issue's closing note on
|
|
2349
|
+
thin-client visibility — so for now this answers correctly on the daemon
|
|
2350
|
+
host (where the local DB IS canonical) and undercounts on a thin client,
|
|
2351
|
+
same known limitation as the rest of this diagnostic path.
|
|
2352
|
+
"""
|
|
2353
|
+
if not of_assignment_id:
|
|
2354
|
+
return False
|
|
2355
|
+
conn = get_connection()
|
|
2356
|
+
row = sql.execute(
|
|
2357
|
+
conn,
|
|
2358
|
+
"SELECT 1 FROM review_claims WHERE of_assignment_id=?",
|
|
2359
|
+
(of_assignment_id,),
|
|
2360
|
+
).fetchone()
|
|
2361
|
+
return row is not None
|
|
2362
|
+
|
|
2363
|
+
|
|
2319
2364
|
def release_review_dispatch_claim(of_assignment_id: str) -> None:
|
|
2320
2365
|
"""Release a claim taken by :func:`claim_review_dispatch`.
|
|
2321
2366
|
|
|
@@ -2350,6 +2395,53 @@ def _release_review_dispatch_claim_local(of_assignment_id: str) -> None:
|
|
|
2350
2395
|
conn.commit()
|
|
2351
2396
|
|
|
2352
2397
|
|
|
2398
|
+
def release_review_claim_if_row_is_review(assignment_id: str) -> None:
|
|
2399
|
+
"""Release *assignment_id*'s own review-dispatch claim, iff that row is
|
|
2400
|
+
itself a ``type="review"`` assignment (#3206).
|
|
2401
|
+
|
|
2402
|
+
This is the ONE "did a review assignment just reach a terminal status,
|
|
2403
|
+
and if so release the claim it took" check — every seam capable of
|
|
2404
|
+
writing a review row's terminal ``status`` must call this SAME function
|
|
2405
|
+
immediately after its own write, rather than re-deriving the
|
|
2406
|
+
``type == "review" and review_of_assignment_id`` test independently.
|
|
2407
|
+
Before #3206 there were two such seams reading the row and applying that
|
|
2408
|
+
test on their own: :func:`coord.issue_store._update_local_state` (the
|
|
2409
|
+
worker self-report / git-floor-backstop path) had it; this module's own
|
|
2410
|
+
:func:`_mark_notified_local` (the ``coord notify`` polling path a
|
|
2411
|
+
reaper-killed headless review's terminal write goes through when no
|
|
2412
|
+
daemon reconcile tick got there first) did not. That gap is exactly how
|
|
2413
|
+
a review SIGKILLed by ``AgentServer._reap``'s 7200s max-wait ceiling
|
|
2414
|
+
left its ``review_claims`` row held forever: `_mark_notified_local`
|
|
2415
|
+
wrote ``status='failed'`` and stopped, so every later
|
|
2416
|
+
``dispatch_review`` for the same work assignment lost
|
|
2417
|
+
``claim_review_dispatch`` permanently and denied with the misleading
|
|
2418
|
+
"lost the atomic dispatch-claim race — #3113" reason, even though
|
|
2419
|
+
nothing was racing (coord-tui#49, stuck ~11h). One shared function
|
|
2420
|
+
closes the gap for both existing callers and any future one.
|
|
2421
|
+
|
|
2422
|
+
Best-effort: a lookup failure here must never turn a successful status
|
|
2423
|
+
write into a raised exception.
|
|
2424
|
+
"""
|
|
2425
|
+
if not assignment_id:
|
|
2426
|
+
return
|
|
2427
|
+
conn = get_connection()
|
|
2428
|
+
try:
|
|
2429
|
+
row = sql.execute(
|
|
2430
|
+
conn,
|
|
2431
|
+
"SELECT type, review_of_assignment_id FROM assignments WHERE assignment_id=?",
|
|
2432
|
+
(assignment_id,),
|
|
2433
|
+
).fetchone()
|
|
2434
|
+
if row is not None:
|
|
2435
|
+
row_type = row["type"] if hasattr(row, "keys") else row[0]
|
|
2436
|
+
row_of_id = (
|
|
2437
|
+
row["review_of_assignment_id"] if hasattr(row, "keys") else row[1]
|
|
2438
|
+
)
|
|
2439
|
+
if row_type == "review" and row_of_id:
|
|
2440
|
+
_release_review_dispatch_claim_local(row_of_id)
|
|
2441
|
+
except Exception: # noqa: BLE001 — best-effort; never break the status write
|
|
2442
|
+
pass
|
|
2443
|
+
|
|
2444
|
+
|
|
2353
2445
|
# ── Review-findings tracking ──────────────────────────────────────────────────
|
|
2354
2446
|
|
|
2355
2447
|
def update_assignment_review_findings(
|
|
@@ -2539,6 +2631,37 @@ def delete_assignments_for_issue(
|
|
|
2539
2631
|
return cur.rowcount
|
|
2540
2632
|
|
|
2541
2633
|
|
|
2634
|
+
def count_review_rows_for_reset(
|
|
2635
|
+
repo_name: str, issue_number: int, *, review_of_assignment_id: str
|
|
2636
|
+
) -> int:
|
|
2637
|
+
"""Count ``type='review'`` rows still matching
|
|
2638
|
+
:func:`delete_assignments_for_issue`'s own ``review_of_assignment_id``
|
|
2639
|
+
predicate (#3206) — used by ``coord diagnose --reset`` to VERIFY a
|
|
2640
|
+
review-row delete actually persisted before reporting success, rather
|
|
2641
|
+
than trusting the delete call's own rowcount.
|
|
2642
|
+
|
|
2643
|
+
A ``DELETE`` statement's rowcount only proves the statement was issued
|
|
2644
|
+
and committed on its own connection; it is not proof the row is
|
|
2645
|
+
actually gone from the canonical board afterward (the coord-tui#49
|
|
2646
|
+
``--reset`` run reported "deleted 1 review row(s)" while the row was
|
|
2647
|
+
still present, unchanged, on the daemon's board immediately after —
|
|
2648
|
+
exactly the "unconfirmed success" shape #2096 calls a defect: a
|
|
2649
|
+
reported outcome must come from a re-read taken AFTER the write, never
|
|
2650
|
+
from the write call's own return value alone). Re-querying with a fresh
|
|
2651
|
+
read against the same predicate is that re-read.
|
|
2652
|
+
"""
|
|
2653
|
+
if not review_of_assignment_id:
|
|
2654
|
+
return 0
|
|
2655
|
+
conn = get_connection()
|
|
2656
|
+
row = sql.execute(
|
|
2657
|
+
conn,
|
|
2658
|
+
"SELECT COUNT(*) AS c FROM assignments WHERE repo_name=? AND "
|
|
2659
|
+
"issue_number=? AND type='review' AND review_of_assignment_id=?",
|
|
2660
|
+
(repo_name, issue_number, review_of_assignment_id),
|
|
2661
|
+
).fetchone()
|
|
2662
|
+
return int(row["c"] if hasattr(row, "keys") else row[0])
|
|
2663
|
+
|
|
2664
|
+
|
|
2542
2665
|
def reset_work_review_state(
|
|
2543
2666
|
repo_name: str, issue_number: int, *, assignment_id: str | None = None
|
|
2544
2667
|
) -> int:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|