Skip to content

Framework hardening and stabilization (phases 0-6) - #57

Merged
chiruu12 merged 10 commits into
mainfrom
fix/framework-hardening
Jul 25, 2026
Merged

Framework hardening and stabilization (phases 0-6)#57
chiruu12 merged 10 commits into
mainfrom
fix/framework-hardening

Conversation

@chiruu12

Copy link
Copy Markdown
Owner

Summary

  • Land framework hardening and stabilization phases 0-6: daemon lifecycle durability, security boundary closure, operator truth parity, agent cycle decomposition, and layered CI merge gates.
  • Add adversarial test suite (243 tests), expanded unit/integration coverage (1865 tests, ~79% coverage), and plan/docs for hardening + stabilization workstreams.
  • Add new examples (24_multi_agent_collaboration, 26_structured_extraction, 28_toolkit_workshop) and operator tooling (hive doctor, budget CLI parity, secure toolkit factory).

Verification

  • uv run ruff check src/ tests/ + ruff format --check
  • uv run mypy src/ (205 files)
  • uv run pytest tests/adversarial/ — 243 passed
  • uv run pytest tests/ --cov=hive --cov-fail-under=77 — 1865 passed, ~79% coverage
  • uv run mkdocs build --strict
  • Examples: py_compile + import check (24 modules; voice example requires [audio] extra)
  • git archive HEAD + uv sync --extra api reproduces full test pass

Test plan

  • CI merge gate (lint, unit, coverage, adversarial, docs)
  • Smoke hive doctor, hive config, daemon start/stop
  • Optional: run examples/24_multi_agent_collaboration.py with API key

Notes

  • Local runtime artifacts (.marshal/, agents/) intentionally not committed.
  • In-tree uv build may fail in Conductor workspaces due to .conductor symlinks; use git archive for reproducible builds.

chiruu12 added 7 commits June 14, 2026 14:32
The run_once / run_structured / run_once_structured paths bypassed the
HITL approval gate and the input/output guardrail pipeline that _run_loop
enforces -- so SDK callers (and the CLI orchestrator) could execute gated
tools with no approval and leak PII. Route run_once tool calls through the
approval gate, run input/output guardrails on all paths, and also guard
task.context in _run_loop (an injection hidden there previously bypassed
the input guardrail). Extracted shared _apply_input/output_guardrail
helpers and added regression tests.
The denylist only matched a handful of suffixes/provider prefixes, so an
agent could read DATABASE_URL, PGPASSWORD, REDIS_URL, bare *_KEY (e.g.
STRIPE_KEY), SSH_*/GH_* creds, etc. via `env`. Broaden the pattern and
err toward over-scrubbing (pass_env=True restores full env for trusted
runs).
web_fetch followed redirects to arbitrary URLs with no scheme/host
checks, so an agent could reach cloud-metadata (169.254.169.254) or
internal services, and resp.text buffered the whole body. Validate the
scheme and resolved IP (reject loopback/private/link-local/reserved),
re-validate every redirect hop manually, and stream with a byte cap.
…ponsive stop

- store.save_session now sets created_at/last_active so the retention
  janitor (created_at < cutoff) and TTL expiry (last_active) actually
  collect daemon sessions instead of leaking them forever.
- _process_life_events reuses the cached per-agent provider instead of
  building a fresh, never-closed client per life event (connection leak).
- the heartbeat sleep now waits on a stop Event so Ctrl+C/SIGTERM is
  honored immediately instead of after up to a full heartbeat; removed
  the dead _pending_shutdown flag.
…ring

These are daemon-lifetime singletons whose histories grew without bound:
- SpecializationTracker now keys history by agent in a bounded deque
  (also removes the O(n^2) full-history rescan on every record()).
- SwarmLearning keeps a bounded deque of reports (only latest/trend read).
- SufferingState trims resolved-stressor history to a cap (it is persisted
  in checkpoints, so it grew them forever).
… cleanup

- MCP server no longer emits notifications/initialized (that is the
  client's message per the lifecycle spec) and validates required
  tools/call args with a clear error instead of an opaque KeyError;
  dropped the unused _request_id field.
- git_add inserts '--' before the pathspec so a leading-dash path is a
  file, not a git option.
- plugin loader uniquifies module names by path hash (no same-stem
  collisions) and pops half-initialized modules from sys.modules on
  exec failure.
Land daemon lifecycle durability, security boundary closure, operator
truth parity, agent cycle decomposition, adversarial test suite, layered
CI gates, and docs/plans so merge-ready behavior matches working tree.
@greptile-apps

greptile-apps Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The follow-up changes complete both previously requested fixes.

  • The clean-build workflow now creates /tmp/hive-ci-build before extracting the archive.
  • HTTPS requests now connect to the validated IP while preserving the original host for the HTTP Host header and TLS SNI.

Confidence Score: 5/5

The PR appears safe to merge because both previously reported failures are resolved and no eligible related defect remains.

No blocking failure remains.

Important Files Changed

Filename Overview
.github/workflows/ci.yml Creates the clean archive destination before extraction, resolving the previously reported build failure.
src/hive/tools/url_safety.py Builds IP-pinned HTTP and HTTPS requests with the original hostname retained for Host and TLS SNI, including valid bracketed IPv6 authorities.
tests/runtime/test_web_tools.py Covers HTTPS IP pinning, Host preservation, SNI selection, and IPv6 authority formatting.

Reviews (4): Last reviewed commit: "test: prove httpx.stream receives HTTPS ..." | Re-trigger Greptile

Comment thread .github/workflows/ci.yml
Comment thread src/hive/tools/url_safety.py Outdated
chiruu12 added 3 commits July 25, 2026 22:49
Merge origin/main trace/metrics work into framework-hardening, keep the
expanded TraceTree API and operator endpoints, adopt main's richer /metrics
format, pin HTTPS fetches to validated IPs with SNI, and mkdir the CI
clean-build extraction directory.
Add sync/async tests that mock httpx clients and assert request_url_safe_sync
and fetch_url_safe pass pinned IP netloc, Host header, and sni_hostname into
client.stream(). Bracket IPv6 literals in build_pinned_request so pinned
URLs parse correctly.
@chiruu12
chiruu12 merged commit eb61d77 into main Jul 25, 2026
8 checks passed
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