Skip to content

Commit 7e2cdbe

Browse files
authored
artifact: add agent artifact bundle example
Adds a deterministic committed example artifact for the agent artifact bundle, a generator script, and exact regeneration parity coverage.
1 parent 52da23a commit 7e2cdbe

3 files changed

Lines changed: 163 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"artifact_id": "agent_artifact_bundle_example_v1",
3+
"bundle": {
4+
"branch": "feat/agent-artifact-bundle-example",
5+
"changed_files": [
6+
"artifacts/agent_artifact_bundle_example.json",
7+
"scripts/generate_agent_artifact_bundle_example.py",
8+
"tests/test_agent_artifact_bundle.py"
9+
],
10+
"mcp_context_output_ref": "artifacts/mcp_context_layer_example.json",
11+
"ok": true,
12+
"result": "PASS",
13+
"safe_pr_gate": {
14+
"allow_dirty": false,
15+
"allowed_prefixes": [],
16+
"branch": "feat/agent-artifact-bundle-example",
17+
"changed_paths": [
18+
"artifacts/agent_artifact_bundle_example.json",
19+
"scripts/generate_agent_artifact_bundle_example.py",
20+
"tests/test_agent_artifact_bundle.py"
21+
],
22+
"ok": true,
23+
"problems": [],
24+
"result": "PASS",
25+
"status_short": []
26+
},
27+
"validation_evidence": [
28+
{
29+
"command": "python -m compileall -q scripts/agent_artifact_bundle.py scripts/generate_agent_artifact_bundle_example.py",
30+
"result": "pass"
31+
},
32+
{
33+
"command": "pytest tests/test_agent_artifact_bundle.py -q",
34+
"result": "pass"
35+
}
36+
]
37+
},
38+
"evaluation_mode": "deterministic",
39+
"external_apis": "none",
40+
"generated_by": "AgentArtifactBundleExampleGenerator",
41+
"llm_judges": "none",
42+
"schema_version": "agent_artifact_bundle_example.v1",
43+
"version": "1.0"
44+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env python3
2+
"""Generate a deterministic agent artifact bundle example."""
3+
4+
from __future__ import annotations
5+
6+
import json
7+
import sys
8+
from pathlib import Path
9+
from typing import Any
10+
11+
REPO_ROOT = Path(__file__).resolve().parents[1]
12+
if str(REPO_ROOT) not in sys.path:
13+
sys.path.insert(0, str(REPO_ROOT))
14+
15+
from scripts.agent_artifact_bundle import build_agent_artifact_bundle
16+
from scripts.safe_pr_gate import GateState
17+
18+
ARTIFACT_ID = "agent_artifact_bundle_example_v1"
19+
OUTPUT_PATH = REPO_ROOT / "artifacts" / "agent_artifact_bundle_example.json"
20+
21+
EXAMPLE_STATE = GateState(
22+
branch="feat/agent-artifact-bundle-example",
23+
status_short=(),
24+
changed_paths=(
25+
"artifacts/agent_artifact_bundle_example.json",
26+
"scripts/generate_agent_artifact_bundle_example.py",
27+
"tests/test_agent_artifact_bundle.py",
28+
),
29+
)
30+
VALIDATION_COMMANDS = [
31+
"python -m compileall -q scripts/agent_artifact_bundle.py scripts/generate_agent_artifact_bundle_example.py",
32+
"pytest tests/test_agent_artifact_bundle.py -q",
33+
]
34+
VALIDATION_RESULTS = ["pass", "pass"]
35+
MCP_CONTEXT_OUTPUT_REF = "artifacts/mcp_context_layer_example.json"
36+
37+
38+
def build_agent_artifact_bundle_example() -> dict[str, Any]:
39+
return {
40+
"artifact_id": ARTIFACT_ID,
41+
"bundle": build_agent_artifact_bundle(
42+
EXAMPLE_STATE,
43+
allow_main=False,
44+
validation_commands=VALIDATION_COMMANDS,
45+
validation_results=VALIDATION_RESULTS,
46+
mcp_context_output_ref=MCP_CONTEXT_OUTPUT_REF,
47+
),
48+
"evaluation_mode": "deterministic",
49+
"external_apis": "none",
50+
"generated_by": "AgentArtifactBundleExampleGenerator",
51+
"llm_judges": "none",
52+
"schema_version": "agent_artifact_bundle_example.v1",
53+
"version": "1.0",
54+
}
55+
56+
57+
def generate_agent_artifact_bundle_example(output_path: Path = OUTPUT_PATH) -> Path:
58+
artifact = build_agent_artifact_bundle_example()
59+
output_path.parent.mkdir(parents=True, exist_ok=True)
60+
output_path.write_text(json.dumps(artifact, indent=2, sort_keys=True) + "\n", encoding="utf-8")
61+
return output_path
62+
63+
64+
def main() -> int:
65+
output_path = generate_agent_artifact_bundle_example()
66+
print(output_path.relative_to(REPO_ROOT).as_posix())
67+
return 0
68+
69+
70+
if __name__ == "__main__":
71+
raise SystemExit(main())

