Repository navigation
fix(gridfs): respect direct upload SHA provenance during recovery (MZ-19) - #14
Conversation
…ast on absent race barrier
Static merge review: MZ-19 and MongoDB Driver 7.8 MZ-18 race fixtureReviewed PR #14's source, recovery SHA provenance, audit integrity, type/docs changes and regression fixtures. The direct SHA trust boundary is preserved: only top-level preverified upload() SHA and resumable session SHA are enforced; metadata-only uploadStream SHA mismatches produce an audit warning after verifying physical chunks. No new P0/P1 source blocker was identified. Found and fixed a CI-only regression in the MZ-18 race test that previously caused release preflight to hit 60 minutes: MongoDB Node driver v7.8 now uses Evidence on exact PR SHA
User-approved merge exception: user explicitly instructed to merge after static review with no blockers, rather than wait for full release preflight. Any subsequent full CI findings must be tracked and repaired promptly; do not describe these pending jobs as passed. No npm release, tag or version bump. |
MZ-19 — direct upload SHA provenance in crash recovery
Problem
The recovery tool treated every visible direct file's
metadata.sha256as a trusted digest. This conflicts with the public contract:upload()with top-leveloptions.sha256verifies bytes before writing.uploadStream()stores the top-level SHA as metadata only.upload()withmetadata.sha256but no top-leveloptions.sha256also does not verify that arbitrary metadata value.A complete visible uploadStream could therefore remain permanently fenced after a crash solely because caller-supplied metadata did not match its bytes.
Changes
uploadMethod,sha256Verified,expectedSha256, andclaimedSha256.upload()owners that pre-verified top-leveloptions.sha256.Deterministic coverage
Current HEAD verification
HEAD:
7b68c6a5aeb0a9c7b563f7edd2590b979894cf3bThe initial full CI exposed a missing documentation matrix entry for the new
gridfs-recoverypage. That entry was added and the latest HEAD reran all checks. The earlier failed run was on an older SHA and is not being treated as current evidence.Merge gate
No package version bump, tag, merge or npm publish is included in this PR.
Note
Medium Risk
Changes GridFS ownership records, recovery unlock rules, and crash-recovery behavior for SHA metadata—safety-critical storage paths that require coordinated writer drain and operator discipline.
Overview
MZ-19 aligns GridFS crash recovery with how SHA-256 is actually trusted at upload time.
Direct
upload()anduploadStream()now persist owner provenance (uploadMethod,sha256Verified,expectedSha256,claimedSha256) in<bucket>.uploadswhen claiming ownership;claimOwnerenforces consistency for verifiedupload()digests.The recovery script
verifyVisibleFilealways checks visible chunk order, per-chunk lengths, and total length. It strictly enforces SHA only for resumable sessions and directupload()owners that pre-verified top-leveloptions.sha256.uploadStream()and arbitrarymetadata.sha256are treated as untrusted: mismatches become audit warnings so a physically complete file is not left permanently fenced. Trusted provenance mismatches still fail closed.Completed recovery audits and CLI receipts include SHA policy, actual/claimed digests, and warnings. Public types and EN/ZH GridFS/recovery docs clarify that byte verification requires top-level
upload()sha256, notmetadata.sha256. The doc example matrix addsgridfs-recovery. Integration tests cover the new provenance and warning paths; ownership regression tests handle MongoDB driver 6 vs 7.8 chunk delete filter shapes.Reviewed by Cursor Bugbot for commit 962d026. Bugbot is set up for automated code reviews on this repo. Configure here.