Skip to content

feat: add Hive Mode pooled memory - #924

Merged
AmitoVrito merged 7 commits into
SynapseKit:mainfrom
DhruvGarg111:feat/issue-748-hive-mode
Aug 12, 2026
Merged

AmitoVrito merged 7 commits into
SynapseKit:mainfrom
DhruvGarg111:feat/issue-748-hive-mode

Conversation

@DhruvGarg111

Copy link
Copy Markdown
Collaborator

Summary

Implements #748 with opt-in local, team, and community scopes; bounded pattern mining; MeshPrivacyFilter redaction; pseudonymization; local differential privacy and epsilon accounting; Ed25519 signatures; optional AES-GCM envelopes; SQLite aggregation; cohort-gated suggestions; withdrawals; transparency reporting; offline cache fallback; a dependency-light HTTP client; an optional FastAPI service; and a local SQLite-backed CLI.

Tests

  • 5 Hive behavior tests passed
  • 46 UMP and marketplace regression tests passed
  • Focused mypy passed
  • Ruff and compileall passed
  • Local CLI and FastAPI route smoke checks passed
  • Full repository suite was started but its output stream closed before returning a final result

Closes #748

@AmitoVrito

Copy link
Copy Markdown
Collaborator

Reviewed — solid, privacy-first design. I pushed fixes for two correctness bugs directly to the branch:

Fixed (blocking):

Both ship with regression tests (concurrent to_thread writes; one contributor submitting the same pattern twice).

Non-blocking follow-ups:

  • HttpHiveTransport + the FastAPI service.py have no tests — auth, query building, and round-trip serialization are unverified. A TestClient/respx boundary test would close this.
  • No EventBus/Live wiring — contribute/withdraw/suggestions should publish to the bus.
  • Threat-model notes: contributor_id isn't bound to the signing key (Sybil defeats minimum_cohort), and envelopes are replayable within max_clock_skew. Fine to defer, but worth documenting.

Two correctness fixes in the Hive aggregator:

- SQLiteHiveStore shares one connection across the worker threads that
  asyncio.to_thread dispatches store calls onto. sqlite3 is not thread-safe
  for concurrent use of a single connection, so guard every access with a
  threading.RLock (fixes a data race under concurrent submit/suggestions).
- suggestions() computed contributor_count as len(values), counting
  observations rather than distinct contributors; a single contributor can
  submit multiple envelopes per day, inflating the count and the derived
  confidence. Track distinct contributor_ids per pattern key instead.

Adds regression tests for both (concurrent to_thread writes; one contributor
submitting the same pattern twice).

Fixes SynapseKit#927
Fixes SynapseKit#928

Co-authored-by: Dhruv Garg <[email protected]>
@AmitoVrito
AmitoVrito force-pushed the feat/issue-748-hive-mode branch from a805422 to 7576299 Compare August 12, 2026 20:18
Hive Mode (SynapseKit#748) published nothing to the Live EventBus, leaving pooled-memory
activity invisible in the glass-box dashboard. Auto-instrument HiveClient the
same way every other subsystem is wired: contribute/withdraw/suggestions_for
publish hive.contribute / hive.withdraw / hive.suggestions events (with scope).
Async contract preserved; no-op when Live is off. Adds a no-mock test driving a
real HiveClient over a real in-process aggregator + SQLite store. Records the
feature and both Hive bug fixes in the changelog.

Co-authored-by: Dhruv Garg <[email protected]>
@AmitoVrito

Copy link
Copy Markdown
Collaborator

Follow-up: wired Hive Mode into SynapseKit Live (commit 6b0ed65) — contribute/withdraw/suggestions now publish hive.contribute / hive.withdraw / hive.suggestions events. Added a no-mock test and a CHANGELOG entry (feature + both bug fixes). Clears the EventBus follow-up. (The HTTP-transport/service.py test-coverage gap from my review is still worth closing before merge.)

Adds the HTTP-boundary coverage the transport layer was missing (no mocks):
- create_hive_app via Starlette TestClient — routes, bearer auth (401/403),
  query params, and JSON round-trips against a real aggregator.
- HttpHiveTransport (stdlib urllib, so respx can't intercept it) driven against
  a real localhost http.server on an ephemeral port — real submit/suggestions/
  withdraw/transparency round-trip over TCP, asserting the bearer header and
  the _quote'd query string cross the socket.

The round-trip test surfaced a real bug: SQLiteHiveStore.revoke() updates the
`revoked` column, but list() rebuilt envelopes from the stored JSON blob (still
`revoked: false`) and ignored the column, so transparency() reported
withdrawn=false even after a withdrawal. list() now overlays the column onto
the reconstructed envelope.

Fixes SynapseKit#931

Co-authored-by: Dhruv Garg <[email protected]>
@AmitoVrito

Copy link
Copy Markdown
Collaborator

Added the HTTP-boundary coverage that was missing (commit eb5b23f), no mocks: create_hive_app via Starlette TestClient (routes, bearer auth 401/403, query params, JSON round-trips), and HttpHiveTransport — which uses stdlib urllib, so respx can't intercept it — driven against a real localhost http.server on an ephemeral port for a true submit/suggestions/withdraw/transparency round-trip over TCP.

That round-trip surfaced a real bug (#931): revoke() updated the revoked column but list() rebuilt envelopes from the stored JSON blob and ignored it, so transparency() reported withdrawn=false even after a withdrawal. Fixed by overlaying the column in list(). This clears the last follow-up from my review.

AmitoVrito added a commit that referenced this pull request Aug 12, 2026
…ive-shell

Integrate #923 + #924 + #925: embeddings layer, Hive Mode, Agent OS Shell
@AmitoVrito
AmitoVrito merged commit e7ac7ae into SynapseKit:main Aug 12, 2026
14 checks passed
@AmitoVrito

Copy link
Copy Markdown
Collaborator

Merged into main via the batch integration PR #932. Thanks @DhruvGarg111! 🙌

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.

v2.1: Hive Mode — opt-in pooled memory across teams (or the world) with differential privacy

2 participants