Repository navigation
✨ feat(config): stage bounded human-merge pin-only policy and classifier - #16300
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
Implement the shared foundation from #16262 for #16242 without loosening any merge admission gate. Carry complete patch evidence, reject unsupported or mixed diffs, and make the remaining trust, review and exact-head obligations explicit. Hive-Run: #16242 Hive-Plan: ordered-children/16262-config-and-classifier Hive-Spec: issue-16242#required-behavior Co-authored-by: hanthor <5840441+hanthor@users.noreply.github.com> Signed-off-by: mendezr <mendezr@users.noreply.github.com>
Signed-off-by: mendezr <mendezr@users.noreply.github.com>
…parity The settings parity test treats every new hive.yaml leaf as a Settings UI gap unless it is allowlisted; the pin-only policy is yaml-only. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
2b90d73 to
7e34ea8
Compare
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. hive/awaiting-ci: branch synced with v5 (picks up the 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. Review findings from Style review (read at head No in-scope blocker against #16262; the schema, accessor, validation,
Review findings from docs-currency review (head Docs match the code: the grammar, fail-closed cases and validation rules described in One advisory (low):
Review findings from Summary: the pin-only classifier and config schema look correct to me and are not wired into any merge decision (verified: Ratchet annotation — should be dropped from this PR (medium)
If the hive does want the forge plumbing out of the ratchet, that is a separate decision for the writeback owner and belongs in its own PR with the gate actually consulted at What I checked and found correct
Docs in Review findings from Read the PR head against What I verified in the tree, not the diff:
One note for the record, not a defect: the body says the branch is #16297's head |
There was a problem hiding this comment.
Code looks correct to me and matches the scope #16262 sets (schema + pure classifier, no gate wiring). Two non-code items need fixing before merge: the body would close the parent tracker early, and this will conflict with #16293.
What I verified:
src/pkg/intent/pin_only.go:34-73—ClassifyPinOnlyrequires every changed file to be in both the human-mergematchesandspec.Paths, statusmodified, non-empty patch, and requires every match to appear infiles; so a PR touching any unguarded file fails closed.classifyPinPatch(76-153) walks hunk headers with explicit old/new counters, rejects\ No newlineand any other non-[ +-]line, and cross-checks additions/deletions against the API counts.pinReplacement(155-203) requires an identical prefix (uses: owner/repo@,FROM image@sha256:,version:), a changed reference, and a byte-identical suffix except the action# vNcomment; quote changes onversion-pinare rejected. I did not find a way to get a non-pin line through it.ClassifyPinOnlyandHumanMergePinOnlyhave no non-test callers outsideconfig/validate.go:203— so "not yet enforced" inhive-merge.mdis accurate.src/pkg/github/human_merge_paths.goonly gainsPatch: f.GetPatch();intent.go/alignment.gokeepDiffFileSummaryfree of the patch body.
Items:
- Body closes the tracker prematurely. The body has both
Closes #16242andRefs #16242. #16242 is the parent whose other children (#16265 relay admission, #16266 sweep admission, #16269 attribution) are still open per this PR's ownhive-merge.mdtext. On merge GitHub will close #16242. It should readRefs #16242 (relay/sweep admission and attribution still open)and keep onlyCloses #16262. - Conflicts with #16293.
git merge-tree pr16300 pr16293→CONFLICT (content): Merge conflict in src/docs/hive-merge.md. Both insert a new section after line 154 (this PR: "Staged pin-only policy"; #16293: "Pin-only exception rollout"). They are complementary, not duplicate — whichever lands second needs a rebase, and ideally the two sections become one.operator-reference/README.mdandhuman_merge_paths.goauto-merge cleanly.
I have not changed or closed anything.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
…rite-site inventory) Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Read head 52953ce (the v5 merge-in). Two things, one new from the merge, one carried over.
New (low, docs): the merge left clientStatusForge.CreateComment listed twice in the write-site inventory table. v5 222fc9c (#16310) already added the row at src/docs/notifications.md:417; this branch's own row survived the conflict resolution at src/docs/notifications.md:428 with different wording ("under prstatus.Write; attributed to the UpsertPRStatusSection caller"). Nothing checks the table against notificationWriteSites (notification_write_sites_test.go only asserts the Go map, line 112), so CI will not catch it. Drop one — the branch's wording is the more specific of the two, so keeping 428 and deleting 417 is fine.
Carried over (medium): the blank-context-line rejection is unchanged. src/pkg/intent/pin_only.go:117 still reads if hunks == 0 || line == "" { return fmt.Errorf("invalid patch line %d", i+1) }, so a GitHub patch whose hunk context includes an empty line — the common case in .github/workflows/*.yml and Containerfiles — fails closed as invalid patch line N. The mechanism and suggested fix are in the review at 33a09b7; nothing in this head touches that function.
Verified and fine: direct-writes-baseline.txt:18 lowering automerge_stage_labels.go 5→2 matches the three // writeback:gated markers added in automerge_stage_labels.go; the ratchet only logs (never fails) when a file is under its baseline (ratchet_test.go:170-182), so leaving pr_status_comment.go at 2/2 after gating its three calls is loose but not red.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
GitHub's compare API renders empty context lines as "" rather than " ", so classifyPinPatch failed closed on most workflow/Containerfile pin bumps that had a blank line inside the hunk. Treat an empty line after a hunk header as a context line; a blank line before any hunk is still rejected. Also drop the duplicate clientStatusForge.CreateComment row left in docs/notifications.md by the v5 merge. Hive-Fix-Attempt: 5/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Correctness delta re-review @ baaf10d — both prior findings are fixed:
src/pkg/intent/pin_only.go:117-124— blank context lines are now normalised to" "after thehunks == 0guard, so a leading blank line before any hunk is still rejected. Covered by the newblank context lines/blank line before hunkcases inpin_only_test.go:20-23. CI test shards are green at this head.src/docs/notifications.md— the duplicateclientStatusForge.CreateCommentrow is gone; one row remains at line 417.
Advisory (non-blocking, fail-closed): pin_only.go:91 does strings.TrimSuffix(file.Patch, "\n") before splitting. If a GitHub patch ends with a blank context line (rendered as a trailing "\n"), that line is dropped, oldLeft/newLeft stay at 1, and the patch is rejected as "incomplete" — i.e. such a pin-only PR falls back to the human path rather than being misclassified as safe. Worth a follow-up test if that shape appears in practice.
— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Conclusion: the pin-only schema and classifier look correct to me and fail closed as documented. One thing should come out before merge: the writeback:gated annotations in commits 33a09b7/d4761a6 lower the direct-write ratchet baseline without any gate actually being consulted.
Finding (medium): six write sites are marked // writeback:gated but nothing on their path calls writeback.Gate.Allowed.
src/pkg/github/automerge/automerge_stage_labels.go:1530,1537,1541(engineStatusForge.EditComment/CreateComment/DeleteComment) andsrc/pkg/github/pr_status_comment.go:62,70,74(clientStatusForge.*) gained the marker.- The marker's meaning, per
src/pkg/writeback/ratchet_test.go:15-24,85-88, is "migrated to the gate": a call that consultswriteback.Gate.Allowedbefore writing. The existing uses follow that contract — e.g.automerge_adoption_close_first.go:162checksc.writebackAllowed(...)and the raw calls at:166-173carry the marker. - Here the only entry points are
postStageNote(automerge_stage_labels.go:1477-1485) andUpsertPRStatusSection; neither consults the gate, andpkg/prstatushas no reference toGate/Allowedat all. The new doc comment (:1501-1505) says "the write-back decision … is made (and ratcheted) at that entry point", butpostStageNotein non-quiet mode is itself an unannotated rawIssues.CreateComment, so no decision is made anywhere. - Consequence:
testdata/direct-writes-baseline.txt:18dropsautomerge_stage_labels.gofrom 5 → 2 andpr_status_comment.gofalls below its baseline silently. The ratchet forbids raising a line, so these six un-gated writes leave its visibility permanently and a future real migration has nothing to ratchet against.
The pin-only feature does not need this: on v5 the baseline already says 5 and 2 for these files and the PR adds no write calls, so the ratchet passes with the v5 baseline untouched. Suggest dropping the six markers, the two forge doc-comment paragraphs, and restoring direct-writes-baseline.txt to the v5 line. (If the intent was to fold these writes into the gate, that is a separate change that adds the Allowed check.)
What I verified on the pin-only change itself (src/pkg/intent/pin_only.go, src/pkg/config/automerge_pin_only.go):
ClassifyPinOnlyrequires every changed file to be in both the human-merge matches and the spec paths, and every guarded match to appear in the file list (pin_only.go:56-70), so a mixed PR or a truncated file list fails closed.classifyPinPatchcross-checks hunk counts and the API's additions/deletions against the parsed patch (:164), rejects\ No newlinemetadata (:155), and requires removed/added lines to pair positionally.ValidateHumanMergePinOnlyis wired intoValidateWithOptions(validate.go:203);HumanMergePinOnlyForrefuses case-ambiguous keys and disabled/invalid entries.- Nothing calls
ClassifyPinOnlyorHumanMergePinOnlyForoutside tests yet — consistent with the body andhive-merge.mdsaying this stages policy without enabling an exception.go build ./pkg/intent/ ./pkg/config/ ./pkg/github/...is clean atbaaf10d;pkg/configalready importedpkg/intenton v5 (intent_defaults.go), so no new import edge. boundedFiles/allFileswere changed from a struct conversion to an explicit projection becauseChangedFilegainedPatch;DiffFileSummarykeeps its four fields, so alignment prompts don't grow.
I have not closed or approved anything.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
CI triage — Job 125663227747 fails in the Go build stage of the image with repeated — a module-proxy download hiccup during 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
…baseline cut Revert the status-comment forge annotations in automerge_stage_labels.go and pr_status_comment.go, and the direct-writes-baseline.txt reduction (automerge_stage_labels.go 5->2), to their v5 state. The annotated EditComment/CreateComment/DeleteComment calls are not actually routed through writeback.Gate.Allowed (prstatus.Write and writeStatusSection never consult it, and only one of four postStageNote callers checks writebackAllowed), so marking them gated would let un-gated writes leave the ratchet permanently. v5 already baselines these files at their current counts, so the change was unnecessary for CI and unrelated to the pin-only policy work in this PR. Hive-Fix-Attempt: 6/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Read the full diff at 230e529 with one question in mind: does anything here change what the hive will merge? It does not, and that is the main thing a maintainer needs to know about an XL PR under auto_merge.
ClassifyPinOnly(src/pkg/intent/pin_only.go:526) andHumanMergePinOnlyFor(src/pkg/config/automerge_pin_only.go:157) have no non-test callers in this diff; the only production wiring isValidateHumanMergePinOnlyinvalidate.go:203, which can only reject a config, never grant anything.hive-merge.mdsays the same ("Staged pin-only policy (not yet enforced)") and names the integration children (#16265, #16266).- The classifier fails closed on every path I traced: unknown kind, non-
modifiedstatus, empty patch, hunk-count or API-count mismatch, interleaved-/+, any line outside the three pin grammars, andunsafePinREon either side (pin_only.go:544-560,classifyPinPatch). Also checks all files in the PR, not just guarded ones, so a mixed PR cannot qualify. ListPRChangedFilesnow carriesPatch(human_merge_paths.go:56).alignment.go:277-280,288-291was changed from a struct conversion to a field copy soPatchstays out ofDiffFileSummary— good, the per-file patch does not reach the intent prompt.- Config accessor returns copies;
TestHumanMergePinOnlyConfigproves mutation does not leak back.
Info only (fail-closed, not a safety gap): unsafePinRE uses \benv\b, so an action or image whose name contains env as a hyphen-separated token (e.g. uses: org/env-setup@<sha>) can never classify as pin-only. Fine for a conservative first cut; worth knowing when #16265 wires it in and operators ask why such a bump was held.
Looks correct to me as staged, unenforced schema.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the diff against merge-base 6355040 plus the callers of intent.ChangedFile and ListPRChangedFiles. Looks correct to me, and it matches the scope #16262 set (schema + accessor + validation, Patch on changed files, pure classifier, docs marked "not yet enforced").
What I verified:
src/pkg/config/automerge_pin_only.go:70-90—HumanMergePinOnlyForfails closed on case-insensitive duplicate keys, disabled policy, or invalid policy, and returns copies of the slices.validate()rejects unknown kinds even when disabled and requires nonemptypaths/kinds/trusted_authorswhen enabled — exactly the issue's rules. Wired intoValidateWithOptionsatvalidate.go:206.src/pkg/intent/pin_only.go:34-73— the classifier checks every file in the PR (not only guarded matches), requires each to be both a human-merge match and inspec.Paths,modified, with a non-empty patch; and then requires every guarded match to have appeared. Mixed PRs and truncated file lists are rejected.pin_only.go:75-147— hunk accounting tracks old/new remaining counts and cross-checksadditions/deletionsagainst the API counts, so a truncated or\ No newlinepatch fails closed. Blank context lines (""from the files API) are handled at line 117.pin_only.go:149-207—unsafePinREis applied to both old and new lines before any kind match; prefix (a[1]) must be identical and onlyaction-shamay vary its trailing# vXcomment;version-pinrefuses quote-style changes.src/pkg/intent/alignment.go:277-291—DiffFileSummaryis now projected field-by-field, so the newPatchdoes not leak into alignment summaries / prompts. The other[]intent.ChangedFileconsumers (automerge_contributor_lane.go:1185,automerge_contributor_held_runs.go:51,cmd/hive/intent_verdicts.go:210) only read filenames/status.- No
config↔intentimport cycle (intentdoes not importconfig); CI build, tests, coverage and patch-coverage are all green atc8d9cb9.
Nothing is wired into a merge gate here, as the issue intended; a reviewer of the follow-up children should make sure trusted_authors is checked against authenticated login, not the PR body, since ClassifyPinOnly deliberately proves syntax only.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Supersedes #16297 (adopted after CI went red and the contributor was unavailable; original commits by @mendezr preserved).
Closes #16262
Refs #16242
This branch is #16297's head
2b90d73dacdeas pushed by @mendezr (forkmendezr/hive), unchanged. Last lane reason on the original:required-check-failing:coverage.Hive fix agent: rebase this branch on
v5, fix the failing checks / review asks, and push to THIS branch. Keep the original author's commits and theirSigned-off-by; add your own sign-off on your commits. Do not open another PR.