Repository navigation
fix(storage): reconcile native and automatic library bindings - #38
Merged
Merged
Conversation
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.
Problem and behavior
Existing automatic libraries have native
RepoStorageId=auto-local:<key>routes but nocf_library_storagerecord, so V2 refuses access. Add a shared reconciliation path for CLI and Hub runtime using native Repo/RepoTrash/GarbageRepos, VirtualRepo, RepoStorageId, Seafile configuration, and physical local directories. No bytes move, no UUID changes, and the legacy storage-key table is neither read nor changed.Baseline:
origin/devatee732e74ce02f184586e1313b489e2198dbc15fe.Head:
2a546363723e3c4aa24ddaa675d2d6c4213aa3c5.storage-reconciledefaults to strictly read-only dry-run: only SELECT/SHOW, no normal or temporary DDL. Missing registry reports independentSCHEMA_MISSINGand continues classifying against an empty registry. Only explicit apply may create the exact reviewed table and insert registrations.INSERT ... SELECTto recheck native source facts and byte-exact routing. Key/owner/route conflicts remain BLOCKED. Unique-key races cannot overwrite records; explicit default-class normalization rolls back both route deletion and registration on failure.reservedwith expectedactiveis compatible and unchanged. Existing active/retired lifecycle disagreement is independentSTATE_DRIFT, reports actual and expected state, and never blocks or changes that state. Newly inserted records derive active from Repo/Trash, retired from Garbage-only.CLI arguments, single-JSON reporting, schema status, lifecycle compatibility, and operational semantics are documented in
docs/storage-reconcile.md. Exit 2 requires business BLOCKED; SCHEMA_MISSING and STATE_DRIFT alone return 0; execution/schema errors return 1.Validation
Only dedicated disposable local database containers and synthetic schemas were used. Exact
SELECT VERSION()results:Deployment-recipe evidence: Docker origin/dev
a7e8c2bf1e4e7630dfa2e54427c1c03d98ad667e,deploy/compose/docker-compose.yml:27, pinsmariadb:11.4. The 11.4 test matches that recipe series; 10.11 is additional compatibility evidence. The actual remote DEV/production running version is not verified because its device is disconnected.Those runs include all classifications, SELECT-only/read-only transaction with existing and missing registry, absent-table dry-run followed by explicit install/apply, reserved compatibility, unchanged lifecycle drift, CE native symlinks, managed-root symlink refusal, route rechecks, concurrent same-library writers, uniqueness, atomic normalization rollback, all lifecycle tables, VirtualRepo skip, global ORPHAN, and legacy sentinel preservation.
Two final focused tests were then verified on both versions:
The lifecycle case includes the exact native-retired-but-still-in-Trash example. The added schema case rejects changed CHECK, uniqueness, collation, and column default without altering the existing table. During implementation, initial metadata verification failed on index sort ordering and MariaDB hiding CHECK_CONSTRAINTS from SELECT-only users; deterministic index sorting and SHOW CREATE parsing corrected both, and the final runs above pass.
Independent CLI acceptance against 11 synthetic libraries + 1 orphan, batch_size=2, passed on both versions:
{"schema_missing_dry_run":{"AUTO_LOCAL":3,"BLOCKED":2,"NATIVE":4,"NATIVE_CLASS_PINNED":1,"ORPHAN_DIRECTORY":1,"SCHEMA_MISSING":1,"VIRTUAL_REPO":1},"dry_run":{"AUTO_LOCAL":3,"BLOCKED":3,"NATIVE":3,"NATIVE_CLASS_PINNED":1,"ORPHAN_DIRECTORY":1,"VIRTUAL_REPO":1},"apply":{"BLOCKED":3,"ORPHAN_DIRECTORY":1,"REGISTERED":7,"VIRTUAL_REPO":1},"replay":{"BLOCKED":3,"ORPHAN_DIRECTORY":1,"REGISTERED":7,"VIRTUAL_REPO":1},"result":"PASS"}The missing registry remained absent after dry-run. An intentionally conflicting registration was then introduced in the fixture; the three expected business BLOCKED cases are S3, invalid key, and registration conflict. Apply added seven correct records, replay made no writes, Trash+Garbage overlap remained active, and the legacy sentinel stayed unchanged.
Not covered
Actual remote database version, real Server upload/download/history/restore, GC/fsck, complete three-repository image acceptance, DEV deployment, or production writes. The real historic 1,407 automatic / 63 default library comparison is post-release acceptance per the user's updated instruction and is not replaced by synthetic counts. The separate effective-permission adaptation is outside this PR. Do not merge before the broader integration requirements are satisfied.