Skip to content
Back to skills

Upstream Tree Carry

ASecurity

Use when carrying an upstream project's tree into your repo.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 1, 2026
ai-agentsgotestingcode-reviewgitapi

Works with

  • api

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add wxxb789/hoa --skill upstream-tree-carry --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Upstream Tree Carry?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Upstream Tree Carry
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wxxb789-upstream-tree-carry/badge)](https://www.skillsdirectory.com/skills/wxxb789-upstream-tree-carry)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: upstream-tree-carry
description: Use when carrying an upstream project's tree into your repo.
version: "0.1.0"
license: MIT
author: Zoe
metadata:
  version: "0.1.0"
  areas: "software-development"
  targets: "runtime-agnostic"
  summary: "carry an upstream tree at a pin: named deviations, a parity gate, a boundary that cannot drift, and a portability gate for the half you own"
  summary_zh: "把上游代码树整体搬进自己的仓:具名偏离、一致性门、不会漂移的边界,以及给自己那半边留一条可回灌上游的通道"
  kind: "mechanism"
  consumes: "upstream-repository"
  produces: "carried-tree-with-boundary"
  hermes:
    tags: [vendoring, upstream-sync, byte-parity, repo-boundary, go-modules]
    related_skills: [verification-probes, concurrent-agent-repo-workflow, gdd, code-review-gates, mechanical-gate-design]
---

# Carrying an upstream tree

You build on another project's code and want **its** code to stay its code — copied verbatim, synced to a
pin, provably unchanged — while your own code grows beside it, and ideally stays mergeable back upstream.

Name the two halves before arguing about anything: the upstream project usually does **n → 1** (n input
formats → one intermediate model) and your product does **1 → n** (that model → n output formats). The
first half must be *their* bytes; the second is yours. Decide which half a change belongs to before writing
code — a private re-implementation of an input format's wire shape or state machine is the defect this
arrangement exists to prevent, and where the two can disagree, the upstream reader or the real binary is
the referee.

## When to Use

- A repo carries a large upstream tree (a fork you track, a library you build a product on) and needs to move
  to a new pin, gain a boundary, or be audited for drift.
- You are choosing the **layout** of that arrangement — where the carried tree lives, how your code sits
  beside it — including when back-porting your half upstream is a stated ambition.
- Not for an ordinary dependency (a package manager) and not for a one-off copy of a few files.

## 1. The three pieces: pin, ledger, gate

- **Pin** — the exact upstream revision in one machine-readable file: commit sha, remote, described version,
  commit date, and the file counts.
- **Ledger** — the path-by-path record: every carried file with blob hash and size, plus an explicit list of
  **deviations** (files deliberately not carried as upstream's bytes, each with its reason) and the path
  prefixes *this* repository owns. Generated by an importer script from a checkout of the pin, never
  hand-edited — at a new pin you re-run it instead of patching it.
- **Parity gate** — a step in the repo's own gate that re-derives the carried set and proves every file is
  byte-identical to the pin, so drift is caught by the command that judges every other change. Pair it with
  a size ceiling and a two-read (`git status`) stability check: a tree still being written grades as
  changed, and that false failure costs a full gate cycle to disprove.

Carrying is the default; a deviation is a decision someone signs. Keep the list short and shrinking, and
expect the *reasons* to be boring: a file that would make your CI run the upstream project's workflows, a
path your repository also owns (`README`, `.gitignore`, an agent control file), a generated build input
upstream restores from an artifact, one fixture whose bytes differ.

## 2. Choose the boundary shape deliberately

| Shape | What it is | Cost |
|---|---|---|
| Allowlist at one root | the carried tree *is* your root; the ledger names the prefixes you own | cheapest; the boundary is a list, and upstream paths and yours interleave in the same directories |
| Your code in one folder | the carried tree stays at the root; all of your code moves under a single top-level folder | a small move; the carried tree is still scattered across the root's directories |
| **Carry in its own folder, two modules** | the whole carried tree moves under one directory with its own build file; your code is a sibling module pointing at it | a whole-tree rename commit and a two-unit build; buys a boundary that cannot drift |

Take the third when **back-porting your half upstream is a real ambition** — not because the import paths
differ (they are identical in the second and third shapes), but for two properties the others cannot give:

- **Your half becomes buildable against a pristine upstream checkout** — one `replace` aimed at a fresh
  clone of the pin. That is the dress rehearsal for an upstream pull request, and it mechanically proves
  your module depends on upstream only through upstream's own APIs, never through your own deviations.
  Under a shared root that proof cannot even be posed.
- **Most deviations stop existing.** Collision-class files stop colliding once each side has one home:
  GitHub reads workflows only from the **repository-root** `.github/`, so upstream's `.github/**` carried
  inside a subdirectory is inert and can be kept byte-for-byte, while your `README` / `.gitignore` / control
  file move outside the carry and no longer overwrite upstream's. Fewer deviations means fewer "ours or
  theirs?" answers when preparing a patch.

State the costs in the same breath: the rename breaks `git log` continuity across it (cosmetic where
provenance is the pin and the ledger rather than linear history), the gate and CI move to two build units (a
root `go test ./...` no longer covers the carry), and the parity ledger is re-pointed from root paths to the
folder.

Then land the portability gate in the same change, so the property is checked rather than asserted: **build
and test your module with the `replace` aimed at a pristine checkout of the pin**, and keep the rule that
only the carried tree may hold deviations — your module may depend on none of them.

## 3. Keep the language's own rules from dictating the layout (Go)

For Go this shape works without touching a byte of the carried tree — provided the module path is chosen
correctly. The `internal/` rule is decided on **import paths**, not directories: a module whose path is a
**subpath** of the carrying module's path may import the carrying module's `internal/...` packages, while an
unrelated module path is refused (`use of internal package … not allowed`). So the carried tree keeps its
own `go.mod` and its files' own import statements **unchanged**, and your module — declared as a subpath of
the upstream module path, with a `replace` to the carried directory — imports them normally. No public
facade, no patched bytes, no forked import lines.

Never move a tree without moving its module root: relocating the carried files while leaving `go.mod` behind
rewrites the import path of every file in the tree and destroys byte-parity. Catch that before the rename,
not after.

Prove the rule against the installed toolchain before pricing the option — seconds of work, and the
difference between a layout chosen and a layout inherited: `scripts/go-internal-boundary-probe.py`
(positive controls must build, the negative control must be refused). Facts, module files and the exact
layout: [`references/go-module-boundary.md`](references/go-module-boundary.md).

## Pitfalls

- **A remembered platform constraint is a claim.** When a design was rejected "because the language forbids
  it", re-probe the constraint before re-pricing the option — inherited vetoes are stated more broadly than
  they hold, and re-testing one has reversed it. Probe design: skill `verification-probes` §1.10.
- **Never edit a byte inside the carried tree to make your tooling work.** Every such edit is a deviation
  somebody has to explain forever; prefer a seam your side owns (a module boundary, a wrapper, a build
  flag). When a deviation is genuinely unavoidable it is written into the ledger, with its reason, in the
  same increment that introduces it.
- **Do not let the carry's scratch directories land in the repo.** A diff/parity tool that creates its own
  working root relative to the current directory leaks one directory per run into the repo root — and they
  are invisible to `git status`, because an empty directory is untracked and reported by nothing. Run such
  tools from a scratch directory, clean their roots, and look for them by name before calling a tree clean.
- **A carry-heavy diff is not a reviewable diff.** Scope the reviewer to the project-owned delta and let the
  parity gate own the copy; project-owned deviations *inside* the carried tree stay in the reviewed set, and
  an unparsable exclusion list fails closed. (Prompt shape: skill `code-review-gates`.)
- **A root file the carry owns governs the whole repository — moving it changes YOUR files' behaviour too.**
  While the carry sits at the repository root, its root-level `.gitattributes` / `.editorconfig` /
  `.gitignore` / CI config applies to *everything*, your own half included. Move the carry into its own
  folder (or carry that file verbatim) and it silently stops governing your half: with `.gitattributes`'s
  `* text=auto eol=lf` gone from the root, your own files check out CRLF on Windows, `gofmt -l` lights up
  **only** on your files, and every LF-sensitive comparison against a recorded artifact fails — on the
  other-OS CI leg, hours later, while the local gate is green. Give your half its own root copy in the same
  increment (the carried copy stays inside the carry, governing it), and measure the effect instead of
  assuming it: `git check-attr text eol -- <your file> <carried file>` (it must answer for both), and a
  Windows checkout simulated on Linux, which is exact and needs no Windows box —
  `git -c core.autocrlf=true worktree add --detach <tmp> HEAD`, then re-run the linter and the suite inside
  it. The other-OS CI leg is the referee; a green local gate says nothing about it.
- **Sync is a re-derivation, not a merge.** At a new pin, re-run the importer and read the ledger's diff:
  new deviations, changed skip reasons and a grown owned-prefix list are the review surface. Resolving a
  conflict by hand inside the carried tree is how the ledger and the tree start disagreeing.

Files in this skill

  • SKILL.md10 KB
  • references/go-module-boundary.md4.5 KB
  • scripts/go-internal-boundary-probe.py4.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.