fix(core): job failure semantics, stale-lock reaper, run-scoped context, reload

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
Lucas Winther
2026-10-30 20:52:51 +01:00
co-authored by Claude Sonnet 5.5
parent 166b8ecb5e
commit 6f628c4693
11 changed files with 356 additions and 83 deletions
+3 -3
View File
@@ -23,9 +23,9 @@ user layer or files a Changes-inbox event.
| `docs/design/mockups` | approved UI mockups (reference only) | exists |
## Data flow
Sync lifecycle (`packages/core/src/sync/`; steps 1–2 are Task 9's job worker, planned):
1. The scheduler enqueues a job.
2. The worker loads the connection and plugin and calls `runSync(deps, plugin, connectionId, mode)`, injecting
Sync lifecycle (`packages/core/src/sync/`; steps 1–2 are `jobs.ts` and `connections.ts`):
1. The scheduler enqueues a `sync` job (lockKey `sync:<connectionId>`) for each non-paused connection that is due.
2. The worker claims the job; `syncHandler` loads the connection and plugin and calls `runSync(deps, plugin, connectionId, mode)`, injecting
`makeContext` (http client, credentials, cursor). `mode` picks `pull`, `pullChanges` or `importFile`.
3. `runSync` opens a `source_runs` row and iterates the plugin's `SourceRecord`s one at a time.
- `listen` records are batched into `ingestListens` (insert-or-ignore into `listens`; no snapshot, no events).