Skip to content

feat: Archon wallet integration — Save Game, Vault backup/restore, PoH Cloak nodes - #5

Open
Flaxscrip wants to merge 6 commits into
mitchuski:mainfrom
Flaxscrip:feature/archon-vault-v2
Open

feat: Archon wallet integration — Save Game, Vault backup/restore, PoH Cloak nodes#5
Flaxscrip wants to merge 6 commits into
mitchuski:mainfrom
Flaxscrip:feature/archon-vault-v2

Conversation

@Flaxscrip

Copy link
Copy Markdown

Summary

  • Archon Vault save/restore — a 💾 Save button in the Mage modal writes a timestamped save-YYYYMMDD-HHMMSS.json to the Archon Vault and checkpoints mage-history.json. Full Mage state (identity, spells, constellations, blades, Swordsman link, mana) is preserved and restored automatically on wallet unlock.
  • Wallet connect UI — new ☁ Archon Vault panel at the bottom of the Mage modal with 🔑 Connect (passphrase unlock), Create/Import tabs (for new or existing wallets), 📤 Export (downloads encrypted wallet JSON), ↻ Browse (lists vault items), and per-item ↓ download.
  • Archon-derived Mage identity — when a did:cid wallet is connected, the Ed25519 blade-signing key is deterministically derived from the Archon keypair (SHA-256(secp256k1_sig_of(MAGE_SEED_DOCUMENT))). Same wallet → same Mage identity on any device.
  • Portability verified — wallet exported from Spellweb imports cleanly into the React Keymaster wallet UI; vault items (saves + history) visible under the GenitriX DID.
  • PoH Cloak registry nodes — 9 nodes + 6 edges from poh-cloak-contribution.ts added to the canonical graph (Proof of Humanity VC decomposition: Issuer, Schema, Credential, Sovereign Identity, three disclosure valves). Nodes carry emoji and hexagram data per the lattice spec.
  • resolveNodeEmoji migration — on state hydration, any placeholder emoji in saved marks/spells/blade constellations is resolved to the current node definition's emoji. Fixes stale saves from before emoji was added to nodes.

New files

File Purpose
src/contexts/KeymasterContext.tsx React context wrapping @didcid/keymaster — wallet state, vault ops, history restore
src/lib/mageHistory.ts MageArchonBackup schema + vault alias constants
src/utils/sessionPassphrase.ts In-memory passphrase store for the unlock flow
src/data/poh-cloak-contribution.ts 9 PoH-cloak nodes + 6 edges (registry contribution format)

Dependencies added

@didcid/cipher @didcid/gatekeeper @didcid/keymaster @noble/hashes buffer

