MILAB-6145: propagate wasm deps through cached template upload path#1689
MILAB-6145: propagate wasm deps through cached template upload path#1689blackcat wants to merge 1 commit into
Conversation
flattenV3Tree in template_cache.ts previously had no handling for tpl.wasm — the loadTemplateCached path (used by dev-v2 blocks) silently stripped wasm field declarations during upload, leaving the backend's PlTemplateV1 resource with no wasm/<alias> fields. RuntimeV1.deps.Wasm was empty at render time, so plapi.loadWasm aborted with 'alias is not a wasm dependency of this template' even though the bytes were bundled in the block-pack. Adds hashWasmV3, a processWasm helper, and wasm field wiring in processTemplate, mirroring the handling already present in direct_template_loader_v3.ts.
🦋 Changeset detectedLatest commit: f54a040 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Code Review
This pull request ensures that WASM dependencies are correctly propagated through the cached template upload path. It introduces hashWasmV3, a processWasm helper, and wires WASM fields within processTemplate inside template_cache.ts to mirror the direct template loader's behavior. There are no review comments, so no feedback is provided.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1689 +/- ##
==========================================
+ Coverage 52.26% 52.31% +0.05%
==========================================
Files 273 273
Lines 16207 16218 +11
Branches 3522 3524 +2
==========================================
+ Hits 8470 8484 +14
+ Misses 6599 6594 -5
- Partials 1138 1140 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
flattenV3Treeintemplate_cache.tspreviously had no handling fortpl.wasm— theloadTemplateCachedpath (used by dev-v2 blocks and others) silently stripped wasm field declarations during upload, leaving the backend'sPlTemplateV1resource with nowasm/<alias>fields.RuntimeV1.deps.Wasmwas empty at render time, soplapi.loadWasmaborted withalias "<id>" is not a wasm dependency of this templateeven though the bytes were bundled in the block-pack.hashWasmV3, aprocessWasmhelper, and the wasm field wiring inprocessTemplate, mirroring the handling already present indirect_template_loader_v3.ts.Test plan
:pframes.build-query-wasmagainst a local source-built backend withwasm:v1capability — block now reachesDonewithoutputErrors: false(previously failed with "alias is not a wasm dependency"). Both upload paths (loadTemplateCachedhere,direct_template_loader_v3.tsalready wired) now create matchingwasm/<alias>fields on the backendPlTemplateV1resource.Greptile Summary
This PR fixes a bug where
flattenV3Treeintemplate_cache.tssilently discardedtpl.wasmentries, leavingPlTemplateV1backend resources with nowasm/<alias>fields on the cached upload path. Blocks usingplapi.loadWasmover theloadTemplateCachedpath therefore always aborted at render time with "alias is not a wasm dependency of this template".hashWasmV3and aprocessWasmclosure inflattenV3Tree, following the sameseen-set deduplication andCacheableNodestructure used for libs and software.processTemplate's child loop, appendingwasm/<alias>fields to the template resource (matchingPlTemplateV1.wasmPrefix) and including their hashes in the parent's hash composition.Confidence Score: 5/5
Safe to merge — the change is a targeted additive fix that brings the cached upload path into parity with the direct loader path without touching any existing logic.
The new processWasm closure and hashWasmV3 function mirror the established patterns for processLib and processSoftware exactly: same seen-set deduplication, same CacheableNode with childHashes: [], same tx.createValue call, and same use of wasm.sourceHash as a proxy for source content. The field name wasm/ is derived from PlTemplateV1.wasmPrefix, matching both direct_template_loader_v3.ts and the backend Go constant. The wasm children are included in the parent template's hash composition, so the cache will correctly invalidate existing entries that are missing wasm fields.
No files require special attention.
Important Files Changed
Sequence Diagram
sequenceDiagram participant Caller participant loadTemplateCached participant flattenV3Tree participant processTemplate participant processWasm participant materialize participant Backend Caller->>loadTemplateCached: spec (CompiledTemplateV3) loadTemplateCached->>flattenV3Tree: data flattenV3Tree->>processTemplate: data.template loop for each tpl.wasm entry processTemplate->>processWasm: wasm (TemplateWasmDataV3) processWasm-->>processTemplate: hash (CacheableNode added) end processTemplate-->>flattenV3Tree: rootHash flattenV3Tree-->>loadTemplateCached: nodes[] loadTemplateCached->>materialize: nodes, rootHash materialize->>Backend: createValue(PlWasmV1, base64Source) materialize->>Backend: createStruct(PlTemplateV1) + createField(wasm/alias) Backend-->>materialize: SignedResourceId materialize-->>loadTemplateCached: rootId loadTemplateCached-->>Caller: SignedResourceIdReviews (1): Last reviewed commit: "MILAB-6145: propagate wasm deps through ..." | Re-trigger Greptile