Repository navigation
🐛 [v6] contribute-hive: forward HIVE_AGENT_ROLE and the quota-guard switches into the contributor container - #17226
Conversation
…iner
The /contribute landing page and contributor-relay.md tell contributors to
`export HIVE_AGENT_ROLE=scanner` before `just contribute-hive`, and the relay
sends that value as auth_response.role. But the default container launch
passes an explicit -e list that did not include HIVE_AGENT_ROLE, and
contributor-agent.sh sources contributor.env without exporting it, so in
container and krun mode the relay always connected with no role and a
contributor-first lane was never covered.
Forward it with ${HIVE_AGENT_ROLE:+-e ...} next to AGENT_MODEL. The recipe
sources contributor.env under set -a, so a value set there is forwarded too.
krun uses the same run command. Local mode already inherits the environment.
The hub still checks the role (roleClaimAllowed).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
[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 |
0b6ed29
ℹ️ Sentinel notice — informational; author is trusted (owner), merge is not blockedHive flagged this PR (author @Danathar, head
Hive did not add the |
|
@Danathar this PR is back in your court ( Failing checks:
Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path. Your relay could not take this as a |
Review follow-ups (below
|
|
Deferring to shared CI incident #17228: 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
Shared CI incident: the red 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Read the recipe, contributor-agent.sh, the relay and the test harness at v6 tip; the fix does what it says and looks correct to me.
What I verified:
Justfile:1003-1006— the recipe sourcescontributor.envunderset -a/set +a, so aHIVE_AGENT_ROLE=line there is exported in the recipe shell and${HIVE_AGENT_ROLE:+-e …}(new line atJustfile:2318) sees it. That is why thecontributor.env-only test case can pass without touching the agent script.bin/contributor-agent.sh:36—source "$CONFIG_FILE"with noset -aanywhere in the script, so inside the container acontributor.envvalue is not exported to child processes; the-eon theruncommand really is the only path for the role to reach the relay.bin/contributor-relay.js:125—AGENT_ROLE = (process.env.HIVE_AGENT_ROLE || '').trim(), sent at:9590. The relay reads exactly the variable now forwarded.src/pkg/dashboard/contribute_agent_roles.go:62—roleClaimAllowedstill gates the claim hub-side, so forwarding a client-supplied role adds no trust surface.- Test harness:
run_recipeappliesenv "${ENV_UNSET[@]}"(test_contributor_container_resources.sh:228) before the trailingVAR=valueargs, and the PR adds-u HIVE_AGENT_ROLEto that list, so the "no role → no argument" case is hermetic rather than dependent on the CI runner's environment. - The
${VAR:+…}form matches the adjacentAGENT_MODEL/AGENT_REASONING_EFFORTlines; an unset or empty role leaves the argv unchanged, consistent with the golden files.
CI note for the maintainer: the red test (rest 3/4) / coverage / test checks come from pkg/github TestCloseOnMergeLedgerSweepSettledClaimsSkipAPI, which this PR (Justfile, a shell test, docs, changelog — no Go) cannot have affected; that failure is unrelated to this change.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Read against the v6 tree, not just the diff. The fix is correct and minimal; looks correct to me. What I verified
CI
Review findings from Read the diff against the Verified
CI: the red One trade-off worth a sentence in the diff (low, not blocking)
|
…tor container When the quota guard holds work, the relay tells the operator to set HIVE_CONTRIBUTOR_QUOTA_GUARD=off at launch, or to run `just contribute-quota continue-once` (and the other scoped controls) against HIVE_CONTRIBUTOR_QUOTA_POOL_DIR. In container and krun mode neither did anything: the recipe's -e list carried neither variable, and contributor-agent.sh sources contributor.env without exporting it. - Forward HIVE_CONTRIBUTOR_QUOTA_GUARD like HIVE_AGENT_ROLE. - Mount HIVE_CONTRIBUTOR_QUOTA_POOL_DIR (created, made absolute) at /home/dev/.hive-quota-pool and point the relay there. Podman and krun use the shared :z label, since the pool is shared by every relay on the account. HIVE_CONTRIBUTOR_QUOTA_POOL_ACCOUNT, part of the pool key, is passed by name. - contributor-agent.sh keeps the -e mount path when contributor.env names the host path. - contribute-quota sources contributor.env under set -a. A plain source never exported the pool dir or AGENT_BACKEND to node, so the control either refused or wrote under the empty-backend pool key. Also corrects a stale contributor-agent.sh line citation in agent-host-confinement.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com>
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. |
There was a problem hiding this comment.
Looks correct to me. Read the v6 tree alongside the diff:
- The red checks are not this PR.
test (rest 3/4)fails inclose_on_merge_ledger_sweep_test.go:188(TestCloseOnMergeLedgerSweepSettledClaimsSkipAPI, "want 3 settled skips"), the wall-clock retention bug that #17230 fixed onv6after this branch was cut;coverageandtestare the aggregates of that same shard. A rebase onto currentv6should go green — nothing in this diff touchespkg/github. - contributor.env-only values do reach the recipe.
Justfile:1003-1005doesset -a; source contributor.env, so the new${HIVE_AGENT_ROLE:+-e …}/${HIVE_CONTRIBUTOR_QUOTA_GUARD:+-e …}expansions see a value set only in the file, which is what the "role set only in contributor.env is forwarded" case asserts. - krun gets the podman branch.
Justfile:1698setsRUNTIME=podmanin krun mode and:1748-1755keysVOLSUF=":Z"off the same variable, so[[ "$RUNTIME" == "podman" ]] → :zcovers krun exactly as the test expects. Using the sharedzlabel for a directory several relays are meant to share (rather than the privateZthe other mounts use) is the right call. - Mount path matches the image. Other mounts already target
/home/dev/...(Justfile:2304-2314), andbin/contributor-relay.js:572,630/bin/contributor-quota-control.js:44readHIVE_CONTRIBUTOR_QUOTA_GUARD/HIVE_CONTRIBUTOR_QUOTA_POOL_DIRstraight fromprocess.env, so the-eoverride is what the relay actually consumes. - Entry-point override is consistent.
bin/contributor-agent.shcaptures the-evalue beforesource "$CONFIG_FILE"and re-exports it after, mirroring the existing_DOCKER_BACKEND/_DOCKER_MAX_PARALLEL_FIXESpattern at:29-31; theHIVE_CONTRIBUTOR_AGENT_TEST_QUOTA_POOL_DIRhook follows the shape of the existing_TEST_RELOCATE_HUB/_TEST_RESOLVE_BACKENDhooks (:60,:170). agent-host-confinement.mdcitation624-641:tmux new-sessionis at:627on base and the diff adds 14 lines above it, so the bump is right (and the citation guard is green).
Two changelog fragments, each a single - bullet, cover both user-visible changes. The body's claims match the diff.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
… test clock fix) Signed-off-by: Danathar <Danathar@users.noreply.github.com>
Summary
Three settings that contributors are told to set before
just contribute-hivedid nothing in the default container mode or in krun mode, because they never reached the relay inside the container:HIVE_AGENT_ROLE, the spoke-agent lane the relay asks for. The relay connected with no role, so a contributor-first lane was never covered.HIVE_CONTRIBUTOR_QUOTA_GUARD. The guard's hold banner says "Set HIVE_CONTRIBUTOR_QUOTA_GUARD=off at launch to opt out", and that did nothing.HIVE_CONTRIBUTOR_QUOTA_POOL_DIR. The banner'sjust contribute-quota continue-onceand the other scoped controls need it, and they did nothing either.This PR passes all three into the container. The pool directory is mounted, not just named, so the host's
just contribute-quotaand the relay in the container really share it. In the pilot, the only thing that worked was addingexport ...=offlines tocontributor.envby hand.What went wrong
contribute-hivein container mode starts the container with an explicit list of-evariables. None of the three were on it.PROVIDER_ENV_ARGSonly carries provider credentials.bin/contributor-agent.shsourcescontributor.envwithoutset -a, so a plainNAME=valueline there was not exported to the relay either.contributor.envunderset -aand starts the relay as a child process, so the relay inherits them.For the role: the landing page (
contribute_landing.go) andsrc/docs/contributor-relay.md("Acting as a spoke agent role") both say to exportHIVE_AGENT_ROLE. The relay reads it and sends it asauth_response.role.The quota guard
Two things were broken on top of the missing
-eentries:just contribute-quota …runs on the host and writes an override file intoHIVE_CONTRIBUTOR_QUOTA_POOL_DIR. The relay reads overrides from its ownHIVE_CONTRIBUTOR_QUOTA_POOL_DIR. Passing the host path into the container would point the relay at a directory that does not exist in there.just contribute-quotadroppedcontributor.env. It sources the file withoutset -a, so thenodecontrol never saw a pool dir set there (it refused: "HIVE_CONTRIBUTOR_QUOTA_POOL_DIR is not set"). It also never sawAGENT_BACKEND, which is part of the pool key. With the pool dir exported in the shell, it wrote under the empty-backend key (6e340b9c…) while a codex relay readsd6316145…, so the override was silently ignored.Choice: mount the directory (option a), not just a banner warning (option b). The change is small and uses the existing mount pattern, and without it the banner sends container users to a command that cannot work. What the recipe does now:
HIVE_CONTRIBUTOR_QUOTA_POOL_DIRis set, it creates the directory, resolves it to an absolute path (docker would treat a relative one as a named volume), mounts it at/home/dev/.hive-quota-pool, and passes that path to the relay with-e. The in-container quota publisher reads the same variable, so it writes its reading where the relay looks.:zSELinux label rather than the private:Zthe other mounts use. The pool is meant to be shared by every relay on the account, and a second container's:Zrelabel would lock the first container out.HIVE_CONTRIBUTOR_QUOTA_POOL_ACCOUNTis also part of the pool key, so it is forwarded too. It is passed by name only (-e NAME), so the account value stays out of the runtime argv, the same way provider keys are passed.contributor-agent.shkeeps the-emount path whencontributor.envnames the host path. This uses the same "docker -e wins over contributor.env" pattern the script already uses forAGENT_BACKEND.contribute-quotanow sourcescontributor.envunderset -a, so it sees the same pool dir, account and backend as the relay.HIVE_CONTRIBUTOR_QUOTA_GUARDis forwarded with the same${VAR:+-e VAR=…}pattern as the role.Nothing changes when these variables are unset: the launch command is byte for byte the same, and the golden argv checks still match.
One limit, documented in
contributor-relay.md: the pool key includes the backend. If you launch with a backend argument that differs fromAGENT_BACKENDincontributor.env, run the controls asAGENT_BACKEND=<backend> just contribute-quota ….What changes
Justfile,contribute-hive: forwardsHIVE_AGENT_ROLEandHIVE_CONTRIBUTOR_QUOTA_GUARD, and adds the pool-dir mount and its-earguments. krun mode uses the sameruncommand, so it is covered. The only otherrunis the krun preflight smoke container, which never starts the relay.Justfile,contribute-quota: sourcescontributor.envunderset -a.bin/contributor-agent.sh: the-epool dir wins overcontributor.env. Adds a test hook that prints the result and exits before anything starts, like the existing hub-relocation hook.roleClaimAllowed).Files
Justfile: the container launch andcontribute-quota, with comments explaining why.bin/contributor-agent.sh,bin/contributor-agent.test.sh: pool-dir precedence and its test.src/deploy/test_contributor_container_resources.sh: the new names in the unset list, plus two new test sections.src/docs/contributor-relay.md: role and quota-guard notes for container and krun mode.src/docs/design/agent-host-confinement.md: corrects a stalecontributor-agent.shline citation.changelog.d/fixed-agent-role-container.md,changelog.d/fixed-quota-guard-container.md: changelog entries.Tests
test_contributor_container_resources.shdrives the real recipe against the stub runtime.contributor.envare each forwarded. No role means no argument./home/dev/.hive-quota-pool(:zfor podman and krun) and pass that path, and the directory is created first;contributor.envare forwarded and mounted;just contribute-quota status, with the pool dir and backend only incontributor.env, succeeds and uses the codex relay's pool key.Before and after:
krunbinary on PATH and that check would start it. CI runs the whole script.The new
contributor-agent.test.shcase (section 7) checks that the-emount path wins over acontributor.envhost path, and that thecontributor.envvalue still applies when there is no-evalue. Without the precedence fix, the first check gets/host/side/quota-pool; with it, it gets/home/dev/.hive-quota-pool.Other checks:
test_contributor_claude_staging.shpasses (50/0).bash -npasses on every touched script, andshellcheckreports the same findings as before.node --test bin/contributor-relay.test.jsgave the same results with and without the role commit.🤖 Generated with Claude Code
https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1