genesis.py python
30 lines 875 B
Raw
sha256:106ef9e12cca7f3be3ffb2a6bd3abfa76f032dce453c9e5010d732a8d86f2e14 Reconcile reviewed credential compatibility 32254cd939885d9… Human patch 8 days ago
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
File History 2 commits
sha256:106ef9e12cca7f3be3ffb2a6bd3abfa76f032dce453c9e5010d732a8d86f2e14 Reconcile reviewed credential compatibility 32254cd939885d9… Human patch 8 days ago
sha256:c87cf2c2f03da507f66f93922cb339a2cbebb33ad6372a6039032fb09a20da12 Reconcile reviewed Overseer recovery d47291d5d9030de5ebef71… Human minor ⚠ 8 days ago