types.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
13 hours ago
| 1 | """Shared types for the L2 honesty module.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from dataclasses import dataclass, field |
| 6 | from typing import Any, Literal |
| 7 | |
| 8 | HonestyErrorToken = Literal[ |
| 9 | "usage", |
| 10 | "config", |
| 11 | "refused", |
| 12 | "missing_verdict", |
| 13 | "missing_verification_evidence", |
| 14 | "missing_deploy_health", |
| 15 | "missing_independent_second_review", |
| 16 | "approval_integrity", |
| 17 | "ledger_broken", |
| 18 | "role_violation", |
| 19 | "evidence_free", |
| 20 | "io", |
| 21 | None, |
| 22 | ] |
| 23 | |
| 24 | ENTRY_KINDS = frozenset( |
| 25 | { |
| 26 | "genesis", |
| 27 | "task_assigned", |
| 28 | "verdict", |
| 29 | "dispute_opened", |
| 30 | "overseer_ruling", |
| 31 | "approval_recorded", |
| 32 | "board_advance", |
| 33 | "hook_check", |
| 34 | "verification_evidence", |
| 35 | "independent_second_review", |
| 36 | } |
| 37 | ) |
| 38 | |
| 39 | VERIFICATION_ARTIFACT_TYPES = frozenset({"test_output", "deploy_health", "screenshot"}) |
| 40 | BV_VERDICTS = frozenset({"pass", "findings", "blocked"}) |
| 41 | ISR_VERDICTS = frozenset({"pass", "findings", "blocked"}) |
| 42 | |
| 43 | ACTOR_ROLES = frozenset({"owner", "overseer", "producer", "verifier"}) |
| 44 | |
| 45 | HOOK_NAMES = frozenset({"board_done", "handoff", "register"}) |
| 46 | |
| 47 | |
| 48 | class EntryValidationError(Exception): |
| 49 | """Raised when an append body fails schema or role checks.""" |
| 50 | |
| 51 | def __init__(self, exit_code: int, message: str) -> None: |
| 52 | super().__init__(message) |
| 53 | self.exit_code = exit_code |
| 54 | |
| 55 | |
| 56 | @dataclass |
| 57 | class HonestyStatusJson: |
| 58 | """Frozen honesty-status JSON schema payload (§K9.9).""" |
| 59 | |
| 60 | ok: bool |
| 61 | exit_code: int |
| 62 | command: str = "honesty-status" |
| 63 | hook: str | None = None |
| 64 | artifact: str | None = None |
| 65 | artifact_sha256: str | None = None |
| 66 | producer_session: str | None = None |
| 67 | matched_verdict_hash: str | None = None |
| 68 | error: HonestyErrorToken = None |
| 69 | verification_evidence: dict[str, Any] | None = None |
| 70 | deploy_health: dict[str, Any] | None = None |
| 71 | independent_second_review: dict[str, Any] | None = None |
| 72 | |
| 73 | def to_dict(self) -> dict[str, Any]: |
| 74 | payload: dict[str, Any] = { |
| 75 | "ok": self.ok, |
| 76 | "exit_code": self.exit_code, |
| 77 | "command": self.command, |
| 78 | "hook": self.hook, |
| 79 | "artifact": self.artifact, |
| 80 | "artifact_sha256": self.artifact_sha256, |
| 81 | "producer_session": self.producer_session, |
| 82 | "matched_verdict_hash": self.matched_verdict_hash, |
| 83 | "error": self.error, |
| 84 | } |
| 85 | if self.verification_evidence is not None: |
| 86 | payload["verification_evidence"] = self.verification_evidence |
| 87 | if self.deploy_health is not None: |
| 88 | payload["deploy_health"] = self.deploy_health |
| 89 | if self.independent_second_review is not None: |
| 90 | payload["independent_second_review"] = self.independent_second_review |
| 91 | return payload |
| 92 | |
| 93 | |
| 94 | @dataclass |
| 95 | class HonestyStatusResult: |
| 96 | """Outcome of ``run_honesty_status``.""" |
| 97 | |
| 98 | exit_code: int |
| 99 | json_payload: HonestyStatusJson |
| 100 | stderr_extra: str = "" |
| 101 | |
| 102 | |
| 103 | @dataclass |
| 104 | class LedgerAppendOptions: |
| 105 | """Input for ``append_entry``.""" |
| 106 | |
| 107 | kind: str |
| 108 | body: dict[str, Any] = field(default_factory=dict) |
| 109 | from_stdin: bool = False |
| 110 | file_path: str | None = None |
| 111 | |
| 112 | |
| 113 | @dataclass |
| 114 | class LedgerResult: |
| 115 | """Generic ledger command outcome.""" |
| 116 | |
| 117 | exit_code: int |
| 118 | stdout_lines: list[str] = field(default_factory=list) |
| 119 | stderr_extra: str = "" |
File History
2 commits
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
13 hours ago
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439
feat: K1-P1 complete — agent provenance, build-verification…
Sonnet 4.6
patch
52 days ago