Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions artifacts/pr_body_from_agent_bundle_example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Summary

Deterministic agent artifact bundle evidence for this change.

## Scope

- `artifacts/agent_artifact_bundle_example.json`
- `scripts/generate_agent_artifact_bundle_example.py`
- `tests/test_agent_artifact_bundle.py`

## Validation

- `python -m compileall -q scripts/agent_artifact_bundle.py scripts/generate_agent_artifact_bundle_example.py`: `pass`
- `pytest tests/test_agent_artifact_bundle.py -q`: `pass`

## Safety Gate

- result: `PASS`
- ok: `true`
- allow_dirty: `false`
- problems: `none`

## Evidence

- branch: `feat/agent-artifact-bundle-example`
- bundle_result: `PASS`
- mcp_context_output_ref: `artifacts/mcp_context_layer_example.json`
33 changes: 33 additions & 0 deletions scripts/generate_pr_body_from_agent_bundle_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python3
"""Generate a deterministic PR body Markdown example from an agent bundle."""

from __future__ import annotations

import sys
from pathlib import Path

REPO_ROOT = Path(__file__).resolve().parents[1]
if str(REPO_ROOT) not in sys.path:
sys.path.insert(0, str(REPO_ROOT))

from scripts.pr_body_from_agent_bundle import render_pr_body_from_file

INPUT_BUNDLE_PATH = REPO_ROOT / "artifacts" / "agent_artifact_bundle_example.json"
OUTPUT_PATH = REPO_ROOT / "artifacts" / "pr_body_from_agent_bundle_example.md"


def generate_pr_body_from_agent_bundle_example(output_path: Path = OUTPUT_PATH) -> Path:
rendered = render_pr_body_from_file(INPUT_BUNDLE_PATH)
output_path.parent.mkdir(parents=True, exist_ok=True)
output_path.write_text(rendered, encoding="utf-8")
return output_path


def main() -> int:
output_path = generate_pr_body_from_agent_bundle_example()
print(output_path.relative_to(REPO_ROOT).as_posix())
return 0


if __name__ == "__main__":
raise SystemExit(main())
9 changes: 9 additions & 0 deletions tests/test_pr_body_from_agent_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
from pathlib import Path

import scripts.pr_body_from_agent_bundle as pr_body
from scripts.generate_pr_body_from_agent_bundle_example import generate_pr_body_from_agent_bundle_example

ARTIFACT_PATH = Path("artifacts/agent_artifact_bundle_example.json")
PR_BODY_ARTIFACT_PATH = Path("artifacts/pr_body_from_agent_bundle_example.md")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The path PR_BODY_ARTIFACT_PATH is defined as a relative path. This makes the test environment-dependent and likely to fail if executed from a directory other than the repository root (e.g., from within the tests/ directory). It is recommended to anchor this path using the repository root. Since scripts.pr_body_from_agent_bundle (imported as pr_body) already calculates and exposes REPO_ROOT, you can use it here for consistency and robustness.

Suggested change
PR_BODY_ARTIFACT_PATH = Path("artifacts/pr_body_from_agent_bundle_example.md")
PR_BODY_ARTIFACT_PATH = pr_body.REPO_ROOT / "artifacts" / "pr_body_from_agent_bundle_example.md"



def test_render_pr_body_from_committed_bundle_is_deterministic() -> None:
Expand Down Expand Up @@ -111,3 +113,10 @@ def test_cli_outputs_markdown_only_for_valid_bundle(tmp_path: Path, capsys) -> N
assert captured.err == ""
assert captured.out.startswith("## Summary\n")
assert "## Safety Gate\n" in captured.out


def test_pr_body_example_artifact_matches_generator_output(tmp_path: Path) -> None:
output_path = tmp_path / "pr_body_from_agent_bundle_example.md"
generate_pr_body_from_agent_bundle_example(output_path)

assert output_path.read_text(encoding="utf-8") == PR_BODY_ARTIFACT_PATH.read_text(encoding="utf-8")
Loading