mirror of
https://github.com/allaunthefox/Research-Stack.git
synced 2026-07-31 03:05:21 +00:00
16 KiB
16 KiB
Unified JSON-L Schema Specification — Manifold Ingestion Stream
Version: 1.0
Status: ACTIVE — replaces discrete Notion/Linear/ENE shims
Ground Truth: 0-Core-Formalism/lean/Semantics/ (bind bridge invariant preservation)
Target: data/substrate_index.db — unified ENE substrate
1. Design Principles
- Single Source of Truth: Every state change — whether from Notion, Linear, ENE, or the blockchain proxy — reduces to one JSON-L line. The ENE SQLite substrate is the manifold.
- Bind Bridge Compliance: Every event carries a
bindstruct withlawful(Bool),cost(Q16_16 UInt32), andinvariant(String). No Python/Rust shim may compute cost; it is extracted from Lean or propagated from upstream. - Temporal Immutability:
tis the single time axis. Events are append-only. Corrections are new events withop: "correct"referencingprev_id. - Genome Addressability: Every event MAY carry a
genomefield. If present, it is a 6D quantized signature deterministically hashable to an 18-bit address (address = genome.hash() & 0x3FFFF). This allows the event to be routed into the same hierarchical multicast buckets as blockchain blocks. - No Open Strings in Decisions: The
srcfield isFin 5(notion, linear, ene, rgflow, swarm). Theopfield isFin 5(upsert, delete, snapshot, correct, attest). All other categorical fields use finite enumerations.
2. Mandatory Root Fields
| Field | Type | Description |
|---|---|---|
t |
f64 |
Unix timestamp with millisecond resolution. Monotonic within a single src. |
src |
Fin 5 |
Origin: notion, linear, ene, rgflow, swarm. |
id |
String |
Unique within src. Format: <src>:<uuid> or deterministic hash. |
op |
Fin 5 |
upsert | delete | snapshot | correct | attest. |
data |
Dict |
Source-specific payload. Schema varies by src (see §4). |
genome |
Genome (optional) |
6D quantized spectral signature for RGFlow routing. |
bind |
Bind (optional) |
Cost, lawful check, invariant extractor. Required for CORE-tier events. |
provenance |
Provenance |
Node, lake seed, and attestation chain. |
3. Common Sub-Structures
3.1 Genome — RGFlow Addressable Signature
{
"mu": 0, // UInt8 — compression ratio bin (0..7)
"rho": 0, // UInt8 — information density bin (0..7)
"c": 0, // UInt8 — thermodynamic cost bin (0..7)
"m": 0, // UInt8 — manifold curvature bin (0..7)
"ne": 0, // UInt8 — negentropy flux bin (0..7)
"sig": 0 // UInt8 — signal-to-noise bin (0..7)
}
- Address:
address = (mu << 15) | (rho << 12) | (c << 9) | (m << 6) | (ne << 3) | sig→ 18-bit value0..262143. - Bucket:
bucket = address >> 15→ top 3 bits,0..7. Used for multicast routing. - Determinism: Every
srcMUST define a pure functionevent → Genomewith no randomness. The genome is a lossy projection ofdata, not a hash.
3.2 Bind — Invariant Preservation Witness
{
"lawful": true, // Bool — does this event preserve all invariants?
"cost": 65536, // UInt32 Q16_16 — computational/thermodynamic cost
"invariant": "bindPreservesState: t_k+1 > t_k => forwardBlit", // String
"class": "informational_bind" // Fin 5: informational | geometric | thermodynamic | physical | control
}
- Cost computation: For
rgflowevents, cost is the byte count of the compressed genome. Foreneevents, cost is the L2 norm of the concept vector scaled to Q16_16. Fornotion/linear, cost is fixed at0x00010000(1.0) until a Lean cost function is extracted. - Rule: If
lawful == false, the event is written to the substrate but flagged inswarm_work_queuefor review. No downstream manifold blit occurs.
3.3 Provenance — Attestation Chain
{
"node": "qfox", // String — hostname of originating node
"lake_seed": "nnyyP7DoHS11CNTRL", // String — Tailscale stable node ID
"tailscale_ip": "100.105.111.120", // String — for routing verification
"attestation_hash": "sha256:...", // String — cumulative hash of event + prev attestation
"prev_id": null // String or null — previous event in causal chain
}
- Attestation: Every event is attested by the node that generated it. The hash chain allows
back-trace re-syncwhen out-of-order events are detected. - Swarm propagation: When an event is pushed via
/sync/manifest, theprovenance.nodefield is updated to the forwarding node, preserving the original in a nestedoriginfield.
4. Source-Specific data Schemas
4.1 src: "notion" — Document Hierarchy Event
{
"page_id": "7a27bd85-9ff0-44fe-b873-7bb90f2a91a0",
"block_id": "...",
"parent_id": "...",
"title": "Quantum Hamiltonian Manifold",
"content_hash": "b3f5...f6bf",
"last_edited_time": "2026-04-24T13:42:00.000Z",
"property_changes": {
"Status": {"old": "Draft", "new": "Review"}
}
}
- Genome mapping:
mu = len(title) % 8,rho = popcount(content_hash) % 8,c = property_changes.count % 8,m = 4(stable document),ne = 7(high semantic density),sig = tier_index("RESEARCH"). - ENE mapping: Upsert into
packagestable.pkg = notion/<page_id>,archetype = "document",concept_anchor.resolution = property_changes["Status"].new.
4.2 src: "linear" — Causal Dependency Event
{
"issue_id": "RES-7",
"linear_id": "d8f2c1b4-...",
"title": "Implement bind bridge for Q16_16",
"state": {"old": "Todo", "new": "In Progress"},
"priority": {"old": 2, "new": 1},
"assignee": {"old": null, "new": "allaun"},
"blocked_by": ["RES-3", "RES-5"],
"identifier": "RES-7"
}
- Genome mapping:
mu = priority.new % 8,rho = len(blocked_by) % 8,c = state_transition_cost(state.old, state.new),m = 2(forming),ne = assignee.new ? 4 : 0,sig = 0. - ENE mapping: Upsert into
packages.pkg = linear/<issue_id>,archetype = "issue",session_id = linear_id.concept_anchor.resolutionmaps from Linear state:Todo→SEED,In Progress→FORMING,Done→STABLE,Canceled→RECOVERED.
4.3 src: "ene" — Substrate Atomic Ingestion
{
"pkg": "semantics/Adaptation",
"version": "2026-04-24T12:00:00Z",
"tier": "CORE",
"domain": "formalization",
"archetype": "lean_module",
"concept_anchor": {
"domain": "formalization",
"concept": "flow_audit_loop",
"resolution": "CRYSTALLIZED"
},
"concept_vector": [1.0, 0.618, 0.0, 0.0, 0.146, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
"idea_weights": {"bind primitive": 0.95, "Q16_16": 0.88},
"files": ["0-Core-Formalism/lean/Semantics/Adaptation.lean"],
"depends": ["semantics/Q16_16/2026-04-20T00:00:00Z"]
}
- Genome mapping: Derived from
concept_vectorvia axis quantization: each dimension is binned to 3 bits usingfloor(dim * 8 / max_dim). - ENE mapping: Direct upsert into
packagestable. All fields map 1:1.
4.4 src: "rgflow" — Blockchain Genome Event
{
"chain": "btc",
"height": 548000,
"block_hash": "0000000000000000000...",
"timestamp": 1777031220,
"genome": {"mu": 3, "rho": 7, "c": 2, "m": 5, "ne": 1, "sig": 6},
"address": 262143,
"bucket": 7,
"raw": {"size": 1456234, "tx_count": 2847, "difficulty": 1.23e14}
}
- Genome mapping: Already computed by
bitcoin_block_to_genome()/ethereum_block_to_genome()inscripts/blockchain_rgflow_proxy.py. Deterministic 6D quantization from block metadata. - ENE mapping: Upsert into
swarm_manifest.t = timestamp,node = provenance.node,genome = json.dumps(genome).
4.5 src: "swarm" — Topology / Work Queue Event
{
"event_type": "topology_change", // topology_change | task_complete | node_failure | sync_manifest
"hostname": "architect",
"tailscale_ip": "100.127.111.7",
"status": "active",
"latency_ms": 281.0,
"load": 0.34,
"manifest_inserted": 42 // only for sync_manifest events
}
- Genome mapping:
mu = latency_ms < 100 ? 0 : latency_ms < 300 ? 2 : 4,rho = load * 8 % 8,c = status == "active" ? 0 : 7,m = 4,ne = manifest_inserted > 0 ? 7 : 0,sig = 0. - ENE mapping: Upsert into
swarm_nodesorswarm_work_queuedepending onevent_type.
5. Manifold Convergence Rules
5.1 Forward Blit (Normal Case)
For any source, if Upsert(t_k) is followed by Upsert(t_{k+1}) where t_{k+1} > t_k:
- The event is lawful by monotonicity.
- The manifold state is updated via a forward blit:
state' = state ⊕ data. - The
bind.costis additive:cost_total = cost_total + bind.cost.
5.2 Back-Trace Re-Sync (Out-of-Order)
If an event arrives with t_k < t_latest:
- The event is written to the substrate with
op: "correct"andprev_idpointing to the event it supersedes. - A back-trace is initiated: the SRAM Scaffolding buffer (last 1024 events in
swarm_query_cache) is replayed fromt_ktot_latest. - Each replayed event is re-evaluated for
bind.lawful. If any event becomes unlawful, the entire segment is quarantined inswarm_work_queuewithstatus: "failed". - The manifold is reconstructed from the quarantine boundary forward.
5.3 SRAM Scaffolding Buffer
The buffer is a circular log of the last 1024 JSON-L events, stored in swarm_query_cache:
query_hash = sha256(event.id + event.t)subjects = event.srcresults = json.dumps(event)semantic_vector = event.genome || event.data.concept_vector || zeros(14)ttl = 86400(24 hours)
6. Ingestion Pipeline
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Notion │ │ Linear │ │ ENE │ │ RGFlow │
│ (pull) │ │ (webhook) │ │ ( Lake ) │ │ (ZMQ/WS) │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │ │
└─────────────────┴─────────────────┴─────────────────┘
│
┌──────▼──────┐
│ JSON-L │
│ Canonical │
│ Converter │
└──────┬──────┘
│
┌──────▼──────┐
│ Bind Bridge│
│ (Lean #eval│
│ or cached)│
└──────┬──────┘
│
┌────────────┼────────────┐
│ │ │
┌──────▼──────┐ ┌───▼────┐ ┌────▼─────┐
│ ENE SQLite │ │Swarm │ │Multicast │
│ substrate │ │Surface │ │239.255.x │
│ (master) │ │(mesh) │ │(buckets) │
└─────────────┘ └────────┘ └──────────┘
6.1 SQLite Insert Paths
src |
Target Table | Unique Key | Conflict Resolution |
|---|---|---|---|
notion |
packages |
pkg = notion/<page_id> |
REPLACE (newer t wins) |
linear |
packages |
pkg = linear/<issue_id> |
REPLACE |
ene |
packages |
(pkg, version) |
REPLACE |
rgflow |
swarm_manifest |
(chain, height) |
INSERT OR IGNORE |
swarm |
swarm_nodes / swarm_work_queue |
hostname / task_id |
REPLACE |
6.2 Swarm Surface Sync
After SQLite insertion on qfox:
- The push loop (
_push_loopinswarm_surface.py) broadcasts the new manifest entry to allactivepeers. - Peers receive via
/sync/manifestand insert into their local ENE DB. - If a peer is
offline, the entry remains in qfox's DB. When the peer comes back online, the pull loop (_pull_loop) catches up by querying/manifest?limit=1000.
7. Verification Requirements
Per AGENTS.md §4, every def that computes a cost or invariant must have a witness. The JSON-L schema enforces this via:
- Eval witness: Every
srcconverter script must include a#eval-style test block (in Lean) or a Pythonassertblock with expected output in a comment. - Theorem witness: The
Bindstruct must satisfybindPreservesInvariant : ∀ e : Event, e.bind.lawful → invariant(e.data) = invariant(state'). - Totality: No
partialfunctions in the conversion pipeline. Everyevent → Genomemapping is total and deterministic.
8. Example Stream
{"t":1777042800.000,"src":"rgflow","id":"rgflow:btc:548000","op":"upsert","data":{"chain":"btc","height":548000,"block_hash":"0000...dead","timestamp":1777042800,"address":42,"bucket":5,"raw":{"size":1456234,"tx_count":2847}},"genome":{"mu":3,"rho":7,"c":2,"m":5,"ne":1,"sig":6},"bind":{"lawful":true,"cost":65536,"invariant":"blockHashConserved","class":"informational_bind"},"provenance":{"node":"qfox","lake_seed":"nnyyP7DoHS11CNTRL","tailscale_ip":"100.105.111.120","attestation_hash":"sha256:abc...","prev_id":null}}
{"t":1777042801.000,"src":"linear","id":"linear:RES-7","op":"upsert","data":{"issue_id":"RES-7","title":"Implement bind bridge","state":{"old":"Todo","new":"In Progress"},"priority":1,"assignee":"allaun","blocked_by":["RES-3"]},"genome":{"mu":1,"rho":1,"c":3,"m":2,"ne":4,"sig":0},"bind":{"lawful":true,"cost":65536,"invariant":"stateTransitionValid","class":"control_bind"},"provenance":{"node":"qfox","lake_seed":"nnyyP7DoHS11CNTRL","tailscale_ip":"100.105.111.120","attestation_hash":"sha256:def...","prev_id":null}}
{"t":1777042802.000,"src":"ene","id":"ene:semantics/Adaptation:2026-04-24T12:00:00Z","op":"upsert","data":{"pkg":"semantics/Adaptation","version":"2026-04-24T12:00:00Z","tier":"CORE","domain":"formalization","archetype":"lean_module","concept_anchor":{"domain":"formalization","concept":"flow_audit_loop","resolution":"CRYSTALLIZED"},"concept_vector":[1.0,0.618,0.0,0.0,0.146,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],"files":["0-Core-Formalism/lean/Semantics/Adaptation.lean"]},"genome":{"mu":0,"rho":5,"c":0,"m":1,"ne":7,"sig":0},"bind":{"lawful":true,"cost":98304,"invariant":"theorem finalLawfulEqEventuallyLawful","class":"informational_bind"},"provenance":{"node":"qfox","lake_seed":"nnyyP7DoHS11CNTRL","tailscale_ip":"100.105.111.120","attestation_hash":"sha256:ghi...","prev_id":null}}
9. Migration Path
Phase 1 — Shim Unification (Now)
swarm_surface.pyexposes/sync/manifestand/topologyblockchain_rgflow_proxy.pywrites toswarm_manifestdirectlynotion.js→ add JSON-L exporter feeding ENEpackageslinear.js→ add JSON-L exporter feeding ENEpackages
Phase 2 — Lean Ground Truth
- Port
event → Genomemappings to Lean 4 (0-Core-Formalism/lean/Semantics/JsonL/Converter.lean) - Prove
bindPreservesInvariantfor eachsrcclass - Extract cost functions to Q16_16 (no Float in hot path)
Phase 3 — Hardware Extraction
- Verilog generator for JSON-L → genome address decoder
- FPGA Warden node runs bind bridge in hardware
Document ID: UNIFIED_JSONL_SCHEMA_v1
Authority: Human architect
Date: 2026-04-24