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
4 changes: 3 additions & 1 deletion .agents/rules/checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions .agents/skills/merged/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ refused, by `merge-guard.sh` and by GitHub:
gh api -X PUT repos/<owner>/<repo>/pulls/<N>/merge -f merge_method=rebase -f sha=<head>

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 <tip>^{tree}` against `<head>^{tree}`. What the review left as
the review returned, `git rev-parse <tip>^{tree}` against `<head>^{tree}`. One that
`tools/complexity.sh <N> <owner>/<repo>` 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.
Expand Down Expand Up @@ -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/<owner>/<harness>/statuses/<merged commit> -f state=success -f context=agent-review -f description='review.js: ready'

Expand Down
8 changes: 7 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tools/checks/cases/merge-guard.cases
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 14 additions & 1 deletion tools/checks/cases/merge-guard.fixture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <dir>

Expand All @@ -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' ;;
Expand Down
17 changes: 14 additions & 3 deletions tools/checks/merge-guard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -58,6 +59,14 @@ passed() {
[ -n "$checks" ] && ! printf '%s\n' "$checks" | grep -vqxE 'success|skipped|neutral'
}

# whether the pull request <number> of the repository <repo> adds what complexity.sh calls small, and a
# comment of the account <login> on it names its head <sha>, 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, "<owner>/<name> <sha>", the pull request of the repository <repo> whose head
# is <head> pins when its one file, <path>, is a submodule; nothing for any other
pinned() {
Expand Down Expand Up @@ -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"
Expand All @@ -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]')
Expand Down
6 changes: 3 additions & 3 deletions tools/complexity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <number> (of the repository origin names)
# Usage: GH_TOKEN=... bash tools/complexity.sh <number> [<owner>/<repo>] (by default, the one origin names)

[ $# -eq 1 ] || { echo "usage: $0 <number>" >&2; exit 2; }
[ $# -eq 1 ] || [ $# -eq 2 ] || { echo "usage: $0 <number> [<owner>/<repo>]" >&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
Expand Down
Loading