Repository navigation
fix(tier3): include staged file permissions in baseline identity #922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Afloat16
wants to merge
10
commits into
NVIDIA:main
Choose a base branch
from
Afloat16:fix/baseline-staged-file-metadata-20261128
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
14663a3
fix(tier3): include staged file metadata in baseline identity
Afloat16 0c104f2
fix(tier3): include staged directory modes and clarify retained-resul…
Afloat16 ad5f6ca
Merge main and combine streaming with versioned staged metadata
Afloat16 e2a1aa7
Merge current main and preserve PR 922 release notes
Afloat16 e9de380
fix: stabilize and version baseline task-tree identities
Afloat16 094ab4b
Merge main while preserving baseline metadata identities
Afloat16 d97b684
Merge main and retain the unreleased changelog entry
Afloat16 2f44a69
Merge main and preserve the unreleased changelog entry
Afloat16 0a05046
Merge frozen main and preserve PR #922 release notes
Afloat16 f473c15
Merge main and preserve PR #922 release notes
Afloat16 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Staged file metadata that changes execution must invalidate baseline reuse.""" | ||
|
|
||
| import os | ||
| import subprocess | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from skillevaluator.tier3.baseline_store import baseline_task_tree_digest, comparison_mismatches | ||
| from skillevaluator.tier3.harbor.secure_copy import copy_file_secure | ||
|
|
||
|
|
||
| @pytest.mark.skipif(os.name != "posix", reason="POSIX executable permission bits") | ||
| def test_staged_executable_permission_change_rejects_the_old_baseline(tmp_path: Path) -> None: | ||
| source = tmp_path / "authored" | ||
| source.mkdir() | ||
| script = source / "check.sh" | ||
| script.write_text("#!/bin/sh\nprintf ready", encoding="utf-8") | ||
| script.chmod(0o755) | ||
| task = tmp_path / "case-001" | ||
| staged = task / "environment" / "repo" / script.name | ||
| staged.parent.mkdir(parents=True) | ||
| copy_file_secure(script, staged, allowed_root=source) | ||
| before = baseline_task_tree_digest({"codex": [task]}) | ||
| assert subprocess.run([str(staged)], capture_output=True, text=True, check=True, timeout=5).stdout == "ready" | ||
|
|
||
| script.chmod(0o644) | ||
| copy_file_secure(script, staged, allowed_root=source) | ||
| assert staged.read_bytes() == script.read_bytes() | ||
| with pytest.raises(PermissionError): | ||
| subprocess.run([str(staged)], capture_output=True, text=True, check=True, timeout=5) | ||
| after = baseline_task_tree_digest({"codex": [task]}) | ||
| assert comparison_mismatches( | ||
| {"config": {}, "baseline_task_tree_digest": after}, | ||
| {"config": {}, "baseline_task_tree_digest": before}, | ||
| ) == ["staged baseline task tree changed"] | ||
|
|
||
|
|
||
| @pytest.mark.skipif(os.name != "posix", reason="POSIX file modes and symlinks") | ||
| def test_regular_file_cannot_impersonate_a_symlinks_digest_payload(tmp_path: Path) -> None: | ||
| task = tmp_path / "case-001" | ||
| task.mkdir() | ||
| entry = task / "entry" | ||
| entry.write_bytes(b"symlink\0target") | ||
| entry.chmod(0o777) | ||
| regular = baseline_task_tree_digest({"codex": [task]}) | ||
| entry.unlink() | ||
| entry.symlink_to("target") | ||
| assert baseline_task_tree_digest({"codex": [task]}) != regular | ||
|
|
||
|
|
||
| @pytest.mark.skipif(os.name != "posix", reason="POSIX permission bits") | ||
| def test_file_permissions_matter_but_timestamps_do_not(tmp_path: Path) -> None: | ||
| task = tmp_path / "case-001" | ||
| task.mkdir() | ||
| entry = task / "settings.json" | ||
| entry.write_text("{}", encoding="utf-8") | ||
| entry.chmod(0o644) | ||
| original = baseline_task_tree_digest({"codex": [task]}) | ||
| os.utime(entry, (1_000_000_000, 1_000_000_000)) | ||
| assert baseline_task_tree_digest({"codex": [task]}) == original | ||
| entry.chmod(0o444) | ||
| assert baseline_task_tree_digest({"codex": [task]}) != original |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.