Repository navigation
feat(local-ai): add verified legacy model cache migration - #1388
Conversation
Add an explicit, recoverable migration that copies verified legacy model weights into the standard Hugging Face cache while keeping the legacy model active for layer 3. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e7ffdfcb-cd94-420d-9f35-b268846a60fc
Keep cache directory and temporary file identities open through copy, verification, promotion, and rollback so reparse swaps and content races fail closed without touching unrelated paths. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e7ffdfcb-cd94-420d-9f35-b268846a60fc
Walk cache and legacy model paths from Windows volume handles, reject every reparse segment, release failed recovery handles, and validate decoded Hugging Face path segments before migration. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e7ffdfcb-cd94-420d-9f35-b268846a60fc
Support volume-root and UNC cache paths, allow migration beside active read-only model use, preserve flat legacy layout for nested Hub paths, and report unconfigured cross-volume proof as skipped. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e7ffdfcb-cd94-420d-9f35-b268846a60fc
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 12:24 AM ET / 04:24 UTC. ClawSweeper reviewWhat this changesAdds an explicit migration API that verifies and copies legacy Local AI models into the Hugging Face cache, records a migration receipt, and preserves the active legacy model. Merge readiness✅ Ready for maintainer review This remains useful, distinct work absent from main and the latest release. No blocking patch defect was found; the staged migration preserves existing model selection and leaves automatic rollout to the next layer. Priority: P2 Review scores
Verification
How this fits togetherLocal AI uses an installation manifest to locate the model launched by the Windows inference runtime. This migration copies verified weights into the shared Hugging Face cache without redirecting that runtime. flowchart TD
A[Explicit migration request] --> B[Read legacy installation receipt]
B --> C{Cache destination exists?}
C -->|Yes| D[Verify existing cache content]
C -->|No| E[Verify source and copy through held handles]
D --> F[Check manifest unchanged and save receipt]
E --> F
F --> G[Runtime continues using legacy model]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep migration explicit and legacy selection intact, with cache activation and downgrade compatibility handled together in the later acquisition layer. Do we have a high-confidence way to reproduce the issue? Not applicable: this adds an explicit migration capability rather than reporting a current-main bug; the supplied cross-volume trace and inspected tests exercise that capability. Is this the best way to solve the issue? Yes, for this staged scope: it reuses verified cache reads, preserves the active model, and separates filesystem migration from automatic installation and runtime rollout. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ce3f51fcb29b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Summary
Layer 2 of the current-main replacement train for #1288 (feat(local-ai): store downloaded models in the standard HF hub cache), stacked after #1385 (feat(shared): add safe Hugging Face cache primitives).
LocalAiManifestStore.MigrateLegacyModelToHubCacheAsynctransactionHuggingFaceHubCache.TryOpenVerifiedCacheFileAsyncModelPathLoadAsync, runtime refresh, status, uninstall, normal downloads, active model selection, installer, reconciler, and setup wiring unchangedThe parent train item remains open. Layer 3 owns normal Hub-cache downloads and switching active selection.
Layer 3 contract
LocalAiInstallManifest.CurrentSchemaVersionremains3for normal setup writes.4means a verified cache-copy receipt exists.ModelPathremains the active legacy path in this layer.ModelCacheRootis the normalized cache root used for verification.CachedModelPathis the verified standard snapshot path.MigrateLegacyModelToHubCacheAsyncexplicitly. Do not trigger migration fromLoadAsyncor another status/runtime/uninstall read path.HuggingFaceHubCachebefore selecting cached content, wireHuggingFaceModelInstaller/LocalAiArtifactInstaller/ reconciler / setup behavior, and decide rollout or downgrade gating before enabling migration automatically.Required proof pools
none: this is a non-UI manifest and filesystem migration API. Deterministic Windows tests and an explicit two-volume local proof cover the changed behavior without a custom host class.Validation
./build.ps1- passeddotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore- 3,991 passed, 32 skippeddotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore- 2,888 passeddotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj --no-restore- 746 passed, 1 cross-volume proof skipped unless explicitly configureddotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restore- 1,134 passedOPENCLAW_TEST_HF_CACHE_ROOT=E:\OpenClawHfMigrationProof- 29 passed, 0 skippedpython .agents\skills\autoreview\scripts\autoreview --mode branch --base origin/main ...- clean, no accepted/actionable findingsReal behavior proof
Current-head cross-volume proof:
The proof asserts the destination bytes equal the pinned content, the legacy source remains unchanged, and the schema-4 receipt records the standard snapshot path. Focused deterministic coverage also proves interruption recovery, cancellation cleanup, hard-link preservation, destination collision handling, directory-swap rejection, source/cache-root reparse rejection, concurrent manifest update/deletion handling, nested Hub paths, and rollback preserving shared-cache content.