Skip to content

[scanner] fix: make repo AGENTS.md outrank hive prompt conventions (InjectionText precedence, base-branch + PR-title deference) - #7171

Closed
hivecommons-hive[bot] wants to merge 1 commit into
v4from
scanner/fix-7159-agentsmd-precedence
Closed

hivecommons-hive[bot] wants to merge 1 commit into
v4from
scanner/fix-7159-agentsmd-precedence

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Fix

Cluster: src/pkg/agentsmd/agentsmd.go (InjectionText + injectionPrecedence), src/pkg/dashboard/contribute_ws.go (buildTaskPromptBodyForAccess base wording), and the PR-title sections of the policy templates under src/pkg/policies/defaults/ + their synced src/policies/ copies. Disjoint from open PRs #7147/#7150/#7152/#7155/#7157.

Agents followed hive's imperative prompt text over the target repo's own AGENTS.md and died on the repo's gates (bluefin base-branch gate, common/review conventional-title gates). Three changes:

  1. Precedence statement — the injected # Repository Agent Instructions (AGENTS.md) block now opens by stating that for repository-local conventions (PR base branch, PR title format, commit style, review workflow) the repo's rules OVERRIDE any conflicting hive instruction in the same prompt. One site covers every kick.
  2. Base-branch deference — both wordings in buildTaskPromptBodyForAccess now defer to a PR target branch named by the repo's AGENTS.md/CONTRIBUTING; defaultBranchRef resolution becomes the fallback. The load-bearing "do not use the branch you find" clause (🐛 bug: the contributor task prompt never names a base branch, so one branch-specific issue redirects every later PR in a session #5729) is kept, and a branch the task itself names (release lines) is not overridden.
  3. [lane] PR-title deference — each template with a hardcoded --title "[<lane>] fix: …" gains a note: house style only for repos with no title convention; the prefix is load-bearing for ISSUE routing (classify), never PR titles (intent.Classify never reads it). Kept rather than removed so behavior on hive's own repos is unchanged.

Tests: new precedence assertion in TestInjectionText; TestBuildTaskPrompt_FallbackWordingCarriesTheFullProcedure updated (placeholder now upstream/<base-branch> + AGENTS.md-deference assertion). go test ./pkg/agentsmd/ ./pkg/policies/ ./pkg/scheduler/ and the dashboard prompt tests pass; src/policies/ copies re-synced as the policies embed-equality test requires.

Closes #7159


Filed by scanner agent (ACMM L5 — hold-gated mode). Hold-gated: human review required.

— hive: agent=scanner backend=copilot model=claude-fable-5

Hive agents opened PRs that died on other repos' gates — wrong base branch
on repos using a promotion model, [lane]-prefixed titles on repos enforcing
Conventional Commits — because the repo's AGENTS.md arrived in the kick as
undifferentiated prose while hive's conflicting instructions carried
imperatives and self-check steps. Nothing said which wins, so agents
followed hive.

Three changes:

- agentsmd.InjectionText now opens the injected block with an explicit
  precedence statement: for repository-local conventions (PR base branch,
  title format, commit style, review workflow) the repo's own rules
  override any conflicting hive instruction in the same prompt.
- Both base-branch wordings in buildTaskPromptBodyForAccess defer to the
  branch the repository's AGENTS.md/CONTRIBUTING names as the PR target;
  the default-branch resolution becomes the fallback for repos that state
  no rule. The 'do not use the branch you find' clause is kept, and an
  explicitly task-named branch (release lines) is not overridden.
- Every policy template with a hardcoded '[<lane>] fix:' PR title gains a
  deference note: hive's house style applies only when the target repo has
  no title convention; the [lane] prefix is load-bearing for ISSUE routing
  (classify), never for PR titles. src/policies/ copies kept in sync with
  the embedded defaults, as the policies tests require.

Fixes #7159

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Sep 16, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign danathar for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 16, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 16, 2026
@clubanderson

Copy link
Copy Markdown
Member

Closing as superseded: #7162 (merged) implements the same AGENTS.md-precedence fix for #7159 — precedence statement with safety carve-outs, plus policy templates/docs no longer asserting repo-only facts. This branch is needs-rebase against that merge. The finding was correct — thanks.

@hivecommons-hive
hivecommons-hive Bot deleted the scanner/fix-7159-agentsmd-precedence branch September 16, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. hold needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 bug: hive's built-in prompts outrank a repository's own AGENTS.md, so repo rules lose every conflict

1 participant