Skip to content
C.W.K.
Lesson 05 of 15 · published

Variants Inherit Down — Copy-and-Adapt Pattern

~12 min · pattern, rule-2

Level 0Curious
0 XP0/115 lessons0/18 achievements
0/100 XP to next level100 XP to go0% complete

Copy-and-adapt, not import-and-share

Each variant's routes/chat.py is a deliberate copy of the Claude route. They share the pattern (JSONL ground truth, SQLite store, ChromaDB embedding, healing) but own their own code. No shared helper extraction across variants.

Why no shared helper

Shared helpers in this layer would force every variant through a lowest-common-denominator interface — exactly what Rule 1 forbids. Each variant evolves independently. If three variants discover they need the same change, the third is the one that proves the pattern is worth extracting. Until then: copy.

Tool bridge is brain-agnostic

Tool execution is where sharing starts to pay, and even there it follows the rule above. Each variant keeps its own tool_bridge.py; the helpers they genuinely have in common live in one shared module beside them, variants/tool_bridge_common.py. Local Read/Write/Edit/Bash execution is the same whichever brain asked for it — and Claude does not use a bridge at all, because its tools run inside the SDK. The variant-specific part is schema format conversion (OpenAI for Codex/Ollama, function_declarations for Gemini, wrapping for Ollama).

The principle: Sharing is correct when the thing being shared is genuinely the same. Tool execution is the same. Wire format is not. Knowing the difference is the architectural skill.

Copy here does not mean copying without limits. It means each provider owns, in its own file, the route and wire adaptation that genuinely differ. Copy a primitive that already has a canonical owner, such as the JSONL writer, healing or tool execution, and you have not made a new variant; you have made a second truth. Differences are absorbed downstream, and a shared responsibility stays with its owner.

Do not apply the third-case rule by counting lines either. Similar text in three files is not, by itself, a reason to extract a helper. The evidence has to be that the three implementations share the same invariant and the same failure behavior, and change for the same reasons. Code that looks alike but has to evolve apart, because each provider's policy differs, is more honest left side by side.

Three questions settle it. Who owns this logic? Do the copies change for the same reason? May a failure in one shake the others? When the answers split, do not force a share; when they agree, inherit from the canonical layer that already exists. The point of copy-and-adapt is not the copying. It is billing each change to the right descendant.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue
💛 by Pippa— warm💛 by Ttori— warm

Comments 0

🔔 Reply notifications (sign in)
Sign in — Please sign in to comment.

No comments yet — be the first.