From a29261ee2788b9634ab3a165981420be31b07265 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 02:26:03 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=8C=B1=20ci:=20run=20crux's=20Go=20fi?= =?UTF-8?q?le-size=20ratchet=20against=20src/crux=20on=20hive=20PRs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .github/workflows/crux-file-size-ratchet.yml | 48 +++++++++++++++++++ .../added-15331-crux-file-size-ratchet.md | 1 + 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/crux-file-size-ratchet.yml create mode 100644 changelog.d/added-15331-crux-file-size-ratchet.md diff --git a/.github/workflows/crux-file-size-ratchet.yml b/.github/workflows/crux-file-size-ratchet.yml new file mode 100644 index 0000000000..96674a2e78 --- /dev/null +++ b/.github/workflows/crux-file-size-ratchet.yml @@ -0,0 +1,48 @@ +name: crux file-size ratchet + +# src/crux is published to hivecommons/crux by the crux-sync workflow, and crux +# main enforces a Go file-size ratchet that hive CI never ran, so a PR growing a +# grandfathered src/crux file was green here and broke crux main on the next +# sync (#15331). crux stays the source of truth: its script and baseline are +# fetched from crux main at run time, never vendored into hive. +on: + pull_request: + paths: + - 'src/crux/**' + - '.github/workflows/crux-file-size-ratchet.yml' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + +jobs: + crux-file-size-ratchet: + name: crux-file-size-ratchet + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + sparse-checkout: src/crux + + - name: Check out the ratchet script and baseline from crux main + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: hivecommons/crux + ref: main + path: crux-ratchet + persist-credentials: false + fetch-depth: 1 + sparse-checkout: | + .github/scripts/check-file-size-ratchet.sh + .github/go-file-size-ratchet.txt + sparse-checkout-cone-mode: false + + - name: Check non-test Go file sizes in src/crux against crux's baseline + working-directory: src/crux + run: bash "$GITHUB_WORKSPACE/crux-ratchet/.github/scripts/check-file-size-ratchet.sh" "$GITHUB_WORKSPACE/crux-ratchet/.github/go-file-size-ratchet.txt" diff --git a/changelog.d/added-15331-crux-file-size-ratchet.md b/changelog.d/added-15331-crux-file-size-ratchet.md new file mode 100644 index 0000000000..ed0e2e5861 --- /dev/null +++ b/changelog.d/added-15331-crux-file-size-ratchet.md @@ -0,0 +1 @@ +- Hive PRs that touch `src/crux/**` now run crux's Go file-size ratchet (the `crux-file-size-ratchet` check), using the script and baseline fetched from crux `main` at run time. A PR that grows a grandfathered `src/crux` file past its baseline now fails in hive with crux's own `::error::` annotation instead of breaking crux `main` on the next sync. (#15331) From 7af26e91c88d21d0da9a65258d522789d3a2a779 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 02:53:23 -0400 Subject: [PATCH 2/2] crux/agent: move Manager options out of manager.go manager.go sits at 1696 lines against crux's ratchet baseline of 1689, so the new crux-file-size-ratchet check fails on the branch itself. Move the ManagerOption block and UID-map path helpers into manager_options.go to bring the file back under the baseline. Refs #15330 Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/crux/agent/manager.go | 42 ---------------------------- src/crux/agent/manager_options.go | 46 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 42 deletions(-) create mode 100644 src/crux/agent/manager_options.go diff --git a/src/crux/agent/manager.go b/src/crux/agent/manager.go index 74dc1fe1ba..1da2552660 100644 --- a/src/crux/agent/manager.go +++ b/src/crux/agent/manager.go @@ -799,48 +799,6 @@ func (m *Manager) GetACMMLevel() int { return m.project.ACMMLevel } -type ManagerOption func(*managerOptions) - -type managerOptions struct { - uidMapPath string - uidMapPathSet bool - sharedPool SharedSessionPool -} - -// WithUIDMapPath points a manager at a specific persisted UID map. Production -// callers keep the default UIDMapPath; tests can inject a hermetic path. -func WithUIDMapPath(path string) ManagerOption { - return func(opts *managerOptions) { - opts.uidMapPath = path - opts.uidMapPathSet = true - } -} - -// WithSharedSessionPool opts a manager into a Hub-coordinated live CLI slot. -// Every Hive retains separate sessions and tenant data; the lease only limits -// how many CLI sessions across the participating Hives remain live. -func WithSharedSessionPool(pool SharedSessionPool) ManagerOption { - return func(opts *managerOptions) { opts.sharedPool = pool } -} - -func (m *Manager) effectiveUIDMapPath() string { - if m.uidMapPath != "" { - return m.uidMapPath - } - return UIDMapPath -} - -func (m *Manager) saveUIDMap() { - if m.uidMap == nil { - return - } - path := m.effectiveUIDMapPath() - _ = m.uidMap.Save(path) - if path == PersistedUIDMapPath && UIDMapPath != "" && UIDMapPath != path { - _ = m.uidMap.Save(UIDMapPath) - } -} - func NewManager(agents map[string]config.AgentConfig, logger *slog.Logger, project ProjectContext) *Manager { return NewManagerWithOptions(agents, logger, project) } diff --git a/src/crux/agent/manager_options.go b/src/crux/agent/manager_options.go new file mode 100644 index 0000000000..06d630bc18 --- /dev/null +++ b/src/crux/agent/manager_options.go @@ -0,0 +1,46 @@ +package agent + +// Manager construction options and the persisted UID-map path they select. +// Kept out of manager.go so that file stays under the crux file-size ratchet. + +type ManagerOption func(*managerOptions) + +type managerOptions struct { + uidMapPath string + uidMapPathSet bool + sharedPool SharedSessionPool +} + +// WithUIDMapPath points a manager at a specific persisted UID map. Production +// callers keep the default UIDMapPath; tests can inject a hermetic path. +func WithUIDMapPath(path string) ManagerOption { + return func(opts *managerOptions) { + opts.uidMapPath = path + opts.uidMapPathSet = true + } +} + +// WithSharedSessionPool opts a manager into a Hub-coordinated live CLI slot. +// Every Hive retains separate sessions and tenant data; the lease only limits +// how many CLI sessions across the participating Hives remain live. +func WithSharedSessionPool(pool SharedSessionPool) ManagerOption { + return func(opts *managerOptions) { opts.sharedPool = pool } +} + +func (m *Manager) effectiveUIDMapPath() string { + if m.uidMapPath != "" { + return m.uidMapPath + } + return UIDMapPath +} + +func (m *Manager) saveUIDMap() { + if m.uidMap == nil { + return + } + path := m.effectiveUIDMapPath() + _ = m.uidMap.Save(path) + if path == PersistedUIDMapPath && UIDMapPath != "" && UIDMapPath != path { + _ = m.uidMap.Save(UIDMapPath) + } +}