Requires a running Archon Gatekeeper (default: http://192.168.1.23:4224 — configurable in the connect modal). Works fully offline if wallet is already unlocked in the session.

Test plan

  • Open Mage modal (M) → scroll to ☁ Archon Vault panel → click 🔑 Connect
  • Create a new wallet or import an existing archon-wallet-*.json
  • Enter passphrase → confirm wallet unlocks and 💾 Save button appears
  • Click 💾 Save → status cycles Saving… → Saved → click ↻ Browse → item appears
  • Click ↓ next to a save file → JSON downloads with correct Mage state + emoji resolved
  • Click 📤 Export → encrypted wallet JSON downloads → import into React Keymaster wallet → vault items visible
  • Reload page → wallet auto-restores Mage state from mage-history.json on unlock
  • Confirm PoH Cloak nodes visible in graph with correct emoji (🌟 🪄 🪪 📜 🎖️ 🔓 🔏 🎭 🧵)

🤖 Generated with Claude Code

Flaxscrip and others added 6 commits May 21, 2026 12:48
Re-implements feature/archon-vault on top of origin/main (v1.7.1):
- KeymasterContext: wallet connect/unlock, vault save/restore/browse
- mageHistory: MageArchonBackup schema + vault constants
- mageIdentity: deriveMageKeyFromKeymaster, archonDid/archonLinked fields
- sessionPassphrase: in-memory passphrase util for KeymasterContext
- poh-cloak-contribution: 9 PoH-cloak nodes with emoji + 6 edges
- nodes.ts: spreads poh-cloak registry nodes into canonical graph
- SpellWeb: 💾 Save button, Archon Vault browser, resolveNodeEmoji
  normalizer, auto-backup on forge, restore from vault on unlock

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add Create/Import tabs to wallet modal (no-wallet state was missing import path)
- Polyfill Buffer globally in main.tsx (keymaster lib uses it as a global)
- Install buffer, @didcid/* and @noble/hashes packages
- Fix @noble/hashes import: sha512/sha256 from sha2.js subpath
- Add walletState + connectWallet to SpellWeb useKeymaster destructure
- Show 🔑 Connect button in vault panel when wallet not linked
- Add REGISTRY_EDGES from poh-cloak-contribution to edges.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Surfaces exportWallet() from KeymasterContext in the vault panel header
(visible when wallet is connected). Downloads the encrypted wallet JSON
for backup or import into another browser / React Keymaster wallet.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each save-*.json item in the vault browser now shows an '↑ Load' button
that restores that save's full state into the current session (spells,
constellations, blades, equippedBlade, userEdges, mana, swordsmanLink).
resolveNodeEmoji runs on load to migrate any legacy '✦' placeholders.
mage-history.json (auto-checkpoint) shows download only, not load.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Drawbridge (port 4222) JSON-encodes plain-text responses, wrapping
returned CIDs in double quotes. Patch gatekeeper.addText in
KeymasterContext to strip outer quotes so vault item CIDs are stored
as bare strings. Direct Gatekeeper (4224) returns clean CIDs so the
strip is a no-op for non-proxied connections.

Also adds a delete (×) button to each vault browser row so users can
remove stale or corrupt vault items directly from the Spellweb UI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…graph

Adds a 🧵 Weaver Vault panel below the Archon Vault in the Mage menu.
Users can browse snapshots saved from the Spell Weaver (spellweb-registry)
and click ↑ Import to inject the transmuted nodes and edges directly into
the running Spellweb force graph without restarting.

- KeymasterContext: listWeaverVaultItems() + getWeaverVaultItem() reading
  from the 'spellweb-weaver-vault' Archon vault alias
- weaverImportedNodes state persisted to localStorage; merged into D3
  nodeDataRef at init time alongside canonical NODES
- nodeDataVersion counter triggers filter effect re-render when nodes are
  added at runtime (pattern reusable for any future dynamic node injection)
- Weaver edges merged into userEdges (existing sync handles D3 update)
- Node types map to existing Spellweb visuals: persona=violet, spell=gold,
  theorem=red, chronicle=cyan, skill=amber, document=grey-blue
- ↓ download retained as secondary option per item

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Flaxscrip

Copy link
Copy Markdown
Author

Update — Weaver Vault import (2026-05-22)

Added in latest commit (8143ccc): a 🧵 Weaver Vault panel in the Mage menu that lets users import registry snapshots from the companion Spell Weaver app directly into the live Spellweb force graph.

How it works

The Spell Weaver (a separate DID/VC registry tool) can transmute its registry items into Spellweb graph format and save them to a dedicated Archon vault (spellweb-weaver-vault) using the same shared Archon wallet. Spellweb then reads that vault and injects the nodes and edges at runtime:

  1. Browse — lists weaver-YYYYMMDD-HHMMSS.json snapshots from the Weaver vault
  2. ↑ Import — decodes { nodes, edges }, deduplicates against canonical nodes, and injects new nodes into nodeDataRef + the D3 force simulation; edges merge into userEdges
  3. ↓ Download — secondary option to save the snapshot JSON locally
  4. Imported nodes persist across sessions via localStorage['spellweb-weaver-imported-nodes']

Node type mapping (Weaver → Spellweb visuals)

Weaver type Spellweb visual
persona (DID holder) violet ring
spell (VC) gold glow
theorem (schema) red stroke
chronicle (anchored event) cyan
skill amber
document (asset) grey-blue

All existing theme styles, glow filters, and interaction handlers (click-to-select, search highlight, fog-of-war) apply automatically to imported nodes.

D3 injection pattern

Uses a nodeDataVersion counter to trigger the filter effect re-render after runtime node additions — a clean, reusable pattern for any future dynamic node injection without resetting graph positions.

mitchuski added a commit that referenced this pull request May 28, 2026
Review of PRs #2-#5; defer the Archon identity-wallet integration (PR #4/#5) until a reachable HTTPS Gatekeeper + hosting model exist. Reject PR #4's grimoire hand-edit and canonical-graph overwrite.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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