Skip to content

docs: Constellation metagraph integration analysis + Phase 1 MPT spec#107

Open
ottobot-ai wants to merge 1 commit intoscasplte2:mainfrom
ottobot-ai:docs/metagraph-integration-analysis
Open

docs: Constellation metagraph integration analysis + Phase 1 MPT spec#107
ottobot-ai wants to merge 1 commit intoscasplte2:mainfrom
ottobot-ai:docs/metagraph-integration-analysis

Conversation

@ottobot-ai
Copy link
Collaborator

Summary

Validates the Constellation metagraph integration approach and specifies Phase 1 implementation (MPT state commitment).

Trello: Analysis: Validate Constellation metagraph integration approach (6996301a)

Validation Results — All GREEN

Primitive Status
OttochainMessage extends DataUpdate wire format ✅ Live today, no Tessellation changes
hashCalculatedState → L0 commitment pathway ✅ Already wired end-to-end
MPT implementation in metakit ✅ Full MerklePatriciaProducer/Prover/Verifier
ML0 rejection handling for new variants ✅ PR #92 covers any DataUpdate subtype
onGlobalSnapshotPull hook (Phase 3) ✅ Real hook in Tessellation source

Phase 1 Spec (Implementation-Ready)

Scope: Add MPT state roots to OttoChain, enabling cryptographic proof of fiber state without full state download.

Changes:

  1. StateMachineFiberRecord + stateRoot: Hash field
  2. CalculatedState + metagraphStateRoot: Hash field
  3. FiberCombiner: computeFiberStateRoot via MerklePatriciaProducer.inMemory
  4. Top-level combiner: computeMetagraphStateRoot aggregates all fiber roots
  5. ML0Service.hashCalculatedState → returns state.metagraphStateRoot
  6. GET /state-proof/:fiberId — inclusion proof endpoint

15 TDD tests defined in 5 groups (fiber roots, metagraph root, hashCalculatedState, proof API, backward compatibility).

Open Questions (Non-Blocking for Phase 1)

  • OQ-1: TokenUnlock semantics for DAG reward emission — needs Constellation team
  • OQ-2: GlobalSnapshotInfo field contents for Phase 3
  • OQ-3: Proto migration timing — should stateRoot be added to proto (card 699621e1) at same time?

5-Type Trie Mapping Clarification

Tokenized-streams protocol dimensions (Permissions/Relationships/Activities/Assets/Group) map to stateData fields inside fibers, not separate metagraph-level tries. One per-fiber MPT covers all dimensions. No structural changes to the metagraph data model needed.

Refs: docs/proposals/state-commitment-mpt.md (6-phase proposal, Phase 1 is this card)

Validates the asset model integration approach and specs Phase 1 MPT
state commitment implementation. All primitives confirmed in production.

Key findings:
- Wire format: OttochainMessage extends DataUpdate — no Tessellation changes
- hashCalculatedState pathway already wired to L0 anchoring
- MPT fully implemented in metakit — zero new dependencies
- ML0 rejection handling works for any new AssetUpdate variants

Phase 1 implementation:
- Add stateRoot to StateMachineFiberRecord
- Add metagraphStateRoot to CalculatedState
- computeFiberStateRoot in FiberCombiner (MerklePatriciaProducer.inMemory)
- Override hashCalculatedState with MPT root
- GET /state-proof/:fiberId ML0 route for inclusion proofs

15 TDD tests in 5 groups defined.

Open questions (non-blocking for Phase 1):
- OQ-1: TokenUnlock semantics (Phase 2 reward emission)
- OQ-2: GlobalSnapshotInfo contents (Phase 3 cross-metagraph)
- OQ-3: Proto migration timing coordination

Refs: Trello 6996301a, docs/proposals/state-commitment-mpt.md
ottobot-ai added a commit to ottobot-ai/ottochain that referenced this pull request Feb 26, 2026
…StateRoot via MPT

Add cryptographic state commitment infrastructure for Constellation metagraph integration (Phase 1).

## Schema Changes

### StateMachineFiberRecord (Records.scala)
- Add `stateRoot: Option[Hash] = None`
- Computed from per-fiber stateData fields via MerklePatriciaProducer.stateless
- Key: UTF-8 hex of field name, Value: JSON-encoded field value
- Backward compatible: defaults to None, existing snapshots decode cleanly

### CalculatedState (CalculatedState.scala)
- Add `metagraphStateRoot: Option[Hash] = None`
- Computed per snapshot from all fiber stateRoots (fiberId → stateRoot MPT)
- Backward compatible: defaults to None

## FiberCombiner changes
- `computeStateRoot` helper: builds MPT from MapValue stateData fields
- `createStateMachineFiber`: computes initial stateRoot from initialData
- `handleCommittedOutcome`: recomputes stateRoot for all updated fibers

## ML0Service changes
- `computeMetagraphStateRoot`: MPT of all (fiberId → fiberStateRoot) pairs
- `combine`: applies metagraphStateRoot computation after all updates
- `hashCalculatedState`: uses metagraphStateRoot when present, falls back to computeDigest

## Tests
- MetagraphIntegrationSuite: 15 passing tests across 5 groups
  - Group 1: StateMachineFiberRecord.stateRoot field (3 tests)
  - Group 2: CalculatedState.metagraphStateRoot field (3 tests)
  - Group 3: Schema consistency (3 tests)
  - Group 4: hashCalculatedState conditional logic (3 tests)
  - Group 5: State proof API readiness preconditions (3 tests)
- All 252 shared-data tests pass

Closes Trello card: 6996301a4dba20da34b4fc9e
Depends on spec: PR scasplte2#107 (docs/metagraph-integration-analysis)
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