feat: enforce skill and SDK attribution in the PreToolUse hook - #55
Open
henry-jackson wants to merge 1 commit into
Open
feat: enforce skill and SDK attribution in the PreToolUse hook#55henry-jackson wants to merge 1 commit into
henry-jackson wants to merge 1 commit into
Conversation
henry-jackson
force-pushed
the
henry-jackson/api-request-env-quoting
branch
from
August 31, 2026 15:10
b216510 to
19931c1
Compare
henry-jackson
force-pushed
the
henry-jackson/hook-skill-attribution
branch
from
August 31, 2026 15:13
82bc740 to
af26e46
Compare
Base automatically changed from
henry-jackson/api-request-env-quoting
to
main
September 2, 2026 17:25
Around 74% of requests from plugin 1.7+ have no skill attribution. The request wrapper sets X-Spotify-Ads-Skill and X-Spotify-Ads-Sdk deterministically, but agents sometimes hand-write curl instead, and those calls are unattributable in per-skill usage and error-rate reporting. The hook now recovers what attribution is available: - SDK header: deterministic, injected verbatim when missing. The value comes from `api-request.sh --env` rather than a second copy of the platform/version logic, so it cannot drift. - Skill header: inferred from the most recent transcript lines, newest-first so recency wins, accepting only names that match a real skill in this plugin. Inferred values carry an "-inferred" suffix so reporting can separate best-effort attribution from the wrapper's exact value. When inference fails, no skill header is invented and the agent gets a nudge toward api() instead. Detection also widens to catch `$BASE_URL/...` commands. The assets and audiences upload flows use that form and were bypassing the hook entirely, missing token refresh as well as attribution. Attribution lives in a sourced library, not a second hook. Matching PreToolUse hooks run in parallel against the original input and the last updatedInput wins in non-deterministic order, so a separate rewriting hook would race the token refresh and silently drop one of the two edits. Antigravity cannot rewrite a command on any hook event, so there the hook warns instead of injecting. Adds 52 assertions to tests/test-check-token.sh. Seven independent mutations of the library each fail the suite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
henry-jackson
marked this pull request as ready for review
September 3, 2026 18:23
henry-jackson
force-pushed
the
henry-jackson/hook-skill-attribution
branch
from
September 3, 2026 18:23
af26e46 to
d2b4489
Compare
daoudsleiman
approved these changes
Sep 4, 2026
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.
Description
The PreToolUse hook now enforces skill and SDK attribution on raw curl calls to the Spotify Ads API. When an agent bypasses the
api()wrapper:api-request.sh --env).-inferredsuffix (e.g.campaigns-inferred) so reporting can distinguish it from wrapper-set values. Only names matching a real skill are accepted.api()and no header is invented.$BASE_URL/...in addition to the literal host, so asset and audience uploads no longer bypass the hook.Attribution lives in
hooks/lib/attribution.sh, sourced byhooks/check-token.sh. It is not a separate hook registration because matching PreToolUse hooks race each other and the last rewrite wins.Verification
52 new assertions covering detection, curl injection edge cases, inference ordering, and per-platform behaviour. Seven independent mutations of the library each fail the suite.
Checklist