Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions bin/hive-open-issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
# Usage (drop-in for the common gh shapes):
# hive-open-issue --repo <owner/repo> --title "<t>" [--body "<b>"|--body-file f] [--label a,b] [--parent <n>] [--blocked-by <n[,n]>] [--close-on-merge] [--needs-decision] [--no-consolidate <reason>] [--claim]
# hive-open-issue comment --repo <owner/repo> <number|url> --body "<b>" [--blocked-on-pr <n>]
# hive-open-issue comment --repo <owner/repo> <number|url> --body "<b>" [--blocked-on-pr <n>] [--not-agent-work <verdict>]
# hive-open-issue claim --repo <owner/repo> <number|url>
# hive-open-issue close --repo <owner/repo> <number|url> [--override-reason "..."]
# hive-open-issue label --repo <owner/repo> <number|url> [--label a,b] [--remove-label c]
Expand Down Expand Up @@ -73,6 +73,15 @@
# `blocked` label and removes `help wanted`; the hive lifts the label itself
# once the PR merges or closes. Never @-mention the PR author in the note.
#
# --not-agent-work <verdict> (comment only) records a triage verdict that the
# issue is not agent work (hivecommons/hive#18675): `not-a-defect` (a
# configuration condition or expected behaviour), `needs-human` (a person's
# action, access or judgement), or `needs-environment` (real logins, hardware,
# a live meeting). The watcher posts the note once with a marker and parks the
# issue on `needs-human`, so it leaves the Actionable lane and the scanner's
# work list; the same verdict again with no human comment since is dropped
# (already_existed). A person's later comment re-queues the issue.
#
# Every shape accepts --dry-run (-n): validate the arguments, print the exact
# request that WOULD be written, and exit 0 without writing it — nothing is
# created. USE IT TO TEST. A live call (no --dry-run) creates a real GitHub
Expand Down Expand Up @@ -156,14 +165,15 @@ CLOSE_ON_MERGE=0
NEEDS_DECISION=0
CLAIM_ON_CREATE=0
BLOCKED_ON_PR=""
NOT_AGENT_WORK=""
NO_CONSOLIDATE=""
NO_CONSOLIDATE_SET=0
DRY_RUN=0
LABELS=()
REMOVE_LABELS=()
REVIEWERS=()
TEAM_REVIEWERS=()
SUPPORTED_FLAGS="--repo/-R, --title/-t, --body/-b, --body-file/-F, --label/-l, --remove-label, --reviewer, --team-reviewer, --number, --parent, --blocked-by, --close-on-merge, --needs-decision, --claim, --no-consolidate, --blocked-on-pr, --override-reason, --dry-run/-n (plus the ignored gh flags --assignee/-a, --milestone/-m, --project/-p, --template/-T, --web/-w, --editor/-e)"
SUPPORTED_FLAGS="--repo/-R, --title/-t, --body/-b, --body-file/-F, --label/-l, --remove-label, --reviewer, --team-reviewer, --number, --parent, --blocked-by, --close-on-merge, --needs-decision, --claim, --no-consolidate, --blocked-on-pr, --not-agent-work, --override-reason, --dry-run/-n (plus the ignored gh flags --assignee/-a, --milestone/-m, --project/-p, --template/-T, --web/-w, --editor/-e)"
while [ $# -gt 0 ]; do
case "$1" in
--repo|-R) REPO="$2"; shift 2;;
Expand Down Expand Up @@ -197,6 +207,8 @@ while [ $# -gt 0 ]; do
--no-consolidate=*) NO_CONSOLIDATE_SET=1; NO_CONSOLIDATE="${1#*=}"; shift;;
--blocked-on-pr) BLOCKED_ON_PR="$2"; shift 2;;
--blocked-on-pr=*) BLOCKED_ON_PR="${1#*=}"; shift;;
--not-agent-work) NOT_AGENT_WORK="$2"; shift 2;;
--not-agent-work=*) NOT_AGENT_WORK="${1#*=}"; shift;;
--dry-run|-n) DRY_RUN=1; shift;;
# Tolerate gh flags we don't need; skip a following value only for flags
# that take one, so a bare flag can't swallow the next real argument.
Expand Down Expand Up @@ -265,6 +277,14 @@ if [ -n "${BLOCKED_ON_PR:-}" ] && [ "$KIND" != "comment" ]; then
echo "hive-open-issue: --blocked-on-pr only applies to a comment; nothing was written." >&2
exit 2
fi
if [ -n "${NOT_AGENT_WORK:-}" ] && [ "$KIND" != "comment" ]; then
echo "hive-open-issue: --not-agent-work only applies to a comment; nothing was written." >&2
exit 2
fi
if [ -n "${NOT_AGENT_WORK:-}" ] && ! [[ "$NOT_AGENT_WORK" =~ ^(not-a-defect|needs-human|needs-environment)$ ]]; then
echo "hive-open-issue: --not-agent-work needs one of not-a-defect, needs-human, needs-environment; nothing was written." >&2
exit 2
fi
if [ -n "${BLOCKED_ON_PR:-}" ] && ! [[ "$BLOCKED_ON_PR" =~ ^[0-9]+$ && "$BLOCKED_ON_PR" -gt 0 ]]; then
echo "hive-open-issue: --blocked-on-pr needs a positive PR number; nothing was written." >&2
exit 2
Expand Down Expand Up @@ -384,9 +404,9 @@ REMOVE_LABELS_JSON="$(printf '%s\n' "${REMOVE_LABELS[@]:-}" | python3 -c 'import
REVIEWERS_JSON="$(printf '%s\n' "${REVIEWERS[@]:-}" | python3 -c 'import json,sys; print(json.dumps([x.rstrip("\n") for x in sys.stdin if x.rstrip("\n")]))')"
TEAM_REVIEWERS_JSON="$(printf '%s\n' "${TEAM_REVIEWERS[@]:-}" | python3 -c 'import json,sys; print(json.dumps([x.rstrip("\n") for x in sys.stdin if x.rstrip("\n")]))')"
BLOCKED_BY_JSON="$(printf '%s\n' "${BLOCKED_BY[@]:-}" | python3 -c 'import json,sys; print(json.dumps([x.rstrip("\n") for x in sys.stdin if x.rstrip("\n")]))')"
python3 - "$TEMP_FILE" "$REQ_FILE" "$KIND" "$REPO" "$TITLE" "${OVERRIDE_REASON:-$BODY}" "$AGENT" "$LABELS_JSON" "${NUMBER:-0}" "$DRY_RUN" "${PARENT:-0}" "$REMOVE_LABELS_JSON" "$REVIEWERS_JSON" "$TEAM_REVIEWERS_JSON" "$BLOCKED_BY_JSON" "$NEEDS_DECISION" "${BLOCKED_ON_PR:-0}" "$NO_CONSOLIDATE" "$CLAIM_ON_CREATE" <<'PY'
python3 - "$TEMP_FILE" "$REQ_FILE" "$KIND" "$REPO" "$TITLE" "${OVERRIDE_REASON:-$BODY}" "$AGENT" "$LABELS_JSON" "${NUMBER:-0}" "$DRY_RUN" "${PARENT:-0}" "$REMOVE_LABELS_JSON" "$REVIEWERS_JSON" "$TEAM_REVIEWERS_JSON" "$BLOCKED_BY_JSON" "$NEEDS_DECISION" "${BLOCKED_ON_PR:-0}" "$NO_CONSOLIDATE" "$CLAIM_ON_CREATE" "${NOT_AGENT_WORK:-}" <<'PY'
import json, os, sys
temporary, path, kind, repo, title, body, agent, labels, number, dry_run, parent, remove_labels, reviewers, team_reviewers, blocked_by, needs_decision, blocked_on_pr, no_consolidate, claim_on_create = sys.argv[1:20]
temporary, path, kind, repo, title, body, agent, labels, number, dry_run, parent, remove_labels, reviewers, team_reviewers, blocked_by, needs_decision, blocked_on_pr, no_consolidate, claim_on_create, not_agent_work = sys.argv[1:21]
labels = [part.strip() for value in json.loads(labels)
for part in value.split(",") if part.strip()]
remove_labels = [part.strip() for value in json.loads(remove_labels)
Expand Down Expand Up @@ -464,6 +484,10 @@ if kind == "comment" and int(blocked_on_pr) > 0:
# --blocked-on-pr: the watcher adds the marker and the `blocked` label
# itself (hivecommons/hive#13093).
req["blocked_on_pr"] = int(blocked_on_pr)
if kind == "comment" and not_agent_work:
# --not-agent-work: the watcher adds the marker and parks the issue on
# needs-human itself (hivecommons/hive#18675).
req["not_agent_work"] = not_agent_work
if dry_run == "1":
# Honour --dry-run: show exactly what would be queued, write nothing.
print("hive-open-issue: DRY RUN — no request written, nothing will be created. Would write %s:" % path)
Expand Down Expand Up @@ -491,6 +515,9 @@ if [ "$KIND" = "comment" ]; then
if [ -n "${BLOCKED_ON_PR:-}" ]; then
echo "hive-open-issue: will park the issue on $REPO#$BLOCKED_ON_PR (blocked label; help wanted removed; no one is @-mentioned)"
fi
if [ -n "${NOT_AGENT_WORK:-}" ]; then
echo "hive-open-issue: will record the $NOT_AGENT_WORK verdict and park the issue on needs-human (an identical repeat is dropped)"
fi
elif [ "$KIND" = "claim" ]; then
echo "hive-open-issue: requested claim of $REPO#$NUMBER (hive/claimed-by-$AGENT label)"
elif [ "$KIND" = "close" ]; then
Expand Down
24 changes: 24 additions & 0 deletions bin/test_hive_open_issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,30 @@ check "--claim refusal writes no request" "" "$(find_req claimcommentbot)"
rm -rf "$REQ_DIR"
mkdir -p "$REQ_DIR"

# --not-agent-work <verdict> carries the verdict on a comment; a bad verdict or a non-comment is refused (#18675).
run_script "nawbot" comment --repo "hiveorg/widgets" 5 --body "not startable" --not-agent-work needs-environment >/dev/null
REQ_FILE="$(find_req nawbot)"
if [ -n "$REQ_FILE" ]; then
GOT="$(python3 -c "import json,sys; r=json.load(open(sys.argv[1])); print(r.get('kind'), r.get('not_agent_work'))" "$REQ_FILE")"
check "--not-agent-work sets not_agent_work on the comment request" "comment needs-environment" "$GOT"
else
echo " FAIL: request file not created for --not-agent-work test"
FAIL=$((FAIL + 1))
fi
rm -rf "$REQ_DIR"
mkdir -p "$REQ_DIR"
set +e
run_script "nawbadbot" comment --repo "hiveorg/widgets" 5 --body "x" --not-agent-work maybe >/dev/null 2>&1
BAD_RC=$?
run_script "nawissuebot" --repo "hiveorg/widgets" --title "t" --body "b" --not-agent-work needs-human >/dev/null 2>&1
BAD_ISSUE_RC=$?
set -e
check "--not-agent-work with an unknown verdict is refused (exit 2)" "2" "$BAD_RC"
check "--not-agent-work on a create is refused (exit 2)" "2" "$BAD_ISSUE_RC"
check "--not-agent-work refusals write no request" "" "$(find_req nawbadbot)$(find_req nawissuebot)"
rm -rf "$REQ_DIR"
mkdir -p "$REQ_DIR"

# --no-consolidate <reason> carries the reason; an empty reason or a non-create is refused.
run_script "noconsolbot" --repo "hiveorg/widgets" --title "Unrelated" --body "b" --no-consolidate "different work"
REQ_FILE="$(find_req noconsolbot)"
Expand Down
1 change: 1 addition & 0 deletions changelog.d/fixed-18675-scanner-not-agent-work-verdict.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The scanner's "not agent work" triage verdict now changes the issue's state instead of only leaving a comment: `hive-open-issue comment --not-agent-work <not-a-defect|needs-human|needs-environment>` (or the `<!-- hive:not-agent-work verdict=... -->` marker) posts the note once and parks the issue on `needs-human`, so it leaves stage/010-actionable on the board and the scanner's work list. An identical verdict with no human comment since is dropped as `already_existed` rather than posted again, and a person's later comment lifts the hive's own `needs-human` and re-queues the issue (#18675).
3 changes: 2 additions & 1 deletion src/docs/hive-open-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Shapes are selected by an optional leading positional keyword (`comment`,

```sh
hive-open-issue --repo <owner/repo> --title "<t>" [--body "<b>"|--body-file f] [--label a,b] [--parent <n>] [--blocked-by <n[,n]>] [--needs-decision] [--no-consolidate <reason>] [--claim]
hive-open-issue comment --repo <owner/repo> <number|url> --body "<b>" [--blocked-on-pr <n>]
hive-open-issue comment --repo <owner/repo> <number|url> --body "<b>" [--blocked-on-pr <n>] [--not-agent-work <verdict>]
hive-open-issue claim --repo <owner/repo> <number|url>
hive-open-issue label --repo <owner/repo> <number|url> [--label a,b] [--remove-label c]
hive-open-issue request-review --repo <owner/repo> <number|url> [--reviewer a,b] [--team-reviewer t]
Expand All @@ -65,6 +65,7 @@ hive-open-issue request-review --repo <owner/repo> <number|url> [--reviewer a,b]
| `--claim` | — | issue | file the new issue **and** claim it for this agent in the same request (see [Filing your own next step](#filing-your-own-next-step)). The request carries `"claim": true`; the result reports `claimed`, or `claim_error` when the claim did not land |
| `--no-consolidate` | — | issue | requires a non-empty reason; the watcher skips open-issue consolidation (same-subject, file-set and component folds) and files a new issue, echoing the reason as `consolidation_skipped_reason` in the result and logging it. Use it for unrelated work that only shares a file or component with an open issue ([#14360](https://github.com/hivecommons/hive/issues/14360)). The request carries `"no_consolidate_reason"`. A request that declares `--parent` or `--blocked-by` needs no reason: it is a distinct DAG node and never takes the file-set, component or canonical-subject folds, and a genuine create reports `consolidation_skipped_reason` as `parent` or `blocked_by` ([#16065](https://github.com/hivecommons/hive/issues/16065)) |
| `--blocked-on-pr` | — | comment | park the issue on open PR `<n>` in the same repo: the watcher prefixes the note with `<!-- hive:blocked-on pr=owner/repo#n -->`, strips `@`-mentions from it, adds the `blocked` label and removes `help wanted` (see [Blocked on an unmerged PR](#blocked-on-an-unmerged-pr)) |
| `--not-agent-work` | — | comment | record a triage verdict that the issue is not agent work (`not-a-defect`, `needs-human` or `needs-environment`, hivecommons/hive#18675): the watcher posts the note once with `<!-- hive:not-agent-work verdict=<v> -->` and adds `needs-human`, so the issue leaves the Actionable lane and the scanner's work list; the same verdict with no human comment since is dropped (`already_existed`), and a person's later comment re-queues the issue |
| `--number` | — | comment, claim, close, label, request-review | the issue/PR number; a bare positional number or a `.../issues/N` or `.../pull/N` URL is also accepted |
| `--dry-run` | `-n` | all | validate the arguments and print the exact request that would be written, then exit `0` **without writing it** — nothing is created, commented, claimed, or closed. **This is how you test the tool.** A live call creates a real GitHub issue/comment/label change under the hive's App identity |

Expand Down
1 change: 1 addition & 0 deletions src/docs/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ without a class. Review submissions and review requests are always counted as
| `github.(*Client).handleOneIssueRequestFrom` | `attention` | |
| `github.(*Client).parkClankerRequestedPR` | `attention` | |
| `github.(*Client).redirectToExistingPR` | `attention` | |
| `github.(*Client).relayNotAgentWorkNote` | `attention` | scanner not-agent-work verdict: posted once with its marker and parks the issue on `needs-human`; an identical repeat records a suppressed comment (#18675) |
| `github.(*Client).relayScannerNote` | `attention` | scanner PR note: an unchanged or edited note records a suppressed comment (#18451) |
| `github.(*Client).remindAttention` | `attention` | attention-pilot reminder: at most one per unresolved episode per `reminder_interval`; write-back gate consulted first |
| `github.(*Client).resolveDuplicateFixGroup` | `attention` | |
Expand Down
Loading
Loading