EPOCH Appchain: Stacks Fork + Native Rust Services
Instead of 5 external services talking to the chain via HTTP, they become native chain modules. Graph Kernel queries happen at chain speed, not network speed. N'Ko inscriptions render inside the block validator. RAG++ vector search is part of consensus.
Full Public Reader
EPOCH Appchain: Stacks Fork + Native Rust Services
The Vision
Instead of 5 external services talking to the chain via HTTP, they become native chain modules. Graph Kernel queries happen at chain speed, not network speed. N'Ko inscriptions render inside the block validator. RAG++ vector search is part of consensus.
What Exists
96,682 lines of production Rust across 6 crates ready for embedding:
| Crate | Lines | Appchain Role |
|---|---|---|
| cc-rag-plus-plus | 33,274 | Native vector similarity precompile |
| cc-inscription | 22,881 | Native inscription validator (the killer feature) |
| cc-graph-kernel | 14,953 | Native context slicing with admissibility tokens |
| cc-protocol | 7,429 | Smart contract type definitions |
| cc-kernel | 4,357 | Ledger/storage layer |
| cc-semantic-language | 4,000 | N'Ko text processing primitives |
Appchain spec: 764 lines at `docs/appchain-mining-spec.md` covering mining rules, bridge contracts, economic model, security analysis.
Fork base: Stacks `feat/app-chain-mvp` branch. Alpha quality, predates Nakamoto upgrade. Needs rebase against v3.[ip].
What Gets Embedded as Clarity Native Functions
5 new native functions that no other Stacks appchain has:
(graph-query context predicate depth) -> context-slice
(verify-admissibility token principal) -> bool
(rag-search embedding-hash k) -> (list results)
(render-inscription dynamics claim-type) -> inscription-id
(analyze-semantic-state text) -> operator-treeThese run inside the block validator at Rust speed, not Clarity interpreter speed.
5-Phase Build Sequence
### Phase A: Standalone Appchain (4-6 weeks)
- Fork stacks-core, rebase against v3.[ip]
- Write mining contract (agent-weighted, 2-second blocks)
- Boot testnet node
- Gate: Node boots, produces blocks, mines correctly
### Phase B: Graph Kernel Embedding (2-3 weeks)
- Replace PostgresGraphStore with embedded SQLite
- Port 14,953 lines into stacks-node as a Rust module
- Expose `graph-query` and `verify-admissibility` as native functions
- Gate: Clarity contract calls `(graph-query ...)` and gets deterministic results
### Phase C: N'Ko Inscription Native (2 weeks)
- Port cc-inscription (22,881 lines) into node
- `render-inscription` becomes native function
- InscriptionId computation happens in consensus (all validators agree)
- Gate: Inscription committed via Clarity, verified by all nodes
### Phase D: RAG++ Vector Search (3-4 weeks)
- Extract core algorithm from cc-rag-plus-plus (remove pgvector dependency)
- Fixed-size embeddings (u8[256])
- `rag-search` as native precompile (500 gas per query)
- Gate: Contract queries vector similarity, gets ranked results
### Phase E: ΨChain Activation (2 weeks)
- Connect all 5 native functions
- Deploy EPOCH V2 contracts on the appchain
- Migrate inscriptions from Stacks L1 to appchain
- Revenue ring operates on dedicated chain
- Gate: Full epoch rotation (6-phase) running with native services
Why This Matters
| Metric | Current (L1 + Docker) | Appchain (Native Rust) |
|---|---|---|
| Block time | 10 min (Stacks L1) | 2 seconds |
| GK query | ~50ms (HTTP + network) | ~1ms (in-process) |
| Inscription | External service call | Consensus-validated |
| RAG search | Docker container + pgvector | Native precompile |
| Throughput | Shared with all Stacks apps | Dedicated blockspace |
| Daily inscriptions | Limited by L1 fees | ~3.6 MB/year, feasible |
Critical Risks
1. Rebase risk: feat/app-chain-mvp predates Nakamoto. Rebase may break.
- Fallback: Cosmos SDK with Bitcoin sidechain bridge
2. GPL v3: All code in stacks-core fork inherits GPL v3. EPOCH Rust crates become open source.
3. Validator determinism: All native functions must produce identical results across all nodes. No floating point, no randomness, no external I/O.
4. Maintenance burden: Keeping a Stacks fork in sync with upstream requires ongoing effort.
First Step
git clone https://github.com/stacks-network/stacks-blockchain.git Desktop/stacks-appchain
cd Desktop/stacks-appchain
git checkout feat/app-chain-mvp
git checkout -b epoch-appchain-v1
# Attempt rebase against latest
git rebase origin/developIf rebase succeeds, the path is clear. If it fails catastrophically, evaluate Cosmos SDK alternative.
Promotion Decision
Promote into a technical note or architecture paper with implementation anchors.
Source Anchor
omega-output/epoch-v2-upgrade-20260320/06-appchain-architecture.md
Detected Structure
Method · Evaluation · Architecture · is Stage Research