Skip to content

Commit 5423e48

Browse files
authored
Create INDEXING_SPEC.md
1 parent afc278d commit 5423e48

1 file changed

Lines changed: 130 additions & 0 deletions

File tree

INDEXING_SPEC.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Off-chain Read Model & Indexing Specification
2+
3+
## Purpose
4+
This document defines the canonical off-chain read model for VeriSphere.
5+
It enables deterministic, fast querying of protocol state without duplicating or redefining on-chain logic.
6+
7+
This specification is **descriptive, not normative**: smart contracts remain the sole authority.
8+
9+
---
10+
11+
## Authority Model
12+
13+
### On-chain (authoritative)
14+
The following contracts define protocol truth:
15+
16+
- PostRegistry — claims and links
17+
- LinkGraph — DAG structure and support/challenge semantics
18+
- StakeEngine — stake custody and epoch mechanics
19+
- ScoreEngine — base and effective Veracity Score (VS)
20+
21+
All off-chain data **must be reproducible** from these contracts.
22+
23+
### Off-chain (derivative)
24+
Indexers MAY:
25+
- cache view calls
26+
- denormalize state
27+
- accelerate queries
28+
29+
Indexers MUST NOT:
30+
- compute VS independently
31+
- invent semantics
32+
- override on-chain results
33+
34+
---
35+
36+
## Indexed Entities
37+
38+
### Claim
39+
- postId
40+
- creator
41+
- timestamp
42+
- text
43+
44+
Source:
45+
- PostRegistry.PostCreated
46+
- PostRegistry.getPost
47+
- PostRegistry.getClaim
48+
49+
### Link
50+
- postId
51+
- independentClaimPostId
52+
- dependentClaimPostId
53+
- isChallenge
54+
55+
Source:
56+
- PostRegistry.createLink
57+
- LinkGraph.EdgeAdded
58+
59+
### Stake Summary
60+
- postId
61+
- supportTotal
62+
- challengeTotal
63+
64+
Source:
65+
- StakeEngine.getPostTotals
66+
67+
### Score Snapshot (cached)
68+
- postId
69+
- baseVSRay
70+
- effectiveVSRay
71+
- blockNumber
72+
73+
Source:
74+
- ScoreEngine view calls
75+
76+
---
77+
78+
## Event Sources
79+
80+
Indexers MUST subscribe to:
81+
- PostRegistry.PostCreated
82+
- LinkGraph.EdgeAdded
83+
- StakeEngine.StakeAdded
84+
- StakeEngine.StakeWithdrawn
85+
- StakeEngine.PostUpdated
86+
87+
View calls MAY be executed after event ingestion.
88+
89+
---
90+
91+
## Query Patterns
92+
93+
Supported queries include:
94+
- claim detail pages
95+
- incoming/outgoing link graphs
96+
- VS visualization
97+
- stake distributions
98+
- historical VS snapshots
99+
100+
---
101+
102+
## Rebuild Guarantees
103+
104+
A valid indexer must be able to:
105+
1. Start from block 0
106+
2. Replay all events
107+
3. Call only public view functions
108+
4. Reconstruct indexed state exactly
109+
110+
Failure implies a non-compliant indexer.
111+
112+
---
113+
114+
## Artifacts
115+
116+
Non-textual artifacts (images, videos, PDFs):
117+
- are optional
118+
- are off-chain only
119+
- have no protocol semantics
120+
- are referenced only via claim text
121+
122+
Indexers may ignore them entirely.
123+
124+
---
125+
126+
---
127+
128+
## Deliverables
129+
- This specification
130+
- No contract changes

0 commit comments

Comments
 (0)