types.py
python
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439
feat: K1-P1 complete — agent provenance, build-verification…
Sonnet 4.6
patch
56 days 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 | "approval_integrity", |
| 14 | "ledger_broken", |
| 15 | "role_violation", |
| 16 | "evidence_free", |
| 17 | "io", |
| 18 | None, |
| 19 | ] |
| 20 | |
| 21 | ENTRY_KINDS = frozenset( |
| 22 | { |
| 23 | "genesis", |
| 24 | "task_assigned", |
| 25 | "verdict", |
| 26 | "dispute_opened", |
| 27 | "overseer_ruling", |
| 28 | "approval_recorded", |
| 29 | "board_advance", |
| 30 | "hook_check", |
| 31 | } |
| 32 | ) |
| 33 | |
| 34 | ACTOR_ROLES = frozenset({"owner", "overseer", "producer", "verifier"}) |
| 35 | |
| 36 | HOOK_NAMES = frozenset({"board_done", "handoff", "register"}) |
| 37 | |
| 38 | |
| 39 | class EntryValidationError(Exception): |
| 40 | """Raised when an append body fails schema or role checks.""" |
| 41 | |
| 42 | def __init__(self, exit_code: int, message: str) -> None: |
| 43 | super().__init__(message) |
| 44 | self.exit_code = exit_code |
| 45 | |
| 46 | |
| 47 | @dataclass |
| 48 | class HonestyStatusJson: |
| 49 | """Frozen honesty-status JSON schema payload (§K9.9).""" |
| 50 | |
| 51 | ok: bool |
| 52 | exit_code: int |
| 53 | command: str = "honesty-status" |
| 54 | hook: str | None = None |
| 55 | artifact: str | None = None |
| 56 | artifact_sha256: str | None = None |
| 57 | producer_session: str | None = None |
| 58 | matched_verdict_hash: str | None = None |
| 59 | error: HonestyErrorToken = None |
| 60 | |
| 61 | def to_dict(self) -> dict[str, Any]: |
| 62 | return { |
| 63 | "ok": self.ok, |
| 64 | "exit_code": self.exit_code, |
| 65 | "command": self.command, |
| 66 | "hook": self.hook, |
| 67 | "artifact": self.artifact, |
| 68 | "artifact_sha256": self.artifact_sha256, |
| 69 | "producer_session": self.producer_session, |
| 70 | "matched_verdict_hash": self.matched_verdict_hash, |
| 71 | "error": self.error, |
| 72 | } |
| 73 | |
| 74 | |
| 75 | @dataclass |
| 76 | class HonestyStatusResult: |
| 77 | """Outcome of ``run_honesty_status``.""" |
| 78 | |
| 79 | exit_code: int |
| 80 | json_payload: HonestyStatusJson |
| 81 | stderr_extra: str = "" |
| 82 | |
| 83 | |
| 84 | @dataclass |
| 85 | class LedgerAppendOptions: |
| 86 | """Input for ``append_entry``.""" |
| 87 | |
| 88 | kind: str |
| 89 | body: dict[str, Any] = field(default_factory=dict) |
| 90 | from_stdin: bool = False |
| 91 | file_path: str | None = None |
| 92 | |
| 93 | |
| 94 | @dataclass |
| 95 | class LedgerResult: |
| 96 | """Generic ledger command outcome.""" |
| 97 | |
| 98 | exit_code: int |
| 99 | stdout_lines: list[str] = field(default_factory=list) |
| 100 | stderr_extra: str = "" |
File History
1 commit
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439
feat: K1-P1 complete — agent provenance, build-verification…
Sonnet 4.6
patch
56 days ago