Skip to content

Stamp env blobs with their producer varlock version to surface version skew - #1052

Open
theoephraim wants to merge 1 commit into
mainfrom
varlock-env-blob-version-stamp
Open

Stamp env blobs with their producer varlock version to surface version skew#1052
theoephraim wants to merge 1 commit into
mainfrom
varlock-env-blob-version-stamp

Conversation

@theoephraim

Copy link
Copy Markdown
Member

Serialized __VARLOCK_ENV blobs cross version boundaries in several supported flows: runtime glue bundled into integrations (the nextjs @next/env replacement), varlock run child processes, and a global CLI vs a local package dependency. Until now the format's cross-version compatibility was implicit, so a skew bug would surface as subtle wrong behavior with nothing pointing at the cause. Follow-up hardening from the discussion on #1051.

Changes

  • getSerializedGraph stamps varlockVersion on every blob. The version comes from package.json at build time; rolldown treeshakes the import down to just the version string, so no package.json contents land in runtime chunks.
  • Automatic injected-env reuse re-resolves when the producer version differs from the consumer (or is absent, matching the existing "older producer didn't record basePath/contentHash" fallbacks). Re-resolving through the current CLI is always correct and costs one resolution. Forced sandbox mode (_VARLOCK_USE_INJECTED_ENV=1) still trusts the blob, since there is nothing to re-resolve from.
  • initVarlockEnv warns once per process (flag on globalThis, since bundlers create multiple module copies) when the blob was produced by a different minor or major than the runtime code consuming it. Patch skew is expected between lockstep releases and stays debug-only.
  • SerializedEnvGraph now documents the requirement that format changes stay backward compatible within a major.

Tests

Unit tests for the reuse gate (mismatch, unversioned, forced-mode bypass), the serialization stamp, and the runtime warning thresholds (match/patch/minor/major, warn-once across module copies). Full varlock unit suite and the injected-env-reuse smoke tests (19 E2E scenarios through the real CLI) pass; verified a real CLI-produced blob carries the stamp.

Blobs cross version boundaries in several supported flows: runtime glue
bundled into integrations, varlock run children, global CLI vs local
package. Until now the format compatibility was implicit.

- getSerializedGraph records varlockVersion (baked from package.json at
  build time, treeshaken to just the version string)
- automatic injected-env reuse re-resolves when the producer version
  differs (or is absent, matching the existing older-producer fallbacks);
  forced sandbox mode still trusts the blob since there is nothing to
  re-resolve from
- initVarlockEnv warns once per process when the blob was produced by a
  different minor/major than the runtime code consuming it; patch skew
  is debug-only
- SerializedEnvGraph documents the backward-compat requirement
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 31, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
varlock-website 3d1f45f Commit Preview URL

Branch Preview URL
Aug 31 2026, 04:36 AM

@github-actions

Copy link
Copy Markdown
Contributor

bumpy-frog

The changes in this PR will be included in the next version bump.

minor Minor releases

  • @varlock/native-helper-darwin 1.17.1 → 1.18.0
  • @varlock/native-helper-linux-arm64 1.17.1 → 1.18.0
  • @varlock/native-helper-linux-x64 1.17.1 → 1.18.0
  • @varlock/native-helper-win32-x64 1.17.1 → 1.18.0
  • varlock 1.17.1 → 1.18.0

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Bundle size

⚠️ grows the bundle by 10.5 KB (+0.3%)

Metric main This PR Δ
Total dist 4128.2 KB 4138.6 KB +10.5 KB (+0.3%)
JS 1596.7 KB 1602.8 KB +6.1 KB (+0.4%)
Sourcemaps 2446.2 KB 2450.2 KB +4.0 KB (+0.2%)
Type defs 85.2 KB 85.6 KB +0.4 KB (+0.4%)
Other 0.0 KB 0.0 KB

dist/ only; native binaries are versioned separately and not counted here.

@pkg-pr-new

pkg-pr-new Bot commented Aug 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

varlock

npm i https://pkg.pr.new/varlock@1052

@varlock/native-helper-darwin

npm i https://pkg.pr.new/@varlock/native-helper-darwin@1052

@varlock/native-helper-linux-arm64

npm i https://pkg.pr.new/@varlock/native-helper-linux-arm64@1052

@varlock/native-helper-linux-x64

npm i https://pkg.pr.new/@varlock/native-helper-linux-x64@1052

@varlock/native-helper-win32-x64

npm i https://pkg.pr.new/@varlock/native-helper-win32-x64@1052

commit: 3d1f45f

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes across the serialized graph contract, automatic blob reuse, runtime skew diagnostics, documentation, and focused tests.

  • Version stamping: EnvGraph.getSerializedGraph() records the build-time varlock package version in every blob and documents the compatibility contract.
  • Reuse gating: automatic consumers re-resolve unstamped or differently versioned blobs, while explicit sandbox trust mode preserves its no-source fallback behavior.
  • Runtime diagnostics: consumers distinguish patch skew from minor or major skew and deduplicate user-facing warnings across module copies through shared global state.
  • Documentation and tests: the integration guide, release note, reuse cases, serialization assertion, and runtime warning thresholds match the implemented behavior.

Pullfrog  | View workflow run | Using azure/gpt-5.6-sol𝕏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant