repair cli - #22
Conversation
- Removed unused `update:msw` script from package.json. - Updated Node.js version in pnpm-lock.yaml to 24.16.0. - Added new dependencies `iso-web` and `p-locate` to repair-cli package.json. - Introduced new commands `datasets` and `providers` in cli.ts. - Deleted obsolete db.ts file. - Enhanced error handling with new error classes in error.ts. - Updated local-schema.ts to include new operation types and statuses. - Refactored repair command to support target provider ID and added delete functionality.
- Updated various package versions in pnpm-lock.yaml and package.json, including '@biomejs/biome', '@types/node', 'msw', and 'pg'. - Enhanced the repair-cli by adding new database functions and refactoring existing ones to improve schema handling. - Introduced new utility functions for dataset management and improved error handling in dataset creation. - Updated TypeScript types and interfaces for better type safety and clarity in the codebase. - Adjusted middleware and command implementations to utilize the updated schema and context management.
|
I've run the repair process, it failed to create datasets due to insufficient funds, and then, after increasing funds in FilecoinPay, it continued to fail because datasets did not exist. It didn't re-try creating the dataset. |
|
I tried running repair from ID=1 to ID=2 on calibnet (ID=1 is my old node): |
- Added `filterPullPiecesNotInDataset` function to exclude CIDs already indexed in a dataset. - Introduced `upsertOperations` function for efficient upserting of operations in the database. - Updated `runPullPiecesPhase` to utilize the new filtering function and improved error handling. - Refactored `createPullPiecesWorker` to streamline the pulling process and handle dataset checks. - Enhanced command responses to include additional target provider information.
|
@silent-cipher: I'd like to have you look at this PR. You'll need to accept the invite to the repo so we can assign you as a reviewer. |
There was a problem hiding this comment.
Pull request overview
Adds a new @filoz/repair-cli package implementing an “early repair” workflow that plans and runs repairs by reading provider/dataset/piece state from a Postgres indexer DB and tracking execution state in a local SQLite DB.
Changes:
- Introduces repair CLI commands (
setup,wallet,repair,datasets,providers) plus middleware/context wiring. - Adds local SQLite + indexer Postgres Drizzle schemas and a set of DB helpers to plan repairs and page through pieces/providers.
- Implements initial pipeline phases for dataset creation and piece pulling, plus supporting utilities (config, migrations, JSON helpers, upsert helpers).
Reviewed changes
Copilot reviewed 36 out of 37 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Updates workspace catalog versions and allows native build for better-sqlite3. |
| packages/repair-cli/tsconfig.json | Includes package.json for TS JSON import support. |
| packages/repair-cli/src/utils.ts | Adds CLI config, wallet client creation, migration helper, metadata helpers, JSON (de)serialization, and misc utilities. |
| packages/repair-cli/src/types.ts | Defines shared types for context, DB handles, piece groups, and provider shape. |
| packages/repair-cli/src/pipeline/pull.ts | Adds pull phase batching/queueing and a pull worker implementation. |
| packages/repair-cli/src/pipeline/create-datasets.ts | Adds dataset creation phase worker/queue and repair dataset validation. |
| packages/repair-cli/src/middleware.ts | Adds context middleware to wire local/indexer DBs + wallet client into commands. |
| packages/repair-cli/src/local-schema.ts | Introduces SQLite schema for repairs/operations with custom JSON/bigint types. |
| packages/repair-cli/src/indexer-schema.ts | Introduces Postgres schema for providers/datasets/pieces in early-repair. |
| packages/repair-cli/src/error.ts | Adds typed error classes for repair creation/runtime failures. |
| packages/repair-cli/src/db/upsert-operations.ts | Adds helper to upsert operation status updates. |
| packages/repair-cli/src/db/update-repair.ts | Adds helper to update repair status/target datasets. |
| packages/repair-cli/src/db/update-operation.ts | Adds helper to update operation status/result/error. |
| packages/repair-cli/src/db/select-alternate-repair-provider.ts | Adds automatic selection of an alternate repair target provider with tier fallback. |
| packages/repair-cli/src/db/get-target-dataset.ts | Adds helper to load/cache target dataset by repair+group. |
| packages/repair-cli/src/db/get-repair-provider.ts | Adds helper to load an explicit target provider by ID. |
| packages/repair-cli/src/db/get-repair-groups.ts | Adds helper to derive repair groups from pending local operations. |
| packages/repair-cli/src/db/get-providers-by-cid.ts | Adds helper to find alternate providers per CID via indexer joins. |
| packages/repair-cli/src/db/get-pieces.ts | Adds paginated piece walk and mapping to local add_piece operations. |
| packages/repair-cli/src/db/get-datasets-by-group.ts | Adds helper to find one dataset per group for payer+source. |
| packages/repair-cli/src/db/get-dataset-for-group.ts | Adds helper to find a dataset for a single group. |
| packages/repair-cli/src/db/filter-pull-pieces-not-in-dataset.ts | Adds helper to filter out CIDs already present in a dataset. |
| packages/repair-cli/src/db/delete-repair.ts | Adds helper to delete a repair and its operations. |
| packages/repair-cli/src/db/create-repair.ts | Adds orchestration to plan a repair (target selection, operations creation, dataset ops). |
| packages/repair-cli/src/commands/wallet.ts | Adds wallet-related commands (fund, balance, deposit, withdraw). |
| packages/repair-cli/src/commands/setup.ts | Adds interactive setup and local DB migration. |
| packages/repair-cli/src/commands/repair.ts | Adds repair commands (create/list/delete/run). |
| packages/repair-cli/src/commands/providers.ts | Adds provider listing command (active providers). |
| packages/repair-cli/src/commands/datasets.ts | Adds dataset listing command with optional provider filter. |
| packages/repair-cli/src/cli.ts | Adds CLI entrypoint and command registration. |
| packages/repair-cli/package.json | Adds dependencies and typing deps for the new CLI package. |
| packages/repair-cli/AGENTS.md | Adds agent/operator documentation for the repair CLI and pipeline. |
| package.json | Removes an unused script and pnpm overrides block. |
| apps/ponder/package.json | Pins drizzle-orm version for the ponder app. |
| .vscode/settings.json | Sets workspace TypeScript SDK path for consistent editor TS version. |
| .agents/skills/incur/SKILL.md | Adds incur framework skill documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Updated CLI versioning to use dynamic import from utils. - Enhanced dataset command description to specify ownership by the repair wallet. - Refactored middleware to create local databases and improved context handling. - Introduced new types for dataset management and updated database queries for better data handling. - Improved provider command to include additional statistics and filtering for approved or endorsed providers.
…ality - Updated the repair CLI to target a single IPFS-enabled dataset, simplifying dataset management. - Removed obsolete dataset grouping logic and refactored related database queries for improved clarity. - Enhanced error handling for missing datasets and improved command responses to include relevant dataset information. - Introduced new utility functions for dataset retrieval and updated existing functions to align with the new dataset structure. - Updated TypeScript types for better type safety and clarity in the codebase.
…agement - Updated the repair CLI to improve the process of creating and managing repair jobs, ensuring a clearer workflow for moving pieces from faulty providers. - Refactored database interactions to simplify the creation and deletion of repair records, enhancing overall performance and maintainability. - Introduced new utility functions for dataset handling, including checks for existing datasets and streamlined dataset creation processes. - Improved error handling and logging for better visibility during repair operations. - Updated TypeScript types for enhanced type safety and clarity across the codebase.
- Bumped versions for '@biomejs/biome' to 2.4.16 and '@types/node' to 25.9.2 in pnpm-lock.yaml and pnpm-workspace.yaml. - Updated 'type-fest' version to 5.7.0 in package.json. - Removed obsolete dependencies from package.json to streamline the repair CLI.
- Removed 'mocha' from the types array in tsconfig.json to streamline type definitions. - Updated the include paths to exclude 'test', focusing on 'src' and 'package.json' for a cleaner build process.
PRAGMA journal_mode = WALcloses #6