Skip to content

fix(config): wire K8s env vars into HiveStack and API server#13

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-19d6
Draft

fix(config): wire K8s env vars into HiveStack and API server#13
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-19d6

Conversation

@cursor

@cursor cursor Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

K8s/Helm deployments set HIVE_VALIDATE_INPUTS, HIVE_RATE_LIMIT, HIVE_MAX_NODES, HIVE_MAX_CONTENT_BYTES, and HIVE_DEFAULT_TTL_S via ConfigMap/deployment env vars, but scripts/hive_api_server.py created a bare HiveStack() that never called HiveConfig.from_env(). Enterprise controls were silently ignored at runtime — input validation, rate limiting, memory caps, and content-size limits had no effect in the REST API path.

Concrete trigger: Deploy via deploy/k8s/ with HIVE_VALIDATE_INPUTS=true and HIVE_RATE_LIMIT=1000, then POST an oversized agent state to /route. Before this fix, validation and rate limiting never ran despite operator configuration.

Root cause

HiveConfig was implemented and documented for env-based configuration, but:

  • hive_api_server.py did not load config from the environment
  • HiveStack did not wire max_memory_nodes, max_content_bytes, or rate_limit from HiveConfig into RustBrain / RateLimiter

Fix

  • Load HiveConfig.from_env() in the REST API server
  • Pass max_nodes from config.max_memory_nodes to RustBrain
  • Auto-create RateLimiter when HIVE_RATE_LIMIT > 0
  • Honor max_content_bytes from config when not explicitly overridden
  • Accept HIVE_MAX_NODES alias (used in K8s manifests)
  • Fix AsyncHiveStack.remember() silently dropping trust/tags

Validation

  • Added regression tests in tests/test_enterprise_config.py, tests/test_hive_api_server.py, and tests/test_async_stack.py
  • Full suite: 184 passed, 6 skipped
Open in Web View Automation 

HiveConfig.from_env() was never used by hive_api_server.py, so K8s/Helm
settings (HIVE_VALIDATE_INPUTS, HIVE_RATE_LIMIT, HIVE_MAX_NODES,
HIVE_MAX_CONTENT_BYTES, TTL) had no effect at runtime.

- Pass max_memory_nodes to RustBrain.max_nodes
- Honor max_content_bytes from config when not overridden
- Auto-create RateLimiter when HIVE_RATE_LIMIT > 0
- Accept HIVE_MAX_NODES alias used in deploy manifests
- Load HiveConfig.from_env() in the REST API server
- Fix AsyncHiveStack.remember() silently dropping trust/tags

Regression tests added for env wiring, validation, and async remember.

Co-authored-by: Daniel <DJLougen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant