Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sovereign-intelligence/blob/main/tools/si-state.sh # sovereign-intelligence Front door to Drake Stapleton's sovereign stack. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `sovereign-intelligence / tools / si-state.sh` 54 lines ยท 2996 bytes Raw Blame History 1 #!/bin/sh 2 # tools/si-state.sh INVENTORY [RECEIPTS]: print the Radicle state compiler/si.om reads, the 3 # generated input compiler/state.tsv. Nothing in it is typed. For each RID of INVENTORY (the second 4 # field of every line that is not empty or a # comment), in inventory order: 5 # D RID BRANCH the default branch the RID's signed identity names (rad inspect RID --payload) 6 # V RID VISIBILITY the first word of rad inspect RID --visibility 7 # H RID BRANCH SHA the canonical refs/heads/BRANCH in Radicle storage (RAD_STORAGE, default 8 # ~/.radicle/storage): the head of the default branch 9 # P RID SHA FILE one line per landing receipt in the directory RECEIPTS whose first line is 10 # exactly "RECEIPT PASS head=SHA" (or the older spelling "LANDING RECEIPT PASS 11 # head=SHA") for that head; FILE is the receipt's file name 12 # and before them one line "T UTC", the time it was read. Fields are TAB-separated. A value it cannot 13 # read is left out, so si refuses the row by name (no default branch, no visibility, no head); every 14 # check is si's, this script only reads. Without RECEIPTS no P line is written. Needs rad, git, jq. 15 # 16 # sh tools/si-state.sh compiler/inventory.tsv /path/to/landing-receipts > compiler/state.tsv 17 set -eu 18 [ $# -ge 1 ] && [ $# -le 2 ] || { echo "usage: si-state.sh INVENTORY [RECEIPTS]" >&2; exit 2; } 19 inv=$1 20 rcp=${2:-} 21 store=${RAD_STORAGE:-$HOME/.radicle/storage} 22 [ -r "$inv" ] || { echo "si-state: cannot read $inv" >&2; exit 2; } 23 [ -d "$store" ] || { echo "si-state: no Radicle storage at $store" >&2; exit 2; } 24 [ -z "$rcp" ] || [ -d "$rcp" ] || { echo "si-state: no receipts directory $rcp" >&2; exit 2; } 25 tab=$(printf '\t') 26 idx=$(mktemp) 27 trap 'rm -f "$idx"' EXIT 28 # The receipts index: "SHA FILE" for every receipt whose first line names a head. 29 if [ -n "$rcp" ]; then 30 for f in "$rcp"/*; do 31 [ -f "$f" ] || continue 32 l=$(head -n 1 "$f") 33 case $l in 34 "RECEIPT PASS head="*|"LANDING RECEIPT PASS head="*) h=${l##*head=} ;; 35 *) continue ;; 36 esac 37 case $h in *[!0-9a-f]*) continue ;; esac 38 [ ${#h} -eq 40 ] || continue 39 printf '%s %s\n' "$h" "${f##*/}" 40 done | LC_ALL=C sort > "$idx" 41 fi 42 printf 'T\t%s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" 43 grep -v '^#' "$inv" | while IFS="$tab" read -r _ rid _; do 44 case $rid in rad:z*) ;; *) continue ;; esac 45 br=$(rad inspect "$rid" --payload 2>/dev/null | jq -r '."xyz.radicle.project".defaultBranch // empty' 2>/dev/null || true) 46 [ -z "$br" ] || printf 'D\t%s\t%s\n' "$rid" "$br" 47 vis=$(rad inspect "$rid" --visibility 2>/dev/null | sed -n '1{s/[[:space:]].*//;p;}' || true) 48 [ -z "$vis" ] || printf 'V\t%s\t%s\n' "$rid" "$vis" 49 [ -n "$br" ] || continue 50 h=$(git --git-dir="$store/${rid#rad:}" rev-parse -q --verify "refs/heads/$br^{commit}" 2>/dev/null || true) 51 [ -n "$h" ] || continue 52 printf 'H\t%s\t%s\t%s\n' "$rid" "$br" "$h" 53 awk -v h="$h" -v r="$rid" '$1 == h { printf "P\t%s\t%s\t%s\n", r, h, $2 }' "$idx" 54 done