tests/test_agent_artifact_bundle.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
from __future__ import annotations
22

33
import json
4+
from pathlib import Path
45

56
import pytest
67

78
import scripts.agent_artifact_bundle as agent_artifact_bundle
9+
from scripts.generate_agent_artifact_bundle_example import (
10+
ARTIFACT_ID,
11+
generate_agent_artifact_bundle_example,
12+
)
813
from scripts.safe_pr_gate import GateState, evaluate_gate
914

15+
ARTIFACT_PATH = Path("artifacts/agent_artifact_bundle_example.json")
16+
1017

1118
def test_build_agent_artifact_bundle_is_deterministic_and_includes_optional_metadata() -> None:
1219
state = GateState(
@@ -160,3 +167,44 @@ def test_main_reports_main_branch_as_deterministic_error_json(
160167
"ok": False,
161168
"result": "ERROR",
162169
}
170+
171+
172+
def test_agent_artifact_bundle_example_matches_generator_output(tmp_path: Path) -> None:
173+
output_path = tmp_path / "agent_artifact_bundle_example.json"
174+
generate_agent_artifact_bundle_example(output_path)
175+
176+
assert output_path.read_text(encoding="utf-8") == ARTIFACT_PATH.read_text(encoding="utf-8")
177+
178+
179+
def test_agent_artifact_bundle_example_has_stable_schema_and_content() -> None:
180+
artifact = json.loads(ARTIFACT_PATH.read_text(encoding="utf-8"))
181+
182+
assert set(artifact) == {
183+
"artifact_id",
184+
"bundle",
185+
"evaluation_mode",
186+
"external_apis",
187+
"generated_by",
188+
"llm_judges",
189+
"schema_version",
190+
"version",
191+
}
192+
assert artifact["artifact_id"] == ARTIFACT_ID
193+
assert artifact["schema_version"] == "agent_artifact_bundle_example.v1"
194+
assert artifact["version"] == "1.0"
195+
assert artifact["evaluation_mode"] == "deterministic"
196+
assert artifact["external_apis"] == "none"
197+
assert artifact["llm_judges"] == "none"
198+
199+
bundle = artifact["bundle"]
200+
assert bundle["branch"] == "feat/agent-artifact-bundle-example"
201+
assert bundle["ok"] is True
202+
assert bundle["result"] == "PASS"
203+
assert bundle["changed_files"] == [
204+
"artifacts/agent_artifact_bundle_example.json",
205+
"scripts/generate_agent_artifact_bundle_example.py",
206+
"tests/test_agent_artifact_bundle.py",
207+
]
208+
assert bundle["mcp_context_output_ref"] == "artifacts/mcp_context_layer_example.json"
209+
assert bundle["safe_pr_gate"]["ok"] is True
210+
assert bundle["safe_pr_gate"]["result"] == "PASS"

0 commit comments

Comments
 (0)