chore(#110): block-private-refs-in-public-repos.sh hook#119
Merged
Conversation
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.
Summary
Adds a new PreToolUse hook
block-private-refs-in-public-repos.shthat scrubs registered private-project identifiers from content destined for public framework repos (me2resh/apexyard+ whatever the fork'supstreamremote resolves to + any extras configured under.leak_protection.public_framework_repos).Catches a common leak vector: an author diagnoses a framework bug while working in a private project, then files the upstream ticket or comment with a helpful "discovered during
<private-project>rebase" reference. Once filed, the private project's name is permanently on a public issue tracker and searchable. This hook is the mechanical backstop for the discipline in the new.claude/rules/leak-protection.mdrule..claude/hooks/block-private-refs-in-public-repos.sh(~230 LOC).claude/rules/leak-protection.md.leak_protection.public_framework_repos,.leak_protection.auto_detect_upstream,.leak_protection.skip_markervia the shared config lib introduced in [Chore] Make ticket-prefix whitelist + schema project-configurable (not hardcoded) #109.claude/project-config.defaults.jsonwith aleak_protectionsubtree.claude/settings.json— five PreToolUse matchers forgh issue create,gh pr create,gh issue comment,gh pr comment,gh apidocs/rule-audit.md, mechanized count bumped.claude/hooks/tests/test_block_private_refs.shHow it works
ghinvocation, parse--repo(or therepos/owner/name/...path ongh api). If the target isn't public-class (not in the configured list + upstream), silent no-op.apexyard.projects.yamlby walking up from CWD; extract each project'sname,repo, andworkspacefields. If the registry is missing, silent no-op — treated as "not an apexyard fork."apexyardon an apexyard upstream ticket doesn't fire.--title,--body,--body-file,-F <path>, andgh api-style-F body=@file/-f body=...) for whole-word matches against the extracted tokens, plusowner/repo#Npatterns.<!-- private-refs: allow -->in the body bypasses with a visible warning.Testing
Ran the committed test fixture — 10 cases, all pass:
Also smoke-tested the config integration after swapping the agent's inlined defaults for shared-lib reads:
public_framework_repos→ hook honours the overrideauto_detect_upstream: false→upstreamremote ignoredScope — what this does NOT do
validate-commit-format.sh/validate-pr-create.sh).--input -/ stdin-drivengh apishape (noted in the hook's own header comment as an accepted gap).Follow-ups
authorcore) could produce false positives. Mitigation is documented in the rule file; can harden with a project-config-level denylist of "skip these names" if pain emerges..claude/hooks/tests/convention was introduced by this hook. If future hook tests accumulate, consider a tiny runner pattern doc.Glossary
me2resh/apexyardby default, plus each fork's configured list + upstream auto-detect.apexyard.projects.yaml. The hook treats these as "do not mention upstream."<!-- private-refs: allow -->in the body that lets one invocation through with a visible warning.Closes #110