From 451fdb2ac9db8ed8b39677c931a2851a5bf3351b Mon Sep 17 00:00:00 2001 From: Lourival Vieira Neto Date: Sun, 22 Nov 2026 18:03:36 -0300 Subject: [PATCH] merge-guard: a small harness change merges on a posted proof A harness pull request the session opened merged on the agent-review status alone, which review.js sets at high, so a change of a few mechanical lines spent a review's agents or waited on the maintainer's words. One complexity.sh calls small now merges on its CI and a proof the session posts on it: a comment of the posting account that names its head, beside the command that shows the defect before, its result after and the case still refused. The maintainer asked for it on 2026-11-22, "devemos atualizar o harness tb para contemplar mudancas mecanicas como essa sem queimar token". complexity.sh takes the repository as a second argument, since the guard reads a pull request of whichever repository the merge names, and the 40 lines it calls small stay its own. A small pull request merged on its proof takes the agent-review status on its merged commit too, so the bump of each project's mount reads it as it reads a reviewed one. Co-Authored-By: Claude Opus 5.5 --- .agents/rules/checks.md | 4 +++- .agents/skills/merged/SKILL.md | 8 ++++++-- AGENTS.md | 8 +++++++- tools/checks/cases/merge-guard.cases | 4 ++++ tools/checks/cases/merge-guard.fixture.sh | 15 ++++++++++++++- tools/checks/merge-guard.sh | 17 ++++++++++++++--- tools/complexity.sh | 6 +++--- 7 files changed, 51 insertions(+), 11 deletions(-) diff --git a/.agents/rules/checks.md b/.agents/rules/checks.md index 68aff46..049244b 100644 --- a/.agents/rules/checks.md +++ b/.agents/rules/checks.md @@ -222,7 +222,9 @@ that it is a harness pull request an agent's review passed: opened by the postin repository's default branch, as GitHub names it, every file the harness as `harness-mixed.sh --outside` reads it, the mount a bump moves among them, or any file of the harness's own repository, and a head that carries the -`agent-review` status, which the merged skill sets once `review.js` returned that head ready, and +`agent-review` status, which the merged skill sets once `review.js` returned that head ready, or, on a +pull request `complexity.sh` calls small, a comment of the posting account that names that head, the +proof a mechanical change merges on (AGENTS.md, *Patches and commits*), and passed every check run, and commits none of which is a `fixup!`, `amend!` or `squash!`, which the `Checks` run warns of without failing. A bump of the mount, a pull request whose one file is the submodule, carries no status of its own: the commit it pins does, on the harness's trunk, where the diff --git a/.agents/skills/merged/SKILL.md b/.agents/skills/merged/SKILL.md index fdb97a8..f814140 100644 --- a/.agents/skills/merged/SKILL.md +++ b/.agents/skills/merged/SKILL.md @@ -18,7 +18,11 @@ refused, by `merge-guard.sh` and by GitHub: gh api -X PUT repos///pulls//merge -f merge_method=rebase -f sha= A fold moves the head and not the tree: the status goes on the folded head when its tree is the one -the review returned, `git rev-parse ^{tree}` against `^{tree}`. What the review left as +the review returned, `git rev-parse ^{tree}` against `^{tree}`. One that +`tools/complexity.sh /` calls small merges on a proof in place of the review: a +comment on it, opened by GitHub's note that an LLM wrote it, naming its head beside the command that +shows the defect before, its result after and the case still refused, or, for text no command reads, +the passage it replaces beside the new one, and the merge names that head. What the review left as issues is filed before the merge, as implement-issue's last stage files it. A pull request the maintainer orders merged in his own words takes `MERGE_OK=1`. The steps below follow either merge, and the report reaches him as it does for his own. @@ -102,7 +106,7 @@ that runs it (AGENTS.md, *Deciding what to change*). A pull request of the harness's own repository reaches a project only through the commit its mount points at. Once one merges, its `agent-review` status goes on the commit the merge put on the harness's trunk, the `sha` the merge answered: the rebase gave the reviewed head a new SHA, and a bump is read on -that one. +that one. A small one merged on its proof takes the status too, its description naming the proof. gh api -X POST repos///statuses/ -f state=success -f context=agent-review -f description='review.js: ready' diff --git a/AGENTS.md b/AGENTS.md index ac406f5..bdeaf26 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -364,7 +364,13 @@ named, not one discovered at that consumer's build. * A harness pull request the session opened, one whose every file `harness-mixed.sh` reads as the harness, merges without waiting for the maintainer once `review.js` ran over its head at `high` and returned it ready and its CI passed: what a correction teaches binds the next session that - day, and the maintainer reads it on master, in the report the merged skill hands him. + day, and the maintainer reads it on master, in the report the merged skill hands him. One that + `tools/complexity.sh` calls small merges on its CI and a proof instead, a comment of the session on + it that names its head beside the command that shows the defect before, its result after and the + case still refused, or, for text no command reads, the passage it replaces beside the new one: a + mechanical change spends no agent on a review, as the maintainer asked on + 2026-11-22, "devemos atualizar o harness tb para contemplar mudancas mecanicas como essa sem + queimar token". `tools/checks/merge-guard.sh` refuses any other merge the session runs; `MERGE_OK=1` merges one he ordered merged in his own words. * A mechanism of the harness that rests on a command an agent runs, a guard's record among them, is diff --git a/tools/checks/cases/merge-guard.cases b/tools/checks/cases/merge-guard.cases index 40f2356..f5ca5c8 100644 --- a/tools/checks/cases/merge-guard.cases +++ b/tools/checks/cases/merge-guard.cases @@ -31,3 +31,7 @@ block tok=$(cat key); GH_TOKEN=$tok gh api -X PUT repos/luainkernel/lunatik/pull block tok=$(cat key); GH_TOKEN=$tok gh api -X PUT repos/luainkernel/lunatik/pulls/12/merge -f merge_method=rebase # a pull request of the harness's own repository is the harness whole, its README and its licenses too pass tok=$(cat key); GH_TOKEN=$tok gh api -X PUT repos/luainkernel/harness/pulls/13/merge -f merge_method=rebase +# a small pull request merges on a proof that names its head, posted by the account that opened it +pass tok=$(cat key); GH_TOKEN=$tok gh api -X PUT repos/luainkernel/lunatik/pulls/14/merge -f merge_method=rebase +block tok=$(cat key); GH_TOKEN=$tok gh api -X PUT repos/luainkernel/lunatik/pulls/15/merge -f merge_method=rebase +block tok=$(cat key); GH_TOKEN=$tok gh api -X PUT repos/luainkernel/lunatik/pulls/16/merge -f merge_method=rebase diff --git a/tools/checks/cases/merge-guard.fixture.sh b/tools/checks/cases/merge-guard.fixture.sh index fd52cbc..d274958 100644 --- a/tools/checks/cases/merge-guard.fixture.sh +++ b/tools/checks/cases/merge-guard.fixture.sh @@ -11,7 +11,9 @@ # #11 and #12 bump the mount, harness, their heads carrying no agent-review status, to a commit of # luainkernel/harness: #10's on its trunk and carrying the status, #11's on its trunk and carrying none, # #12's carrying it and not on its trunk. #13 is a pull request of luainkernel/harness that changes its -# README and a license with a check. +# README and a license with a check. #14, #15 and #16 change a check, their heads carrying no +# agent-review status: #14 adds 12 lines and a comment of the posting account names its head, #15 adds +# 12 and no comment names it, #16 adds 90 and a comment names it. # # Usage: bash tools/checks/cases/merge-guard.fixture.sh @@ -22,6 +24,17 @@ cat > stub/gh <<'STUB' #!/bin/sh [ "$GH_TOKEN" = cases ] || exit 1 case "$*" in + */pulls/1[45]\ -q\ .additions) echo 12 ;; + */pulls/16\ -q\ .additions) echo 90 ;; + */pulls/14\ *) printf 'open\tmaster\tcases\t1414141414141414141414141414141414141414\n' ;; + */pulls/15\ *) printf 'open\tmaster\tcases\t1515151515151515151515151515151515151515\n' ;; + */pulls/16\ *) printf 'open\tmaster\tcases\t1616161616161616161616161616161616161616\n' ;; + */pulls/1[456]/files*) echo tools/checks/cases.sh ;; + */pulls/1[456]/commits*) echo 'checks: name a case' ;; + */issues/14/comments*) echo 'The defect before and the case after, on 141414141' ;; + */issues/15/comments*) echo 'The defect before and the case after' ;; + */issues/16/comments*) echo 'The defect before and the case after, on 161616161' ;; + */commits/1[456]1[456]*/status\ *) ;; */pulls/[78]\ *) printf 'open\tmaster\tcases\t0123456789abcdef0123456789abcdef01234567\n' ;; */pulls/9\ *) printf 'open\tbump\tcases\t0123456789abcdef0123456789abcdef01234567\n' ;; */pulls/10\ *) printf 'open\tmaster\tcases\t1010101010101010101010101010101010101010\n' ;; diff --git a/tools/checks/merge-guard.sh b/tools/checks/merge-guard.sh index 63aecb4..f0711dc 100755 --- a/tools/checks/merge-guard.sh +++ b/tools/checks/merge-guard.sh @@ -5,7 +5,8 @@ # # PreToolUse (Bash) hook: the session merges a pull request without the maintainer only when the # posting account opened it on the repository's default branch, it changes the harness alone, its head carries the -# agent-review status and passed every check run, and none of its commits waits for a squash, which +# agent-review status, or the pull request is small by complexity.sh and a comment of the posting account +# on it names the head, and passed every check run, and none of its commits waits for a squash, which # the Checks run warns of without failing (AGENTS.md, "Patches and commits"). A bump of the mount, whose # one file is the submodule, carries the agent-review status of the harness commit it pins instead, a # commit on the harness's trunk that passed every check run of its own (the merged skill, section 5). @@ -58,6 +59,14 @@ passed() { [ -n "$checks" ] && ! printf '%s\n' "$checks" | grep -vqxE 'success|skipped|neutral' } +# whether the pull request of the repository adds what complexity.sh calls small, and a +# comment of the account on it names its head , the proof a mechanical change merges on +proved() { + [ "$(GH_TOKEN=$token bash "$checks/../complexity.sh" "$2" "$1" 2>/dev/null)" = "complexity: small" ] && + github "repos/$1/issues/$2/comments?per_page=100" --paginate --jq ".[] | select(.user.login == \"$3\") | .body" | + grep -qF "${4:0:9}" +} + # the repository and the commit, "/ ", the pull request of the repository whose head # is pins when its one file, , is a submodule; nothing for any other pinned() { @@ -91,7 +100,8 @@ while IFS= read -r merge; do [ -n "$head" ] || refuse "GitHub did not answer for #$number" trunk=$(github "repos/$repo" --jq .default_branch) [ "$state" = open ] && [ -n "$trunk" ] && [ "$base" = "$trunk" ] || refuse "#$number is not open on the default branch, ${trunk:-which GitHub did not answer}" - [ "$author" = "$(github user --jq .login)" ] || refuse "#$number was not opened by the posting account" + login=$(github user --jq .login) + [ "$author" = "$login" ] || refuse "#$number was not opened by the posting account" paths=$(github "repos/$repo/pulls/$number/files?per_page=100" --paginate --jq '.[] | .filename, .previous_filename // empty') [ -n "$paths" ] || refuse "GitHub did not answer for the files of #$number" @@ -112,7 +122,8 @@ while IFS= read -r merge; do reviewed "$upstream" "$pin" || refuse "${pin:0:9}, which #$number pins, carries no agent-review status" passed "$upstream" "$pin" || refuse "the CI of ${pin:0:9}, which #$number pins, has not passed" else - reviewed "$repo" "$head" || refuse "the head of #$number, ${head:0:9}, carries no agent-review status" + reviewed "$repo" "$head" || proved "$repo" "$number" "$login" "$head" || + refuse "the head of #$number, ${head:0:9}, carries no agent-review status, nor a proof that names it" fi passed "$repo" "$head" || refuse "the CI of ${head:0:9} has not passed" subjects=$(github "repos/$repo/pulls/$number/commits?per_page=100" --paginate --jq '.[].commit.message | split("\n")[0]') diff --git a/tools/complexity.sh b/tools/complexity.sh index 7acdcc4..7afe5f0 100755 --- a/tools/complexity.sh +++ b/tools/complexity.sh @@ -8,12 +8,12 @@ # `complexity: large`. The maintainer picks what he reviews by that label, the small first; the lines # a change removes do not count, since a removal reads at a glance. # -# Usage: GH_TOKEN=... bash tools/complexity.sh (of the repository origin names) +# Usage: GH_TOKEN=... bash tools/complexity.sh [/] (by default, the one origin names) -[ $# -eq 1 ] || { echo "usage: $0 " >&2; exit 2; } +[ $# -eq 1 ] || [ $# -eq 2 ] || { echo "usage: $0 [/]" >&2; exit 2; } . "$(dirname "$(readlink -f "$0")")/checks/project.sh" -added=$(gh api "repos/$(project_repo)/pulls/$1" -q .additions) || exit 1 +added=$(gh api "repos/${2:-$(project_repo)}/pulls/$1" -q .additions) || exit 1 if [ "$added" -le 40 ]; then size=small elif [ "$added" -le 150 ]; then