genesis.py python
30 lines 875 B
Raw
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83 chore(governance): sync handover+roadmap to 84db8c8 (drift:… Human 2 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 1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199 fix(ISR): default require_independent_second_reviewer to require Human minor 2 days ago