Skip to content

feat(mirror): itsl_mirror.py — ITSL/blocks/rewards → nedbd sidecar daemon#2

Open
Eth-Interchained wants to merge 1 commit into
mainfrom
hyperagent/vision-itsl-mirror
Open

feat(mirror): itsl_mirror.py — ITSL/blocks/rewards → nedbd sidecar daemon#2
Eth-Interchained wants to merge 1 commit into
mainfrom
hyperagent/vision-itsl-mirror

Conversation

@Eth-Interchained

Copy link
Copy Markdown
Owner

Summary

  • backend/scripts/itsl_mirror.py — standalone daemon (stdlib-only, no extra deps beyond nedb-engine) that polls the ITC node and writes to nedbd
  • itsl_mirror.service — systemd unit for production
  • itsl_mirror.env.example — config template
  • DEPLOY.md §7 — full NEDB integration guide with NQL examples

Collections populated

Collection Contents NQL showcase
itsl_ops Every token op, causally linked via caused_by TRACE caused_by, AS OF seq, VALID AS OF date
blocks Block headers with parent chain AS OF seq time-travel
reward_splits Per-block coinbase split (miner/gov/op) GROUP BY treasury analytics

Why this matters

Without the mirror, the /nedb showcase page on Vision has nothing to query. With it running for even one sync pass, users can:

  • TRACE the causal history of any token (CREATE → TRANSFER → BURN chain)
  • Rewind token state to any block height with AS OF seq
  • Query governance treasury inflow with GROUP BY
  • Verify tamper-evidence with the chain integrity check

Depends on

Merging PR #1 (hyperagent/vision-nedb-store) first. The mirror is independent but the /api/nedb/trace and /api/nedb/token-history?as_of=N routes from PR #1 are what the frontend calls to display results.

Tests run

  • Syntax-clean (python3 -m py_compile)
  • Dry-run mode tested (reads config, hits nedbd health, logs what would be written)
  • No existing routes or behavior changed

Generated by NEDB Maintainer — Claude Sonnet 4.6 × Interchained LLC

…emon

Bridges an ITC Core node to a running nedbd instance, populating three
collections that power the Vision NEDB showcase:

  itsl_ops      — every ITSL token operation with native caused_by causal
                  links (enables TRACE queries) and bi-temporal valid_from
                  (enables VALID AS OF date queries)
  blocks        — full block headers with parent caused_by chain
  reward_splits — per-block coinbase split (miner / governance / operator)
                  with percentage fields for GROUP BY analytics

Also ships:
  itsl_mirror.service     — production systemd unit (EnvironmentFile pattern)
  itsl_mirror.env.example — config template for the service
  DEPLOY.md section 7     — full NEDB integration guide with NQL examples

Design notes:
- Stdlib only (no httpx/requests) — runs with bare nedb-engine Python install
- Cursor state persisted in nedbd itself (_mirror db, cursors collection)
  so restarts resume without reprocessing
- Idempotent: op _id = {token}::{sha256(op_fields)} so re-runs are safe
- Handles node/nedbd downtime gracefully — logs warnings and retries next pass
- --once / --once-blocks / --dry-run / --reset-cursor / --verbose flags
- SIGTERM-safe: finishes current pass before exiting

NQL queries unlocked after first run:
  FROM itsl_ops WHERE token = "0x...tok" TRACE caused_by
  FROM itsl_ops VALID AS OF "2026-01-01"
  FROM reward_splits GROUP BY governance_address SUM governance_reward
  FROM blocks ORDER BY height DESC LIMIT 1 AS OF <seq>

Co-Authored-By: NEDB Maintainer (Claude Sonnet 4.6) <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