Skip to content

merged: harness merges run through tools/merge.sh - #48

Merged
lneto merged 1 commit into
masterfrom
merge-script
Nov 27, 2026
Merged

lneto merged 1 commit into
masterfrom
merge-script

Conversation

@lneto

@lneto lneto commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

After a /clear, the session cannot merge a small harness pull request on its proof: the auto mode classifier refused the merge of luainkernel/lunatik#2744, whose CI had passed and whose proof was posted, until the maintainer's words were back in the conversation. tools/merge.sh runs a merge only where merge-guard.sh admits it, so a narrow permissions.allow rule over the script can let those merges through and nothing else:

# token: a file that holds a GitHub token allowed to merge
# checkout: the absolute path of the lunatik checkout sessions start in
head=$(gh api repos/luainkernel/lunatik/pulls/2744 --jq .head.sha)    # a full SHA
bash "$checkout"/harness/tools/merge.sh luainkernel/lunatik 2744 "$head" token
# {"sha":"<the commit the rebase put on master>","merged":true,"message":"Pull Request successfully merged"}

The script hands the guard the exact rebase merge it would run, the head named, and runs it only when the guard passes it. It never adds MERGE_OK=1, and its arguments must be a repository's name, a number and a full SHA, so neither the environment nor an argument can carry the marker. Sections 0 and 5 of the merged skill merge through it, a harness pull request and a bump of the mount alike, and a merge the maintainer orders in his own words keeps MERGE_OK=1 on the plain gh api call.

The allow rules belong in the maintainer's own ~/.claude/settings.json, and this pull request adds no settings. Each names its script, merge.sh and tools/agent-review.sh alike, by its absolute path in the checkout sessions start in, which follows master, since merge.sh runs the merge-guard.sh beside it: a copy in a worktree, where an edit to either would decide, matches no rule and goes to the classifier. The skill now spells agent-review.sh by that absolute path too, so the maintainer's existing rules for it, which match the relative bash tools/agent-review.sh, no longer match and are replaced in his settings by rules on the absolute path. An edit made under that checkout's own mount is still run under the rule with no classifier, as its hooks run it.

Closes #45

@lneto lneto added complexity: medium Several call sites, a new test, or a core path to audit workflow-reviewed reviewed end to end by a review workflow labels Nov 27, 2026
@lneto

lneto commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Note

This comment was written by an LLM, not a human.

