Skip to content
Merged
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ Hive did not historically maintain a complete changelog. This file starts a prag
### Fixed

- release: cap GitHub Release notes at `RELEASE_NOTES_MAX_CHARS` (120000) before the SBOM/NOTICE trailer, cutting the changelog section at a bullet boundary and linking the tag's full `CHANGELOG.md` section, so a first-on-the-line release such as v6.0.0 no longer fails `gh release create` with HTTP 422 "body is too long" after the tag and image retags have landed.

## 2026-11-08 (v5.204.1)

### Fixed

- Fleet report: repeated `copilot sniff: upstream dial failed` ERRORs β€” the proxy could not reach a `*.githubcopilot.com` host it was usage-sniffing, such as a dial timeout to `telemetry.enterprise.githubcopilot.com` β€” are now classified as `proxy_connect_dial_failed` (medium, component `github-proxy`, remedy "restore the spoke's outbound proxy or network path") alongside `proxy: CONNECT dial failed`, instead of surfacing as `unclassified_error_repeated` ([#17262](https://github.com/hivecommons/hive/issues/17262)).

## 2026-11-08 (v5.204.0)

### Added

- crux: agent step service, the sixth work service of the Crux work-services RFC ([hivecommons/crux#114](https://github.com/hivecommons/crux/issues/114) S6). `POST /v1/runs` with `"profile": "agent"` now opens a step session β€” a contained run that provisions its checkout and waits β€” and `POST /v1/runs/{id}/steps` runs one agent step inside it: a `claude`, `codex` or `process` backend reads the prompt in the sandbox and its JSON answer is checked against the request's `output_schema`, with bounded re-asks on a mismatch, a per-attempt timeout, tool and turn limits where the backend can enforce them, and a recorded `unsupported` refusal where it cannot. Each step is logged in the S4 command log, announced as a `step` turn signal, and read back with `GET /v1/runs/{id}/steps[/{n}]` or `crux --server … step run|list|show`.

## 2026-11-08 (v5.203.0)

### Added
Expand Down
1 change: 1 addition & 0 deletions changelog.d/added-crux-s7-saved-run-results.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- crux: saved run results complete, the seventh work service of the Crux work-services RFC ([hivecommons/crux#114](https://github.com/hivecommons/crux/issues/114) S7). A finished run can now be re-run with `POST /v1/runs/{id}/restart` (`crux --server … runs restart`): the server re-validates the request the run was accepted with as its original owner against the current configuration, links the two records (`restarted_from` / `restarted_by`), audits the restart with its reason, and refuses with `409 conflict` while the old run is still live so two drivers never resume one task. `GET /v1/runs` lists the caller's runs newest first (the operator's view is every run; `?status=` and `?limit=` narrow it), `GET /v1/runs/{id}/history` is the record's status transitions, and a `crux serve` restart now settles the `running` steps of an unfinished session to `unfinished` alongside the run. `crux runs list|restart|history` round out the CLI.
1 change: 1 addition & 0 deletions changelog.d/added-etag-cache-size-setting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The GitHub conditional-request (ETag / 304) response cache is now sized by `github.etag_cache_max_mb` and `github.etag_cache_max_entries` (env `HIVE_GITHUB_ETAG_CACHE_MAX_MB` / `HIVE_GITHUB_ETAG_CACHE_MAX_ENTRIES`), editable under Settings β†’ Forge App and applied without a restart. The built-in default rises from 64 MiB / 4096 entries to 128 MiB / 8192 entries, cached bodies are stored gzip-compressed so the cap holds several times as many responses, and `/api/gh-rate-limits` plus the Debug β†’ GitHub API budget panel show the cache's fill level (`bytes` / `max_bytes` / `max_entries`) so an operator can see eviction pressure before the hit rate slides.
4 changes: 4 additions & 0 deletions src/cmd/hive/github_client_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ func (b *boot) applyGitHubClientConfigHooks(client *github.Client) {
// open PR nor blanks the Matrix feed until the next sweep (#16276).
client.SetSentinelHeadsPath(sentinelHeadsStatePath)
client.SetAPIBudgetThresholds(b.cfg.GitHub.APIReserve, b.cfg.GitHub.APICritical)
// The conditional-request cache is process-wide, not per client; size it
// from github.etag_cache_max_mb / _max_entries so a hive that evicts
// within hours can be given more room without a rebuild.
github.SetETagCacheLimits(b.cfg.GitHub.EffectiveETagCacheMaxBytes(), b.cfg.GitHub.EffectiveETagCacheMaxEntries())
// Per-repo pause (#6203). A live predicate over the shared config, so a
// pause taken in the dashboard narrows the very next enumeration and
// automerge sweep without a restart.
Expand Down
33 changes: 33 additions & 0 deletions src/crux/agentstep/agentstep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,36 @@ func TestHostWithoutLogOrSignalsStillRuns(t *testing.T) {
t.Fatalf("step = %+v", step)
}
}

func TestReconcileMarksRunningStepsUnfinished(t *testing.T) {
store := Store{RunDir: t.TempDir()}
now := time.Date(2026, 11, 8, 12, 0, 0, 0, time.UTC)
for _, st := range []string{api.StepSucceeded, api.StepRunning, api.StepRunning} {
if _, err := store.Create(api.Step{Run: "run_1", Status: st, CreatedAt: now}); err != nil {
t.Fatal(err)
}
}
// A corrupt record is skipped so the rest still settle.
if err := os.MkdirAll(store.Dir(4), 0o700); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(store.Dir(4), RecordName), []byte("{"), 0o600); err != nil {
t.Fatal(err)
}
changed, err := store.Reconcile("serve restarted", now)
if err != nil || len(changed) != 2 || changed[0].N != 2 || changed[1].N != 3 {
t.Fatalf("Reconcile = %+v, %v", changed, err)
}
for _, n := range []int{2, 3} {
got, err := store.Get(n)
if err != nil || got.Status != api.StepUnfinished || got.Reason != "serve restarted" || got.FinishedAt == nil || !got.FinishedAt.Equal(now) {
t.Fatalf("step %d = %+v, %v", n, got, err)
}
}
if got, _ := store.Get(1); got.Status != api.StepSucceeded {
t.Fatalf("finished step touched: %+v", got)
}
if again, err := store.Reconcile("x", now); err != nil || len(again) != 0 {
t.Fatalf("second reconcile = %+v, %v", again, err)
}
}
26 changes: 26 additions & 0 deletions src/crux/agentstep/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"sort"
"strconv"
"sync"
"time"

"github.com/hivecommons/hive/crux/api"
)
Expand Down Expand Up @@ -157,3 +158,28 @@ func (s Store) AppendTranscript(n int, a attempt) error {
}
return werr
}

// Reconcile marks every step still recorded as running unfinished with
// reason and returns the steps it changed. It runs when the run that owns
// the steps is itself reconciled at `crux serve` start: the process that
// ran the step is gone, so its outcome is not knowable and is never
// guessed. A corrupt record is skipped, not an error, so the rest settle.
func (s Store) Reconcile(reason string, now time.Time) ([]api.Step, error) {
steps, err := s.List()
if err != nil && !errors.Is(err, ErrCorrupt) {
return nil, err
}
var changed []api.Step
for _, step := range steps {
if step.Status != api.StepRunning {
continue
}
at := now
step.Status, step.Reason, step.FinishedAt = api.StepUnfinished, reason, &at
if err := s.Write(step); err != nil {
return changed, err
}
changed = append(changed, step)
}
return changed, nil
}
75 changes: 72 additions & 3 deletions src/crux/api/runs.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
package api

import "time"
import (
"net/url"
"strconv"
"time"
)

// Contained runs and saved run results (hivecommons/crux#114, S2 and S7):
//
// POST /v1/runs run an untrusted command in a sandbox
// GET /v1/runs/{id} the saved record, whatever the process state
// POST /v1/runs/{id}/cancel cancel; after completion returns the result
// unchanged with already_finished: true
// GET /v1/runs the caller's saved records (all, for the
// operator), newest first, ?status= ?limit=
// POST /v1/runs/{id}/restart explicit, audited re-run of a finished run as
// a new record linked to the old one; 409
// conflict while the saved state is still live
// GET /v1/runs/{id}/history every status the record passed through
//
// Routes beyond these (restart, listing) are deferred; see
// src/docs/design/crux-work-services.md.
// See src/docs/design/crux-work-services.md (S7).
const PathRuns = "/" + Version + "/runs"

// RunPath is the route of one run's saved record.
Expand All @@ -19,6 +28,29 @@ func RunPath(id string) string { return PathRuns + "/" + id }
// RunCancelPath is the route that cancels one run.
func RunCancelPath(id string) string { return RunPath(id) + "/cancel" }

// RunRestartPath is the route that re-runs one finished run (S7).
func RunRestartPath(id string) string { return RunPath(id) + "/restart" }

// RunHistoryPath is the route of one run's status history (S7).
func RunHistoryPath(id string) string { return RunPath(id) + "/history" }

// RunsListQuery is the query string of GET /v1/runs: status filters on one
// status of the closed set, limit caps the page (newest first); either may
// be empty or zero for no filter and the server default.
func RunsListQuery(status string, limit int) string {
q := url.Values{}
if status != "" {
q.Set("status", status)
}
if limit > 0 {
q.Set("limit", strconv.Itoa(limit))
}
if len(q) == 0 {
return PathRuns
}
return PathRuns + "?" + q.Encode()
}

// The runs routes answer CodeUnsupported (501, shared with the checkout
// routes) when the request asks for something the configured backend cannot
// enforce (a network mode, a profile, a workspace form); the message names it
Expand Down Expand Up @@ -124,4 +156,41 @@ type ContainedRun struct {
// AlreadyFinished is set on a cancel response when the run had already
// reached a terminal status; the record is returned unchanged.
AlreadyFinished bool `json:"already_finished,omitempty"`
// RestartedFrom is the finished run this one re-ran (S7); RestartedBy
// is the run that re-ran this one. Both are saved, so the chain is
// readable from either end after a restart of the serving process.
RestartedFrom string `json:"restarted_from,omitempty"`
RestartedBy string `json:"restarted_by,omitempty"`
}

// RunRestartRequest is POST /v1/runs/{id}/restart (S7). The run re-runs
// with the request it was created from; only the bookkeeping is new.
type RunRestartRequest struct {
// Reason is recorded with the new run and in the audit record.
Reason string `json:"reason,omitempty"`
// IdempotencyKey makes a repeated restart return the run the first one
// started instead of a third run.
IdempotencyKey string `json:"idempotency_key,omitempty"`
// Detach returns the accepted record instead of waiting for the result.
Detach bool `json:"detach,omitempty"`
}

// ContainedRunList is GET /v1/runs: the caller's saved records (every
// record for the operator), newest first, without the command output.
type ContainedRunList struct {
Runs []ContainedRun `json:"runs"`
}

// RunTransition is one status the record passed through, in order.
type RunTransition struct {
At time.Time `json:"at"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
}

// RunHistory is GET /v1/runs/{id}/history: the saved record's statuses in
// the order they were written, the proof of what happened to the run.
type RunHistory struct {
Run string `json:"run"`
Transitions []RunTransition `json:"transitions"`
}
22 changes: 22 additions & 0 deletions src/crux/api/runs_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,25 @@ func (c *Client) CancelRun(ctx context.Context, id string) (ContainedRun, error)
err := c.Do(ctx, http.MethodPost, RunCancelPath(id), nil, &out)
return out, err
}

// ListRuns is GET /v1/runs.
func (c *Client) ListRuns(ctx context.Context, status string, limit int) (ContainedRunList, error) {
var out ContainedRunList
err := c.Do(ctx, http.MethodGet, RunsListQuery(status, limit), nil, &out)
return out, err
}

// RestartRun is POST /v1/runs/{id}/restart: the new run's record, final
// unless req.Detach.
func (c *Client) RestartRun(ctx context.Context, id string, req RunRestartRequest) (ContainedRun, error) {
var out ContainedRun
err := c.Do(ctx, http.MethodPost, RunRestartPath(id), req, &out)
return out, err
}

// RunHistory is GET /v1/runs/{id}/history.
func (c *Client) RunHistory(ctx context.Context, id string) (RunHistory, error) {
var out RunHistory
err := c.Do(ctx, http.MethodGet, RunHistoryPath(id), nil, &out)
return out, err
}
83 changes: 82 additions & 1 deletion src/crux/api/runs_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
package api

import "testing"
import (
"context"
"encoding/json"
"errors"
"net/http"
"net/http/httptest"
"strings"
"testing"
)

func TestRunPaths(t *testing.T) {
if PathRuns != "/v1/runs" || RunPath("run_a") != "/v1/runs/run_a" || RunCancelPath("run_a") != "/v1/runs/run_a/cancel" {
Expand All @@ -10,3 +18,76 @@ func TestRunPaths(t *testing.T) {
t.Fatal("unsupported-limit refusals must be distinguishable from a not-configured server")
}
}

func TestSavedRunPathsAndQuery(t *testing.T) {
if RunRestartPath("run_a") != "/v1/runs/run_a/restart" || RunHistoryPath("run_a") != "/v1/runs/run_a/history" {
t.Fatalf("paths: %s %s", RunRestartPath("run_a"), RunHistoryPath("run_a"))
}
for _, tc := range []struct {
status string
limit int
want string
}{
{"", 0, "/v1/runs"},
{"", -1, "/v1/runs"},
{RunUnfinished, 0, "/v1/runs?status=unfinished"},
{"", 7, "/v1/runs?limit=7"},
{"a b", 2, "/v1/runs?limit=2&status=a+b"},
} {
if got := RunsListQuery(tc.status, tc.limit); got != tc.want {
t.Fatalf("RunsListQuery(%q, %d) = %q want %q", tc.status, tc.limit, got, tc.want)
}
}
}

func TestSavedRunClientRoutesAndDecodes(t *testing.T) {
var seen []string
mux := http.NewServeMux()
mux.HandleFunc("GET "+PathRuns, func(w http.ResponseWriter, r *http.Request) {
seen = append(seen, r.Method+" "+r.URL.RequestURI())
_ = json.NewEncoder(w).Encode(ContainedRunList{Runs: []ContainedRun{{ID: "run_1", Status: RunUnfinished}}})
})
mux.HandleFunc("POST "+PathRuns+"/{id}/restart", func(w http.ResponseWriter, r *http.Request) {
var req RunRestartRequest
_ = json.NewDecoder(r.Body).Decode(&req)
seen = append(seen, r.Method+" "+r.URL.RequestURI()+" "+req.Reason)
if r.PathValue("id") == "run_live" {
w.WriteHeader(http.StatusConflict)
_ = json.NewEncoder(w).Encode(Error{Error: "run run_live is running", Code: CodeConflict})
return
}
_ = json.NewEncoder(w).Encode(ContainedRun{ID: "run_2", Status: RunAccepted, RestartedFrom: r.PathValue("id")})
})
mux.HandleFunc("GET "+PathRuns+"/{id}/history", func(w http.ResponseWriter, r *http.Request) {
seen = append(seen, r.Method+" "+r.URL.RequestURI())
_ = json.NewEncoder(w).Encode(RunHistory{Run: r.PathValue("id"), Transitions: []RunTransition{{Status: RunAccepted}, {Status: RunRunning}}})
})
srv := httptest.NewServer(mux)
t.Cleanup(srv.Close)
c, err := NewClient(srv.URL, "tok")
if err != nil {
t.Fatal(err)
}
ctx := context.Background()

list, err := c.ListRuns(ctx, RunUnfinished, 5)
if err != nil || len(list.Runs) != 1 || list.Runs[0].ID != "run_1" {
t.Fatalf("ListRuns = %+v, %v", list, err)
}
again, err := c.RestartRun(ctx, "run_1", RunRestartRequest{Reason: "flaky"})
if err != nil || again.ID != "run_2" || again.RestartedFrom != "run_1" {
t.Fatalf("RestartRun = %+v, %v", again, err)
}
var se *StatusError
if _, err := c.RestartRun(ctx, "run_live", RunRestartRequest{}); !errors.As(err, &se) || se.Status != http.StatusConflict || se.Body.Code != CodeConflict {
t.Fatalf("live restart error = %v", err)
}
hist, err := c.RunHistory(ctx, "run_1")
if err != nil || hist.Run != "run_1" || len(hist.Transitions) != 2 {
t.Fatalf("RunHistory = %+v, %v", hist, err)
}
want := []string{"GET /v1/runs?limit=5&status=unfinished", "POST /v1/runs/run_1/restart flaky", "POST /v1/runs/run_live/restart ", "GET /v1/runs/run_1/history"}
if strings.Join(seen, "|") != strings.Join(want, "|") {
t.Fatalf("requests = %q", seen)
}
}
3 changes: 3 additions & 0 deletions src/crux/api/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ const (
// StepUnsupported: the request asked for something the backend cannot
// enforce (a tool allowlist, a turn limit); the step never ran.
StepUnsupported = "unsupported"
// StepUnfinished: the serving process stopped while the step ran, so
// its outcome is not knowable (S7 reconciliation); never a guess.
StepUnfinished = "unfinished"
)

// Step backends shipped with crux. Process is the generic adapter: the
Expand Down
6 changes: 4 additions & 2 deletions src/crux/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,10 @@ Commands (each maps onto crux.Runtime):
runtime that spawned it, not run by hand
cline-turn one bounded Cline CLI turn (stdin prompt);
--model provider/model, --check for preflight
runs start|status|cancel contained command runs on a crux serve
(--server only; 'crux runs help' for flags)
runs start|status|cancel|list|restart|history
contained command runs on a crux serve and
their saved results (--server only;
'crux runs help' for flags)

Work services (no runtime; hivecommons/crux#114):
checkout add|rm|list pinned checkouts under <workdir>/checkouts
Expand Down
9 changes: 9 additions & 0 deletions src/crux/cli/runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (
const runsUsage = `usage: crux --server ADDR runs start [flags] -- <command> [args…]
crux --server ADDR runs status <id>
crux --server ADDR runs cancel <id>
crux --server ADDR runs list [--status S] [--limit N] [--json]
crux --server ADDR runs restart [--reason TEXT] [--idempotency-key KEY] [--detach] [--json] <id>
crux --server ADDR runs history [--json] <id>

start flags:
--checkout ID run in a pinned checkout you own (crux checkout add)
Expand Down Expand Up @@ -46,6 +49,12 @@ func (e *Env) remoteRuns(ctx context.Context, c *api.Client, args []string) int
return e.remoteRunsGet(ctx, c, args[1:])
case "cancel":
return e.remoteRunsCancel(ctx, c, args[1:])
case "list":
return e.remoteRunsList(ctx, c, args[1:])
case "restart":
return e.remoteRunsRestart(ctx, c, args[1:])
case "history":
return e.remoteRunsHistory(ctx, c, args[1:])
case "help", "-h", "--help":
fmt.Fprintln(e.Stderr, runsUsage)
return ExitOK
Expand Down
Loading
Loading