Skip to content

Preserve per-tag directory structure when constructing bundle paths (merges into #96)#102

Closed
cubic-dev-ai[bot] wants to merge 1 commit into
codex/implement-parser-hardening-and-safety-improvementsfrom
cubic-fix-evidence-packager-py-L268-1760700774
Closed

Preserve per-tag directory structure when constructing bundle paths (merges into #96)#102
cubic-dev-ai[bot] wants to merge 1 commit into
codex/implement-parser-hardening-and-safety-improvementsfrom
cubic-fix-evidence-packager-py-L268-1760700774

Conversation

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot commented Oct 17, 2025

🤖 PR by cubic

This PR addresses the comment in #96 – Harden parser validation and evidence guardrails

File: evidence/packager.py
Line: 268
Comment:

resolve_within_root flattens tag names, so different namespaced tags now produce the same bundle filename and overwrite existing bundles. Please keep the per-tag directory structure when constructing the bundle path.

This fix was automatically generated. Please review the changes carefully before merging.


Summary by cubic

Preserves per-tag directory structure when creating manifest and bundle paths to prevent overwriting bundles for namespaced tags. Tags like namespace/repo:v1.0.0 now write under namespace/repo/ instead of flattening the tag.

  • Bug Fixes
    • Derives tag subdirs from Path(tag).parent and creates them under manifest_dir and bundle_dir.
    • Writes files as .yaml and .zip inside the derived subdirs, avoiding collisions.
    • Adds a test that uses a namespaced tag and asserts nested paths are created and the manifest retains the full tag.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR.

Comment thread evidence/packager.py
Comment on lines +264 to +274
tag_path = Path(tag)
tag_manifest_dir = resolve_within_root(manifest_dir, str(tag_path.parent)) if tag_path.parent != Path(".") else manifest_dir
tag_bundle_dir = resolve_within_root(bundle_dir, str(tag_path.parent)) if tag_path.parent != Path(".") else bundle_dir
tag_manifest_dir.mkdir(parents=True, exist_ok=True)
tag_bundle_dir.mkdir(parents=True, exist_ok=True)

manifest_path = tag_manifest_dir / f"{tag_path.name}.yaml"
with manifest_path.open("w", encoding="utf-8") as handle:
yaml.safe_dump(manifest, handle, sort_keys=False)

bundle_path = resolve_within_root(bundle_dir, f"{tag}.zip")
bundle_path = tag_bundle_dir / f"{tag_path.name}.zip"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve namespace in evidence API

Creating bundles now writes manifests and archives into nested directories based on the tag (e.g., namespace/repo:v1.0.0 ends up under manifests/namespace/repo.yaml and bundles/namespace/repo.zip). The FastAPI evidence routes still glob only manifest_dir/*.yaml and build bundle paths as bundle_dir / f"{tag}.zip", and the /{release} route cannot even accept slashes in the tag. As a result, namespaced bundles generated by this change will never be listed or fetched through the API despite being written to disk. Consider teaching the API to recurse through namespace directories (and using a path parameter for release) so these bundles remain accessible.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="evidence/packager.py">

<violation number="1" location="evidence/packager.py:264">
The logic for creating nested directories from namespaced tags is flawed. The implementation in `evidence/packager.py` incorrectly parses the tag string, and as a result, the assertions in the corresponding test in `tests/test_evidence_bundle.py` will fail. The code does not produce the intended directory structure.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Comment thread evidence/packager.py
}

manifest_path = resolve_within_root(manifest_dir, f"{tag}.yaml")
tag_path = Path(tag)
Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai cubic-dev-ai Bot Oct 17, 2025

Choose a reason for hiding this comment

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

The logic for creating nested directories from namespaced tags is flawed. The implementation in evidence/packager.py incorrectly parses the tag string, and as a result, the assertions in the corresponding test in tests/test_evidence_bundle.py will fail. The code does not produce the intended directory structure.

Prompt for AI agents
Address the following comment on evidence/packager.py at line 264:

<comment>The logic for creating nested directories from namespaced tags is flawed. The implementation in `evidence/packager.py` incorrectly parses the tag string, and as a result, the assertions in the corresponding test in `tests/test_evidence_bundle.py` will fail. The code does not produce the intended directory structure.</comment>

<file context>
@@ -261,11 +261,17 @@ def create_bundle(inputs: BundleInputs) -&gt; dict[str, Any]:
     }
 
-    manifest_path = resolve_within_root(manifest_dir, f&quot;{tag}.yaml&quot;)
+    tag_path = Path(tag)
+    tag_manifest_dir = resolve_within_root(manifest_dir, str(tag_path.parent)) if tag_path.parent != Path(&quot;.&quot;) else manifest_dir
+    tag_bundle_dir = resolve_within_root(bundle_dir, str(tag_path.parent)) if tag_path.parent != Path(&quot;.&quot;) else bundle_dir
</file context>
Fix with Cubic

@devin-ai-integration
Copy link
Copy Markdown
Contributor

Closing as part of PR consolidation. Useful changes have been cherry-picked into PR #240.

DevOpsMadDog added a commit that referenced this pull request May 6, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants