feat(scripts): add cousin workflow for opted-in Rust subpaths#11
Merged
Conversation
…d-party repos Introduces the concept of 'cousin' repositories — third-party projects that contain Rust code in explicitly whitelisted subpaths, but are not forks of this template. Cousins follow their own conventions and may have unrelated tooling (Bazel, custom CI, etc.), so the workflow is hyper-conservative: nothing is touched unless it is explicitly opted-in in scripts/cousins.json, and a 'forbidden_paths' hard deny list acts as a belt-and-suspenders safety net. Schema (scripts/cousins.json): - cousins[].name / url / notes - cousins[].targets[].path / applies[] / check (per-crate) - cousins[].global_applies[] (rare; repo-root files) - cousins[].forbidden_paths[] (glob deny list) Four new scripts: - cousin_review.sh / cousin_review_all.sh — read-only, produce a markdown report classifying diffs as SUGGEST-ADOPT, SUGGEST-NEW-FILE, KEEP-COUSIN, or NOT-APPLICABLE. Allowed tools: Read Bash. Never modifies anything. - cousin_apply.sh / cousin_apply_all.sh — write mode. Clones the cousin fresh into a tempdir, copies template bytes verbatim into opted-in slots only (no retyping via Write), runs per-target checks with priority 1) targets[].check 2) 'cargo check --manifest-path <target>/Cargo.toml' 3) skip, reverts failed targets, and opens a single PR per cousin. Reuses scripts/lib/pr_prompt.sh for deferred PR URL prompting. A new scripts/lib/cousins.sh helper handles jq parsing and cousin lookup. justfile: adds cousin-review (cr), cousin-review-all (cra), cousin-apply (ca), cousin-apply-all (caa).
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.
Summary
Introduces the concept of cousin repositories — third-party projects that contain Rust code in explicitly whitelisted subpaths but are not forks of this template. Cousins have their own conventions and unrelated tooling (Bazel, custom CI, etc.), so the workflow is hyper-conservative.
Core safety principle: nothing is touched unless explicitly opted-in via `scripts/cousins.json`, and a `forbidden_paths` glob deny list acts as a belt-and-suspenders check.
Schema — `scripts/cousins.json`
```json
{
"cousins": [
{
"name": "acme-monorepo",
"url": "git@github.com:acme/monorepo.git",
"notes": "Bazel-based. CI is Bazel-managed — never touch .github.",
"targets": [
{
"path": "backend/services/auth",
"applies": ["rustfmt.toml", "clippy.toml"],
"check": "bazel test //backend/services/auth/..."
}
],
"global_applies": ["CLAUDE.md"],
"forbidden_paths": [".github/**", "Cargo.toml", "justfile"]
}
]
}
```
A `$example` key inside the JSON documents the schema inline. The shipped file has `cousins: []`.
Scripts
Per-target check resolution
For each `targets[i]` that had changes applied, in priority order:
Reused infra
justfile
Adds `cousin-review` (`cr`), `cousin-review-all` (`cra`), `cousin-apply` (`ca`), `cousin-apply-all` (`caa`).
Test plan