artifact: add agent artifact bundle example#204
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a deterministic agent artifact bundle example, including a new JSON artifact, a generation script, and comprehensive tests to verify schema stability and generator output. Feedback was provided to improve the robustness of JSON loading in the test suite by implementing error handling for missing files or malformed content and validating the resulting data structure.
|
|
||
|
|
||
| def test_agent_artifact_bundle_example_has_stable_schema_and_content() -> None: | ||
| artifact = json.loads(ARTIFACT_PATH.read_text(encoding="utf-8")) |
Contributor
There was a problem hiding this comment.
Adhere to the general rule for loading JSON files: handle FileNotFoundError and json.JSONDecodeError by raising a RuntimeError that includes the repo-relative path. Additionally, validate that the decoded payload is a dictionary before proceeding.
try:
artifact = json.loads(ARTIFACT_PATH.read_text(encoding="utf-8"))
except (FileNotFoundError, json.JSONDecodeError) as exc:
raise RuntimeError(f"Failed to load artifact from {ARTIFACT_PATH.as_posix()}: {exc}") from exc
if not isinstance(artifact, dict):
raise RuntimeError(f"Expected artifact in {ARTIFACT_PATH.as_posix()} to be a dictionary, got {type(artifact).__name__}")References
- When loading JSON files, handle FileNotFoundError and JSONDecodeError by raising a RuntimeError that includes a repo-relative path. Additionally, validate that the decoded payload is of the expected type (e.g., a dictionary) before proceeding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a deterministic committed example artifact for the agent artifact bundle.
Includes:
artifacts/agent_artifact_bundle_example.jsonscripts/generate_agent_artifact_bundle_example.pytests/test_agent_artifact_bundle.pyScope
Artifact-backed reproducibility only. No timestamps, no random IDs, no network, no external APIs, and no unrelated artifact rewrites.
Validation
python -m compileall -q scripts/agent_artifact_bundle.py scripts/generate_agent_artifact_bundle_example.pypytest tests/test_agent_artifact_bundle.py -q