mirror of
https://github.com/hanzoai/insights.git
synced 2026-11-03 00:52:32 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
73 lines
2.6 KiB
Bash
Executable File
73 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Constrained marker I/O for the autoresolve sweep: the agent must never read raw PR
|
|
# comment bodies, so this helper emits/accepts only strictly validated data.
|
|
#
|
|
# Marker state is only trusted from our own App: reads and the comment chosen for update
|
|
# are restricted to comments authored by AUTORESOLVE_BOT_LOGIN (the Loop's `<slug>[bot]`
|
|
# login). A commenter can otherwise plant a marker to spoof "already attempted" and skip a
|
|
# PR. Fail closed: with the login unset, `get` returns nothing and `set` always creates,
|
|
# so a fuzzy match never trusts or overwrites another author's comment.
|
|
set -euo pipefail
|
|
|
|
MARKER_RE='<!-- autoresolve-attempt:[0-9a-f]{40}:[0-9a-f]{40} -->'
|
|
BOT_LOGIN=${AUTORESOLVE_BOT_LOGIN:-}
|
|
|
|
usage() {
|
|
echo "usage: $0 get <owner/repo> <pr_number>" >&2
|
|
echo " $0 set <owner/repo> <pr_number> <head_oid> <master_oid> < body.md" >&2
|
|
echo "requires AUTORESOLVE_BOT_LOGIN (the Loop App's <slug>[bot] login)" >&2
|
|
exit 2
|
|
}
|
|
|
|
cmd=${1:-}
|
|
repo=${2:-}
|
|
pr=${3:-}
|
|
[ -n "$cmd" ] && [ -n "$repo" ] && [ -n "$pr" ] || usage
|
|
[ -n "$BOT_LOGIN" ] || usage
|
|
case "$repo" in
|
|
*/*) ;;
|
|
*) usage ;;
|
|
esac
|
|
case "$pr" in
|
|
'' | *[!0-9]*) usage ;;
|
|
esac
|
|
|
|
# Bodies of this PR's comments authored by our App only.
|
|
own_comment_bodies() {
|
|
gh api "repos/$repo/issues/$pr/comments" --paginate \
|
|
--jq '.[] | select(.user.login == env.BOT_LOGIN) | .body' 2>/dev/null
|
|
}
|
|
|
|
case "$cmd" in
|
|
get)
|
|
BOT_LOGIN="$BOT_LOGIN" own_comment_bodies |
|
|
grep -oE "$MARKER_RE" |
|
|
tail -1 |
|
|
grep -oE '[0-9a-f]{40}:[0-9a-f]{40}' || true
|
|
;;
|
|
set)
|
|
head_oid=${4:-}
|
|
master_oid=${5:-}
|
|
printf '%s' "$head_oid" | grep -qE '^[0-9a-f]{40}$' || usage
|
|
printf '%s' "$master_oid" | grep -qE '^[0-9a-f]{40}$' || usage
|
|
body="$(cat)
|
|
|
|
<!-- autoresolve-attempt:${head_oid}:${master_oid} -->"
|
|
existing_id=$(BOT_LOGIN="$BOT_LOGIN" gh api "repos/$repo/issues/$pr/comments" --paginate \
|
|
--jq '[.[] | select(.user.login == env.BOT_LOGIN)
|
|
| select(.body | test("<!-- autoresolve-attempt:[0-9a-f]{40}:[0-9a-f]{40} -->"))
|
|
| .id] | last // empty')
|
|
case "$existing_id" in
|
|
'' | *[!0-9]*) existing_id='' ;;
|
|
esac
|
|
if [ -n "$existing_id" ]; then
|
|
gh api -X PATCH "repos/$repo/issues/comments/$existing_id" -f body="$body" --jq .id >/dev/null
|
|
else
|
|
gh api -X POST "repos/$repo/issues/$pr/comments" -f body="$body" --jq .id >/dev/null
|
|
fi
|
|
;;
|
|
*)
|
|
usage
|
|
;;
|
|
esac
|