Skip to content

design(#77): merge-driver design + multi-model review + consolidated decisions - #80

Closed
thehoff wants to merge 2 commits into
developfrom
design/branding-merge-driver-77
Closed

thehoff wants to merge 2 commits into
developfrom
design/branding-merge-driver-77

Conversation

@thehoff

@thehoff thehoff commented May 19, 2026

Copy link
Copy Markdown
Owner

Design-only PR for #77. No production code in this PR — only docs/contributing/.

Three artifacts

  • `REBRAND_MERGE_DRIVER_DESIGN.md` — full design from feature-dev:code-architect agent (architecture diagram, .gitattributes scope, TOML schema, substitution engine semantics, driver script contract, single-source-of-truth strategy, 5 failure modes, rollout plan, dry-run validation, 5 open questions, FORBIDDEN_TOKENS → TOML rule mapping appendix)
  • `REBRAND_MERGE_DRIVER_REVIEW_CODEX.md` — Codex/GPT-5 review
  • `REBRAND_MERGE_DRIVER_REVIEW_GEMINI.md` — Gemini 0.42.0 review
  • `REBRAND_MERGE_DRIVER_DECISIONS.md` — consolidated decisions (Claude)

Cross-model consensus on the 5 open questions

Q Resolution Both models?
Q1: Shell vs Rust Rust — standalone `tools/branding-engine/` workspace member ✅
Q2: Line-number stability Forbid newline-changing rules at TOML load ✅
Q3: Conflict-marker handling Skip blocks — driver MUST NOT touch `<<<<<<<`/`=======`/`>>>>>>>` regions ✅
Q4: safe_guard scope Per-rule TOML + hardcoded global classes (Codex pref; Gemini dissent → hybrid) noted Codex over Gemini
Q5: Rebase invocation cost No special-casing — compiled binary makes per-commit cost negligible ✅

Critical design fixes the reviews surfaced

  • Diff-aware coordinate bug (Codex) — original union of `%O→%A` and `%O→%B` line-number sets crossed coordinate systems. Fix: derive target lines from `%A` only.
  • Atomic write missing (Codex) — helper could partially-write `%A` and exit 0. Fix: `%A.tmp` + rename.
  • UTF-8 validation missing (Gemini) — non-UTF-8 file would silently corrupt. Fix: validate at process start; exit 0 + log warning on non-UTF-8.
  • TOML schema under-specified (Codex) — no rules for duplicate IDs, duplicate needles, regex dialect, newline handling. Fix: loader rejects all of these.
  • Single-source-of-truth asymmetry (Codex) — FORBIDDEN_TOKENS could drift downward silently. Fix: bidirectional equivalence test + `// driver-managed` marker convention.

Implementation order (per decisions doc)

  1. `tools/branding-engine/` — standalone Rust workspace member
  2. `branding/rebrand.toml` — initial 16 rules from FORBIDDEN_TOKENS
  3. `scripts/branding-merge-driver.sh` — thin wrapper around the binary
  4. `scripts/install-merge-driver.sh` — build + git config write
  5. `.gitattributes`
  6. branding_lint test with bidirectional assertion
  7. UPSTREAM_REBASE.md update
  8. CI workflow integration

What this PR asks for

Approval of the consolidated decisions before implementation begins. The implementation PR will land separately on the same issue.

Related PRs in flight

🤖 Generated with Claude Code

thehoff and others added 2 commits May 19, 2026 10:09
…uestions for multi-model review

Pre-implementation design doc for #77. Covers:
- Architecture: git 3-way merge → driver → diff-aware substitution → exit
- .gitattributes scope: src/**/*.rs + Cargo.toml + release-please-config.json
  (NOT tests/, scripts/, hooks/, docs/ — each justified)
- branding/rebrand.toml schema: literal + regex rules with safe_guard,
  scope globs, reason/issue metadata
- Substitution engine: diff-aware (changed-line set only), first-match-wins,
  literals before regex
- Driver script contract: bash skeleton, argv/exit-code/log policy,
  trap-based cleanup on partial-write
- Single source of truth: TOML authoritative; cargo test asserts equivalence
  with FORBIDDEN_TOKENS (option c over codegen/shared-file)
- Failure modes: F1 partial-write, F2 malformed TOML, F3 self-conflict,
  F4 driver-not-installed, F5 wrong-substitution — recovery procedures
- Rollout: install-merge-driver.sh, CI workflow integration, UPSTREAM_REBASE.md updates
- Dry-run validation against c35339e (last heavy upstream merge)

Five open questions for multi-model review before implementation:
1. Shell vs Rust binary for rule application sub-script
2. Line-number stability under length-changing regex substitutions
3. Conflict-marker handling: substitute inside blocks or skip them?
4. safe_guard scope: per-rule field vs global table
5. Driver invocation cost during git rebase (per-commit replay) vs merge

Refs #77. Generated by feature-dev:code-architect agent from
the FORBIDDEN_TOKENS history, UPSTREAM_REBASE.md, and the c35339e
last-heavy-merge audit.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… decisions

Three artifacts:
- REBRAND_MERGE_DRIVER_REVIEW_CODEX.md — Codex/GPT-5 review
- REBRAND_MERGE_DRIVER_REVIEW_GEMINI.md — Gemini 0.42.0 review
- REBRAND_MERGE_DRIVER_DECISIONS.md — Claude consolidation, resolves all 5 open questions

Cross-model consensus on all 5 open questions:
- Q1 Rust (both) — bash too fragile given branding_lint's existing complexity
- Q2 Forbid newline-changing rules at TOML load (both)
- Q3 Skip conflict-marker blocks (both flagged design's "substitute inside" as wrong)
- Q4 Per-rule safe_guard + hardcoded global classes (Codex; design current); Gemini
     dissent (hybrid) noted but Codex's structural-vs-rule split is more durable
- Q5 No rebase special-casing — compiled binary makes per-commit cost negligible

Critical fixes the reviews surfaced (NOT in original design):
- Diff-aware coordinate bug — union of two diff coordinate systems was incorrect
  (Codex). Fix: derive line-number set from %A only.
- Atomic write missing in apply-rules helper (Codex). Fix: write to %A.tmp + rename.
- UTF-8 validation missing (Gemini). Fix: validate at process start; exit 0 + warn
  on non-UTF-8 so file is left for human review.
- TOML schema under-specified (Codex): duplicate IDs, duplicate needles, regex
  dialect, newline rules. Fix: TOML loader rejects all of these with id-referenced errors.
- Single-source-of-truth asymmetry (Codex): FORBIDDEN_TOKENS can drift downward
  silently. Fix: bidirectional equivalence test + `// driver-managed` marker convention.

Implementation order revised (in decisions doc):
1. tools/branding-engine/ — standalone Rust workspace member
2. branding/rebrand.toml — initial rule set
3. scripts/branding-merge-driver.sh — thin wrapper around the binary
4. scripts/install-merge-driver.sh — builds binary + writes git config
5. .gitattributes
6. branding_lint test with bidirectional assertion
7. UPSTREAM_REBASE.md update
8. CI workflow

Refs #77. Implementation pending Hoff approval per decisions doc.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@thehoff

thehoff commented Jun 10, 2026

Copy link
Copy Markdown
Owner Author

Closing — not pursuing a custom branding-rebrand merge driver (#77 closed too). Upstream-rebase ergonomics handled via the existing sentinel-block convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant