18b03db272
P2 (Wave 2, feat) — REQ-189, REQ-200, REQ-201, REQ-207 New components: - core/metrics/collector.py — reads all grounded signals (REGRESSION_REPORT.json, per-run manifests, junit XML, coverage.json, decision ledger, lifecycle reports) → SQLite cold store (metrics/nova_metrics.db) with fact_run, fact_capability, fact_policy_check, fact_confidence, fact_test, fact_decision, fact_cost_estimate, fact_lifecycle, dim_capability, dim_milestone tables - core/metrics/decision_ledger_cli.py — CLI with query/verify-chain/stats/export/replay - tests/test_metrics_collector.py — 7 tests (all pass, incl. idempotent re-run REQ-200) D-120: Nova-native (SQLite, no ClickHouse) D-125: hybrid (reads files + events → SQLite) D-126: cold-only (no hot path) ---ci--- project: acdl phase: 2 milestone: v1.17 status: execute ---/ci---
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
"""Nova Decision Ledger CLI (REQ-207).
|
|
|
|
Subcommands: query, verify-chain, stats, export, replay.
|
|
Read-only CLI for the Decision Ledger SQLite hash-chain.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
|
from core.metrics.decision_ledger import query_by_run, verify_chain, stats, export_since, replay_run
|
|
|
|
|
|
def main():
|
|
if len(sys.argv) < 2:
|
|
print("usage: decision_ledger_cli.py <query|verify-chain|stats|export|replay> [args]", file=sys.stderr)
|
|
sys.exit(2)
|
|
cmd = sys.argv[1]
|
|
if cmd == "query" and len(sys.argv) >= 3:
|
|
print(json.dumps(query_by_run(sys.argv[2]), indent=2))
|
|
elif cmd == "verify-chain":
|
|
ok, broken, details = verify_chain()
|
|
print(f"chain_ok={ok} broken={broken} details={details}")
|
|
sys.exit(0 if ok else 1)
|
|
elif cmd == "stats":
|
|
print(json.dumps(stats(), indent=2))
|
|
elif cmd == "export" and len(sys.argv) >= 3:
|
|
fmt = sys.argv[3] if len(sys.argv) >= 4 else "json"
|
|
print(export_since(sys.argv[2], fmt=fmt))
|
|
elif cmd == "replay" and len(sys.argv) >= 3:
|
|
print(replay_run(sys.argv[2]))
|
|
else:
|
|
print(f"unknown command: {cmd}", file=sys.stderr)
|
|
sys.exit(2)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |