feat(swarm): migration 071 — peer + signed-record storage (#88)#92
Merged
Conversation
Storage floor for /swarm/lessons and /swarm/hubs (Phase 3/4 endpoints land later). Schemas mirror docs/SWARM_SPEC.md §3.1 (Lesson) and §3.2 (HubAnchor); peer + local-trust columns extend `nodes` from migration 070. SWARM_SPEC §3.4 trust stays local — flat columns on `nodes`, no `trust_edges` table that could be JOINed into a wire response. Column-level CHECKs map to §5 rejection rules (defense in depth behind the wire-validator from PR #89): rule 9 signed_at >= created_at, rule 11 synthesized_from_cluster_size >= 2, rule 12 content/topic_label size caps, rule 4 embedding dim 768. HNSW vector_cosine_ops indexes match every other embedding index in the codebase (memories, experiences, lessons, soul_traits — migrations 002, 004, 015, 017). The issue body's ivfflat reference contradicted the established pattern; HNSW keeps query plans uniform. File only — Reed runs migrations manually after merge. Sibling SQL-text contract test pins every column, CHECK, FK, and index so a later edit cannot silently weaken the schema before the Phase 3/4 endpoints come online. Closes #88.
This was referenced Apr 28, 2026
Dewinator
added a commit
that referenced
this pull request
Apr 29, 2026
Updates the stale "spec-only" header (phases 0–3 have all merged via PRs #79/#81/#82/#85/#89/#91/#92) and pins each phase to its issue + merged commit so a reader can tell at a glance which sections are wired on `main` vs. still paper. Phases 4–9 are deliberately listed as "_not yet issued_" — the project's current priority is *Gehirn perfektionieren* per CLAUDE.md § Roadmap (Reed 2026-04-26), and the wire contract is frozen at v1.0 so an independent implementer can build a phase-3-equivalent peer today. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Dewinator
added a commit
that referenced
this pull request
Apr 29, 2026
The cryptographic foundation of the swarm (SWARM_SPEC v1, Ed25519 signing, JCS canonicalization, wire-validator, .well-known discovery, peer/signed-record storage — PRs #78,#79,#81,#82,#85,#89,#91,#92) was landing on main while the README/MANIFESTO still claimed "pairing/swarm/federation deferred". This commit fixes that mismatch. README (EN+DE): - new "Swarm — federation in flight" section with merged-PR table and a "what is next" subsection pointing to the swarm label - Roadmap rewritten: phase 4-5 from "deferred" to "Phase 1 shipped" - existing /.well-known/mycelium-node block folded into the new section - promo video as a clickable poster near the top, served from a v0.4-swarm-phase-1 GitHub release asset (14 MB H.264 1080p) MANIFESTO (EN+DE): - "What is built today" split into brain core + Swarm Phase 1 - aspirational Tailscale+mTLS / mutual-pairing claims removed; those pieces remain on archive/swarm-deferred as historical reference - "What is not built yet" sharpened to the social layer (verification, reputation, banishment-by-consensus, Sybil resistance) plus micro-transactions Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
supabase/migrations/071_swarm_storage.sql— extendsnodeswith peer + local-trust columns, addsswarm_lessons(§3.1) andswarm_hub_anchors(§3.2). File only — Reed runs migrations manually after merge.mcp-server/src/__tests__/migration-071-swarm-storage.test.ts(11 tests) pins every column, CHECK, FK, and index so a later edit cannot silently weaken the schema.vector_cosine_opsembedding indexes (matches the codebase-wide pattern from migrations 002, 004, 015, 017, 022). The issue body'sivfflatwas inconsistent with the existing memory-embedding index, which is HNSW.Research summary
CREATE TABLE IF NOT EXISTS,COMMENT ON TABLEreferencingdocs/SWARM_SPEC.md, no DROP / DELETE. Replicated structure here.mcp-server/src/__tests__/. Strip comments, lowercase + collapse whitespace, regex-pin structural contracts. Same pattern asmigration-070-node-identity.test.ts— the autonomy loop is forbidden from executing migrations, so a runtime DB-side test wouldn't run; the SQL-text contract is what survives.trust_edgestable would create the temptation to JOIN it into a wire response. Flat columns onnodes(trust_weight,trust_reason) satisfy the local-only contract; the contract test guards against re-introduction of atrust_edgestable.VECTOR(768) NOT NULLCHECK (signed_at >= created_at)onswarm_lessonsCHECK (synthesized_from_cluster_size >= 2)(wire floor, stricter than §3.1's >= 1)CHECK (octet_length(content) <= 8192)andoctet_length(topic_label) <= 256What this does NOT do
/swarm/lessonsand/swarm/hubsship in later Phase 3/4 issues.CREATE TABLE IF NOT EXISTSandALTER TABLE … ADD COLUMN IF NOT EXISTS. The newnodescolumns get safe defaults (or are nullable) so the bootstrapis_selfrow from migration 070 / phase 1b survives untouched.bash scripts/migrate.shmanually after merge (matches Phase 1a / 1b precedent).trust_edgestable. §3.4 forbids trust on the wire; flat columns onnodesare the deliberate choice.(origin_node_id, embedding)onswarm_hub_anchors. Issue body explicitly skips it as expensive and not required.Constitution affirmation
This change touches:
origin_node_idprovenance and asignature; storage knows who said what without a central registry.nodes(node_id)make every signed record trace back to a known cryptographic identity; trust is structurally local-only (notrust_edgestable on the wire path).No pillar is weakened. Pillars 2, 4, 5 are not touched.
Test plan
cd mcp-server && npm run build— clean TypeScript buildcd mcp-server && npm test— full suite green: 365 tests pass, 0 fail (the 11 new tests for migration 071 ride along)node --test dist/__tests__/migration-071-swarm-storage.test.js— 11/11 pass in isolationcd scripts && bash migrate.shagainst a real Supabase to apply 071 (out of scope for this PR per Phase 1a precedent)supabase/migrations/071_swarm_storage.sqland verify it only containsCREATE TABLE IF NOT EXISTS,ALTER TABLE … ADD COLUMN IF NOT EXISTS,CREATE INDEX IF NOT EXISTS,COMMENT ON TABLE— no DROP, no DELETE, no INSERTCloses #88.