2.1 KiB
2.1 KiB
readme.hints.md
Internal development notes for @push.rocks/smartmigration. This file is not published to npm.
Architecture
- The ledger is the source of truth. Two backends: mongo (a single document in smartdata's
SmartdataEasyStorecollection) and S3 (viabucket.fastPut/fastGet). - Step execution is sequential and registration-ordered. The
from/tofields exist for chain validation, not for DAG resolution. - Drivers (
mongodb.Db,S3Client) are exposed viactx, not wrapped. smartmigration writes no SQL or S3 wrappers of its own.
Locking caveats
- The mongo lock uses atomic
findOneAndUpdate/updateOneoperations against theSmartdataEasyStorecollection and a background heartbeat that extendslock.expiresAtwhile steps are running. - The S3 lock is best-effort (S3 has no conditional writes without versioning). S3-only deployments should not run multiple instances against the same ledger without external coordination.
Why reuse SmartdataEasyStore?
- The collection already exists in the smartdata ecosystem and is a natural fit for singleton blobs keyed by
nameId. - Reusing it avoids introducing a second smartmigration-specific collection just to store one document per ledger.
- The lock path talks directly to the collection for atomic updates; the persisted document shape still mirrors EasyStore's
{ nameId, data }layout. - See
/mnt/data/lossless/push.rocks/smartdata/ts/classes.easystore.tsfor the reference document shape.
Runtime notes
plan()/dryRunresolve the same fresh-install shortcut asrun(), so theircurrentVersionAftervalue is predictive rather than just echoing the current ledger version.- Successful resumable steps clear
checkpoints[stepId]; failed steps leave checkpoints intact so the next run can resume.
Testing notes
- Use
@push.rocks/smartmongo'sSmartMongo.createAndStart()for an in-memory replica set. - After
createAndStart(), callgetMongoDescriptor()and feed the result tonew SmartdataDb(...). - Always call
db.close()andsmartMongo.stop()in test cleanup.