8월 7일까지 워킹트리에만 남아 있던 미커밋 작업을 커밋한다. 여러 사본 폴더(worktree·clone)에 흩어져 있던 중간 스냅샷을 정리하기 전에 원본을 git 이력으로 고정하는 것이 목적이다. - contracts/routes/services: measurement, outcome_trajectory, rupture_repair, deliberate_practice, calibration_transfer, supervision_research, multimodal_alliance, continuous_improvement 계열 신규 모듈과 테스트 - infra/db/init: 07~16 마이그레이션(측정 기반~calibration transfer 실행) - apps/web: 세션 리뷰 카드·관리 화면·E2E 스펙 추가 - docs/ops: G0~G8 라이브 통합·배포·롤백 증거 문서와 evidence JSON/PNG - scripts: smoke·ledger·릴리스 에이전트·NAS 프리뷰 운영 스크립트 engine.public 로그 .bak과 apps/web/test-results 산출물은 커밋에서 제외했다.
77 lines
3.1 KiB
Python
77 lines
3.1 KiB
Python
from __future__ import annotations
|
|
|
|
import importlib.util
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
SCRIPT_PATH = Path(__file__).with_name("smoke-continuous-improvement-api.py")
|
|
SPEC = importlib.util.spec_from_file_location(
|
|
"smoke_continuous_improvement_api", SCRIPT_PATH
|
|
)
|
|
assert SPEC is not None and SPEC.loader is not None
|
|
MODULE = importlib.util.module_from_spec(SPEC)
|
|
sys.modules[SPEC.name] = MODULE
|
|
SPEC.loader.exec_module(MODULE)
|
|
|
|
|
|
def _event(status: str) -> dict[str, object]:
|
|
evidence = ["audit://synthetic/g8/rollback-approval"]
|
|
receipt_id = None
|
|
executor_evidence = None
|
|
if status == "executed":
|
|
receipt_id = "rollback-execution-001"
|
|
executor_evidence = ["audit://rollback-executor/model/execution-001"]
|
|
evidence.extend(executor_evidence)
|
|
return {
|
|
"lifecycle_event_id": "10000000-0000-0000-0000-000000000001",
|
|
"target_kind": "model_change_gate",
|
|
"target_id": "20000000-0000-0000-0000-000000000001",
|
|
"event_type": "rollback",
|
|
"event_status": status,
|
|
"approval_event_id": "30000000-0000-0000-0000-000000000001",
|
|
"artifact_record_id": "40000000-0000-0000-0000-000000000001",
|
|
"evidence_refs": evidence,
|
|
"executor_receipt_id": receipt_id,
|
|
"executor_evidence_refs": executor_evidence,
|
|
}
|
|
|
|
|
|
class ContinuousImprovementSmokeUnitTest(unittest.TestCase):
|
|
def test_requested_failed_and_executed_states_are_recorded_honestly(self) -> None:
|
|
for status in ("requested", "failed", "executed"):
|
|
proof = MODULE._rollback_execution_proof(_event(status))
|
|
self.assertEqual(proof["status"], status)
|
|
self.assertTrue(proof["receipt_contract_satisfied"])
|
|
self.assertEqual(proof["executed_receipt_bound"], status == "executed")
|
|
if status == "executed":
|
|
self.assertEqual(
|
|
proof["executor_receipt_id"], "rollback-execution-001"
|
|
)
|
|
self.assertEqual(len(proof["executor_evidence_refs"]), 1)
|
|
else:
|
|
self.assertIsNone(proof["executor_receipt_id"])
|
|
self.assertEqual(proof["executor_evidence_refs"], [])
|
|
|
|
def test_executed_state_rejects_missing_receipt(self) -> None:
|
|
event = _event("executed")
|
|
event["executor_receipt_id"] = None
|
|
with self.assertRaisesRegex(MODULE.SmokeError, "omitted executor receipt"):
|
|
MODULE._rollback_execution_proof(event)
|
|
|
|
def test_executed_state_rejects_unbound_executor_evidence(self) -> None:
|
|
event = _event("executed")
|
|
event["evidence_refs"] = ["audit://synthetic/g8/rollback-approval"]
|
|
with self.assertRaisesRegex(MODULE.SmokeError, "not bound"):
|
|
MODULE._rollback_execution_proof(event)
|
|
|
|
def test_non_executed_state_rejects_false_receipt(self) -> None:
|
|
event = _event("failed")
|
|
event["executor_receipt_id"] = "false-receipt"
|
|
with self.assertRaisesRegex(MODULE.SmokeError, "false receipt"):
|
|
MODULE._rollback_execution_proof(event)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|