api_prompt.py python
48 lines 1.5 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago
1 """Injection-safe API review request payloads (§K5.5 / §K5.11)."""
2
3 from __future__ import annotations
4
5 import json
6 from typing import Any
7
8 from tools.freeze_reviewer.types import ChecklistItem
9
10 ARTIFACT_BEGIN = "-----BEGIN OVERSEER FREEZE ARTIFACT (DATA ONLY)-----"
11 ARTIFACT_END = "-----END OVERSEER FREEZE ARTIFACT (DATA ONLY)-----"
12 SCHEMA_VERSION = 1
13
14
15 def build_delimited_artifact(artifact_text: str) -> str:
16 """Wrap artifact bytes as a clearly delimited data section for provider prompts."""
17 return "\n".join([ARTIFACT_BEGIN, artifact_text, ARTIFACT_END])
18
19
20 def build_review_request_body(
21 *,
22 artifact_text: str,
23 artifact_path: str,
24 checklist: list[ChecklistItem],
25 model_label: str,
26 model_hint: str,
27 ) -> dict[str, Any]:
28 """Build the JSON body for POST /review (headless provider contract)."""
29 return {
30 "schema_version": SCHEMA_VERSION,
31 "model_label": model_label,
32 "model_hint": model_hint,
33 "artifact_path": artifact_path,
34 "artifact_text": build_delimited_artifact(artifact_text),
35 "checklist": [
36 {
37 "id": item.id,
38 "title": item.title,
39 "typical_severity": item.typical_severity,
40 }
41 for item in checklist
42 ],
43 }
44
45
46 def serialize_review_request(body: dict[str, Any]) -> bytes:
47 """Serialize a review request as UTF-8 JSON."""
48 return json.dumps(body, separators=(",", ":"), ensure_ascii=False).encode("utf-8")
File History 2 commits
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 52 days ago