Repository navigation
Conversation
…r turn.Runner (hivecommons#18464) First library slice of RFC hivecommons#18464 (Family C, stateless LLM backends). - pkg/turn/llmrouter: turn.LLMClient over an ordered list of OpenAI-compatible /chat/completions providers. 429 honours Retry-After; 5xx/408/transport and 200-with-error bodies fail over; 401/403 and 404/410 (retired free model) fail over with long cooldowns; other 4xx are returned without resending. Cooldowns and per-UTC-day request caps live behind a Ledger interface so a stateless coordinator can persist them. API keys are referenced by env var name only. - pkg/turn: new ErrInferenceCapacity sentinel. Runner.Step parks the session as paused without consuming a turn when the LLM client reports it, and resumes on the next served inference. Previously any LLM error marked the session failed. Not wired into any binary or config; default behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com> (cherry picked from commit 11fae40) Signed-off-by: James Reilly <jreilly1821@gmail.com>
…runs (hivecommons#18464) Converge with the in-flight gateway work instead of a parallel config: - FromGateway builds a provider from crux/config.GatewayConfig, authenticates via crux/inference.ResolveGatewayAuth (key env/file, watsonx IAM mint + project header) and POSTs to config.LiteLLMChatCompletionsURL, the URL rule the inference translator and Test Connection share. Keyless gateways stay keyless. - HealthHook feeds crux/inferencehealth so free-tier throttling shows in the existing gateway-health surface; a served attempt clears it. Fixes found by running turn.Runner + llmrouter live against Workers AI: - Tool names: hive-tool/v1 dotted names are mapped to the OpenAI function-name alphabet and back. With "issue.read", llama-4-scout silently answered in prose; with "issue_read" it called the tool. - Assistant tool-call messages send content "" not null: Workers AI gpt-oss-120b 400s on null. - A 200 whose content is one repeated character (seen: ~300 '!') is malformed and fails over instead of entering the envelope. - A 429 naming a per-day limit (RPD/TPD/daily) cools the provider down until 00:00 UTC rather than 60s; cooldown uses a fresh clock read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com> (cherry picked from commit 56841d4) Signed-off-by: James Reilly <jreilly1821@gmail.com>
…es, tool_choice (hivecommons#18464) From live finish-phase runs (only task.complete offered): - the model still called repo__search_code and then repo.read_file. The router built its wire-name map only from the offered tools, so the first reached toolapprove unmapped, and the Runner executed the second although it was never offered. - turn.Runner denies (before approval, never executes) any call to a tool outside AvailableTools when that list is non-empty; the deny is recorded as a tool_approval operation and returned to the model with the list of available tools. An empty list keeps today's behaviour. - llmrouter maps names seen in the conversation history back as well. - llmrouter.WithToolChoice sets OpenAI tool_choice. Measured on Workers AI: llama-4-scout and glm-4.7-flash honour "required"; gpt-oss-120b ignores it and still reports finish_reason "tool_calls". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com> (cherry picked from commit 63039da) Signed-off-by: James Reilly <jreilly1821@gmail.com>
…ivecommons#18464) A plain sliding window (DefaultCompactor{2,20}) dropped the issue itself in a live Family C run. The model re-read it and repeated identical searches until max-turns. DigestCompactor keeps the pinned head (primer + task) and a recent window, and replaces the dropped middle with one deterministic user message listing the tool calls already made. The list is carried forward across compactions, deduplicated and bounded, so no extra model call is needed. The recent window never starts on a tool result whose tool_calls message was dropped, because OpenAI-compatible APIs may reject an orphaned tool message. Opt-in via WithCompactor. DefaultCompactor is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com> (cherry picked from commit e314989) Signed-off-by: James Reilly <jreilly1821@gmail.com>
…ommons#18464) The tool-host surface proposed in RFC hivecommons#18464 uses dotted names (issue.read, pr.create, ...). None of toolapprove's heuristics (pull_request, merge, mcp__github__ prefixes) recognised them, so: - reads were "side-effectful" and operator-gated at L1-L4 (measured in a live turn.Runner session: every file read stalled for approval), and - pr.create / issue.comment / repo.patch_files were neither GitHub writes nor issue/PR operations, so an ADVISORY agent's calls skipped the AgentMode capability checks and auto-approved at L5/L6 on a green scan. Explicit classes fix both before any tool-hosted backend exists. No CLI backend emits these names, so no current verdict changes (the RFC hivecommons#4000 parity constraint). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com> (cherry picked from commit c8e3b18) Signed-off-by: James Reilly <jreilly1821@gmail.com>
…ommons#18464) The read side of the tool host from RFC hivecommons#18464: a turn.ToolExecutor for credential-less backends, pinned to one repository and ref. - Tools: issue.read, repo.list_files, repo.read_file (<=200 lines per call, with a continuation hint), repo.search_code (CodeSearcher; the CodeIndexSearcher adapter uses pkg/codeindex, not GitHub code search), checks.read, task.complete / task.abort. Write tools are absent and return ErrUnknownTool naming what is available. - Every output is capped at 12k chars with a "narrow the request" hint. Paths are confined to the repository. An identical repeated call (canonical JSON) is refused with a pointer to the earlier result. A failed call can be retried. - Evidence gate (RequireEvidence): task.complete records which path:line citations the session actually served (read ranges and search hits). Optionally it refuses a summary with none. - ParseFenced: ```hive-tool JSON blocks for chat-only bridges and for models that write a tool call as prose. - Definitions/FinishOnly produce tool schemas in the llmrouter convention. Each rule comes from a measured failure in live turn.Runner runs on Workers AI (hivecommons#18464 comment): GitHub search loops, re-reads, ungrounded two-turn "triage", and runs that never finished. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com> (cherry picked from commit da52100) Signed-off-by: James Reilly <jreilly1821@gmail.com>
…mons#18464) Fork-first build of RFC hivecommons#18464's Family C on top of the upstream PR slices (llmrouter hivecommons#18465, toolapprove classes hivecommons#18467, hivetool hivecommons#18472): - pkg/hivelite.RunTriage drives one session: - ioscan-screened issue body pinned in the task message, plus a per-session canary; - DigestCompactor; - forced-finish phase that offers only terminal tools (tool_choice "required" where honoured); - finish-phase prose accepted only through the same evidence gate; - canary echo or an ioscan output block withholds the result; - ErrInferenceCapacity propagates so a later pass can retry. - cmd/hive-lite: gateways.yaml (Hive GatewayConfig entries in failover order, plus model and daily_cap) and pkg/codeindex search over a checkout. Dry-run by default; -post upserts one marked advisory comment. Exit 75 means no free capacity now. - .github/workflows/hive-lite-triage.yml: workflow_dispatch on a free hosted runner. Live run (Workers AI free tier, hivecommons#18441, dry run): 13 turns, 68s, a grounded advisory with 1 of 1 citations verified. glm-4.7-flash returned HTTP 500 mid-session; the router cooled it down, gpt-oss-120b served 8 turns, and glm served the final one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
408110d
ℹ️ Sentinel notice — informational; author is trusted (owner), merge is not blockedHive flagged this PR (author @hanthor, head
Hive did not add the |
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. @hanthor this PR is held at Failing checks:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. |
… branches - A 400 whose body shows the provider failed to parse the model's own tool-call generation (Workers AI code 3030: glm-4.7-flash emitted "<tool_call>…" its server parser rejected as json_invalid, seen live in a hive-lite fix session) is a malformed generation, not a bad request: it now fails over with the short cooldown. Plain 400s still do not. - Coverage for the package was 86.3%, below the 90% gate. This adds tests for key-file and Auth resolution with extra headers, transport-error failover, context cancellation, ledger errors, a cooldown that never shortens, parseResponse/normalizeArguments edge cases, rejected request bodies, CapacityError text, keyless FromGateway, and a truncated 200 body. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com> (cherry picked from commit 0ce5f50) Signed-off-by: James Reilly <jreilly1821@gmail.com>
…r failures Package coverage was 84.9%, below the 90% gate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com> (cherry picked from commit e69be78) Signed-off-by: James Reilly <jreilly1821@gmail.com>
…eate The write half of RFC hivecommons#18464 ModeToolHosted (fork-first; gated upstream). The model holds no credential; Hive applies its patches to an executor-pinned work branch via the Git Data API and opens a DRAFT PR. Guards, each enforced in the executor independently of toolapprove: - the mode must be push-capable (ISSUES_AND_PRS+); Writer and WorkBranch must be set; - pushbroker.DefaultProtectedPaths are refused (.github/workflows/, OWNERS, policies/ ...), and paths are confined to the repository; - search/replace must match exactly once; - a whole-file content write that drops more than 30% of an existing file's lines is refused (live: a free model "fixed" a one-line bug by rewriting the file and deleted an unrelated function); - an optional Verifier runs before every commit, and its report goes back to the model on failure; - any argument carrying the session canary is refused; size limit 256 KiB; - one draft PR per session; - closing keywords in the PR body become "Refs #N"; - Hive appends its own verification record (or a warning that none ran), so the model's prose claims are distinguishable from checks that ran; - reads follow the work-branch head once it exists (live: a resumed session read the base and kept re-patching). Comparer/RESTWriter.Compare render the branch diff for resumed sessions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
- hivelite.Config.Fix/Writer/WorkBranch/Verifier. In fix mode the session runs as ISSUES_AND_PRS at ACMM >= 5, the finish phase still offers repo.patch_files and pr.create (live: a session diagnosed the bug exactly and could not patch), and a resumed session's task message pins the work branch's existing diff (live: it otherwise redid the fix). - cmd/hive-lite: -fix (refuses while a hive-lite draft is open for the issue) and -verify '<cmd>', which runs in a scratch copy of -checkout with credential variables scrubbed. Model-authored code executes there, so use an ephemeral runner. Live (Workers AI free tier, private sandbox hanthor/hive-lite-sandbox#1): - first attempt without guards: a broken draft (deleted Page(), a failing test), closed and recorded; - with guards: a verified one-line fix (ceiling division), and draft PR #4 in 4 turns of a resumed session. It closes no issue and was gofmt-, vet- and test-clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
Adds the two non-CLI admission modes from RFC hivecommons#18464 §2. A declaration-only mode is refused by the binding unless the adapter lists it via PostureDeclarer, so existing adapters keep refusing them. ClampMode caps the tool host's agent mode at the posture ceiling (tool-hosted: ISSUES_AND_PRS; everything else: ADVISORY). VetMediatedPR is the outside-contributor bar for vendor-written PRs: green checks, no protected paths, an approval by someone other than the author or a Hive identity. hive-lite fix mode now runs as a tool-hosted admission and is refused under report-only or github-mediated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
…ed calls
Live (Workers AI gpt-oss-120b, 2026-11-16): a task.complete call was cut
off mid-string by the output limit. The executor refused it, but the
router resent those bytes as history, and Workers AI rejected every later
request with HTTP 400 code 3030 "Unterminated string" (the column was
where the summary value began). Invalid arguments are now wrapped as
{"invalid_arguments": "<raw>"} when resent; a tool call with invalid
arguments and finish_reason length is malformed (fail over) since the
same request would be cut off again; Provider.MaxTokens sets max_tokens.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: James Reilly <jreilly1821@gmail.com>
pkg/coordstate is the small Store from RFC hivecommons#18464 §7: compare-and-swap per key, a memory driver and a GitHub Contents API driver whose Version is the blob sha (PUT with a stale sha is a 409, the only per-file CAS GitHub offers). It bootstraps an orphan state branch. The router Ledger loads once and merges on flush (same-day counts add, later cooldown wins) so overlapping passes neither lose nor double spend. hive-lite checkpoints the envelope plus executor memory (evidence spans, duplicate fingerprints, write-side state) on every exit and resumes an unfinished checkpoint of the same admission mode. The canary never reaches the store: the system prompt is emptied and rebuilt with a fresh canary on resume, and any echo is replaced before writing. A save conflict is reported, never overwritten. Live on a private sandbox: pass 1 paused at a daily cap of 3 (exit 75); pass 2 was refused by the persisted ledger; pass 3 resumed at turn 3; pass 4 resumed at turn 11 and completed with 3/3 citations verified against code read in earlier passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
A remote MCP server (Streamable HTTP, POST-only, JSON responses, the same shape as the dashboard's public knowledge endpoint) through which an MCP-capable agent spends its own inference on Hive work, per RFC hivecommons#18464 §3a. Hive holds no model credential and the client holds no GitHub credential; every tool call is executed by hivetool.Executor under a tool-hosted admission (ClampMode: never merge; no Writer means no write tools). - Bearer tokens are stored hashed and map to a principal and mode. - hive_next_task offers issue number and title only; hive_accept_task delivers the ioscan-screened brief; hive_decline_task skips. - Sessions (executor evidence and duplicate memory) and per-issue claim leases live in a coordstate.Store under CAS, so the handler is stateless; a lapsed claim taken by someone else ends the old session. - Per-principal call budget; sessions bound to the opening principal. Live: Claude Code (haiku) connected over MCP and triaged a sandbox issue in 9 turns for $0.006 of its own inference, 4/4 citations verified. Two concurrent clients on a GitHub state branch claimed different issues and both completed (5/5, 4/4 verified). That run exposed that the Contents API answers 409 for a concurrent write to a DIFFERENT file on the same branch; ContentsStore now re-reads the key and retries when its version still matches, so only a real change is ErrConflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
The malformed answer in the first half of the test cools provider a down, so the second half was served by b. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
…trip Acquire returns three values; v2-tests on the branch caught the assignment mismatch. Adds a State JSON round-trip test (duplicates, evidence, write-side fields, outcome) for hivetool coverage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
D1Store keeps each key as a row (key, value, version) and uses the D1 HTTP query API, so it works from a CI runner as well as a Worker. Create is INSERT ... ON CONFLICT DO NOTHING, update is UPDATE ... WHERE version = ?, and the changed-row count decides success or ErrConflict: a real per-row CAS with no branch-wide serialisation and no history. Table creation is retried until it succeeds rather than memoised. coordstate.Open parses github, github:owner/name@branch and d1:<account>/<database>; hive-lite and hive-mcp use it for -state. Live (free D1, replication off): CAS semantics hold; 20 concurrent increments of one key end at exactly 20 (10.7 s wall, hot-key contention); two overlapping ledger flushes merge to the exact sum; ~0.86 s per get+put from this host vs ~1.0 s for the Contents driver. Two concurrent Claude Code clients on hive-mcp with -state d1 claimed different issues and both completed: 4 rows, ~32 row writes, versus 52 commits on a state branch for the same run on the Contents driver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
… no GitHub writes Aligns the fork's hive-lite work with the maintainer decision on RFC hivecommons#18464 (issuecomment-6938430548): phase 1 is a default-off, report-only shadow advisory engine; phase 2 is a read-only MCP server at ADVISORY. Vendor agents never write to GitHub, all writes stay with the Hive App, and tool-hosted is capped at ISSUES_AND_PRS. Removed: - extwork: the github-mediated posture (ModeGitHubMediated, MediatedPR, VetMediatedPR, ErrMediatedPR) and its tests. ClampMode now also caps at ToolHostedCeiling and treats an out-of-range request as ADVISORY. - hivetool: the whole write side (repo.patch_files, pr.create, Writer, RESTWriter, Verifier, Comparer, work-branch reads) and the write fields of the executor snapshot. Definitions offers read tools at every mode. - hive-lite: -post, -fix and -verify (verify.go). The GitHub client is GET-only. hivelite.Config has no Fix/Writer/WorkBranch/Verifier, and any admission above ADVISORY is refused. Checkpoint shape bumped to v2 so a v1 fix-mode checkpoint never resumes. - hive-mcp: -write and Config.Writer/Verifier. Every principal is clamped to ADVISORY, and token entries naming any other mode are refused. - coordstate.Open no longer selects the GitHub Contents driver (each checkpoint is a commit, so a GitHub write); the driver stays in code, marked unused and deferred. Binaries take memory (default) or d1:. - hive-lite-triage.yml: contents/issues read, no post input, no -state github; optional D1 state via the HIVE_LITE_STATE secret. Added: - llmrouter: Provider.TrainsOnInputs (trains_on_inputs) with WithPrivateRepo and WithAllowTrainingProvidersForPrivate. A private router skips training providers, and New fails with ErrOnlyTrainingProviders when none would be left. hive-lite sets it from the repository's visibility (unknown or internal counts as private) and reads allow_training_providers_for_private from gateways.yaml (mapping form) or a flag. - Tests: ClampMode never raises over every mode and request; no github-mediated admission; Definitions read-only at every mode; hive-lite offers read tools only and refuses tool-hosted; hive-mcp lists and resolves no write tool for any principal and clamps a stored session; Open refuses github specs; router privacy cases. A withheld advisory's summary is also redacted from hive-lite's JSON output, since that output now lands in a step summary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
Owner decisions on the two open items from the hivecommons#18464 scope cut: - coordstate.Open now refuses d1: specs too, because serverless stores are deferred per hivecommons#18464. Only "" and "memory" are accepted, so hive-lite and hive-mcp are memory-only. The D1 driver code stays, with a doc comment marking it deferred and unwired. Open loses its Cloudflare token argument, and both binaries drop cfToken. - .github/workflows/hive-lite-triage.yml is deleted. Phase 1's report-only engine runs inside the Hive over Model Gateways, not as a public Actions job, and a step summary on a public repo is published output. The changelog fragments no longer mention the workflow, D1 state or the HIVE_LITE_STATE secret. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: James Reilly <jreilly1821@gmail.com>
There was a problem hiding this comment.
Decision needed: @hanthor should decide whether the policy changes in src/pkg/extwork (admission.go, binding.go, posture.go) and src/crux/toolapprove/classify.go may land as part of this 8k-line hive-lite PR, given that it is stacked on #179 and two checks are red.
I did not review the full diff: it is 8,226 added lines across 55 files, too much to read honestly in one pass, so this is routing, not a code review.
What I can state from the PR metadata:
- Base is
sync/upstream-v6-dea69b3, notmain. The body says it is stacked on #179 and GitHub retargets it once that merges. overlapandrelease-lines-in-syncare failing on this head. The failed-log tail I could fetch contained only checkout cleanup, so I do not know why they fail; the runs date from 2026-11-17.- It changes trust-adjacent code:
src/pkg/extwork/admission.go,binding.go, newposture.go, andsrc/crux/toolapprove/classify.go. The body describes these as enforcing hard rules (no GitHub-mediated mode,ClampModecapped atISSUES_AND_PRS, read-onlyhivetool). I did not verify those claims against the code. - Positive: it ships tests alongside the new packages (e.g.
src/pkg/extwork/posture_test.go,src/pkg/hivetool/hivetool_test.go) and achangelog.d/fragment per feature.
Suggestion: a maintainer familiar with the extwork/toolapprove policy should review those four files specifically, after #179 lands and the two checks are green.
— hive: agent=reviewer backend=claude model=claude-sonnet-5-5 effort=high claude=2.1.322
Fork-first build of hivecommons#18464 (non-CLI backends and a zero-cost CLI-less coordinator), cut to the scope the maintainer accepted.
Stacked on #179 (
sync/upstream-v6-dea69b3), so this diff is only the hive-lite work. Merge #179 first, and GitHub retargets this PR totuna/v6.Scope per hivecommons#18464 decision
Decision (clubanderson): accepted with scope cuts, targeting v6.
This PR now enforces those rules:
pkg/extworktool-hostedexists.github-mediated,MediatedPRandVetMediatedPRare gone.ClampModenever returns a mode above the request, the posture's ceiling or ISSUES_AND_PRS, and a test covers every mode and request.pkg/hivetoolrepo.patch_files,pr.create,RESTWriter, Verifier) is removed, and a test asserts thatDefinitionsis read-only at every agent mode.cmd/hive-lite-post,-fixand-verifyare gone, and the GitHub client is GET-only. State is memory-only, so it writes nothing anywhere. It prints the advisory and JSON to stdout.cmd/hive-mcp-writeis gone, every principal is clamped to ADVISORY, and a token entry naming any other mode is refused. Tests assert that no write tool is listed or callable.pkg/coordstateOpenaccepts onlymemory, so both binaries are memory-only.githubspecs are refused as a GitHub write (each checkpoint would be a commit).d1:specs are refused because serverless stores are deferred. The Contents and D1 driver code stays, marked deferred and unwired.hive-lite-triage.ymlpkg/turn/llmroutertrains_on_inputsper provider.WithPrivateReposkips training providers unlessallow_training_providers_for_privateopts in. hive-lite sets it from repo visibility, and treats unknown or internal visibility as private.Contents
The first six commits are cherry-picked (
-x) from the upstream PRs, unchanged:llmrouteron Model Gateways, Runner capacity pause, offered-tools capability set,tool_choice,DigestCompactortoolapproveclasses forhive-tool/v1(a security gap fix)pkg/hivetoolread executor with evidence gateNew, fork-only:
pkg/hivelite.RunTriageholds the session policies proven in live runs:report-onlyadmission runs. Anything above ADVISORY is refused.cmd/hive-lite:gateways.yaml(HiveGatewayConfigentries in failover order, as a list or a mapping withgateways:andallow_training_providers_for_private:) andpkg/codeindexsearch. Exit 75 means no free capacity.pkg/coordstate: a compare-and-swap Store with a memory driver and a merge-on-flush router ledger.pkg/hivelitecheckpoints to a configured Store, with the canary stripped. The binaries configure none, because durable stores are deferred.pkg/hivemcp+cmd/hive-mcp: the Family E agent-driven MCP server, read-only.max_tokensis configurable.Earlier live results (before the scope cut)
pkg/codeindexhit its 64 MB text budget on the hive repo, so search coverage was partial.Testing
The fork's PR checks run no Go tests (this PR's base is not a release branch), so
v2-tests.ymlis dispatched on the branch. Following the repo'sCLAUDE.md, the suite wasn't run locally. Locally, only gofmt ran, plus a compile and type-check of the changed packages and their tests.🤖 Generated with Claude Code