@caddis/cli 0.4.79 → 0.4.83
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.
- package/bundles/antigravity-plugin/plugin.json +1 -1
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_exit.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_file_lock.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_frontmatter.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_redact.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_roadmap.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_roadmap_page.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_rows.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_tidy.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_todo.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_workstreams.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_worktree_safety.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/caddis_coordinate.py +128 -7
- package/bundles/antigravity-plugin/scripts/caddis_gate.py +3 -3
- package/bundles/antigravity-plugin/scripts/caddis_hub_collect.py +8 -0
- package/bundles/antigravity-plugin/scripts/caddis_roadmap.py +29 -3
- package/bundles/antigravity-plugin/scripts/caddis_roadmap_page.py +4 -3
- package/bundles/antigravity-plugin/scripts/caddis_workstreams.py +24 -0
- package/bundles/antigravity-plugin/scripts/schemas/coordinator.schema.json +28 -1
- package/bundles/antigravity-plugin/scripts/schemas/hub-collect.schema.json +127 -0
- package/bundles/antigravity-plugin/scripts/schemas/hub-relays.schema.json +36 -0
- package/bundles/antigravity-plugin/scripts/schemas/hub-roadmaps.schema.json +91 -0
- package/bundles/antigravity-plugin/skills/coordinate/SKILL.md +17 -1
- package/bundles/antigravity-plugin/skills/cross-review/SKILL.md +1 -1
- package/bundles/antigravity-plugin/skills/feature-plan/SKILL.md +18 -9
- package/bundles/antigravity-plugin/skills/handoff/SKILL.md +5 -0
- package/bundles/antigravity-plugin/skills/implement/SKILL.md +23 -8
- package/bundles/antigravity-plugin/skills/mmr/SKILL.md +1 -1
- package/bundles/antigravity-plugin/skills/pr-merge/SKILL.md +2 -2
- package/bundles/antigravity-plugin/skills/ship/SKILL.md +1 -1
- package/bundles/antigravity-plugin/skills/ship-merge/SKILL.md +1 -1
- package/bundles/antigravity-plugin/skills/ship-pr/SKILL.md +2 -2
- package/bundles/antigravity-plugin-extras/plugin.json +1 -1
- package/bundles/antigravity-plugin-extras/skills/cross-review/SKILL.md +1 -1
- package/bundles/manifest.json +3 -3
- package/dist/allowed-urls.txt +19 -0
- package/dist/cli.js +1811 -784
- package/dist/export/assets/export-C0_skoDL.css +1 -0
- package/dist/export/assets/export-DErZHj4B.js +150 -0
- package/dist/export/assets/mark-small-CwCIyjyC.svg +8 -0
- package/dist/export/assets/wordmark-CD0s2ofS.svg +99 -0
- package/dist/export/fonts/LICENSE-Lucide.txt +43 -0
- package/dist/export/fonts/OFL-Atkinson.txt +93 -0
- package/dist/export/fonts/OFL-MapleMono.txt +93 -0
- package/dist/export/fonts/atkinson-400.849ae6f0.woff2 +0 -0
- package/dist/export/fonts/atkinson-700.3a9cc18a.woff2 +0 -0
- package/dist/export/fonts/maple-mono-400.071799fd.woff2 +0 -0
- package/dist/export/fonts/maple-mono-700.1e17b237.woff2 +0 -0
- package/dist/export/index.html +16 -0
- package/dist/ui/assets/Activity-CaqQ_HdD.js +6 -0
- package/dist/ui/assets/{Guide-D6PTiZmH.js → Guide-9PV1m0e9.js} +1 -1
- package/dist/ui/assets/RoadmapTab-CDm42wB2.js +31 -0
- package/dist/ui/assets/{index-DWiypj6N.css → index-Cv4RVfyi.css} +1 -1
- package/dist/ui/assets/index-Dotj3WfG.js +221 -0
- package/dist/ui/assets/time-D00tu2ZP.js +1 -0
- package/dist/ui/fonts/LICENSE-Lucide.txt +43 -0
- package/dist/ui/index.html +2 -2
- package/package.json +2 -2
- package/dist/ui/assets/index-D7fsc0PF.js +0 -221
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -386,12 +386,26 @@ def lock_holder(rid: str) -> dict | None:
|
|
|
386
386
|
"started_at": holder.get("started_at"), "alive": _holder_alive(holder)}
|
|
387
387
|
|
|
388
388
|
|
|
389
|
-
def release_lock(rid: str, pid: int) ->
|
|
390
|
-
"""Remove the lock if `pid` holds it; do nothing otherwise.
|
|
389
|
+
def release_lock(rid: str, pid: int) -> bool:
|
|
390
|
+
"""Remove the lock if `pid` holds it; do nothing otherwise. Returns True when it was released.
|
|
391
|
+
|
|
392
|
+
A release is a clean stop: `coordinator.json` then gets `stopped_at`, so the hub shows "stopped", not "not
|
|
393
|
+
responding" (hub ruling R36). The marker is best effort: the lock is already gone when it is written."""
|
|
394
|
+
released = False
|
|
391
395
|
with locked_path(_lock_path(rid)) as path:
|
|
392
396
|
holder = _read_holder(path)
|
|
393
397
|
if holder is not None and holder["pid"] == pid:
|
|
394
398
|
retry_denied(lambda: path.unlink(missing_ok=True))
|
|
399
|
+
released = True
|
|
400
|
+
if released and state_path(rid).exists(): # checked first: a release never creates a state file
|
|
401
|
+
try:
|
|
402
|
+
with locked_path(state_path(rid)) as path:
|
|
403
|
+
state = _read_state_strict(path)
|
|
404
|
+
state["stopped_at"] = _now()
|
|
405
|
+
_write_state_unlocked(path, state)
|
|
406
|
+
except (OSError, ValueError): # unreadable state: the hub then shows "not responding", as before
|
|
407
|
+
pass
|
|
408
|
+
return released
|
|
395
409
|
|
|
396
410
|
|
|
397
411
|
# --- queue operations (C1.3) --------------------------------------------------------------------------------------
|
|
@@ -791,6 +805,12 @@ def _apply(state: dict, req: dict, heads: dict[int, str | None], at: str) -> dic
|
|
|
791
805
|
state.setdefault("ledger", []).append(_ledger_entry(what=what, decision=action, by="owner",
|
|
792
806
|
reason="owner click", window="hub",
|
|
793
807
|
request_id=req["id"], at=at))
|
|
808
|
+
# The owner decided: the open ask for the same PR and text is answered (hub ruling R37).
|
|
809
|
+
asks = state.get("owner_asks")
|
|
810
|
+
if isinstance(asks, list):
|
|
811
|
+
state["owner_asks"] = [a for a in asks if not (isinstance(a, dict) and a.get("pr") == pr
|
|
812
|
+
and isinstance(a.get("what"), str)
|
|
813
|
+
and a["what"].strip() == what)]
|
|
794
814
|
return result("done", "")
|
|
795
815
|
|
|
796
816
|
|
|
@@ -835,13 +855,24 @@ def queue_merged(rid: str, pr: int, merge_sha: str) -> bool:
|
|
|
835
855
|
return outcome[-1]
|
|
836
856
|
|
|
837
857
|
|
|
838
|
-
|
|
858
|
+
DEPLOY_MARKS = ("pass", "fail", "skip")
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
def deploy_check_set(rid: str, pr: int, *, deploy_run: int | None = None, health: str | None = None,
|
|
862
|
+
checks: dict | None = None, reason: str | None = None) -> None:
|
|
839
863
|
"""Set the deploy run and/or health of the newest deploy check for a PR; a health also sets `at` to now.
|
|
840
|
-
|
|
864
|
+
`checks` ({D1..D5: pass|fail|skip}) and `reason` are the detail of a `deploy_verify` run (hub ruling R39).
|
|
865
|
+
Raises ValueError for a health not in `DEPLOY_HEALTH`, a run that is not an integer, bad checks, or a PR with no
|
|
866
|
+
deploy check."""
|
|
841
867
|
if health is not None and health not in DEPLOY_HEALTH:
|
|
842
868
|
raise ValueError(f"unknown deploy health: {health!r}")
|
|
843
869
|
if deploy_run is not None and (isinstance(deploy_run, bool) or not isinstance(deploy_run, int)):
|
|
844
870
|
raise ValueError(f"a deploy run is an integer: {deploy_run!r}")
|
|
871
|
+
if checks is not None and (not isinstance(checks, dict) or set(checks) - set(DEPLOY_CHECKS)
|
|
872
|
+
or any(v not in DEPLOY_MARKS for v in checks.values())):
|
|
873
|
+
raise ValueError(f"deploy checks are D1..D5 mapped to pass, fail or skip: {checks!r}")
|
|
874
|
+
if reason is not None and not isinstance(reason, str):
|
|
875
|
+
raise ValueError("a deploy check reason is a string")
|
|
845
876
|
|
|
846
877
|
def change(state: dict) -> None:
|
|
847
878
|
check = next((c for c in reversed(state.get("deploy_checks") or [])
|
|
@@ -853,6 +884,10 @@ def deploy_check_set(rid: str, pr: int, *, deploy_run: int | None = None, health
|
|
|
853
884
|
if health is not None: # stamp `at`, so the newest entry by `at` is the newest health (freeze rule)
|
|
854
885
|
check["health"] = health
|
|
855
886
|
check["at"] = _now()
|
|
887
|
+
if checks is not None:
|
|
888
|
+
check["checks"] = {name: checks[name] for name in DEPLOY_CHECKS if name in checks}
|
|
889
|
+
if reason is not None:
|
|
890
|
+
check["reason"] = " ".join(reason.split())[:500]
|
|
856
891
|
_mutate_state(rid, change)
|
|
857
892
|
|
|
858
893
|
|
|
@@ -884,6 +919,70 @@ def ledger_record(rid: str, *, what: str, decision: str, by: str, reason: str, w
|
|
|
884
919
|
_mutate_state(rid, lambda state: state.setdefault("ledger", []).append(entry))
|
|
885
920
|
|
|
886
921
|
|
|
922
|
+
# --- owner asks: open owner-only items with the coordinator's recommendation (hub H3, ruling R37) ----------------
|
|
923
|
+
|
|
924
|
+
ASK_RECOMMENDATIONS = ("approve", "hold") # spec D16
|
|
925
|
+
ASK_WHAT_MAX = 200
|
|
926
|
+
ASK_TEXT_MAX = 600
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
def _one_line(name: str, value: object, limit: int) -> str:
|
|
930
|
+
if not isinstance(value, str) or not value.strip():
|
|
931
|
+
raise ValueError(f"ask {name} must be a non-empty string")
|
|
932
|
+
text = " ".join(value.split())
|
|
933
|
+
if len(text) > limit:
|
|
934
|
+
raise ValueError(f"ask {name} is longer than {limit} characters")
|
|
935
|
+
return text
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
def ask_add(rid: str, *, what: str, recommendation: str, reason: str, evidence: str, pr: int | None = None,
|
|
939
|
+
head_sha: str | None = None) -> dict:
|
|
940
|
+
"""Record an owner-only item with a recommendation (D15, D16). Returns the ask.
|
|
941
|
+
|
|
942
|
+
The owner answers it in the hub (an approve/decline request with the same `pr` and `what`), and intake then
|
|
943
|
+
removes it. An ask with the same `pr` and `what` as an open one replaces it, so a re-run never doubles an item.
|
|
944
|
+
`from` is the coordinator session name. A recommendation is never the approval. Raises ValueError."""
|
|
945
|
+
what = _one_line("what", what, ASK_WHAT_MAX)
|
|
946
|
+
if recommendation not in ASK_RECOMMENDATIONS:
|
|
947
|
+
raise ValueError(f"an ask recommendation is approve or hold: {recommendation!r}")
|
|
948
|
+
reason = _one_line("reason", reason, ASK_TEXT_MAX)
|
|
949
|
+
evidence = _one_line("evidence", evidence, ASK_TEXT_MAX)
|
|
950
|
+
if (pr is None) != (head_sha is None):
|
|
951
|
+
raise ValueError("an ask names a PR and its head SHA together, or neither")
|
|
952
|
+
if pr is not None and (isinstance(pr, bool) or not isinstance(pr, int) or pr <= 0):
|
|
953
|
+
raise ValueError(f"a PR is a positive integer: {pr!r}")
|
|
954
|
+
if head_sha is not None and (not isinstance(head_sha, str) or not _SHA.fullmatch(head_sha)):
|
|
955
|
+
raise ValueError(f"a head SHA is 40 hex characters: {head_sha!r}")
|
|
956
|
+
out: list[dict] = []
|
|
957
|
+
|
|
958
|
+
def change(state: dict) -> None:
|
|
959
|
+
session = state.get("coordinator_session") if isinstance(state.get("coordinator_session"), dict) else {}
|
|
960
|
+
name = session.get("name") if isinstance(session.get("name"), str) and session.get("name") else None
|
|
961
|
+
ask = {"id": "ask-" + os.urandom(4).hex(), "what": what, "pr": pr,
|
|
962
|
+
"head_sha": head_sha.lower() if head_sha else None, "recommendation": recommendation,
|
|
963
|
+
"reason": reason, "evidence": evidence, "from": name, "at": _now()}
|
|
964
|
+
asks = [a for a in state.get("owner_asks") or [] if isinstance(a, dict)]
|
|
965
|
+
state["owner_asks"] = [a for a in asks if not (a.get("pr") == pr and a.get("what") == what)] + [ask]
|
|
966
|
+
out.append(ask)
|
|
967
|
+
_mutate_state(rid, change)
|
|
968
|
+
return out[-1]
|
|
969
|
+
|
|
970
|
+
|
|
971
|
+
def ask_remove(rid: str, ask_id: str) -> bool:
|
|
972
|
+
"""Remove one open ask by id. Returns False when no ask has that id (nothing written)."""
|
|
973
|
+
found: list[bool] = []
|
|
974
|
+
|
|
975
|
+
def change(state: dict) -> bool:
|
|
976
|
+
asks = [a for a in state.get("owner_asks") or [] if isinstance(a, dict)]
|
|
977
|
+
kept = [a for a in asks if a.get("id") != ask_id]
|
|
978
|
+
found.append(len(kept) != len(asks))
|
|
979
|
+
if found[-1]:
|
|
980
|
+
state["owner_asks"] = kept
|
|
981
|
+
return found[-1]
|
|
982
|
+
_mutate_state(rid, change)
|
|
983
|
+
return found[-1]
|
|
984
|
+
|
|
985
|
+
|
|
887
986
|
# --- command line (C1.5) ------------------------------------------------------------------------------------------
|
|
888
987
|
|
|
889
988
|
EXIT_OK, EXIT_ERROR, EXIT_USAGE, EXIT_LOCK_REFUSED = 0, 1, 2, 3
|
|
@@ -932,6 +1031,7 @@ def _claim_state(rid: str, session: dict) -> None:
|
|
|
932
1031
|
state["coordinator_session"] = {"name": session["name"], "sessionId": session["sessionId"],
|
|
933
1032
|
"pid": session["pid"]}
|
|
934
1033
|
state["heartbeat_at"] = _now()
|
|
1034
|
+
state.pop("stopped_at", None) # a new coordinator is live again (R36)
|
|
935
1035
|
_write_state_unlocked(path, state)
|
|
936
1036
|
|
|
937
1037
|
|
|
@@ -1514,7 +1614,7 @@ def deploy_verify(rid: str, cfg: dict, pr: int, merge_sha: str, *, docs_only: bo
|
|
|
1514
1614
|
if health == "ok":
|
|
1515
1615
|
reason = _checks_summary(checks, docs_only)
|
|
1516
1616
|
run_id = found.get("id")
|
|
1517
|
-
deploy_check_set(rid, pr, deploy_run=run_id, health=health)
|
|
1617
|
+
deploy_check_set(rid, pr, deploy_run=run_id, health=health, checks=checks, reason=reason)
|
|
1518
1618
|
return {"checks": checks, "run": run_id, "health": health, "reason": reason}
|
|
1519
1619
|
|
|
1520
1620
|
|
|
@@ -1647,6 +1747,17 @@ def _parser() -> argparse.ArgumentParser:
|
|
|
1647
1747
|
p.add_argument("--config-path", required=True, help="the repo root, or its .caddis/coordinator.md")
|
|
1648
1748
|
p.add_argument("--docs-only", action="store_true", help="a docs-only merge: D1, D2 and D5 only")
|
|
1649
1749
|
|
|
1750
|
+
ask = sub.add_parser("ask").add_subparsers(dest="ask_command", required=True, parser_class=_Parser)
|
|
1751
|
+
p = command("add", ask)
|
|
1752
|
+
p.add_argument("--what", required=True, help="what the owner decides, one line")
|
|
1753
|
+
p.add_argument("--recommendation", choices=ASK_RECOMMENDATIONS, required=True)
|
|
1754
|
+
p.add_argument("--reason", required=True, help="one or two sentences")
|
|
1755
|
+
p.add_argument("--evidence", required=True, help="cost estimate, test or CI result, risk, how to undo")
|
|
1756
|
+
p.add_argument("--pr", type=int)
|
|
1757
|
+
p.add_argument("--head-sha")
|
|
1758
|
+
p = command("remove", ask)
|
|
1759
|
+
p.add_argument("--id", required=True)
|
|
1760
|
+
|
|
1650
1761
|
ledger = sub.add_parser("ledger").add_subparsers(dest="ledger_command", required=True, parser_class=_Parser)
|
|
1651
1762
|
p = command("record", ledger)
|
|
1652
1763
|
p.add_argument("--what", required=True)
|
|
@@ -1710,8 +1821,8 @@ def _dispatch(args: argparse.Namespace) -> int:
|
|
|
1710
1821
|
f"pid {holder['pid']} ({holder['name']}, session {holder['sessionId']}, "
|
|
1711
1822
|
f"{'alive' if holder['alive'] else 'not alive'})")
|
|
1712
1823
|
return EXIT_OK
|
|
1713
|
-
release_lock(rid, args.pid)
|
|
1714
|
-
_emit(args, {"released":
|
|
1824
|
+
released = release_lock(rid, args.pid)
|
|
1825
|
+
_emit(args, {"released": released}, "released" if released else "not the holder: nothing released")
|
|
1715
1826
|
return EXIT_OK
|
|
1716
1827
|
if args.command == "heartbeat":
|
|
1717
1828
|
if not state_path(rid).exists(): # checked first so an unknown repo id leaves no folder or lock file behind
|
|
@@ -1746,6 +1857,16 @@ def _dispatch(args: argparse.Namespace) -> int:
|
|
|
1746
1857
|
marks = " ".join(f"{name}={mark}" for name, mark in out["checks"].items())
|
|
1747
1858
|
_emit(args, out, f"{out['health']}: {marks} ({out['reason']})")
|
|
1748
1859
|
return EXIT_OK if out["health"] == "ok" else EXIT_ERROR
|
|
1860
|
+
if args.command == "ask":
|
|
1861
|
+
if args.ask_command == "add":
|
|
1862
|
+
got = ask_add(rid, what=args.what, recommendation=args.recommendation, reason=args.reason,
|
|
1863
|
+
evidence=args.evidence, pr=args.pr, head_sha=args.head_sha)
|
|
1864
|
+
_emit(args, got, got["id"])
|
|
1865
|
+
return EXIT_OK
|
|
1866
|
+
if not ask_remove(rid, args.id):
|
|
1867
|
+
raise ValueError(f"no open ask with id {args.id!r}")
|
|
1868
|
+
_emit(args, {"ok": True}, "ok")
|
|
1869
|
+
return EXIT_OK
|
|
1749
1870
|
if args.command == "deploy-check":
|
|
1750
1871
|
deploy_check_set(rid, args.pr, deploy_run=args.run, health=args.health)
|
|
1751
1872
|
elif args.command == "ledger":
|
|
@@ -580,7 +580,7 @@ TIER_REVIEWERS = {
|
|
|
580
580
|
"0": 0,
|
|
581
581
|
"1-small": 0,
|
|
582
582
|
"1": 1,
|
|
583
|
-
"2":
|
|
583
|
+
"2": 1,
|
|
584
584
|
}
|
|
585
585
|
|
|
586
586
|
|
|
@@ -738,10 +738,10 @@ def gate_review_tier(
|
|
|
738
738
|
except Exception as exc: # noqa: BLE001 - a diff we cannot read is reviewed in full, never skipped
|
|
739
739
|
sys.stderr.write(f"caddis-gate: review-tier could not read the diff ({exc}); counting it as tier 2\n")
|
|
740
740
|
print("TIER: 2")
|
|
741
|
-
print("REVIEWERS:
|
|
741
|
+
print("REVIEWERS: 1")
|
|
742
742
|
return EXIT_OK
|
|
743
743
|
tier = review_tier(files, plan_risk=risk)
|
|
744
|
-
reviewers = TIER_REVIEWERS.get(tier,
|
|
744
|
+
reviewers = TIER_REVIEWERS.get(tier, 1)
|
|
745
745
|
print(f"TIER: {tier}")
|
|
746
746
|
print(f"REVIEWERS: {reviewers}")
|
|
747
747
|
return EXIT_OK
|
|
@@ -71,6 +71,8 @@ def _guide_json() -> dict:
|
|
|
71
71
|
_REPO_COLLECTORS = {"roadmaps": _roadmaps_json, "plans": _plans_json, "relays": _relays_json}
|
|
72
72
|
|
|
73
73
|
|
|
74
|
+
RUNNER_DIR = "caddis-runner" # the runner folder in the git common dir; a test keeps it equal to caddis_roadmap.RUNNER_DIR
|
|
75
|
+
|
|
74
76
|
_REPARSE_POINT = 0x400 # FILE_ATTRIBUTE_REPARSE_POINT: a junction or a symlink on Windows
|
|
75
77
|
|
|
76
78
|
|
|
@@ -145,6 +147,11 @@ def _origin_ref_files(common: Path) -> list[Path]:
|
|
|
145
147
|
return files + _files(common / "refs" / "remotes" / "origin", recurse=True)
|
|
146
148
|
|
|
147
149
|
|
|
150
|
+
def _runner_files(common: Path) -> list[Path]:
|
|
151
|
+
"""The roadmap runner's lock and last-stop files (R45): a runner start or stop must refresh the data."""
|
|
152
|
+
return _files(common / RUNNER_DIR, recurse=True)
|
|
153
|
+
|
|
154
|
+
|
|
148
155
|
def fingerprint(repo: Path) -> str:
|
|
149
156
|
"""sha256 over the sorted (name, mtime_ns, size) of every input file and origin ref file. Empty list: still a hash.
|
|
150
157
|
|
|
@@ -154,6 +161,7 @@ def fingerprint(repo: Path) -> str:
|
|
|
154
161
|
common = git_common_dir(repo)
|
|
155
162
|
if common is not None:
|
|
156
163
|
named.extend((f"git:{path.relative_to(common).as_posix()}", path) for path in _origin_ref_files(common))
|
|
164
|
+
named.extend((f"git:{path.relative_to(common).as_posix()}", path) for path in _runner_files(common))
|
|
157
165
|
rows = []
|
|
158
166
|
for name, path in named:
|
|
159
167
|
try:
|
|
@@ -2204,13 +2204,39 @@ def list_roadmaps_checked(root: Path) -> tuple[list[str], set[str] | None]:
|
|
|
2204
2204
|
return sorted(slugs), folders
|
|
2205
2205
|
|
|
2206
2206
|
|
|
2207
|
+
_PR_REF_RE = re.compile(r"#(\d+)")
|
|
2208
|
+
|
|
2209
|
+
|
|
2210
|
+
def _roadmap_detail(root: Path, slug: str) -> dict:
|
|
2211
|
+
"""status() plus the hub's detail (R45): per phase name, model, lane, risk, Tracker cell, tile and the PR numbers
|
|
2212
|
+
the cell names; per roadmap lanes, open owner gates, the runner and the origin commit. The page module owns
|
|
2213
|
+
this logic. Its machine-local session marks and its clock text are left out."""
|
|
2214
|
+
scripts_dir = str(Path(__file__).resolve().parent)
|
|
2215
|
+
if scripts_dir not in sys.path:
|
|
2216
|
+
sys.path.insert(0, scripts_dir)
|
|
2217
|
+
import caddis_roadmap_page
|
|
2218
|
+
model = caddis_roadmap_page.build(Path(root), slug, _THIS_MODULE, sessions=False)
|
|
2219
|
+
model.pop("sessions", None)
|
|
2220
|
+
model.pop("generated", None)
|
|
2221
|
+
for ms in model["milestones"]:
|
|
2222
|
+
for ph in ms["phases"]:
|
|
2223
|
+
ph["prs"] = sorted({int(n) for n in _PR_REF_RE.findall(str(ph.get("tracker", "")))})
|
|
2224
|
+
return model
|
|
2225
|
+
|
|
2226
|
+
|
|
2207
2227
|
def roadmaps_json(root: Path) -> dict:
|
|
2208
|
-
"""The hub's roadmap list: status() of each slug, in `list` order.
|
|
2209
|
-
|
|
2228
|
+
"""The hub's roadmap list: status() of each slug plus the detail keys, in `list` order. If the detail fails, the
|
|
2229
|
+
entry keeps the plain status() keys and gains `detail_error` (one line). A roadmap whose status() raises gives {"roadmap": slug, "error":
|
|
2230
|
+
"<one line>"} and the rest still list. Never prints, never exits."""
|
|
2210
2231
|
entries: list[dict] = []
|
|
2211
2232
|
for slug in list_roadmaps(Path(root)):
|
|
2212
2233
|
try:
|
|
2213
|
-
|
|
2234
|
+
try:
|
|
2235
|
+
entries.append(_roadmap_detail(Path(root), slug))
|
|
2236
|
+
except Exception as exc: # the detail is optional: keep the plain status and say why it is missing
|
|
2237
|
+
lines = str(exc).strip().splitlines()
|
|
2238
|
+
entries.append({**status(Path(root), slug),
|
|
2239
|
+
"detail_error": lines[0] if lines else type(exc).__name__})
|
|
2214
2240
|
except Exception as exc: # one broken file must not hide the others
|
|
2215
2241
|
lines = str(exc).strip().splitlines()
|
|
2216
2242
|
entries.append({"roadmap": slug, "error": lines[0] if lines else type(exc).__name__})
|
|
@@ -163,8 +163,9 @@ def _artifact_dir(root: Path) -> Path:
|
|
|
163
163
|
|
|
164
164
|
# ---- the model -------------------------------------------------------------------------------------------------
|
|
165
165
|
|
|
166
|
-
def build(root: Path, slug: str, roadmap_mod, now: datetime.datetime | None = None) -> dict:
|
|
167
|
-
"""status() plus per-phase Tracker cell, name, model, lane, risk and tile state; waiting sessions; the runner.
|
|
166
|
+
def build(root: Path, slug: str, roadmap_mod, now: datetime.datetime | None = None, sessions: bool = True) -> dict:
|
|
167
|
+
"""status() plus per-phase Tracker cell, name, model, lane, risk and tile state; waiting sessions; the runner.
|
|
168
|
+
The hub passes `sessions=False`: it has live sessions of its own, so the marker folder is not read."""
|
|
168
169
|
root = Path(root)
|
|
169
170
|
now = now or datetime.datetime.now(datetime.timezone.utc)
|
|
170
171
|
model = roadmap_mod.status(root, slug)
|
|
@@ -191,7 +192,7 @@ def build(root: Path, slug: str, roadmap_mod, now: datetime.datetime | None = No
|
|
|
191
192
|
model["waiting"] = [{"milestone": ms["id"], "reason": b["reason"], "check": b["check"]}
|
|
192
193
|
for ms in model["milestones"] for b in ms["blockers"]
|
|
193
194
|
if b["type"] == "owner-gate" and ms["status"] not in roadmap_mod.FINISHED]
|
|
194
|
-
model["sessions"] = waiting_sessions(_artifact_dir(main_checkout(root)) / "session-state", now)
|
|
195
|
+
model["sessions"] = (waiting_sessions(_artifact_dir(main_checkout(root)) / "session-state", now) if sessions else [])
|
|
195
196
|
|
|
196
197
|
lock_path = roadmap_mod.runner_lock_path(root, "roadmap", slug)
|
|
197
198
|
lock, lock_err = _read_json(lock_path)
|
|
@@ -229,6 +229,29 @@ def _next_step(text: str) -> str:
|
|
|
229
229
|
return _single_line(match.group(1), 120) or "next step unrecorded"
|
|
230
230
|
|
|
231
231
|
|
|
232
|
+
_RECOMMENDATION = re.compile(r"^\s*(?:[-*]\s*)?recommendation:\s*(approve|hold)\b", re.IGNORECASE)
|
|
233
|
+
_REC_DETAIL = re.compile(r"^\s*(?:[-*]\s*)?(reason|evidence):\s*(.+)$", re.IGNORECASE)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def _recommendation(text: str) -> dict | None:
|
|
237
|
+
"""The asking session's recommendation for an owner gate (hub spec D16): a `recommendation: approve|hold` line,
|
|
238
|
+
then the first `reason:` and `evidence:` lines after it. None when the relay has no recommendation line."""
|
|
239
|
+
lines = split_document(text)[1].splitlines()
|
|
240
|
+
for index, line in enumerate(lines):
|
|
241
|
+
match = _RECOMMENDATION.match(line)
|
|
242
|
+
if not match:
|
|
243
|
+
continue
|
|
244
|
+
found = {"decision": match.group(1).lower(), "reason": None, "evidence": None}
|
|
245
|
+
for rest in lines[index + 1:]:
|
|
246
|
+
if _RECOMMENDATION.match(rest):
|
|
247
|
+
break
|
|
248
|
+
detail = _REC_DETAIL.match(rest)
|
|
249
|
+
if detail and found[detail.group(1).lower()] is None:
|
|
250
|
+
found[detail.group(1).lower()] = _single_line(detail.group(2), 300)
|
|
251
|
+
return found
|
|
252
|
+
return None
|
|
253
|
+
|
|
254
|
+
|
|
232
255
|
def _age(when: datetime, now: datetime) -> str:
|
|
233
256
|
seconds = max(0, int((now - when).total_seconds()))
|
|
234
257
|
if seconds < 3600:
|
|
@@ -294,6 +317,7 @@ def relays_json(root: Path, now: datetime | None = None) -> dict:
|
|
|
294
317
|
"status": status,
|
|
295
318
|
"status_arg": status_arg,
|
|
296
319
|
"next_step": None if step == "next step unrecorded" else step,
|
|
320
|
+
"recommendation": _recommendation(content),
|
|
297
321
|
})
|
|
298
322
|
return {"schema": JSON_SCHEMA, "relays": sorted(rows, key=lambda r: r["name"])}
|
|
299
323
|
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"heartbeat_at": {"$ref": "#/$defs/utc"},
|
|
21
|
+
"stopped_at": {"$ref": "#/$defs/utc", "description": "optional; written by lock release (a clean stop), removed by lock acquire. At or after heartbeat_at: stopped, not down"},
|
|
21
22
|
"queue": {
|
|
22
23
|
"type": "array",
|
|
23
24
|
"items": {
|
|
@@ -55,7 +56,14 @@
|
|
|
55
56
|
"merge_sha": {"type": "string", "pattern": "^[0-9a-f]{40}$", "description": "lower-cased"},
|
|
56
57
|
"deploy_run": {"type": ["integer", "null"]},
|
|
57
58
|
"health": {"enum": ["pending", "ok", "failed"]},
|
|
58
|
-
"at": {"$ref": "#/$defs/utc"}
|
|
59
|
+
"at": {"$ref": "#/$defs/utc"},
|
|
60
|
+
"checks": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"description": "optional; the D1-D5 marks of the last deploy_verify run",
|
|
63
|
+
"propertyNames": {"enum": ["D1", "D2", "D3", "D4", "D5"]},
|
|
64
|
+
"additionalProperties": {"enum": ["pass", "fail", "skip"]}
|
|
65
|
+
},
|
|
66
|
+
"reason": {"type": "string", "description": "optional; the failure reason or the pass summary"}
|
|
59
67
|
}
|
|
60
68
|
}
|
|
61
69
|
},
|
|
@@ -75,6 +83,25 @@
|
|
|
75
83
|
}
|
|
76
84
|
}
|
|
77
85
|
},
|
|
86
|
+
"owner_asks": {
|
|
87
|
+
"type": "array",
|
|
88
|
+
"description": "optional; open owner-only items with the coordinator's recommendation (D15, D16). Intake removes an ask when an approve or decline with the same pr and what is done",
|
|
89
|
+
"items": {
|
|
90
|
+
"type": "object",
|
|
91
|
+
"required": ["id", "what", "pr", "head_sha", "recommendation", "reason", "evidence", "from", "at"],
|
|
92
|
+
"properties": {
|
|
93
|
+
"id": {"type": "string", "minLength": 1},
|
|
94
|
+
"what": {"type": "string", "minLength": 1, "maxLength": 200},
|
|
95
|
+
"pr": {"type": ["integer", "null"], "minimum": 1},
|
|
96
|
+
"head_sha": {"type": ["string", "null"], "pattern": "^[0-9a-f]{40}$"},
|
|
97
|
+
"recommendation": {"enum": ["approve", "hold"]},
|
|
98
|
+
"reason": {"type": "string", "minLength": 1},
|
|
99
|
+
"evidence": {"type": "string", "minLength": 1},
|
|
100
|
+
"from": {"type": ["string", "null"], "description": "the coordinator session name"},
|
|
101
|
+
"at": {"$ref": "#/$defs/utc"}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
78
105
|
"processed_requests": {
|
|
79
106
|
"type": "array",
|
|
80
107
|
"items": {
|
|
@@ -164,6 +164,36 @@
|
|
|
164
164
|
},
|
|
165
165
|
"state": {
|
|
166
166
|
"type": "string"
|
|
167
|
+
},
|
|
168
|
+
"plan": {
|
|
169
|
+
"type": "string"
|
|
170
|
+
},
|
|
171
|
+
"name": {
|
|
172
|
+
"type": "string"
|
|
173
|
+
},
|
|
174
|
+
"model": {
|
|
175
|
+
"type": "string"
|
|
176
|
+
},
|
|
177
|
+
"lane": {
|
|
178
|
+
"type": "string"
|
|
179
|
+
},
|
|
180
|
+
"risk": {
|
|
181
|
+
"type": "string"
|
|
182
|
+
},
|
|
183
|
+
"tracker": {
|
|
184
|
+
"type": "string"
|
|
185
|
+
},
|
|
186
|
+
"tile": {
|
|
187
|
+
"type": "string"
|
|
188
|
+
},
|
|
189
|
+
"num": {
|
|
190
|
+
"type": "integer"
|
|
191
|
+
},
|
|
192
|
+
"prs": {
|
|
193
|
+
"type": "array",
|
|
194
|
+
"items": {
|
|
195
|
+
"type": "integer"
|
|
196
|
+
}
|
|
167
197
|
}
|
|
168
198
|
}
|
|
169
199
|
}
|
|
@@ -198,6 +228,67 @@
|
|
|
198
228
|
},
|
|
199
229
|
"line": {
|
|
200
230
|
"type": "string"
|
|
231
|
+
},
|
|
232
|
+
"origin_commit": {
|
|
233
|
+
"type": "string"
|
|
234
|
+
},
|
|
235
|
+
"lanes": {
|
|
236
|
+
"type": "array",
|
|
237
|
+
"items": {
|
|
238
|
+
"type": "string"
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
"waiting": {
|
|
242
|
+
"type": "array",
|
|
243
|
+
"items": {
|
|
244
|
+
"type": "object",
|
|
245
|
+
"properties": {
|
|
246
|
+
"milestone": {
|
|
247
|
+
"type": "string"
|
|
248
|
+
},
|
|
249
|
+
"reason": {
|
|
250
|
+
"type": "string"
|
|
251
|
+
},
|
|
252
|
+
"check": {
|
|
253
|
+
"type": [
|
|
254
|
+
"string",
|
|
255
|
+
"null"
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
"runner": {
|
|
262
|
+
"type": "object",
|
|
263
|
+
"properties": {
|
|
264
|
+
"lock": {
|
|
265
|
+
"type": [
|
|
266
|
+
"object",
|
|
267
|
+
"null"
|
|
268
|
+
]
|
|
269
|
+
},
|
|
270
|
+
"stale_lock": {
|
|
271
|
+
"type": [
|
|
272
|
+
"object",
|
|
273
|
+
"null"
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
"last_stop": {
|
|
277
|
+
"type": [
|
|
278
|
+
"object",
|
|
279
|
+
"null"
|
|
280
|
+
]
|
|
281
|
+
},
|
|
282
|
+
"errors": {
|
|
283
|
+
"type": "array",
|
|
284
|
+
"items": {
|
|
285
|
+
"type": "string"
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
"detail_error": {
|
|
291
|
+
"type": "string"
|
|
201
292
|
}
|
|
202
293
|
}
|
|
203
294
|
},
|
|
@@ -411,6 +502,42 @@
|
|
|
411
502
|
"string",
|
|
412
503
|
"null"
|
|
413
504
|
]
|
|
505
|
+
},
|
|
506
|
+
"recommendation": {
|
|
507
|
+
"description": "the asking session's recommendation (D16), or null",
|
|
508
|
+
"anyOf": [
|
|
509
|
+
{
|
|
510
|
+
"type": "null"
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
"type": "object",
|
|
514
|
+
"required": [
|
|
515
|
+
"decision",
|
|
516
|
+
"reason",
|
|
517
|
+
"evidence"
|
|
518
|
+
],
|
|
519
|
+
"properties": {
|
|
520
|
+
"decision": {
|
|
521
|
+
"enum": [
|
|
522
|
+
"approve",
|
|
523
|
+
"hold"
|
|
524
|
+
]
|
|
525
|
+
},
|
|
526
|
+
"reason": {
|
|
527
|
+
"type": [
|
|
528
|
+
"string",
|
|
529
|
+
"null"
|
|
530
|
+
]
|
|
531
|
+
},
|
|
532
|
+
"evidence": {
|
|
533
|
+
"type": [
|
|
534
|
+
"string",
|
|
535
|
+
"null"
|
|
536
|
+
]
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
]
|
|
414
541
|
}
|
|
415
542
|
}
|
|
416
543
|
}
|
|
@@ -71,6 +71,42 @@
|
|
|
71
71
|
"string",
|
|
72
72
|
"null"
|
|
73
73
|
]
|
|
74
|
+
},
|
|
75
|
+
"recommendation": {
|
|
76
|
+
"description": "the asking session's recommendation (D16), or null",
|
|
77
|
+
"anyOf": [
|
|
78
|
+
{
|
|
79
|
+
"type": "null"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"type": "object",
|
|
83
|
+
"required": [
|
|
84
|
+
"decision",
|
|
85
|
+
"reason",
|
|
86
|
+
"evidence"
|
|
87
|
+
],
|
|
88
|
+
"properties": {
|
|
89
|
+
"decision": {
|
|
90
|
+
"enum": [
|
|
91
|
+
"approve",
|
|
92
|
+
"hold"
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"reason": {
|
|
96
|
+
"type": [
|
|
97
|
+
"string",
|
|
98
|
+
"null"
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
"evidence": {
|
|
102
|
+
"type": [
|
|
103
|
+
"string",
|
|
104
|
+
"null"
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
]
|
|
74
110
|
}
|
|
75
111
|
}
|
|
76
112
|
}
|