Repository navigation
feat(ts): per-checkpoint SHA-256 artifact verification in Router - #723
Merged
NandhaKishorM merged 1 commit intoSep 29, 2026
Merged
Conversation
Owner
|
Passed checks and merged. Thank you @Swatantra-66! It ships in 0.3.22. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
In
laya-ts, artifact digest verification (expectedSha256) was previously only supported at the individual bundle/provider level (loadNodeBundle,loadWebBundle,createNodeProvider). When usingRouterto manage multiple resident checkpoints:RouterOptionshad nosha256Digests/sha256_digestsoption to verify weights and models per checkpoint.LAYA_SHA256_DIGESTSenvironment variable ({ "model.safetensors": "..." }) could only ever match a single checkpoint, because each model ships distinct weights and ONNX files. Loading a second resident model would fail with a digest mismatch or file not found error.{ [model]: { [artifact]: digest } }), preventing multi-model servers from pinning artifacts safely.This brings
laya-tsinto complete parity with Python PR #572.What
RouterOptions&RouterProperties:sha256Digests?: Record<string, Record<string, string> | null> | nulland snake_case aliassha256_digests.this.sha256Digestsfromprocess.env["LAYA_SHA256_DIGESTS"]viadigestsFromEnv(this.models).normaliseName(), allowing aliases (en,ml,typed) and failing immediately on typos or unknown models at construction time.Environment Variable Parsing (
digestsFromEnv/_digestsFromEnv):{ artifact: digest }maps return{}so the underlying provider/bundle loader handles single-checkpoint verification as before.{ model: { artifact: digest } }maps are parsed per checkpoint, normalizing model keys and defaulting unlisted resident models to{}(deliberately unpinned, preventing accidental fallback to environment model-keyed maps).Model Loader Integration (
Router.load):expectedSha256to the model loader when a model is listed inthis.sha256Digests.nullor{}entries pass{}to mask environment defaults for that specific model.Exports:
digestsFromEnvand parity alias_digestsFromEnv, along withRouterOptionsandRouteOptionstypes inlaya-ts/src/index.ts.Unit Tests:
laya-ts/tests/revision-pinning.test.tsverifying key normalization, snake_case alias acceptance, typo refusal, per-checkpointexpectedSha256forwarding upon load, and flat/nested/mixed/unparseable environment shapes.Checklist
laya-ts(npm test -- --run)npm run build)ruff check laya/,python -m compileall -q laya/ tests/) pass cleanlyfeat(ts): ...)