Repository navigation
Proposal: Sustainable Upstream Sync Strategy #48
Description
Proposal
Context
This fork of OpenCode tracks an upstream repository on the dev branch. The current sync process (script/sync-upstream.ts + FORK_WORKFLOW.md) creates a worktree and merges upstream into it, but leaves much of the validation and custom-change preservation to manual effort. As the fork accumulates local features (Skein integration, beads, llama-swap patches, llama-skein), each sync becomes more error-prone and time-consuming.
Why
Without a structured, repeatable sync strategy:
- Custom changes (token cache_write, SSE usage injection, HTTP/1.1 upstream) are at risk of being lost during merges
- Validation is manual and incomplete — typechecks, builds, and smoke tests happen ad hoc
- The Skein dependency chain (upstream → fork → tagged snapshot → skein port) has no automation to enforce tagging discipline
- Conflict resolution is unguided — no tooling identifies which files will likely conflict
What
A comprehensive, automatable upstream sync strategy that includes:
- Enhanced sync script — extends
script/sync-upstream.tswith conflict detection, pre-merge analysis, and post-merge validation hooks - Custom change preservation guide — documents each custom change with exact file locations, diff context, and re-application steps
- Validation checklist — automated checks for typecheck, build, and smoke test in the sync worktree
- Tagging discipline — enforces the upstream → fork → tagged snapshot → skein port dependency chain
- Updated FORK_WORKFLOW.md — consolidates all sync procedures into a single authoritative reference
Scope
-
In scope:
- Enhance
script/sync-upstream.tswith conflict analysis and validation hooks - Expand
FORK_WORKFLOW.mdwith full custom-change catalog and re-application procedures - Add a validation script (
script/sync-validate.ts) for the sync worktree - Document the Skein port chain enforcement procedure
- Add a GitHub Action or pre-commit hook for sync readiness checks
- Enhance
-
Out of scope:
- Merging specific upstream commits (that is an operational use of this strategy)
- Changes to Skein, beads, llama-swap, or llama-skein repositories themselves
- Automating the actual conflict resolution (we document the process, not auto-fix)
Risks
- Scope creep — mitigated by keeping tasks focused on documentation and lightweight tooling
- Script complexity — the sync script could become fragile; mitigated by keeping it simple and well-tested
- Stale custom-change docs — mitigated by including custom-change docs as part of the sync validation checklist
Disposition (2026-09-18)
Archived — superseded/obsolete. Superseded by fork/manifest.json + script/fork-verify.ts + script/sync-check.ts + FORK_WORKFLOW.md.
Tasks
Phase 1 — Custom Change Catalog
-
Catalog every custom change in
FORK_WORKFLOW.md— for each, record: source file, purpose, upstream commit hash where divergence began, and current diff context. Add todocs/UPSTREAM_SYNC.mdunder a "Custom Change Catalog" section. Validation:grep -c "^###" docs/UPSTREAM_SYNC.md≥ 4 -
Document token cache_write patch — record exact file (
src/config/config.tsor wherever it lives), the upstream line range, the local modification, and the re-application steps. Add todocs/UPSTREAM_SYNC.mdas a subsection with agit apply-able patch block. Validation:grep -q "cache_write" docs/UPSTREAM_SYNC.md -
Document SSE usage injection patch — record the file, purpose, and re-application procedure. Validation:
grep -q "SSE" docs/UPSTREAM_SYNC.md -
Document HTTP/1.1 upstream patch — record the file, purpose, and re-application procedure. Validation:
grep -q "HTTP/1.1" docs/UPSTREAM_SYNC.md -
Document llama-skein mDNS service registration — record the service name, port, and how the fork's
src/local/mdns.tsdiscovers it. Validation:grep -q "mdns" docs/UPSTREAM_SYNC.md
Phase 2 — Enhanced Sync Script
-
Add conflict-preanalysis to
script/sync-upstream.ts— before the merge, rungit diff --name-only upstream/dev...HEADagainst the last known sync point to identify files that have diverged; log them as "likely conflict files". Validation:bun script/sync-upstream.ts --dry-runexits 0 and prints "likely conflict files" -
Add
--validateflag toscript/sync-upstream.ts— after merge, run typecheck, build, and smoke-test in the worktree; exit non-zero on failure. Validation:bun script/sync-upstream.ts --validate --dry-runexits 0 -
Add custom-change re-application hooks — after merge, the script detects which custom changes are still needed and applies them in order, logging each as "re-applied" or "already present". Validation:
bun script/sync-upstream.ts --dry-run --apply-customsprints re-application status for each cataloged change -
Add post-sync summary — output a markdown summary of what changed: upstream commits merged, custom changes re-applied, validation results, remaining conflicts. Validation:
bun script/sync-upstream.ts --dry-runoutputs a "--- Sync Summary ---" block
Phase 3 — Validation Script
-
Create
script/sync-validate.ts— standalone script that runs the full validation suite:bun typecheck,bun run build, and a smoke test (e.g.,opencode run --helpexits 0). Accepts a--worktreeflag pointing to the sync worktree. Validation:bun script/sync-validate.ts --worktree .exits 0 -
Add build check to validation — ensure
bun run buildsucceeds in the worktree. Validation:bun script/sync-validate.ts --worktree . --check buildexits 0 -
Add smoke test to validation — run
opencode run --helpand verify exit code 0 and output contains "Usage". Validation:bun script/sync-validate.ts --worktree . --check smokeexits 0
Phase 4 — Tagging Discipline
-
Document the upstream → fork → tagged snapshot → skein port chain in
docs/UPSTREAM_SYNC.mdwith a diagram and step-by-step procedure. Validation:grep -q "tagged snapshot" docs/UPSTREAM_SYNC.md -
Add
script/tag-upstream.sh— helper that creates a semver-tagged snapshot of the fork at the current upstream merge point, prints the tag name, and logs it. Validation:bash script/tag-upstream.shcreates a tag and prints it -
Document skein port update procedure — steps to update
skein's dependency on the fork to point to the new tagged snapshot. Validation:grep -q "skein" docs/UPSTREAM_SYNC.md
Phase 5 — Automation & CI
-
Add GitHub Action for sync readiness —
./.github/workflows/sync-readiness.ymlthat runsscript/sync-validate.tson every PR todev. Validation:cat .github/workflows/sync-readiness.yml | grep -q "sync-validate" -
Add pre-commit hook for sync readiness —
./script/pre-commit-syncthat runs a lightweight check (typecheck + build) before commits todev. Validation:test -x ./script/pre-commit-sync -
Document when to use the GitHub Action vs. pre-commit hook in
docs/UPSTREAM_SYNC.md. Validation:grep -q "pre-commit" docs/UPSTREAM_SYNC.md
Phase 6 — Consolidation
-
Rewrite
FORK_WORKFLOW.md— consolidate all sync procedures into a single authoritative reference, cross-referencingdocs/UPSTREAM_SYNC.mdfor the custom change catalog. Validation:cat FORK_WORKFLOW.md | grep -q "UPSTREAM_SYNC.md" -
Create
docs/UPSTREAM_SYNC.md— the master document containing: custom change catalog, sync procedure, validation checklist, tagging discipline, and Skein port update steps. Validation:wc -l docs/UPSTREAM_SYNC.md≥ 50 -
Add a CHANGELOG entry for the sync strategy changes. Validation:
grep -q "sync" CHANGELOG.md||grep -q "Sync" CHANGELOG.md
Unchecked items above: see Disposition in proposal.md (2026-09-18).
Activity
androidand commentedon Sep 17, 2026
Archived 2026-09-18 — see the change's Disposition section.