genesis.py file-level

at sha256:c · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:8 docs: queue board-identity follow-ups so they survive the session Capt… · aaronrene · Sep 5, 2026
1 """Ledger genesis constant and entry factory (§K9.7)."""
2
3 from __future__ import annotations
4
5 import hashlib
6 from datetime import datetime, timezone
7 from typing import Any
8
9 from tools.honesty.canonical import compute_entry_hash
10
11 _GENESIS_SEED = b"overseer-kit-honesty-ledger-v1"
12 GENESIS_PREV = hashlib.sha256(_GENESIS_SEED).hexdigest().lower()
13
14
15 def utc_now_z() -> str:
16 """Return ISO-8601 UTC timestamp with ``Z`` suffix."""
17 return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
18
19
20 def build_genesis_entry(ts: str | None = None) -> dict[str, Any]:
21 """Construct a genesis ledger entry with server-filled hashes."""
22 timestamp = ts or utc_now_z()
23 body: dict[str, Any] = {
24 "v": 1,
25 "ts": timestamp,
26 "kind": "genesis",
27 "prev_hash": GENESIS_PREV,
28 }
29 body["entry_hash"] = compute_entry_hash(body)
30 return body