Skip to content

feat: add migrate state store and CLI parsers - #653

Draft
SgtPooki wants to merge 6 commits into
masterfrom
feat/migrate-1-state-store
Draft

feat: add migrate state store and CLI parsers#653
SgtPooki wants to merge 6 commits into
masterfrom
feat/migrate-1-state-store

Conversation

@SgtPooki

@SgtPooki SgtPooki commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

What changed

Part 1 of 5 splitting #652 into reviewable slices. Adds the migrate command's SQLite resume state store (migrate.db schema and lifecycle transitions: pending, packed, parked, add_unconfirmed, committed), trustless-gateway CAR URL construction, the size/int flag parsers (shared in src/utils/cli-helpers.ts next to formatFileSize), and the CID-list parser. Uses node:sqlite (DatabaseSync, WAL), unflagged since Node 23.4.

Also carries documentation/migrate.md and the migrate glossary entries: the design doc rides in the first slice so the pipeline, resume guarantees, and exit contract get agreement before the code that implements them. Start the review there.

No CLI wiring yet.. the command activates in part 5, so this is dead code until the stack lands. Code review focus: the schema and the state transitions, they are the resume model everything else leans on.

How to verify

pnpm install && pnpm run build && pnpm test

Notes / risks

Stack: #652 is the umbrella with the full pipeline description. Merge order is 1 through 5; each PR's base is the previous branch.

First slice of the migrate command split (#652): the SQLite-backed
resume state store (migrate.db schema and lifecycle transitions),
trustless-gateway CAR URL construction, size/int/CID-list flag
parsers, and duration formatting. No CLI wiring yet; the command
lands at the end of the stack.
@FilOzzy FilOzzy added team/filecoin-pin "Filecoin Pin" project is a stakeholder for this work. team/fs-wg FOC working group is a stakeholder for this work, and thus wants to track it on their project board. labels Aug 14, 2026
@FilOzzy FilOzzy added this to FOC Aug 14, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Aug 14, 2026
@BigLep BigLep moved this from 📌 Triage to ⌨️ In Progress in FOC Aug 19, 2026
A garbage-collected secondary copy was hidden from secondary
scheduling forever: the NOT EXISTS in subPiecesMissingSecondary
matched rows of any status. It now excludes only live and terminal
states, matching subPiecesNeedingUpload.

deleteSubPieceForRebuild blocked a rebuild only for a committed
primary, so a committed secondary's on-chain breadcrumb could be
deleted and the piece re-added later. Any committed row now blocks,
and the member reset to pending happens inside the same transaction
so a crash cannot strand done rows with no member file.

Also: recordUploadParked no longer demotes a committed row, a unique
index makes double-packing a member impossible, parseSize accepts
decimal spellings as binary aliases, and a stale docstring goes.
Adds a MigrationDB unit test file covering these transitions.
documentation/migrate.md and the migrate glossary entries move from
the final slice (#657) to the first so the pipeline design, resume
guarantees, and exit contract get agreement before the code that
implements them is reviewed. The doc describes the completed stack;
flags it mentions land in later slices.
The stderr log() claimed stdout stays reserved for machine-readable
output, but that is a convention no other filecoin-pin command has:
human-facing output goes through src/utils/cli-logger.ts (clack in
TTY, console.log otherwise) and only errors hit stderr. Later slices
switch their call sites to cli-logger; a --json mode is a possible
follow-up if scripted consumption is ever needed.
parseSize and parsePositiveInt are generic CLI flag parsers, not
migrate concepts; they move next to formatFileSize (parseSize's
inverse) in src/utils/cli-helpers.ts so the next command with a size
or count flag reuses them instead of writing a third parser.
parseCidList stays in migrate's util: it parses migrate's input file
format. Folding payments/setup.ts's TiB-per-month regex into
parseSize is a possible follow-up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team/filecoin-pin "Filecoin Pin" project is a stakeholder for this work. team/fs-wg FOC working group is a stakeholder for this work, and thus wants to track it on their project board.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants