types.py python
95 lines 2.0 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 21 hours ago
1 """Shared types for the L1 checkpoint orchestrator."""
2
3 from __future__ import annotations
4
5 from dataclasses import dataclass, field
6 from typing import Any, Literal
7
8 VerifyMode = Literal["step", "through", "all"]
9 ErrorToken = Literal[
10 "usage",
11 "config",
12 "refused",
13 "step_order",
14 "verify_fail",
15 "io",
16 None,
17 ]
18
19
20 @dataclass
21 class StepState:
22 """One manifest step entry."""
23
24 verified: bool = False
25 verified_at: str | None = None
26 artifact_sha256: str | None = None
27
28
29 @dataclass
30 class ManifestState:
31 """Parsed active work-unit manifest."""
32
33 schema_version: int
34 template_id: str
35 slug: str
36 current_step: str
37 steps: dict[str, StepState]
38 meta: dict[str, Any] = field(default_factory=dict)
39 source_path: str = ""
40
41
42 @dataclass
43 class StepDef:
44 """One policy step definition."""
45
46 verify_script: str
47 description: str | None = None
48
49
50 @dataclass
51 class PolicyState:
52 """Parsed checkpoint policy."""
53
54 version: int
55 placeholder_tokens: list[str]
56 steps: dict[str, StepDef]
57 templates: dict[str, list[str]]
58 overrides_default: dict[str, Any]
59 overrides_by_template: dict[str, dict[str, Any]]
60 source_path: str = ""
61
62
63 @dataclass
64 class VerifyStepJson:
65 """Frozen verify-step JSON schema payload."""
66
67 ok: bool
68 exit_code: int
69 command: str = "verify-step"
70 mode: VerifyMode | None = None
71 dry_run: bool = False
72 manifest: str | None = None
73 steps: list[dict[str, Any]] = field(default_factory=list)
74 error: ErrorToken = None
75
76 def to_dict(self) -> dict[str, Any]:
77 return {
78 "ok": self.ok,
79 "exit_code": self.exit_code,
80 "command": self.command,
81 "mode": self.mode,
82 "dry_run": self.dry_run,
83 "manifest": self.manifest,
84 "steps": self.steps,
85 "error": self.error,
86 }
87
88
89 @dataclass
90 class VerifyStepResult:
91 """Outcome of ``run_verify_step``."""
92
93 exit_code: int
94 json_payload: VerifyStepJson
95 stderr_extra: str = ""
File History 2 commits
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 21 hours ago
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 52 days ago