Repository navigation
Description
Problem
Every upstream rebase from `rtk-ai/rtk` re-introduces `rtk` strings via:
- NEW upstream additions that touch our hardened branding lines (not conflicts — just additions; rerere doesn't help)
- Refactors that move our brand-applied strings to a new file (rerere mismatches)
We catch most via `branding_lint` post-merge, but the current flow is:
- Merge upstream
- Run `cargo test`
- Branding lint fails
- Hand-fix each leak
That's 4-step manual labour every rebase. The 2026-05-15 heavy rebase (641 commits, v0.39 → v0.41) took a full day; even light rebases hit ≥1 lint failure each.
Goal
Make the rebrand SWEEP automatic for the high-leak file set, and document the new flow in UPSTREAM_REBASE.md.
Proposed approach
1. Centralise the substitution rules
A single `branding/rebrand.toml` listing:
```toml
[substitutions]
"RTK savings" = "ContextCrawler savings"
"RTK adoption" = "ContextCrawler adoption"
"[rtk]" = "[contextcrawler]"
"$(rtk " = "$(contextcrawler "
... pulled from FORBIDDEN_TOKENS history
```
Substitutions are SCOPED (only fire on lines added or modified by the merge; only inside specific path globs) to avoid mangling legitimate references.
2. Custom merge driver
`.gitattributes`:
```
src/main.rs merge=branding-rebrand
src/cmds//*.rs merge=branding-rebrand
src/discover/report.rs merge=branding-rebrand
src/analytics//*.rs merge=branding-rebrand
src/hooks/init.rs merge=branding-rebrand
```
`.git/config` driver:
```
[merge "branding-rebrand"]
name = Three-way merge then apply branding substitutions
driver = scripts/branding-merge-driver.sh %O %A %B %L %P
```
Driver script:
- Run `git merge-file %A %O %B` (standard 3-way)
- Apply substitutions from `branding/rebrand.toml` to %A — diff-aware, NEW lines only
- Exit 0 / 1 based on merge-file result
3. CI gate retained as backstop
`branding_lint` still runs in CI — if a substitution rule is missing or wrong, CI still blocks the merge.
4. UPSTREAM_REBASE.md updates
Add the new flow + a "if branding-rebrand driver misfires, here's how to debug" section.
Definition of done
- `.gitattributes` registered for the high-leak file set
- `branding/rebrand.toml` populated from FORBIDDEN_TOKENS + survey of past leak commits
- `scripts/branding-merge-driver.sh` shipped with unit tests on the substitution engine
- `scripts/install-merge-driver.sh` one-shot to register the driver in `.git/config` (for fresh clones)
- UPSTREAM_REBASE.md updated
- Dry-run on commit c35339e (last heavy upstream merge) reproduces the hand-fix sweep without manual intervention
Risks
- Driver corrupts legitimate code: mitigation = scoped substitutions + diff-aware (NEW lines only) + branding_lint as backstop
- Substitution rules drift from FORBIDDEN_TOKENS: mitigation = generate the TOML from the test file as part of `cargo test`, or vice versa — single source of truth
Why
Durably fixes the whack-a-mole. After this lands, an upstream rebase that touches a branding-leak file produces a CLEAN tree without manual intervention — only NEW leak CLASSES should fail (not new instances of known classes).
Review plan
Multi-model peer review (claude + codex + gemini) on the merge-driver design BEFORE implementation, since driver bugs cause silent code corruption.
Sequencing
- Issue A (clap-aware lint) and Issue B (KNOWN_UNBRANDED debt reduction) ship first.
- Their outputs feed the substitution rule set used here.
- This issue lands LAST in the trilogy.
Activity
design(thehoff#77): merge-driver design + multi-model peer review + c…
thehoff commentedon Jun 10, 2026
Closing — not pursuing a custom rebrand merge driver (design PR #80 closed too). Upstream rebases use the existing sentinel-block convention.