Skip to content

The Drift Log · Model independence and repeatable builds

Ensuring Byte‑Identical Builds by Pinning System Time

18 November 2026 · 3 min read · 713 words · established

Two identical crystal prisms casting exactly the same refraction

Eliminate build output variance by clamping archive timestamps to SOURCE_DATE_EPOCH and injecting explicit clocks into code generation.

You run a clean build from commit 8f21b4c. You run it again five minutes later on the same machine. The two output binaries differ by twelve bytes.

When you diff the artifact headers, you find an ISO 8601 timestamp written into the metadata table. The compiler was pure, the dependencies were pinned, and the input source was identical. The build broke byte-level parity simply because the machine was aware of what time it was.

Clocks are silent sources of ambient entropy. If your pipeline lets compilers, bundlers, packaging tools, or test harnesses query the system clock directly, you do not have deterministic builds. You have builds that happen to look identical until the second changes.

Where Clocks Contaminate Artifacts

Time leaks into builds through three primary vectors:

  1. Archive headers and container layers. The ZIP, TAR, and OCI image specifications write file modification times into archive central directories and layer manifests. If two workers tar the same tree at different seconds, the resulting tarballs have different SHA-256 hashes.
  2. Metadata injection during compilation. Many toolchains embed compilation timestamps into binary headers, debug tables, or generated asset manifests.
  3. Code generation scripts. Build-time scripts that stamp generated code with comments like // Generated at <timestamp> inject clock noise directly into source trees before the compiler even runs.

In testing, the problem worsens. Flaky tests that compare elapsed wall-clock intervals or verify expiration tokens fail intermittently when run across machines with differing CPU loads. Relying on real time inside unit and integration suites couples the verdict of your logic to thread scheduling and core availability.

To achieve reproducible artifacts, you must strip ambient clock access from the build pipeline and pass time explicitly into your application code.

Standardising the Build Boundary

The industry standard for build-level time containment is SOURCE_DATE_EPOCH. This specification defines an environment variable containing a Unix timestamp in seconds—typically derived from the commit timestamp of the source tree.

Tools that respect SOURCE_DATE_EPOCH use that pinned value instead of time(NULL) or gettimeofday() for file modification dates and embedded metadata.

## Derive the epoch from the last commit
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)

## Package the artifact using the pinned timestamp
tar --sort=name \
    --mtime="@${SOURCE_DATE_EPOCH}" \
    --owner=0 --group=0 --numeric-owner \
    -czf dist.tar.gz ./dist

If a toolchain does not support SOURCE_DATE_EPOCH natively, wrap the execution in a virtual clock shim (like libfaketime on Linux) to intercept clock_gettime syscalls during compilation.

Replacing Ambient Calls in Application Code

Toolchain isolation solves the archive problem, but code generation and test harnesses require structural changes.

Do not allow application logic or generators to read global clocks directly. Global time mocking—such as monkey-patching Date.now() or Python’s datetime.now at runtime—creates race conditions when tests run concurrently across shared memory.

Instead, treat time as a dependency. Pass an explicit clock interface:

export interface Clock {
  now(): number;
}

export class SystemClock implements Clock {
  now(): number {
    return Date.now();
  }
}

export class PinnedClock implements Clock {
  constructor(private readonly epoch: number) {}
  now(): number {
    return this.epoch;
  }
}

// In build tools and generators:
export function generateManifest(files: string[], clock: Clock): Manifest {
  return {
    version: 1,
    generatedAt: clock.now(),
    entries: files.sort(),
  };
}

When building release bundles or running verification suites, supply PinnedClock initialised from your build metadata. During normal runtime execution, supply SystemClock. This separates real-world progression from the transformation of source into software.

Treating time as an explicit input is part of a broader engineering discipline. As discussed in our doctrine on model independence and repeatable software builds, runtime variance and ambient entropy destroy your ability to reason about what you ship.

How SHPBL Handles Build Verification

At SHPBL, every release artifact is computed rather than generated, and published archives are byte-for-byte reproducible. We do not permit ambient clock queries, network-dependent timestamps, or non-deterministic build steps to alter release outputs.

Our build pipeline pins all metadata timestamps to source-derived epochs. Every catalog component undergoes strict execution checks in our certification harness, which executes inputs against clear contracts to yield reproducible verdicts. We publish verifiable checksums on our root of trust page so callers can verify release archives down to the exact byte.

What to Do on Monday

  1. Audit your archive creation. Inspect your release scripts for tar, zip, or Docker layer creation. Ensure file modification times are clamped to a static timestamp or SOURCE_DATE_EPOCH, and ensure file ordering is sorted.
  2. Search for ambient clock calls in build scripts. Grep your codebase for new Date(), Date.now(), time.time(), and DateTime.UtcNow inside any script executed during the build phase.
  3. Run a double-build check in CI. Build your artifact twice in sequence with a clock-skewed sleep between runs. Fail the build if the SHA-256 hashes of the resulting archives do not match.

This post supports the longer argument in Model Independence and Repeatable Software Builds.

Keep reading

Next in the log

The Strategic Master Library · written and reviewed under the house's own epistemic rules: nothing claimed that we cannot show.