-
-
Notifications
You must be signed in to change notification settings - Fork 468
chore(ai): Add check-code-attribution skill (JAVA-499) #5449
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
0xadam-brown
wants to merge
1
commit into
main
Choose a base branch
from
chore/check-code-attribution-skill-with-warden
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 all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,5 @@ | |
| !test/** | ||
| !btrace-perfetto/ | ||
| !btrace-perfetto/** | ||
| !check-code-attribution/ | ||
| !check-code-attribution/** | ||
Large diffs are not rendered by default.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
.claude/skills/check-code-attribution/validation-tests/EXPECTED.json
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,53 @@ | ||
| [ | ||
| { | ||
| "id": "header-complete-and-notice-present", | ||
| "file": "HeaderCompleteAndNoticePresent.java", | ||
| "expectFinding": false, | ||
| "notes": "Header matches catalog entry" | ||
| }, | ||
| { | ||
| "id": "header-complete-but-notice-missing", | ||
| "file": "HeaderCompleteButNoticeMissing.java", | ||
| "expectFinding": true, | ||
| "isolated": true, | ||
| "notes": "Full header; no catalog / root NOTICES entry. Isolated: prompt-cache priming in a concurrent batch suppresses the missing-NOTICES finding below medium." | ||
| }, | ||
| { | ||
| "id": "header-missing-but-notice-present", | ||
| "file": "HeaderMissingButNoticePresent.java", | ||
| "expectFinding": true, | ||
| "isolated": true, | ||
| "notes": "NOTICES entry claims file is vendored but file has no attribution header. Isolated: a complete NOTICES entry suppresses the missing-header finding in a concurrent batch." | ||
| }, | ||
| { | ||
| "id": "header-fully-stripped", | ||
| "file": "HeaderFullyStripped.java", | ||
| "expectFinding": true, | ||
| "notes": "Header has no required attribution fields" | ||
| }, | ||
| { | ||
| "id": "header-partially-stripped", | ||
| "file": "HeaderPartiallyStripped.java", | ||
| "expectFinding": true, | ||
| "notes": "Adapted from + URL only; no copyright or license name" | ||
| }, | ||
| { | ||
| "id": "header-missing-non-essential-info", | ||
| "file": "HeaderMissingNonEssentialInfo.java", | ||
| "expectFinding": false, | ||
| "notes": "All four required fields present; no license boilerplate — boilerplate is not required in the header" | ||
| }, | ||
| { | ||
| "id": "header-vs-notice-mismatch", | ||
| "file": "THIRD_PARTY_NOTICES.md", | ||
| "expectFinding": true, | ||
| "isolated": true, | ||
| "notes": "Copyright in metadata field does not match embedded license text. Isolated: mismatch finding needs an independent assertion free of interference from other NOTICES changes." | ||
| }, | ||
| { | ||
| "id": "new-license-type", | ||
| "file": "NewLicenseType.java", | ||
| "expectFinding": true, | ||
| "notes": "AGPL v3 license in file header — absolute ban, must be removed" | ||
| } | ||
| ] |
41 changes: 41 additions & 0 deletions
41
.claude/skills/check-code-attribution/validation-tests/README.md
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,41 @@ | ||
| # Attribution skill validation tests | ||
|
|
||
| Self-contained samples for validating `check-code-attribution` without touching production SDK sources. | ||
|
|
||
|
|
||
| ## Run the tests | ||
|
|
||
| ```bash | ||
| ./check-code-attribution-tests.sh | ||
| ``` | ||
|
|
||
| Requires Node.js and an Anthropic API key (`WARDEN_ANTHROPIC_API_KEY` or `ANTHROPIC_API_KEY`). See SKILL.md "Warden CLI" section for all auth options. | ||
|
|
||
| In practice, straight command line runs tend to be a bit flakier than asking Claude Code to run the tests for you. | ||
|
|
||
| ## Layout | ||
|
|
||
| - `EXPECTED.json` — scenario IDs and expected outcomes (single source of truth). | ||
| - `THIRD_PARTY_NOTICES.catalog.md` — NOTICES-style entries for validation class names. | ||
| - `scenarios/` — `.java` files and `THIRD_PARTY_NOTICES.mismatch-snippet.md` (copyright-mismatch fixture). | ||
| - `check-code-attribution-tests.sh` — runs Warden on a temp branch and asserts per-scenario pass/fail. | ||
| - `assert-scenarios.mjs` — validation driver (`list-isolated`, `routing-set`, `assert` subcommands); parses Warden JSONL and checks outcomes from `EXPECTED.json`. | ||
|
|
||
| ### assert-scenarios.mjs commands | ||
|
|
||
| ```bash | ||
| node assert-scenarios.mjs validate EXPECTED.json scenarios/ # pre-flight (no API); run automatically by the shell script | ||
| node assert-scenarios.mjs list-isolated EXPECTED.json # id<TAB>file per isolated scenario | ||
| node assert-scenarios.mjs list-main-java EXPECTED.json scenarios/ # .java files for the main Warden batch | ||
| node assert-scenarios.mjs routing-set routing.json <id> <path> # update id → Warden JSONL path | ||
| node assert-scenarios.mjs assert EXPECTED.json <dest-pkg> routing.json | ||
| ``` | ||
|
|
||
| Warden runs are limited to 300s. On macOS the script uses `gtimeout` (from `brew install coreutils`) when available, otherwise GNU `timeout`, otherwise `perl` with `alarm`. | ||
|
|
||
| ## Add a scenario | ||
|
|
||
| 1. Add `scenarios/<UniqueClassName>.java`. | ||
| 2. Add or omit a catalog entry in `THIRD_PARTY_NOTICES.catalog.md`. | ||
| 3. Add an entry to `EXPECTED.json`. | ||
| 4. **Isolation (if needed):** If the scenario relies on a finding that could be suppressed by Anthropic prompt-cache priming when analyzed alongside many other files (e.g. a missing-NOTICES entry, or a missing header on a file that has a complete NOTICES entry), add `"isolated": true` to its `EXPECTED.json` entry. The test script creates a dedicated worktree for each isolated scenario automatically — no changes to the script itself are needed. |
130 changes: 130 additions & 0 deletions
130
...e/skills/check-code-attribution/validation-tests/THIRD_PARTY_NOTICES.catalog.md
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,130 @@ | ||
| # Test THIRD_PARTY_NOTICES catalog (not shipped) | ||
|
|
||
| Used only when validating `check-code-attribution` against `validation-tests/scenarios/**`. | ||
| Grep this file in addition to the repository root `THIRD_PARTY_NOTICES.md`. | ||
|
|
||
| --- | ||
|
|
||
| ## Example — HeaderFullyStripped (MIT) | ||
|
|
||
| **Source:** https://github.com/example/attribution-fixtures<br> | ||
| **License:** MIT License<br> | ||
| **Copyright:** Copyright (c) 2016 Example Author | ||
|
|
||
| ### Scope | ||
|
|
||
| Attribution validation sample. The code resides in `io.sentry.skills.verification.HeaderFullyStripped` (`validation-tests/scenarios/HeaderFullyStripped.java`). | ||
|
|
||
| ``` | ||
| MIT License | ||
|
|
||
| Copyright (c) 2016 Example Author | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
| WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Example — HeaderMissingButNoticePresent (Apache 2.0) | ||
|
|
||
| **Source:** https://github.com/example/notices-without-header<br> | ||
| **License:** Apache License 2.0<br> | ||
| **Copyright:** Copyright 2023 Example Corp. | ||
|
|
||
| ### Scope | ||
|
|
||
| Attribution validation sample. The code resides in `io.sentry.skills.verification.HeaderMissingButNoticePresent`. | ||
|
|
||
| ``` | ||
| Copyright 2023 Example Corp. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Example — HeaderMissingNonEssentialInfo (MIT) | ||
|
|
||
| **Source:** https://github.com/example/examplelib<br> | ||
| **License:** MIT License<br> | ||
| **Copyright:** Copyright 2020 Example Corp. | ||
|
|
||
| ### Scope | ||
|
|
||
| Attribution validation sample. The code resides in `io.sentry.skills.verification.HeaderMissingNonEssentialInfo`. | ||
|
|
||
| ``` | ||
| MIT License | ||
|
|
||
| Copyright (c) 2020 Example Corp. | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
| WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Example — HeaderCompleteAndNoticePresent (Apache 2.0) | ||
|
|
||
| **Source:** https://github.com/example/complete-with-notices<br> | ||
| **License:** Apache License 2.0<br> | ||
| **Copyright:** Copyright 2020 Example Authors | ||
|
|
||
| ### Scope | ||
|
|
||
| Attribution validation sample. The code resides in `io.sentry.skills.verification.HeaderCompleteAndNoticePresent`. | ||
|
|
||
| ``` | ||
| Copyright 2020 Example Authors | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| ``` | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catalog source URL mismatches scenario header URLs
Medium Severity
The
header-complete-and-notice-presentscenario expects no findings, but the catalog Source URL (https://github.com/example/complete-with-notices) doesn't match either URL in the Java file header (https://github.com/example,https://github.com/example/something). Since source URL is a required field and SKILL.md flags header-vs-NOTICES inconsistencies on required fields, the AI can intermittently report a finding here, making this negative test case flaky.Additional Locations (1)
.claude/skills/check-code-attribution/validation-tests/scenarios/HeaderCompleteAndNoticePresent.java#L1-L13Reviewed by Cursor Bugbot for commit 93b92d7. Configure here.