updated 2026-11-26·6 min read
Poly-Repo Contract Coordination & Version Skew
Coordinating separate repo deployments with downstream-first buffer expansion, cross-repo SHA-256 digests, and 2-phase staging.
In real edge setups, SQL migrations, ETL workers, and Rust proxies rarely share a monorepo. They live in separate repositories and deploy on completely different schedules:
| Repository | Layer & Technology | Release Cadence | Skew Risk |
|---|---|---|---|
repo-analytics-ddl | ClickHouse SQL schemas | Bi-weekly Friday release | Adds shard columns expanding emitted schema to 280 fields |
repo-feature-worker | Python ETL engine | Daily continuous release | Reflects wider schema into dynamic KV payloads |
repo-edge-proxy | Rust L7 proxy | Weekly canary release | Still running [Feature; 200] stack buffer, causing overflow panic |
When three repos deploy independently, version skew isn’t an edge case; it’s the normal state. Stokes handles poly-repo rollouts with strict ordering rules, cross-repo AST digests, and a 2-Phase Semantic Staging Protocol.
The Downstream-First Deployment Sequence
Cross-repo safety comes down to one deployment ordering rule: never deploy an upstream schema expansion while any live downstream consumer still allocates fewer buffer slots than the new payload emits (buffer_capacity >= emitted_columns throughout the rollout). If an upstream repo ships 280 fields while the edge fleet still expects [Feature; 200], slice.try_into().unwrap() panics on every node before a downstream rollback can finish building.
Stepwise Rollout Lifecycle
Growing a pipeline from 200 to 280 features runs through four clean steps:
- Phase 0Baseline State (200 emitted / 200 slots)
repo-analytics-ddl emits 200 columns; repo-edge-proxy allocates 200 slots. Safe steady state.
- Step 1Downstream Expansion (200 emitted / 512 slots)
repo-edge-proxy deploys 512 slots first while upstream still emits 200 (ratio 0.39). Safe.
- Step 2Upstream Migration (280 emitted / 512 slots)
repo-analytics-ddl deploys 280 columns into an active 512-slot edge fleet (ratio 0.55). Zero downtime.
- Step 3 (Optional)Downstream Compaction (280 emitted / 280 slots)
repo-edge-proxy compacts capacity from 512 down to 280 (ratio 1.00) once rollout finishes.
| Sequence Strategy | Timeline & State Transitions | Outcome & Risk Evaluation |
|---|---|---|
| Downstream-First Sequence | Step 0: Downstream 200, Upstream 200 → Step 1: Downstream deploys 512 → Step 2: Upstream emits 280 | Risk at Step 1: 0.39; Risk at Step 2: 0.55. Zero downtime, zero packet loss. |
| Upstream-First Sequence | Step 0: Downstream 200, Upstream 200 → Step 1: Upstream emits 280 → Step 2: Downstream blocked | Risk at Step 1: 280 / 200 = 1.40. Edge fleet panics or drops traffic immediately. |
Cross-Repo AST Digest Hashing in stokes.lock
Instead of forcing Git submodules or monorepo lockstep, Stokes links decoupled repos by storing normalized SHA-256 digests in stokes.lock:
Cross-Repo Lockfile Example (stokes.lock)
{
"$schema": "https://stokes.dev/schema/v1.json",
"version": "1.0.0",
"workspace": "cloudflame-l7-proxy",
"root_digest": "sha256:1dfc7d7909530fa6b0c5b9df552315786642929620cd186bbcf1c22f76fc2fd8",
"invariants": {
"max_features": 512,
"max_heap_bytes": 0,
"max_p99_latency_ns": 10.0,
"core_reserved_slots": 128
},
"targets": [
{
"id": "clickhouse-schema",
"repository": "github.com/org/repo-analytics-ddl",
"path": "migrations/001_bot_signals.sql",
"digest": "sha256:7b5d63f03b221087cf28b0754ff31e05be4c9a419bdfc836928e4695ce2dc03a",
"cardinality_limit": 280
},
{
"id": "rust-proxy-buffer",
"repository": "github.com/org/repo-edge-proxy",
"path": "crates/cloudflame-proxy/src/engine/feature_ingest.rs",
"digest": "sha256:1a4f89d3e5b7c9102837465abdf0123456789abcdef0123456789abcdef01234",
"capacity_limit": 512
}
]
}Because Stokes strips comments, whitespace, and formatting before hashing normalized declarations, cosmetic edits never break downstream lockfiles. Changing a column count or shifting UInt16 to UInt64, though, mutates the digest right away.
Eliminating Circular Merge Deadlocks
A naive poly-repo CI gate deadlocks immediately: repo-edge-proxy PR #412 (bumping the buffer 200 → 512) blocks waiting on the upstream contract on main, while repo-analytics-ddl PR #89 (adding 80 columns) blocks waiting on the downstream proxy deployment.
Stokes breaks the cycle with 2-phase staging (prepare then commit):
- Phase 1: Capacity Preparation (prepare stage)
repo-edge-proxy declares staged_capacity_limit = 512 and stage = "prepare" in stokes.toml, then runs stokes verify --stage=prepare. Once verified (512 >= 200), the PR merges and deploys 512 slots to production.
- Phase 2: Upstream Production Expansion (commit stage)
repo-analytics-ddl sets stage = "commit" and runs stokes verify --stage=commit --remote-lock=edge-proxy.lock. Stokes verifies 280 / 512 = 0.546 <= 1.0 against the deployed lockfile and clears the upstream merge.
Prepare & Commit Stage Manifests (stokes.toml)
# Downstream prepare manifest (repo-edge-proxy/stokes.toml)
[[channels]]
id = "analytics_to_edge_l7"
stage = "prepare"
[channels.consumer]
rust_source = "crates/cloudflame-proxy/src/engine/feature_ingest.rs"
capacity_limit = 200
staged_capacity_limit = 512# Upstream commit manifest (repo-analytics-ddl/stokes.toml)
[[channels]]
id = "analytics_to_edge_l7"
stage = "commit"
remote_downstream_lock = "https://internal-registry.corp/locks/edge-proxy.lock"
[channels.producer]
sql_schema = "migrations/001_bot_signals.sql"
cardinality_limit = 280Production CI Workflows
Downstream & Upstream GitHub Actions Workflows
# repo-edge-proxy: .github/workflows/stokes-boundary-gate.yml
name: Stokes Downstream Boundary Verification Gate
on:
pull_request:
paths: ['crates/cloudflame-proxy/**', 'stokes.toml', 'stokes.lock']
push:
branches: [main]
jobs:
verify-downstream-contracts:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install Stokes CLI Engine
run: curl -fsSL https://trystokes.pages.dev/install.sh | sh
- name: Execute Strict Boundary Audit
run: |
stokes verify --strict --manifest=stokes.toml --lockfile=stokes.lock
- name: Generate PR Attestation Summary
if: always()
run: |
stokes cert --output=stokes.lock
cat CONFORMANCE.md >> $GITHUB_STEP_SUMMARY# repo-analytics-ddl: .github/workflows/stokes-upstream-gate.yml
name: Stokes Upstream Boundary Verification Gate
on:
pull_request:
paths: ['migrations/**', 'schemas/**', 'stokes.toml']
jobs:
verify-upstream-expansion:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install Stokes CLI Engine
run: curl -fsSL https://trystokes.pages.dev/install.sh | sh
- name: Fetch Live Downstream Production Lockfile
run: |
curl -sSf https://registry.internal.net/v1/locks/edge-proxy.lock \
-H "Authorization: Bearer ${{ secrets.LOCK_REGISTRY_TOKEN }}" \
-o .stokes/remote-edge-proxy.lock
- name: Execute Strict Poly-Repo Compatibility Check
run: |
stokes verify --strict --manifest=stokes.toml --remote-lock=.stokes/remote-edge-proxy.lock --stage=commitArchitectural Comparison Matrix
| Evaluation Dimension | Uncoordinated Poly-Repo | Git Submodules / Monorepo | Intrusive IDL | Stokes Poly-Repo Protocol |
|---|---|---|---|---|
| Cross-Repo Safety | None (single-repo scope) | Manual sync | Schema only | Cross-repo AST & bounds check |
| Capacity Verification | Zero | Zero | Zero (repeated unbounded) | Enforced (emitted <= capacity) |
| Merge Deadlock Freedom | High deadlock risk | High merge friction | Medium friction | Zero deadlocks (2-Phase) |
| Deployment Order | Manual runbooks | Lockstep rollouts | Manual ordering | Automated staging gates |
| Runtime Overhead | 0 ns | 0 ns | 150 to 800 ns / msg | 0 ns (compile/CI gate) |
| AST Digest Precision | None | File Git hash (fragile) | Protocol hash | Normalized structural AST |
See Projection Isolation and Deterministic CI Gate & Native MCP Server for how unconsumed fields and automated gates interact with poly-repo rollouts.