feat: add agent artifact bundle#203
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new script, scripts/agent_artifact_bundle.py, designed to generate deterministic evidence bundles for AI-assisted workflows, accompanied by documentation and a comprehensive test suite. The script integrates with the safe_pr_gate module to evaluate the current branch state and include validation evidence. The review feedback focuses on improving the robustness of the output by suggesting that the top-level status fields (ok and result) should dynamically reflect the underlying safety gate evaluation rather than being hardcoded to success. Additionally, it is recommended that the script return a non-zero exit code when the safety gate fails to ensure that calling processes, such as CI/CD pipelines, can correctly detect and respond to failures.
| "ok": True, | ||
| "result": "PASS", |
There was a problem hiding this comment.
The top-level ok and result fields are currently hardcoded to True and "PASS". This is misleading if the underlying safe_pr_gate evaluation fails. These fields should reflect the aggregate status of the bundle based on the gate result to ensure the evidence bundle accurately represents the work state.
| "ok": True, | |
| "result": "PASS", | |
| "ok": safe_pr_gate_result.ok, | |
| "result": "PASS" if safe_pr_gate_result.ok else "FAIL", |
References
- Maintain strictness in data processing to ensure the output accurately represents the state.
| mcp_context_output_ref=args.mcp_context_output_ref, | ||
| ) | ||
| sys.stdout.write(json.dumps(bundle, indent=2, sort_keys=True) + "\n") | ||
| return 0 |
There was a problem hiding this comment.
The main function always returns 0 on success, even if the safety gate failed. To be consistent with safe_pr_gate.py and to allow calling processes (such as CI/CD pipelines or git hooks) to detect and react to failures, it should return a non-zero exit code when the bundle status is not ok.
| return 0 | |
| return 0 if bundle["ok"] else 1 |
References
- Ensure failures are visible in CI rather than failing silently.
Adds a minimal deterministic agent artifact bundle script for AI-assisted work evidence.
Includes:
scripts/agent_artifact_bundle.pysafe_pr_gateresult reuseScope
Local evidence bundling only. No network, no external APIs, no runtime execution, no timestamps, no random IDs.
Validation
python -m compileall -q scripts/agent_artifact_bundle.pypytest tests/test_agent_artifact_bundle.py -q