@biffo/cli 0.298.16 → 0.298.18
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/package.json +1 -1
- package/scripts/claim.sh +137 -4
package/package.json
CHANGED
package/scripts/claim.sh
CHANGED
|
@@ -578,6 +578,60 @@ note() { REASONS="${REASONS} $1\n"; TAKEN=1; }
|
|
|
578
578
|
# "free" or "taken" for certain.
|
|
579
579
|
note_cannot_tell() { REASONS="${REASONS} $1\n"; CANNOT_TELL=1; }
|
|
580
580
|
|
|
581
|
+
# ADVISORY: reported, never blocking (ADR-0008, ADR-0009 Sec3b; biffo-fleet#372, M5).
|
|
582
|
+
# What used to be `note()` for the label and the open-PR/branch checks below, now that
|
|
583
|
+
# the lease is the authority for those two and can answer conclusively. Kept distinct
|
|
584
|
+
# from `note()` on purpose -- a caller reading REASONS cannot tell an advisory line from
|
|
585
|
+
# a blocking one by string alone, but the exit code and TAKEN can, and that is the
|
|
586
|
+
# property every downstream reader (this script's own summary, and any external caller
|
|
587
|
+
# parsing `Taken`/`Free`) must keep being able to rely on.
|
|
588
|
+
note_advisory() { REASONS="${REASONS} $1\n"; }
|
|
589
|
+
|
|
590
|
+
# --- THE LEASE, THE ONE AUTHORITY (ADR-0008; ADR-0009 Sec3b; biffo-fleet#372, M5) -------
|
|
591
|
+
#
|
|
592
|
+
# `claim.sh` used to have THREE signals that each independently set TAKEN=1: the label,
|
|
593
|
+
# an open PR, a remote branch. Every one is correct about ITSELF and none is correct
|
|
594
|
+
# about reality -- tabsii-platform#1126 is the measured cost: a builder pushed the
|
|
595
|
+
# cross-tenant RLS fix across 304/337 policies and died before opening a PR. The label
|
|
596
|
+
# said Taken from a claim nobody was renewing, the branch alone ALSO said Taken with no
|
|
597
|
+
# takeover path (#180), and the issue became permanently unreachable -- "the signal that
|
|
598
|
+
# proves work is happening became the signal that guarantees it never resumes" (ADR-0008).
|
|
599
|
+
#
|
|
600
|
+
# The lease registry (ADR-0007) is a claim with an expiry the holder must keep renewing,
|
|
601
|
+
# so a dead holder is detected by absence rather than by a human noticing. It lives in
|
|
602
|
+
# `biffo-fleet`, a SEPARATE repo on this same machine (ADR-0007: single machine, no
|
|
603
|
+
# remote-host handling) -- this script cannot `import` it, so it shells out to the one
|
|
604
|
+
# bridge that repo built for exactly this (`bin/liveness.py`; see its own docstring).
|
|
605
|
+
#
|
|
606
|
+
# lease_query <issue> prints one TAB-separated line to stdout and returns:
|
|
607
|
+
# 0 "live\t<holder>\t<expires_at>" -- a live lease names a holder
|
|
608
|
+
# 0 "free\t\t" -- the registry answered: nobody holds a live lease
|
|
609
|
+
# 2 "unknown\t\t<reason>" -- could not consult it (see below)
|
|
610
|
+
lease_query() {
|
|
611
|
+
_lq_bridge="${FLEET_DIR:-$HOME/.claude/fleet}/liveness.py"
|
|
612
|
+
if [ ! -f "$_lq_bridge" ]; then
|
|
613
|
+
printf 'unknown\t\tliveness.py not found at %s (not yet deployed, or this box has no fleet)\n' "$_lq_bridge"
|
|
614
|
+
return 2
|
|
615
|
+
fi
|
|
616
|
+
if ! command -v python3 >/dev/null 2>&1; then
|
|
617
|
+
printf 'unknown\t\tpython3 not on PATH\n'
|
|
618
|
+
return 2
|
|
619
|
+
fi
|
|
620
|
+
_lq_out=$(python3 "$_lq_bridge" live "$(repo_slug)" "$1" 2>/dev/null)
|
|
621
|
+
_lq_rc=$?
|
|
622
|
+
case "$_lq_rc" in
|
|
623
|
+
0) printf '%s\n' "$_lq_out"; return 0 ;;
|
|
624
|
+
2) printf '%s\n' "$_lq_out"; return 2 ;;
|
|
625
|
+
*)
|
|
626
|
+
# A THIRD exit code from the bridge is a fact this script has never seen before,
|
|
627
|
+
# and a check whose only two known outcomes are hard-coded above must not silently
|
|
628
|
+
# trust a third one as either "live" or "free". Same "cannot tell" reasoning as
|
|
629
|
+
# everywhere else in this file.
|
|
630
|
+
printf 'unknown\t\tliveness.py exited %s, an outcome this script does not recognise\n' "$_lq_rc"
|
|
631
|
+
return 2 ;;
|
|
632
|
+
esac
|
|
633
|
+
}
|
|
634
|
+
|
|
581
635
|
# --- --release <token>: only the holder clears it (#1279) --------------------
|
|
582
636
|
#
|
|
583
637
|
# A claim nobody can prove ownership of is one anybody can clear, and a stale
|
|
@@ -865,7 +919,57 @@ if [ "$state" != "OPEN" ]; then
|
|
|
865
919
|
exit 1
|
|
866
920
|
fi
|
|
867
921
|
|
|
922
|
+
# --- 0.5. THE LEASE. The one authority for "is this being worked on" ---------
|
|
923
|
+
#
|
|
924
|
+
# ADR-0008: "The lease decides. A unit with no live lease is available, whatever
|
|
925
|
+
# else exists." So this runs FIRST, ahead of the label/PR/branch below, and its
|
|
926
|
+
# answer decides whether those three still BLOCK (`note`) or only INFORM
|
|
927
|
+
# (`note_advisory`) -- the "many inputs, one authority" split ADR-0008 draws
|
|
928
|
+
# between detection (fine, encouraged, kept) and a second STORED verdict (the
|
|
929
|
+
# defect this migration removes).
|
|
930
|
+
#
|
|
931
|
+
# INTERIM RULE FOR DISAGREEMENT (temporarily SEVEN sources, not one -- ADR-0008's
|
|
932
|
+
# own phrase for this migration window): a LIVE lease always wins outright. A
|
|
933
|
+
# lease the registry can positively report as FREE demotes the label/PR/branch
|
|
934
|
+
# below to advisory. But when the lease CANNOT be consulted at all -- the most
|
|
935
|
+
# likely state today, since nothing acquires one until the fleet's restart
|
|
936
|
+
# milestones (biffo-fleet#376/#377) wire dispatch through `supervise.py`, and
|
|
937
|
+
# `bin/liveness.py` itself needs a one-time hand symlink into $FLEET_DIR before
|
|
938
|
+
# any instance repo can even reach it (see `lease_query`'s own docstring) -- this
|
|
939
|
+
# falls back to EXACTLY the pre-migration three-signal behaviour below, unchanged,
|
|
940
|
+
# rather than degrading every claim to "Cannot tell" for the length of that gap.
|
|
941
|
+
# That would be a worse regression than the one this migration fixes: a script
|
|
942
|
+
# every agent runs before starting any work would refuse ALL of them.
|
|
943
|
+
LEASE_KNOWN=0
|
|
944
|
+
_lease_line=$(lease_query "$ISSUE")
|
|
945
|
+
_lease_rc=$?
|
|
946
|
+
_lease_kind=$(printf '%s' "$_lease_line" | cut -f1)
|
|
947
|
+
_lease_holder=$(printf '%s' "$_lease_line" | cut -f2)
|
|
948
|
+
_lease_exp=$(printf '%s' "$_lease_line" | cut -f3)
|
|
949
|
+
case "$_lease_rc $_lease_kind" in
|
|
950
|
+
"0 live")
|
|
951
|
+
LEASE_KNOWN=1
|
|
952
|
+
if [ -n "$HOLDER" ] && [ "$_lease_holder" = "$HOLDER" ]; then
|
|
953
|
+
echo "${DIM}lease held by ${HOLDER} — that is you${OFF}"
|
|
954
|
+
else
|
|
955
|
+
note "${RED}lease${OFF} held by ${_lease_holder:-unknown}, expires ${_lease_exp:-unknown}"
|
|
956
|
+
fi
|
|
957
|
+
;;
|
|
958
|
+
"0 free")
|
|
959
|
+
LEASE_KNOWN=1
|
|
960
|
+
;;
|
|
961
|
+
*)
|
|
962
|
+
# 2/unknown, or any shape this script does not recognise -- fail closed to
|
|
963
|
+
# the OLD rule (LEASE_KNOWN stays 0), never to "must be free".
|
|
964
|
+
;;
|
|
965
|
+
esac
|
|
966
|
+
|
|
868
967
|
# --- 1. The label. Easiest to check, easiest to forget. ----------------------
|
|
968
|
+
#
|
|
969
|
+
# ADVISORY once the lease has an opinion (LEASE_KNOWN=1): reported via
|
|
970
|
+
# `note_advisory` rather than `note`, so it is never again what makes an issue
|
|
971
|
+
# permanently unreachable on its own (ADR-0009 Sec3, once the lease exists).
|
|
972
|
+
# Still the ONLY signal used, unchanged, when the lease could not be consulted.
|
|
869
973
|
|
|
870
974
|
case ",$labels," in
|
|
871
975
|
*",$LABEL,"*)
|
|
@@ -891,8 +995,20 @@ case ",$labels," in
|
|
|
891
995
|
fi
|
|
892
996
|
case "$_held_status" in
|
|
893
997
|
0) echo "${DIM}label carries '$LABEL', held by ${HOLDER} — that is you${OFF}" ;;
|
|
894
|
-
2)
|
|
895
|
-
|
|
998
|
+
2)
|
|
999
|
+
if [ "$LEASE_KNOWN" -eq 1 ]; then
|
|
1000
|
+
note_advisory "${YELLOW}label${OFF} carries '$LABEL' — cannot tell who holds it (comments unreadable; advisory, the lease already answered)"
|
|
1001
|
+
else
|
|
1002
|
+
note_cannot_tell "${YELLOW}label${OFF} carries '$LABEL' — cannot tell who holds it (comments unreadable)"
|
|
1003
|
+
fi
|
|
1004
|
+
;;
|
|
1005
|
+
*)
|
|
1006
|
+
if [ "$LEASE_KNOWN" -eq 1 ]; then
|
|
1007
|
+
note_advisory "${YELLOW}label${OFF} carries '$LABEL' (issue last updated $updated) — advisory, the lease decides"
|
|
1008
|
+
else
|
|
1009
|
+
note "${YELLOW}label${OFF} carries '$LABEL' (issue last updated $updated)"
|
|
1010
|
+
fi
|
|
1011
|
+
;;
|
|
896
1012
|
esac
|
|
897
1013
|
;;
|
|
898
1014
|
esac
|
|
@@ -915,7 +1031,14 @@ if [ -n "$open_prs" ]; then
|
|
|
915
1031
|
printf '%s\n' "$open_prs" | while IFS= read -r pr; do
|
|
916
1032
|
[ -n "$pr" ] && echo " ${RED}open PR${OFF} $pr"
|
|
917
1033
|
done
|
|
918
|
-
|
|
1034
|
+
# ADVISORY once the lease has an opinion (ADR-0008/0009 Sec3b): a human working by
|
|
1035
|
+
# hand opens a PR and holds no lease, and this is what keeps that visible without
|
|
1036
|
+
# letting it wedge the issue the way it did for tabsii-platform#1126's branch.
|
|
1037
|
+
if [ "$LEASE_KNOWN" -eq 1 ]; then
|
|
1038
|
+
note_advisory "${RED}open PR${OFF} see above — advisory, the lease decides"
|
|
1039
|
+
else
|
|
1040
|
+
note "${RED}open PR${OFF} see above — someone has working code"
|
|
1041
|
+
fi
|
|
919
1042
|
fi
|
|
920
1043
|
|
|
921
1044
|
# --- 3. A remote branch naming it --------------------------------------------
|
|
@@ -945,7 +1068,17 @@ if [ -n "$branches" ]; then
|
|
|
945
1068
|
printf '%s\n' "$branches" | while IFS= read -r b; do
|
|
946
1069
|
[ -n "$b" ] && echo " ${RED}branch${OFF} $b"
|
|
947
1070
|
done
|
|
948
|
-
|
|
1071
|
+
# ADVISORY once the lease has an opinion (ADR-0008/0009 Sec3b) -- this is THE signal
|
|
1072
|
+
# ADR-0009 Sec3b names by number: "a remote branch names this issue" alone used to set
|
|
1073
|
+
# TAKEN=1 unconditionally and had no takeover path (#180). tabsii-platform#1126 is
|
|
1074
|
+
# exactly this shape: a branch existed, no PR, the builder was gone, and this line is
|
|
1075
|
+
# why the issue could never be reclaimed. It stays reported -- a human working by hand
|
|
1076
|
+
# creates a branch and holds no lease -- it just no longer decides on its own.
|
|
1077
|
+
if [ "$LEASE_KNOWN" -eq 1 ]; then
|
|
1078
|
+
note_advisory "${RED}branch${OFF} a remote branch names this issue — advisory, the lease decides"
|
|
1079
|
+
else
|
|
1080
|
+
note "${RED}branch${OFF} a remote branch names this issue"
|
|
1081
|
+
fi
|
|
949
1082
|
fi
|
|
950
1083
|
|
|
951
1084
|
# --- 4. A recently merged PR that already closed it --------------------------
|