Repository navigation
feat(shared): add safe Hugging Face cache primitives - #1385
Conversation
Co-authored-by: Copilot App <[email protected]> Copilot-Session: ba1185b3-ebb0-40d0-a225-5391956934b6
|
🦞👀 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: blocked before merge. Reviewed September 9, 2026, 9:10 PM ET / September 10, 2026, 01:10 UTC. ClawSweeper reviewWhat this changesAdds shared helpers for locating Hugging Face model-cache files, checking Windows paths, and returning an open stream after size and SHA-256 verification. Merge readiness⛔ Blocked before merge - 5 items remain This is a useful, bounded foundation that is absent from main, but two introduced validation defects need correction before merge. The supplied Windows copy proof supports the intended handle-based design. Priority: P2 Review scores
Verification
How this fits togetherLocal AI currently installs models into app-owned storage. These new shared helpers prepare future cache reuse by accepting cache locations and artifact pins, then returning verified file streams without changing installation or migration behavior. flowchart TD
A[Environment and cache location] --> B[Resolve cache root]
C[Repository and artifact path] --> D[Validate cache entry]
B --> D
D --> E[Open and check resolved path]
F[Pinned size and digest] --> G[Verify file contents]
E --> G
G --> H[Rewound stream or rejection]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The cache reader has a pathname-race policy bypass; no dependency, credential, permission, or content-integrity bypass was found. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the verified-stream design, enforce destination policy independently of stale pathname attributes, and align repository-name limits with Hugging Face. Do we have a high-confidence way to reproduce the issue? Yes, source establishes both triggers: replace a regular entry with an in-root cross-repository symlink between stat and open, or supply owner/ followed by a 96-character repository name. Neither scenario was executed during this read-only review. Is this the best way to solve the issue? The verified-handle approach is appropriate, but the proposed implementation needs handle-bound path validation and the upstream repository-name length rule. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3edc9b1b5b6e. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Layer 2 of #1288 after #1385: add explicit, handle-bound migration of verified legacy Local AI model weights into the standard Hugging Face cache while preserving the active legacy model path. Layer 3 owns downloads and active selection.`n`nCo-authored-by: Copilot App <[email protected]>`nCopilot-Session: e7ffdfcb-cd94-420d-9f35-b268846a60fc
Related: #1288
What Problem This Solves
The Local AI replacement train needs a safe, reusable way to locate and read standard Hugging Face hub-cache entries before setup, migration, manifests, or runtime behavior can move to that cache.
Why This Change Was Made
This is layer 1 replacing the shared portion of #1288 (feat(local-ai): store downloaded models in the standard HF hub cache). It lands only independently valuable
OpenClaw.Sharedpath and verified-read primitives. Later layers will own model acquisition, cross-volume materialization, legacy migration, manifest compatibility, setup reconciliation, and runtime routing.The API deliberately does not expose a validate-then-mutate path contract. A returned string cannot authorize a race-free later mutation. Instead, verified reads return the same rewound file handle that was safely opened and hashed, so a later layer can copy from that handle across volumes without reopening the path.
User Impact
No product behavior changes in this layer. Developers gain a tested foundation for standard Hugging Face cache interoperability without committing setup or migration code to a same-volume hard-link strategy.
Evidence
HF_HUB_CACHE,HUGGINGFACE_HUB_CACHE,HF_HOME,XDG_CACHE_HOME, and the user-profile default.C:\toD:\; the destination hash matched the pin..partiallength limits.CONIN$/CONOUT$andCON .ggufwere rejected after Microsoft documentation review and live Windows file-creation proof showed they are valid ordinary path components.Change Type
Scope
winnodeRequired proof pools
none: this Shared-only path and verified-read layer requires no capacity-dependent host class. Focused tests create and validate real Windows symbolic links, and the live proof copies from the verified handle across local volumes.Validation
.\build.ps1: passed, all 5 projects built.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter "FullyQualifiedName~HuggingFaceHubCacheTests|FullyQualifiedName~WindowsPathSafetyTests": passed, 47/47.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: passed, 3,991 passed and 32 skipped.dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: passed, 2,865/2,865.python .agents\skills\autoreview\scripts\autoreview --mode local --prompt <layer-1 scope>.Real Behavior Proof
6cd0f147.OpenClaw.Shared.dll, created a pinned snapshot under a temporaryC:\cache, calledTryOpenVerifiedCacheFileAsync, then copied from the returned rewound stream to a temporaryD:\destination.SourceVolume=C:\,DestinationVolume=D:\,Bytes=27,HashMatches=True,CopiedFromVerifiedHandle=True.Security Impact
Yes, explain the risk and mitigation: N/ACompatibility and Migration
Review Conversations