# Sharing code without a dependency chain

Author: Chris Chabot
Canonical URL: https://chabot.dev/blog/sharing-code-without-a-dependency-chain/
Published: 2026-10-09

Why a one-dependency rule is a supply-chain defense, what it costs in code reuse, and how lockfiles, drift checks and a signed index make copied source trustworthy.

Every major supply-chain advisory, like the Shai-Hulud worm that compromised more than 500 npm packages, exposes the same baseline risk: a typical application depends on hundreds of transitive packages written by strangers, any of which can run code at install or build time. Public registries and transitive resolution let teams ship quickly, yet lockfiles, audit tools, and the tacit hope that no upstream maintainer gets phished monitor that surface without removing the chain.

Cutting the chain altogether leaves vendoring, and making that vendoring accountable moves trust from an open dependency resolver to a signed publisher of source copies. On Ferrite, my cloud platform for applications built by users' coding agents, each deployed application is a single Rust crate linking only the platform SDK. Build scripts, procedural macros, and install scripts are refused, and the platform compiles source offline against its own SDK. Shared subsystems, from sign-in and payments to MCP, an application framework, and a WebAssembly interpreter, ship as source packages copied into an application's tree through a CLI or the platform's MCP server.

## Why one dependency, and what it costs

The single-crate rule also enforces authority. Because the SDK is an application's entire capability boundary, the platform's code gate checks dependency names without considering where Cargo resolves them, blocking workspace path dependencies alongside registry crates. A second crate would open a way out beyond what the SDK permits.

Owning copied source carries a separate security advantage. When an ecosystem links one popular registry package, a single compromise scales uniformly across every consumer. Code that an application owns and adapts is less uniform, making it a harder target to exploit in bulk.

The cost is code reuse: two applications needing the same subsystem can share only source, and hand copies drift quietly because they record nothing. On Ferrite, two hand copies of a WebAssembly interpreter shared 35 files with 7 drifted, and two agent runtimes shared 25 paths with 15 drifted. Once missed fixes and intentional local changes mix in an unattributed tree, reconciling them requires reconstructing intent hunk by hunk, so they stay forked.

## Accountable source packages

Copying is not the mistake under a one-dependency rule; a copy that records nothing is. I built Ferrite's package tool around four pieces: one canonical source per package, a declared mount in each consuming application, a lockfile recording a SHA-256 digest for every generated file, and a drift check in CI that fails the build on any mismatch.

Rather than checking only the lockfile, the drift check recomputes expected output from canonical source, verifies both working tree and lockfile against it, and rejects undeclared files inside a mount. Generated files carry an origin header so engineers and coding agents recognize managed code instead of learning about the check from CI. External applications install from a published index through the CLI, which writes those headers, verifies per-file SHA-256 digests, and refuses to overwrite local edits unless forced; agents without a shell fetch the same source through the MCP server.

## Signing the index and the installer

Per-file SHA-256 digests prove that downloaded source matches the published index, which buys nothing if an attacker can modify both. Removing the dependency resolver concentrates trust on the publisher of the copies, so both the index and the client tooling must be authenticated.

The published index carries an Ed25519 signature over its exact bytes, verified before release and swapped in atomically with the index. Both files are served uncached so a stale signature never pairs with a fresh index, and the CLI rejects a one-byte change, an untrusted key, or a missing signature.

The CLI installer needed the same rule after a security audit caught it undoing its own verification: it checked a signed checksum list, installed the CLI, and then ran a setup step that re-downloaded the list and binary unsigned, overwriting the verified executable. Anyone with write access to the downloads host, the exact adversary the signature existed to stop, could have replaced the binary verifying every package afterward. Setup now pins the release key, verifies the signature before trusting the checksums, binds the version against replay of older signed releases, and reuses the verified binary.

## Checking deployability and propagating fixes

Byte-identical copies can still break deployment. Four package commits introduced test-only code that stopped eight applications from deploying: the platform's code gate scans an application's full source tree, test modules included, whereas the drift check only verified matching copies. The package tool now runs that gate on every package as the smallest application carrying it, in both forms consumers receive: in full for synced applications, and with test modules stripped for the CLI and MCP server.

The payoff shows during remediation. When a whole-repository security sweep turned up findings in a dozen packages covering sign-in, OAuth, payments, caching, headers, and protocol parsing, each fix landed once in canonical source and was resynced into every consuming application in one pass. The lockfile and drift check proved every consumer carried the fix, instead of leaving anyone to grep across applications hoping no hand-copied fork had been missed.
