feat: add AI workflow snapshot command#210
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new script, scripts/ai_workflow_snapshot.py, along with comprehensive unit tests to generate deterministic local AI workflow evidence snapshots. The script integrates with existing artifact and safety gate utilities to produce a compact JSON payload. Feedback was provided to enhance the robustness of the snapshot construction by strictly validating the validation_evidence field, ensuring it is treated as a list or raising a RuntimeError for unexpected types, which aligns with the repository's standards for processing JSON-like structures.
| snapshot: dict[str, Any] = { | ||
| "agent_artifact_bundle": agent_artifact_bundle, | ||
| "ok": agent_artifact_bundle["ok"], | ||
| "result": agent_artifact_bundle["result"], | ||
| "safe_pr_gate": agent_artifact_bundle["safe_pr_gate"], | ||
| "validation_evidence": agent_artifact_bundle["validation_evidence"], | ||
| } |
There was a problem hiding this comment.
To maintain strictness when processing JSON-like data structures, expected list fields should be treated as empty lists if missing or null, and a RuntimeError should be raised for other non-list types. This ensures robustness even if the underlying bundle structure changes, adhering to the repository's general rules for JSON processing.
| snapshot: dict[str, Any] = { | |
| "agent_artifact_bundle": agent_artifact_bundle, | |
| "ok": agent_artifact_bundle["ok"], | |
| "result": agent_artifact_bundle["result"], | |
| "safe_pr_gate": agent_artifact_bundle["safe_pr_gate"], | |
| "validation_evidence": agent_artifact_bundle["validation_evidence"], | |
| } | |
| validation_evidence = agent_artifact_bundle.get("validation_evidence") | |
| if validation_evidence is None: | |
| validation_evidence = [] | |
| if not isinstance(validation_evidence, list): | |
| raise RuntimeError("validation_evidence must be a list") | |
| snapshot: dict[str, Any] = { | |
| "agent_artifact_bundle": agent_artifact_bundle, | |
| "ok": agent_artifact_bundle["ok"], | |
| "result": agent_artifact_bundle["result"], | |
| "safe_pr_gate": agent_artifact_bundle["safe_pr_gate"], | |
| "validation_evidence": validation_evidence, | |
| } |
References
- When processing JSON data, treat null or missing values for expected list fields as empty lists, but raise a RuntimeError for other non-list types to maintain strictness.
Adds a minimal deterministic AI workflow snapshot command.
Validation: