feat(dvm): add dvm job persistence migration and repository - #727
Open
Priyanshubhartistm wants to merge 3 commits into
Open
feat(dvm): add dvm job persistence migration and repository#727Priyanshubhartistm wants to merge 3 commits into
Priyanshubhartistm wants to merge 3 commits into
Conversation
Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
🦋 Changeset detectedLatest commit: 5c212bf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Priyanshubhartistm
requested review from
Anshumancanrock,
Justxd22 and
cameri
and removed request for
Justxd22
August 12, 2026 10:44
Collaborator
This was referenced Aug 12, 2026
cameri
approved these changes
Aug 12, 2026
There was a problem hiding this comment.
Pull request overview
Adds a new persistence layer for NIP-90 DVM job lifecycle tracking, introducing a dvm_jobs table plus a typed repository API so job state can survive relay restarts (with ingestion/dispatch intentionally deferred to follow-up PRs).
Changes:
- Added
dvm_jobsmigration and new DVM domain types (DvmJob,DvmJobStatus,DBDvmJob). - Implemented
DvmJobRepository+IDvmJobRepositoryinterface for creating, assigning, updating, and polling pending jobs. - Added unit tests for the new repository and updated
.knip.json/changeset metadata for the new files.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/repositories/dvm-job-repository.spec.ts | Unit tests for repository behavior and query-builder interactions. |
| src/repositories/dvm-job-repository.ts | New repository implementing DVM job persistence operations. |
| src/@types/repositories.ts | Adds IDvmJobRepository to the repository type surface. |
| src/@types/dvm.ts | Introduces DVM job domain/DB row types and status enum. |
| migrations/20260812_150000_create_dvm_jobs_table.js | Creates dvm_jobs table and indexes to support job lifecycle persistence. |
| .knip.json | Ignores the new repository until it’s wired into a consumer. |
| .changeset/dvm-job-persistence.md | Declares a minor release for the new persistence feature. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… in updateStatus Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
cameri
approved these changes
Aug 12, 2026
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.
Description
Adds the DVM job persistence layer: a migration and a repository for tracking NIP-90 job state in the database, so job lifecycle survives relay restarts. This is a persistence-only PR — no event ingestion or IPC dispatch yet, those are separate follow-up PRs.
dvm_jobstable (migration20260812_150000_create_dvm_jobs_table.js):id,requester_pubkey,kind,worker_index,status(Postgres enum:submitted/picked_up/completed/failed/timed_out),result_event_id,error, and lifecycle timestamps (picked_up_at,completed_at,created_at,updated_at), with named indexes onrequester_pubkey,status, andkind.src/@types/dvm.ts(DvmJob,DvmJobStatus,DBDvmJob), following the existing camelCase/snake_case split used byInvoice/DBInvoice.DvmJobRepository(src/repositories/dvm-job-repository.ts) andIDvmJobRepositoryinterface (src/@types/repositories.ts):create,findById,assignWorker(atomic conditionalUPDATEgated onstatus = 'submitted', so two workers can't race to pick up the same job),updateStatus(setscompleted_atonly for terminal statuses),findPendingJobs.src/repositories/dvm-job-repository.tsto.knip.json'signorelist since it has no consumer yet, mirroring the existinginvite-code-repository.tsentry for the same situation.Related Issue
Part of #639
Motivation and Context
Following up on the worker registry/process topology added in #721, the relay needs somewhere to durably track each DVM job's lifecycle (submitted, picked up, completed, failed, timed out) so in-flight jobs aren't silently lost if the relay restarts. This PR adds that persistence layer in isolation so it can be reviewed independently of the ingestion and IPC-dispatch logic that will build on top of it.
How Has This Been Tested?
DvmJobRepositorycovering every method (create,findById,assignWorkerincluding the atomic-pickup race guard,updateStatusincluding terminal-status handling,findPendingJobs), following the existingInviteCodeRepositorytest conventions (stubbed Knex query-builder chains).pnpm exec commitlint,pnpm exec changeset status,pnpm lint,pnpm check:format,pnpm check:deps,pnpm run build:check,pnpm run build,pnpm run verify:cli:build,pnpm run test:unit(1564 passing),pnpm run test:cli,pnpm run cover:unit(dvm-job-repository.tsat 97%+ statement coverage, 100% function coverage),pnpm run docker:test:integrationandpnpm run docker:cover:integration(99 scenarios / 489 steps passing) — confirms the migration applies cleanly against real Postgres.Screenshots (if appropriate):
N/A — persistence layer change, no UI.
Types of changes
Checklist: