Skip to content

✨ Sandboxed fix kicks push to the agent's own PR; sandbox PRs are credited to their agent - #18587

Merged
kubestellar-prow[bot] merged 3 commits into
v5from
feat/18574-sandbox-existing-pr
Nov 17, 2026
Merged

kubestellar-prow[bot] merged 3 commits into
v5from
feat/18574-sandbox-existing-pr

Conversation

@clubanderson

Copy link
Copy Markdown
Member

What

#18575: credit sandbox-opened PRs to their agent. The sandbox executor opened its PR through plain CreatePR, so the PR carried no agent credit. The governor's per-agent signals (FIX-BEFORE-NEW, red-CI kick, review threads, held PRs) read the agent_pr_created audit entry, found none, and defaulted to scanner. The head-ref fallback made it worse: it credited hive/<agent>/<stamp> to an agent named hive.

  • New optional seam crux.AgentPRCreator. github.Client.CreateAgentPR runs the same credit steps as the pr-request watcher: the attribution trailer (when on), PR-opened hooks, and agent_pr_created (with via=sandbox).
  • When the PR client can't record the entry itself (the sidecar callback adapter), the manager emits the same agent_pr_created entry through the sandbox audit callback. That entry is never written twice.
  • prFixAgent's branch fallback now reads hive/<agent>/<stamp> through sandbox.WorkBranchAgentSlug.

#18574: sandboxed fix kicks push to an existing PR.

  • SandboxKickSpec.TargetPR is resolved from hive-written kick lines, in this order: an explicit [hive:target-pr <repo>#<n>] first line, the red-PR kick header, the red-CI webhook kick header, the first FIX-BEFORE-NEW row (adopted rows skipped), or a single topic claim. It is set only for kicks that may push, through a client that implements crux.PRPushTargetReader.
  • Workspace prep reads the PR and refuses it unless it is open, not a fork (head in the same repo), and credited to this agent. It then fetches and checks out the head branch, refuses a head that moved between the read and the fetch, and prepends a [hive:sandbox-target-pr] prompt section.
  • Before the push, the executor reads the PR again: same checks, same head branch, same head SHA. The broker gets LeaseSHA: commits must descend from it, the scans cover only the kick's commits, and the push carries --force-with-lease=refs/heads/<head>:<sha>. No new PR is opened.
  • Every refusal wraps ErrSandboxTargetPRRefused, writes a sandbox_target_pr_refused audit line, and pushes nothing.

Tests

  • crux/agent: success (lease and branch in the push, no new PR, prompt section); refusals for a moved head, a fork, another agent's PR, a non-hive PR, a closed PR, a bad ref, a wrong number, a fetch race, a renamed head, a PR closed during the run, a read error and no reader; scan failure; run-stage refusal; parser table; manager resolution, refusal audit, fallback credit, and no double credit.
  • crux/pushbroker: leased push, a lease that is not an ancestor (refused), a malformed lease, and a lease rejection.
  • pkg/github: CreateAgentPR trailer, audit and hooks; trailer off; errors; PRPushTarget (own PR, fork, App trailer fallback, a stranger's trailer ignored).
  • pkg/scheduler: regression test. A sandbox-opened PR, credited through RecordAgentPROpened, resolves to its agent and appears in that agent's FIX-BEFORE-NEW block, not scanner's.
  • cmd/hive: prFixAgent reads the work branch, and auditPRAgents reads the fallback credit line.

Docs: src/docs/sandbox-isolation.md. Changelog: changelog.d/added-18574-sandbox-existing-pr.md.

Fixes #18574
Fixes #18575

cc @joerunde

🤖 Generated with Claude Code

A sandboxed fix kick that names one of the agent's open PRs (explicit
[hive:target-pr] line, red-PR or red-CI kick header, first FIX-BEFORE-NEW
row, or a single topic claim) now checks out that PR's head branch and the
push broker adds the kick's commits to it. The push needs the PR open,
same-repo, credited to this agent by its agent_pr_created record, still at
the checked-out head (re-read before the push and --force-with-lease in the
push), and the usual broker scans to pass; otherwise the kick fails with the
reason and nothing is pushed.

A PR a sandboxed kick opens is credited like a relay-opened PR: attribution
trailer, agent_pr_created audit entry and PR-opened hooks through
github.Client.CreateAgentPR, or a runtime-emitted agent_pr_created entry
when the PR client cannot record it. The governor's head-ref fallback reads
the agent out of hive/<agent>/<stamp> work branches.

Fixes #18574
Fixes #18575

Signed-off-by: Andy Anderson <andy@clubanderson.com>
@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

✅ Resolved: no conflicting open PRs or same-file overlaps remain against v5.

pushbroker.go passed the crux 800-line limit with the lease support.

Signed-off-by: Andy Anderson <andy@clubanderson.com>
@github-actions

Copy link
Copy Markdown
Contributor

Mutation testing

❌ gremlins did not produce a report for 2 package(s), so no verdict can be derived from this run (see the job log):

  • crux: gremlins exited 1
  • pkg/github: gremlins exited 137

Verdict: error (#17349).

@clubanderson clubanderson added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 17, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

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

The pull request process is described 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 removed the lgtm Indicates that a PR is ready to be merged. label Nov 17, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@clubanderson clubanderson added the lgtm Indicates that a PR is ready to be merged. label Nov 17, 2026
@kubestellar-prow
kubestellar-prow Bot merged commit 8f232c7 into v5 Nov 17, 2026
97 of 99 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the feat/18574-sandbox-existing-pr branch November 17, 2026 03:03
joerunde pushed a commit to joerunde/spyre-inference that referenced this pull request Nov 17, 2026
Checks in the hive `deps` agent's prompt, definition and dependency
targets under `.hive/`, where hive's repo agent discovery looks for
them. The flow is unchanged: bump one dependency group, compile it, open
an issue if that fails, open one PR on success, fix our side when CI is
red, file dependency bugs upstream, recommend a refresh only when a
newer release may fix the bug, never run the test suite and never wait
for CI.

Hive features this now uses, all merged in hive v5:

- `hive-topic claim` from the sandbox, so each group keeps its one-PR
claim (hivecommons/hive#18586).
- `hive-open-issue` from the sandbox for dependency bugs (on
torch-spyre) and compile failures (here). This replaces the `known_bad`
ledger PR. `known_bad` stays in `targets.yaml` as a cap maintainers can
set by hand (hivecommons/hive#18586).
- Fix kicks on the agent's own red bump PR commit on top of it, and
sandbox PRs are credited to `deps`, so red CI kicks `deps` and not
`scanner` (hivecommons/hive#18587). PRs opened before that fix still get
the fix as a patch in the report.
- `${NEW_RELEASES}` from the release-feed watcher
(hivecommons/hive#18507).
- `.hive/agents/` discovery (hivecommons/hive#18505).

Files:

- `.hive/agents/deps.md`: the kick template (`prompt_source`).
- `.hive/agents/deps.yaml`: optional presentation-only definition.
- `.hive/deps/targets.yaml`: dependency groups. Only `deps-torch-spyre`
is enabled.
- `.gitignore`: keeps hive's per-run scratch under `.hive/` ignored and
tracks only `.hive/agents/` and `.hive/deps/`.

This overlaps torch-spyre#1626, which puts the prompt at
`.github/hive/prompts/deps.md` and ignores all of `.hive/`. Its prompt
content is merged into `.hive/agents/deps.md` here. If this lands first,
torch-spyre#1626 can drop its prompt and `.gitignore` hunks.

## Setup after merge (hive owner)

1. **Approve the prompt source.** Settings, Security, Prompt sources. On
the `torch-spyre/spyre-inference` row, click **Approve…** and confirm.
Leave `allow_github_prompt` and `github_prompt_allowlist` alone.
2. **Point the agent at the prompt.** Agents, `deps`, General tab,
**Prompt from GitHub repo**: Owner `torch-spyre`, Repo
`spyre-inference`, File path `.hive/agents/deps.md`, Ref `main`. Save.
Keep the current kick template as the cold-start fallback, and replace
its text with this file so the fallback runs the same flow.
3. **Variables tab** (static, template scope):
- `DEPS_LOCAL_CHECK`: `uv sync --frozen --inexact && uv run --no-sync
python -c 'import torch_spyre, spyre_inference;
print(torch_spyre.__version__)'`
   - `DEPS_MAX_REFRESHES`: `2`
   - `DEPS_UPSTREAM_REPO`: `torch-spyre/torch-spyre`
4. **Cadences tab.** idle, quiet and busy `24h`, surge `pause`.
5. **Optional, release-feed kicks** (YAML only, no Settings control
yet): `governor.release_feeds.agents.deps.sources: [{kind: github_tag,
repo: torch-spyre/torch-spyre}]`, with `cooldown_s: 21600`. Keep the
daily cadence for CI follow-up.
6. **Import tab.** `deps.yaml` will show under "Declared in your repos".
Leave it pending or reject it, because approving it would create a
second `deps` agent.
7. Unpause `deps`.

cc @joerunde

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Andy Anderson <andy@clubanderson.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has signed the DCO. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

1 participant