What #45 requires, as the review read the change meeting it:

  • Met: Update 7206781299: "tools/merge.sh <owner>/<repo> <N> <head> <file that holds the token> hands merge-guard.sh the merge it would run, gh api -X PUT repos/<owner>/<repo>/pulls/<N>/merge -f merge_method=rebase -f sha=<head>, and runs it only where the guard passes it" tools/merge.sh:22 builds that array. Lines 24-25 hand its text to checks/merge-guard.sh as a hook input and exit 1 when the guard refuses. Line 26 runs the same array. Case: merge-guard.cases: pass gh api -X PUT repos/luainkernel/lunatik/pulls/7/merge -f merge_method=rebase -f sha=0123... and block ... pulls/8/merge ... -f sha=... under # env: GH_TOKEN=cases. Neither can fail on the script's own || exit 1, which only the stub proof covers (left as an issue).
  • Met: Update 7206781299: "it merges what the guard admits, a harness pull request whose head a review passed or a proof names, and a bump of the mount" tools/merge.sh:26 runs the merge once the guard exits 0. The proof reaches the PUT for review.js: the reader's answer schema has no remarks field #7, checks: the path-taking checks a hook runs keep no cases #10, implement-issue: the repo a harness issue's run is launched with #13 and hooks: a session past 300k tokens writes its state to a file #14. Case: merge-guard.cases: pass ... pulls/7/merge -f merge_method=rebase -f sha=.... The bump and the proof cases are held in the guard's own spelling by lines 29, 33 and 35.
  • Met: Update 7206781299: "and nothing the guard refuses, since it never carries MERGE_OK=1" tools/merge.sh:17-18 hold $1..$3 to [A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+, digits and 40-hex, none of which can spell MERGE_OK=1. The environment's MERGE_OK never reaches the guard, which reads only the command (merge-guard.sh:32-34). Case: merge-guard.cases: block gh api -X PUT repos/luainkernel/lunatik/pulls/8/merge -f merge_method=rebase -f sha=.... The argument check has no committed case, only the proof (exit 2 for each argument that carries the marker), left as an issue.
  • Met: Update 7206781299: "The merged skill's sections 0 and 5 merge through it" .agents/skills/merged/SKILL.md:18 spells bash tools/merge.sh <owner>/<repo> <N> <head> <file that holds the token> where the gh api PUT stood. Section 5 (line 130) merges the bump "through tools/merge.sh" and reads the sha it prints (line 117). Case: None can fail: this is a skill's prose, which no command reads.
  • Met: Update 7206781299: ".agents/rules/checks.md describes it beside tools/agent-review.sh" .agents/rules/checks.md:280-288, the paragraph after agent-review.sh's. Case: None can fail: this is rule prose.
  • Met: Update 7206781299: "The maintainer's ~/.claude/settings.json takes narrow permissions.allow rules for it, Bash(bash tools/merge.sh *) and Bash(bash harness/tools/merge.sh *) ... the session writes the script under /tmp that adds them, and he runs it once" The diff writes no settings file (git diff --name-only shows none). The /tmp script that adds the rules is the session's to write, as the round states. Case: None can fail: the rules belong to the maintainer's untracked settings.
  • Differs: Update 7206781299: "the merge through it is exercised under auto mode in a session started by /clear before the pull request merges" Not in the diff. The round assigns it to the session after the maintainer adds the rules, and it is owed before this pull request merges. Case: None the tree can hold: only a session under auto mode sees the classifier's verdict.
  • Met: Issue merged: a merge on a proof is refused after a clear #45 contract: "One that tools/complexity.sh calls small merges on its CI and a proof instead" (AGENTS.md, Patches and commits), after a /clear A small pull request with a proof passes merge-guard.sh (gh_proved), and merge.sh runs that merge under its own allow rule, so no order of the maintainer's has to be in the conversation. Case: Proof: hooks: a session past 300k tokens writes its state to a file #14 reaches the PUT through merge.sh, and review-pr: a rebase or a split rereads only what moved #15 (no proof) and memory-guard: no case holds a Write of the index past 8192 bytes #16 (not small) do not. merge-guard.cases:35-37 hold the guard's verdict. The classifier side is the step above.

The matrix the change is held to:

Matrix for tools/merge.sh: operation by input by outcome.

Proved with the merge-guard fixture and a gh stub that records each PUT, on both d3fe260 and the final tip:

Committed coverage: merge-guard.cases now holds the guard to merge.sh's exact spelling with the token in the environment (pass #7, block #8), and both cases fail under mutation. The script's own steps, the argument check and || exit 1, have no committed case: cases.sh runs hooks only, and that gap is left as an issue.

What nothing on this host can see: the auto mode classifier's verdict on bash harness/tools/merge.sh ... under the maintainer's allow rule, in a session started by /clear. The Update makes that the session's step before the merge. A real GitHub merge was not run; only the stub answered.

The auto mode classifier refused the merge of luainkernel/lunatik#2744,
small, its CI passed and its proof posted, as "Destructive or Unwanted
Actions" in a session started by /clear and continue, and passed the
same command once the maintainer's words were in the conversation. A
merge on a proof sets no status before it runs, so nothing the session
does after a clear lets it through, and a small pull request waits on
him.

tools/merge.sh hands merge-guard.sh, as a hook input, the rebase merge
it runs, the head named, and runs it only where the guard exits 0, so a
narrow permissions.allow rule over it lets through what the guard
admits and nothing else: the command never carries MERGE_OK=1, which
the guard reads in the command alone, and the arguments are held to a
repository's name, a number and a full SHA. It reads the token from the
file it is handed, as tools/agent-review.sh does (#35), and prints
GitHub's answer, whose sha section 5 of the merged skill reads for the
status and the bumps. Sections 0 and 5 merge through it; a merge the
maintainer ordered in his own words keeps MERGE_OK=1 on the gh api call.
The merge-guard cases hold the guard to the command the script hands
it, the token in GH_TOKEN.

The rules go in the maintainer's own settings, not in a tracked file,
which would bind every session opened on the checkout, and each names
its script by the absolute path of the checkout sessions start in.
merge.sh runs the merge-guard.sh beside it, so a rule that matched the
relative `bash tools/merge.sh` in any directory would let a worktree
whose guard or script an edit changed decide a merge with no classifier;
the same holds of agent-review.sh, whose rules matched the relative
spelling since #35, and the skill now spells both from that checkout.
The rule runs that checkout's tree as it stands, as its hooks do, so an
edit under its mount still decides a merge with no classifier.

Closes #45

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lneto lneto changed the title merged: a script runs the merges merge-guard.sh admits merged: harness merges run through tools/merge.sh Nov 27, 2026
@lneto

lneto commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Note

This comment was written by an LLM, not a human.

Exercise of the absolute-path rule, the kind #48's merged skill relies on, in a session cleared after /tmp/merge-allow.sh put Bash(bash <checkout>/harness/tools/agent-review.sh *) in the allow list, <checkout> the absolute path of the checkout sessions start in, with no order of the maintainer in the conversation, run as a command of its own from the checkout's root:

$ bash <checkout>/harness/tools/agent-review.sh luainkernel/harness 46b1f308ebeb3f9e577d554e090b8dc9d3fe1f40 <token file>
agent-review: 46b1f308e: review.js: ready, wf_0f0f3584-3af at high

The classifier let it run. merge.sh is exercised on its first merge once the bump brings it to the start checkout.

@lneto
lneto merged commit 1a1d3e4 into master Nov 27, 2026
2 checks passed
lneto added a commit to luainkernel/lunatik that referenced this pull request Nov 27, 2026
The `harness/` mount moves to luainkernel/harness@1a1d3e4, which carries
luainkernel/harness#48: sections 0 and 5 of the merged skill merge a
harness pull request and a bump of the mount through tools/merge.sh,
which runs the rebase merge only where merge-guard.sh admits it, and
spell it and tools/agent-review.sh by the absolute path of the checkout
sessions start in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lneto added a commit to luainkernel/luaebpf that referenced this pull request Nov 27, 2026
The `harness/` mount moves to luainkernel/harness@1a1d3e4, which carries
luainkernel/harness#48: sections 0 and 5 of the merged skill merge a
harness pull request and a bump of the mount through tools/merge.sh,
which runs the rebase merge only where merge-guard.sh admits it, and
spell it and tools/agent-review.sh by the absolute path of the checkout
sessions start in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lneto

lneto commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Note

This comment was written by an LLM, not a human.

First run of tools/merge.sh under its rule, Bash(bash <checkout>/harness/tools/merge.sh *), once luainkernel/lunatik#2747 brought it to the start checkout, in the same cleared session, with no order of the maintainer in the conversation, as a command of its own:

$ bash <checkout>/harness/tools/merge.sh luainkernel/luaebpf 65 b11c76d8d368df475312100511725c796e8c3e3a <token file>
{"sha":"10b7743f306bab9025d26959890c047b1210b427","merged":true,"message":"Pull Request successfully merged"}

The classifier let it run, and merge-guard.sh admitted the bump on the commit it pins, 1a1d3e4, which carries the agent-review status of this pull request's review.

@lneto
lneto deleted the merge-script branch November 27, 2026 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

complexity: medium Several call sites, a new test, or a core path to audit workflow-reviewed reviewed end to end by a review workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

merged: a merge on a proof is refused after a clear

1 participant