Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
29c0fa0
Isolate time-travel ancestor traversal and reset by job
tinchoz49 Nov 7, 2026
e8d5367
Merge accepted time-travel job isolation
tinchoz49 Nov 7, 2026
e267efc
Apply step updatedAfter to both search branches
tinchoz49 Nov 7, 2026
1a1a0c4
Merge accepted step-search boundary fix
tinchoz49 Nov 7, 2026
39028eb
Fix global job listing order and pagination
tinchoz49 Nov 7, 2026
75753be
Merge accepted global job listing
tinchoz49 Nov 7, 2026
2c9584f
Preserve elapsed retained-step timestamps across DST
tinchoz49 Nov 7, 2026
2c66276
Merge accepted elapsed timestamp shifting
tinchoz49 Nov 7, 2026
07009d6
Share lifecycle cleanup and use SQL heartbeat time
tinchoz49 Nov 7, 2026
d51b077
Merge accepted lifecycle cleanup and SQL heartbeat
tinchoz49 Nov 7, 2026
5f247c0
Make SQL notification emission safe and non-destructive
tinchoz49 Nov 7, 2026
84f5ead
Merge accepted safe SQL notifications
tinchoz49 Nov 7, 2026
5ac7228
Coordinate scheduled archive pruning on an owned session
tinchoz49 Nov 8, 2026
d9699b3
Merge accepted scheduled prune ownership and cleanup
tinchoz49 Nov 8, 2026
0479f59
fix: reconcile pending waits with bounded read deadlines
tinchoz49 Nov 9, 2026
d45ecde
Merge accepted wait reconciliation and bounded read deadlines
tinchoz49 Nov 9, 2026
3156e06
fix: claim jobs in SERIALIZABLE transactions published only after commit
tinchoz49 Nov 10, 2026
6782501
test: retain owned claim test databases when cleanup preconditions fail
tinchoz49 Nov 10, 2026
69de465
test: release claim test gates before awaiting owned work
tinchoz49 Nov 10, 2026
63c85f8
Merge verified Serializable claim admission fix
tinchoz49 Nov 10, 2026
0512dab
fix: lock the job row in cancel/complete/fail and step creation
tinchoz49 Nov 16, 2026
5fc2064
Merge cancellation storage consistency repair
tinchoz49 Nov 16, 2026
640f094
test: report session identities when prune transport count differs
tinchoz49 Nov 16, 2026
5c29001
Merge prune session failure diagnostics
tinchoz49 Nov 16, 2026
9dc267f
test(postgres): bound and report native wait fixture cleanup
tinchoz49 Nov 28, 2026
90f089f
Merge fix/pg-wait-native-cleanup: bounded native wait fixture cleanup
tinchoz49 Nov 28, 2026
ff7b9fb
chore(postgres): test against postgres.js 4.1.1
tinchoz49 Nov 29, 2026
87caa18
fix(postgres): wait for driver stats to drain after a timed-out end
tinchoz49 Nov 29, 2026
ad470bb
Merge fix/postgres-js-v4: test against postgres.js 4.1.1
tinchoz49 Nov 29, 2026
102f059
fix(postgres): lock recovery jobs before reading their steps
tinchoz49 Nov 29, 2026
9b5015d
docs: describe recovery's per-phase step membership guarantee
tinchoz49 Nov 29, 2026
f94723f
test(postgres): keep recovery snapshot test output quiet
tinchoz49 Nov 29, 2026
f0b6cd9
Merge fix/pg-recovery-snapshot: lock recovery jobs before reading the…
tinchoz49 Nov 29, 2026
dbe0f78
fix(duron): coordinate worker discovery and monotonic recovery
tinchoz49 Nov 29, 2026
617535a
docs: warn against awaiting client.fetch() inside a job handler
tinchoz49 Nov 29, 2026
7c86fa0
Merge fix/pg-10-worker-reconciliation: coordinate worker discovery an…
tinchoz49 Nov 29, 2026
dfb0611
fix(duron): suppress locally claimed jobs cancelled before their hand…
tinchoz49 Nov 29, 2026
8f896a4
test(duron): release every local-cancellation test hold on close
tinchoz49 Nov 29, 2026
edfd9a7
test(duron): wait for intents to drain after in-flight automatic fetches
tinchoz49 Nov 29, 2026
e47d46b
Merge fix/pg-12b-local-cancellation: suppress locally claimed jobs ca…
tinchoz49 Nov 29, 2026
a14ce5a
test: add cross-mechanism acceptance and finish residual docs (ticket…
tinchoz49 Nov 29, 2026
8064176
docs: correct F2 session lifetime and group-limit JSDoc (ticket 11 re…
tinchoz49 Nov 29, 2026
64eb7a9
Merge fix/pg-11-integration-verification: cross-mechanism acceptance …
tinchoz49 Nov 29, 2026
c8c81a2
fix: recover without pausing claims; own id only on first recovery
tinchoz49 Nov 29, 2026
1560c4a
fix: claim nothing until a recovery has succeeded once
tinchoz49 Nov 29, 2026
cfbeb18
docs: qualify the own-jobs recovery guarantee for direct recoverJobs …
tinchoz49 Nov 29, 2026
dddc97d
Merge fix/pg-recovery-no-pause: recover without pausing claims
tinchoz49 Nov 29, 2026
53acf57
chore: bump drizzle-orm and drizzle-kit to 1.0.0-rc.6; type JSON para…
tinchoz49 Nov 30, 2026
9c57982
chore: upgrade drizzle-kit snapshot to format 10
tinchoz49 Nov 30, 2026
6c58203
docs: install drizzle-orm@rc and state tested versions and Node floor
tinchoz49 Nov 30, 2026
c71d9c1
Merge exp/drizzle-postgres-driver: drizzle-orm and drizzle-kit 1.0.0-…
tinchoz49 Nov 30, 2026
9bd3ab7
chore: upgrade PGlite to 0.5.17 (PostgreSQL 18.7)
tinchoz49 Nov 30, 2026
b68743d
docs: pin PGlite 0.5 in install instructions
tinchoz49 Nov 30, 2026
9452a9a
Merge fix/pglite-0.5: PGlite 0.5.17 (PostgreSQL 18.7)
tinchoz49 Nov 30, 2026
7299b01
chore(deps): remove unused deps, add duron peer deps, apply in-range …
tinchoz49 Nov 30, 2026
003e149
fix(deps): keep @opentelemetry/api below 1.10, update multi-worker dr…
tinchoz49 Nov 30, 2026
188523e
Merge chore/deps-cleanup: remove unused deps, peer dependencies, in-r…
tinchoz49 Nov 30, 2026
ea8dc9e
chore(fmt): upgrade oxfmt to 0.80, rename experimentalSortImports to …
tinchoz49 Nov 30, 2026
a5d8300
style: reformat with oxfmt 0.80
tinchoz49 Nov 30, 2026
e61db6e
chore(ts): TypeScript 7 in docs and shared-actions, @types/node 26
tinchoz49 Nov 30, 2026
e69a400
chore(ts): type check with bun check instead of tsc --noEmit
tinchoz49 Nov 30, 2026
8426e62
build(duron): clean dist before building, stop publishing drizzle.config
tinchoz49 Nov 30, 2026
37d8909
fix(lint): resolve the 12 oxlint 1.95 warnings
tinchoz49 Nov 30, 2026
38054b0
Merge chore/tooling-majors: oxfmt 0.80, TypeScript 7, bun check, clea…
tinchoz49 Nov 30, 2026
7726aa6
chore(dashboard): upgrade lucide-react 1, motion 14, nanoid 6, react-…
tinchoz49 Nov 30, 2026
fdc99ec
Merge chore/dashboard-majors: dashboard UI majors
tinchoz49 Nov 30, 2026
b8012d3
chore(docs): vite 8, TanStack Start 1.170, fumadocs 16.19/mdx 15, luc…
tinchoz49 Nov 30, 2026
d04b10d
fix(examples): pass variables in server example; typecheck examples a…
tinchoz49 Nov 30, 2026
715108f
chore(shared-actions): AI SDK 7 (ai 7, @ai-sdk/openai 4, @ai-sdk/otel)
tinchoz49 Nov 30, 2026
b1d95d5
Merge chore/docs-examples-majors: docs and examples majors
tinchoz49 Nov 30, 2026
84befb0
perf(listing): index-friendly getJobs sort keys and per-table sort in…
tinchoz49 Nov 30, 2026
3130cda
docs(listing): migration locking and pre-build path; IF NOT EXISTS in…
tinchoz49 Nov 30, 2026
d75334b
Merge fix/job-list-sorting: index-friendly job listing sorts
tinchoz49 Nov 30, 2026
e0bff4f
chore(dashboard): remove unreachable code and its dependencies
tinchoz49 Nov 30, 2026
584413d
Merge chore/dashboard-dead-code: remove unreachable dashboard code
tinchoz49 Nov 30, 2026
381c238
fix(docs): no React #418 when hydrating the home page shell
tinchoz49 Nov 30, 2026
965bdb9
Merge fix/docs-hydration: avoid React #418 on the docs home page
tinchoz49 Nov 30, 2026
bc9b51f
chore(dashboard): remove unused exports
tinchoz49 Nov 30, 2026
c5f651f
chore(dashboard): remove unread dataTableConfig keys
tinchoz49 Nov 30, 2026
e897b6b
Merge chore/dashboard-unused-exports: remove unused dashboard exports…
tinchoz49 Nov 30, 2026
1532cb5
chore(deps): oxlint 1.96, oxfmt 0.81, react-virtual 3.14.31, p-retry 9
tinchoz49 Nov 30, 2026
305d4f0
Merge chore/minor-bumps: oxlint 1.96, oxfmt 0.81, react-virtual, p-re…
tinchoz49 Nov 30, 2026
314ddd9
fix(time-travel): lossless archive restore keeps sub-millisecond step…
tinchoz49 Nov 30, 2026
158832f
Merge fix/time-travel-restore: keep earlier steps when time travellin…
tinchoz49 Nov 30, 2026
9b997be
fix(postgres): archive the job row with SQL so stored values stay exact
tinchoz49 Nov 30, 2026
ee667b1
fix(postgres): keep the driver JSON encoding for archived output and …
tinchoz49 Nov 30, 2026
b11ee65
Merge fix/archive-job-row-lossless: archive job rows in SQL
tinchoz49 Nov 30, 2026
a9352cc
fix(docs): show the not-found page for unknown paths
tinchoz49 Nov 30, 2026
254587f
Merge fix/docs-not-found: proper not-found pages on the docs site
tinchoz49 Nov 30, 2026
528cfb4
chore: test on PostgreSQL 19 and PGlite 0.6
tinchoz49 Nov 30, 2026
59e6bff
Merge chore/postgres-19: PGlite 0.6 and PostgreSQL 19 test container
tinchoz49 Nov 30, 2026
470258c
feat(telemetry)!: depend only on @opentelemetry/api, take tracerProvi…
tinchoz49 Dec 1, 2026
86a7382
fix(telemetry): reject un-migrated telemetry config, propagate ids wi…
tinchoz49 Dec 1, 2026
f05a3e6
Merge feat/otel-api-only: Duron depends only on @opentelemetry/api
tinchoz49 Dec 1, 2026
3348c95
fix(test): run duron tests without --concurrent
tinchoz49 Dec 1, 2026
ff4070e
Merge fix/test-script: run duron tests without --concurrent
tinchoz49 Dec 1, 2026
b354449
fix: retry claim conflicts and keep draining job bursts
tinchoz49 Dec 1, 2026
92c0ed4
fix: address G1 review (follow-up demand, stop gate, docs)
tinchoz49 Dec 1, 2026
66d108e
fix: back off claim conflict retries exponentially
tinchoz49 Dec 1, 2026
64a866c
Merge fix/claim-conflicts-and-bursts: retry claim conflicts, drain jo…
tinchoz49 Dec 1, 2026
c9b2cb9
fix: recover this worker's own abandoned jobs, never its held ones
tinchoz49 Dec 1, 2026
6eed6ce
fix: one Client per adapter; address G2 review advisories
tinchoz49 Dec 1, 2026
f38b9a3
fix: no Client constructor side effects before its fallible steps
tinchoz49 Dec 1, 2026
c8f49eb
Merge fix/own-stuck-jobs: recover this worker's own abandoned jobs (P…
tinchoz49 Dec 1, 2026
b5390b4
chore: native CI matrix, install docs and review nits (PR #9 review R…
tinchoz49 Dec 1, 2026
ca825e9
fix: CI build on a clean checkout; narrower shutdown log demotion (G3…
tinchoz49 Dec 1, 2026
be19993
Merge chore/review-docs-ci-nits: native CI matrix, install docs, revi…
tinchoz49 Dec 1, 2026
a67ce91
fix: pre-existing bugs from the PR #9 review (time travel, prune lock…
tinchoz49 Dec 1, 2026
0332c46
fix: G4 review (stop ordering test, replaced prune locks released, re…
tinchoz49 Dec 1, 2026
1ee7267
test: count only client backends in native session assertions
tinchoz49 Dec 1, 2026
f57fd25
Merge fix/review-preexisting-bugs: pre-existing bugs from the PR #9 r…
tinchoz49 Dec 1, 2026
ede0719
fix: aborted steps settle before their job; CI-only test timing assum…
tinchoz49 Dec 1, 2026
e9c11cc
chore(test): pass --timeout 10000 explicitly to bun test (bunfig time…
tinchoz49 Dec 1, 2026
d4ffb80
fix: an aborted parent step waits only for started children (G5 review)
tinchoz49 Dec 1, 2026
e01d873
Merge fix/ci-native-flakes: aborted steps settle before their job; CI…
tinchoz49 Dec 1, 2026
317429a
fix: prune-lock replacement edge cases (G4 recheck N1-N4)
tinchoz49 Dec 1, 2026
ad2f2a7
fix: prune replacement review (R1, A1, A2, A4)
tinchoz49 Dec 1, 2026
8322af2
test: prune backoff probes only after the due time is recorded (R2); …
tinchoz49 Dec 1, 2026
11377d1
Merge fix/prune-reestablish-edges: prune-lock replacement edge cases
tinchoz49 Dec 1, 2026
0a51ad5
test(worker-discovery): seed direct-claim fixtures before the Client …
tinchoz49 Dec 1, 2026
9f4ce55
test: silence no-unmodified-loop-condition in prune-backoff (async co…
tinchoz49 Dec 1, 2026
dccf408
Merge fix/ci-flake-worker-discovery: seed worker-discovery fixtures b…
tinchoz49 Dec 1, 2026
8838a20
fix: scope stop() drain exclusion to the caller's job; hide heldJobId…
tinchoz49 Dec 1, 2026
98a4cee
fix: run queued steps in the pusher's context; pin the discovery and …
tinchoz49 Dec 1, 2026
206e1d3
Merge fix/review2-runtime: PR #9 follow-up review (N1, C2, C3, nits, …
tinchoz49 Dec 1, 2026
78986c8
fix(discovery): follow up short claims; wake discovery when a job of …
tinchoz49 Dec 1, 2026
2ef4fb3
fix(discovery): re-arm empty-claim retries per hint; keep waking whil…
tinchoz49 Dec 1, 2026
e40d50d
test: settle past the empty-claim retry tail before the idle check (R…
tinchoz49 Dec 1, 2026
2764089
Merge fix/review2-discovery: multi-worker bursts and group-limited ba…
tinchoz49 Dec 1, 2026
0d00131
ci: run the test workflow for pull requests into any branch (stacked …
tinchoz49 Dec 2, 2026
4021c43
PR #9 follow-ups: claim locking, release on stop, faster tests, refac…
tinchoz49 Dec 2, 2026
b313d38
test: prune tests that guard no behavior
tinchoz49 Dec 2, 2026
1a22773
test: guard the single uuid[] recovery binding with a large recovery
tinchoz49 Dec 2, 2026
f94a1fc
Merge chore/prune-tests-v2: prune tests that guard no behaviour
tinchoz49 Dec 3, 2026
e9787ec
docs: archive pruning in the Client and Server API, retention details…
tinchoz49 Dec 3, 2026
f0dc407
docs: Upgrading page with every breaking and behaviour change since main
tinchoz49 Dec 3, 2026
2b2f7a9
docs: audit pages and READMEs against the current API
tinchoz49 Dec 3, 2026
39767a5
examples: multi-worker worker stops gracefully on SIGTERM
tinchoz49 Dec 3, 2026
8560ee4
docs: review fixes for the Upgrading page and the multi-worker example
tinchoz49 Dec 3, 2026
b1f730d
Merge docs/audit-after-pr9: Upgrading page and docs audit
tinchoz49 Dec 3, 2026
bd8e156
fix: access tokens only on protected routes, Client migrateOnStart, m…
tinchoz49 Dec 3, 2026
13e3e6d
fix: migrationsFolder, dashboard getHTML options and enableLogin docs…
tinchoz49 Dec 3, 2026
e196491
feat: action concurrency is a cross-worker limit on the running jobs …
tinchoz49 Dec 3, 2026
6fa6790
chore: review follow-ups for the pre-existing bug fixes
tinchoz49 Dec 3, 2026
ef330bc
Merge fix/preexisting-bugs-2: token types, migrateOnStart, custom sch…
tinchoz49 Dec 3, 2026
3040182
fix: built-in migrations only for the duron schema; fail fast for a c…
tinchoz49 Dec 3, 2026
c94cd34
chore: review follow-ups for the custom-schema startup check
tinchoz49 Dec 3, 2026
b3a3191
Merge fix/custom-schema-design: built-in migrations only for the duro…
tinchoz49 Dec 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,71 @@ name: Tests
on:
push:
branches: [main]
# Every pull request, including stacked PRs that target another branch.
pull_request:
branches: [main]

# Bun 1.4.5 is the first stable release used here with `bun check` (the typecheck script).
# Keep it pinned so a new Bun release cannot change CI results on its own.
env:
BUN_VERSION: 1.4.5

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Install dependencies
run: bun install
run: bun install --frozen-lockfile
- name: Run typecheck
run: bun run typecheck
- name: Run lint
run: bun run lint
- name: Run format check
run: bun run fmt:check
# typecheck uses `bun check`; the published `dist` is emitted by tsc, so build it too.
- name: Build
run: bun run build
# scripts/test-parallel.ts: files in parallel processes, timing-sensitive files serially.
- name: Run tests
run: bun run test
# getHTML inlines the built dist/ assets, so this runs after Build (CI=true: never skipped).
- name: Run dashboard tests
working-directory: packages/duron-dashboard
run: bun test

# The native PostgreSQL suite (POSTGRES_TEST=true) on every supported server major.
# test/docker.ts provisions the server itself: it runs DURON_TEST_POSTGRES_IMAGE as the
# container duron-postgres-test-<image> on port 5440 and creates one database per test
# over SQL from a template database. The runner's Docker daemon is enough, so no
# `services:` container is used (docker.ts would refuse one that holds port 5440).
native:
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image: [postgres:16-alpine, postgres:19-alpine]
name: native (${{ matrix.image }})
env:
POSTGRES_TEST: 'true'
DURON_TEST_POSTGRES_IMAGE: ${{ matrix.image }}
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Install dependencies
run: bun install --frozen-lockfile
# Pull before the tests, so the first test's timeout does not include the download.
- name: Pull PostgreSQL image
run: docker pull "$DURON_TEST_POSTGRES_IMAGE"
# Every PostgreSQL test runs only with POSTGRES_TEST; the test job above is PGlite only.
- name: Run native tests
run: bun run test
- name: PostgreSQL container logs
if: failure()
run: docker logs "duron-postgres-test-${DURON_TEST_POSTGRES_IMAGE//[^a-zA-Z0-9_.-]/-}" 2>&1 | tail -200
2 changes: 1 addition & 1 deletion .oxfmtrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"arrowParens": "always",
"endOfLine": "lf",
"ignorePatterns": ["dist", "build", "node_modules", ".wrangler", "**/drizzle", "**/*.gen.ts"],
"experimentalSortImports": {
"sortImports": {
"order": "asc",
"groups": [
["side_effect"],
Expand Down
13 changes: 12 additions & 1 deletion .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
"suspicious": "warn"
},
"rules": {
"import/no-unassigned-import": ["error", { "allow": ["./app.css", "**/*.css"] }],
"import/no-unassigned-import": [
"error",
{
"allow": ["./app.css", "**/*.css"]
}
],
"no-underscore-dangle": "off"
},
"overrides": [
Expand All @@ -20,6 +25,12 @@
"rules": {
"no-shadow": "off"
}
},
{
"files": ["packages/duron/test/*.test.ts"],
"rules": {
"unicorn/consistent-function-scoping": "off"
}
}
],
"ignorePatterns": ["dist", "build", "node_modules", ".wrangler", "**/*.gen.ts", "**/env.d.ts"]
Expand Down
46 changes: 33 additions & 13 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ bun run dev:dashboard # dashboard dev server
bun run dev:examples:basic # basic example

# Verification (CI runs in this order)
bun run typecheck # tsc --noEmit across packages
bun run typecheck # bun check across packages (Bun's built-in type checker)
bun run lint # oxlint check
bun run lint:fix # oxlint fix
bun run fmt:check # oxfmt check
bun run fmt # oxfmt fix
bun test # runs packages/duron tests with --concurrent
bun run test # packages/duron tests in parallel processes (scripts/test-parallel.ts)

# Build
bun run build # all packages
Expand All @@ -48,7 +48,7 @@ bun run build:docs # docs only

## Database

- PostgreSQL for dev: `docker-compose up -d` → `postgres://duron:duron@localhost:5435/duron`
- PostgreSQL 19 for dev: `docker-compose up -d` → `postgres://duron:duron@localhost:5435/duron`. A container created with the earlier PostgreSQL 16 image is recreated empty; its data stays in the old anonymous volume.
- PGLite for tests/development.
- Generate migrations:
```bash
Expand All @@ -60,9 +60,24 @@ bun run build:docs # docs only

- Framework: `bun:test`
- Tests live in `packages/duron/test/*.test.ts`
- Run single file: `bun test specific.test.ts`
- Core tests run with `--concurrent` via `bun test` in `packages/duron/package.json`
- Test setup (`test/setup.ts`) auto-creates a Docker container `duron-postgres-test` on port 5440 for PostgreSQL tests. Docker must be running.
- Run single file: `bun test --timeout 10000 specific.test.ts`
- Default per-test timeout: pass `--timeout 10000` (the runner and CI do). Bun ignores a `timeout` key in `bunfig.toml` (oven-sh/bun#7789), so a plain `bun test` uses 5000 ms.
- Full suite: `bun run test` (root or `packages/duron`) runs `packages/duron/scripts/test-parallel.ts`. CI uses it too.
- Each test file runs in its own `bun test --timeout 10000 <file>` process. Files without wall-clock budgets run in a pool of `--jobs N` processes (default: half the CPU cores; `DURON_TEST_JOBS` overrides).
- Files with wall-clock budgets (the `SERIAL` list in the script: `lifecycle*`, `prune-*`, `stop*`, `shutdown-*`, `wait-native*`, `wait-timing`, `discovery-throughput`, `claim-isolation`, `claim.test`, `cross-mechanism`, `step-abort-settlement`, `local-cancellation.test`, `worker-discovery`) run after the pool, one at a time, with no other test process. Add a file there when it asserts elapsed time or observes timers/cadences under a bound, and put a timing-sensitive test only in a file of that list.
- Test files are grouped by feature (for example `lifecycle.test.ts`, `prune-lock.test.ts`, `prune-scheduler.test.ts`, `wait.test.ts`, `wait-timing.test.ts`). Each former file is one `{ ... }` block with its own helpers, under a `// ===` banner with its old name; the imports are shared at the top. Keep a new group's helpers inside its block (the lint override for `packages/duron/test/*.test.ts` turns off `unicorn/consistent-function-scoping` for this reason).
- Output: one line per finished file (pass/skip/fail counts, time); then the complete output of each failed file, a per-file count table and the totals. Exit status 1 when a file fails (non-zero `bun test` exit, a failed test, no summary, or longer than the file timeout: 300000 ms, `--file-timeout` or `DURON_TEST_FILE_TIMEOUT`; a timed-out file is killed and reported by name, and the run continues). Every file's log is kept in `DURON_TEST_LOG_DIR` (default: a new temporary directory; the path is printed).
- Filters: `bun run test -- wait-` (in `packages/duron`) runs the files whose path contains a filter.
- `bun test --timeout 10000` (root, or `bun run test:serial` in `packages/duron`) still runs every file in one process, one file after another. It is slower; use it for one file or to compare.
- PGlite tests need no Docker. PostgreSQL tests run only with `POSTGRES_TEST=true`; every file that uses PostgreSQL gates it on that variable.
- Test databases (`test/adapters.ts`, `test/docker.ts`):
- `pgliteFactory` / `postgresFactory` give a database with all migrations already applied; `migrateOnStart` only checks them. With `fresh: true` or `migrateOnStart: false` the database is empty (as a new one). Use `fresh: true` in a test that observes the migrations themselves.
- PGlite: each process dumps one migrated and one empty engine once (`dumpDataDir`); every factory engine starts from a dump (`loadDataDir`), which skips `initdb` (about 450 ms of the 500 ms of a new engine).
- PostgreSQL: each test database is `CREATE DATABASE "<random>" TEMPLATE "<template>"` over SQL, and `deleteDb` drops it over SQL. The templates `duron_test_tpl_base_<key>` (pgcrypto) and `duron_test_tpl_migrated_<key>` (plus all migrations) are built once per server, under an advisory lock. `<key>` hashes the migrations folder and the Drizzle version, so a changed migration builds new templates. The runner drops the templates of other keys before a run (best effort); a run that loses its template rebuilds it. With `POSTGRES_TEST=true` the runner prepares the container and templates once and sets `DURON_TEST_CONTAINER_READY=1`, so the test processes skip the container checks. `getPostgresConnection()` gives an empty (base) database unless `{ migrated: true }`.
- With `POSTGRES_TEST=true`, `test/docker.ts` auto-creates a Docker container on port 5440 for the PostgreSQL tests. Docker must be running.
- Image: `DURON_TEST_POSTGRES_IMAGE` (default `postgres:19-alpine`). The suite is also verified on `postgres:16-alpine`.
- Container: `duron-postgres-test-<image>` (for example `duron-postgres-test-postgres-19-alpine`), so a changed image never reuses a container of another version. `DURON_TEST_POSTGRES_CONTAINER` overrides the name; an existing container must run the selected image.
- Only one test container can publish port 5440: stop the other one before switching images.

## Lint / Format (Oxlint/Oxfmt)

Expand All @@ -76,7 +91,7 @@ bun run build:docs # docs only

## Build Details

- `packages/duron`: `tsc --project tsconfig.node.json`
- `packages/duron`: `tsc --project tsconfig.node.json` (tsc only emits `dist`; type checking uses `bun check --no-script`)
- `packages/duron-dashboard`: `NODE_ENV=production bun run build.ts && bun run build:get-html`
- Docs: `vite build`

Expand All @@ -103,7 +118,10 @@ bun run build:docs # docs only

## CI

Workflow `.github/workflows/test.yml` runs: `bun install` → `typecheck` → `lint` → `test`.
Workflow `.github/workflows/test.yml` (Bun pinned with `BUN_VERSION`, currently 1.4.5) has two jobs:

- `test`: `bun install --frozen-lockfile` → `typecheck` → `lint` → `fmt:check` → `build` → `bun run test` (parallel runner, PGlite only, no Docker) → `bun test` in `packages/duron-dashboard` (the `getHTML` test reads the built `dist`; it is skipped without `dist` locally, and fails without it when `CI=true`).
- `native`: matrix over `postgres:16-alpine` and `postgres:19-alpine` (`DURON_TEST_POSTGRES_IMAGE`), `POSTGRES_TEST=true bun run test`. `test/docker.ts` starts the container on the runner's Docker.

## Branch Workflow

Expand All @@ -114,15 +132,17 @@ Workflow `.github/workflows/test.yml` runs: `bun install` → `typecheck` → `l
```bash
bun run typecheck # TypeScript check across all packages
bun run lint # Lint check
bun test # Full test suite (not just packages/duron)
bun run test # Full test suite (parallel runner)
```

## Telemetry

Configured on the Duron client:
Duron depends only on `@opentelemetry/api` (peer dependency `^1.9.0`). The application owns the SDK.

- `telemetry: { traceExporter }` → export to OTel backends
- No config → disabled
- `telemetry: { tracerProvider }` → Duron gets its tracer with `tracerProvider.getTracer('duron')`. The application creates the provider (Resource, span processors, exporters) and shuts it down.
- No config → disabled (no-op tracer; the global tracer provider is not used)
- Duron does not create a Resource and does not register, flush or shut down the provider.
- Tests use `@opentelemetry/sdk-trace` 3 (`TracerProvider` + `InMemorySpanExporter`) as dev dependencies only.

## Key Files

Expand All @@ -133,5 +153,5 @@ Configured on the Duron client:
| `packages/duron/src/server.ts` | REST API server |
| `packages/duron/src/step-manager.ts` | Step execution & nested steps |
| `packages/duron/src/adapters/adapter.ts` | Base adapter |
| `packages/duron/src/telemetry/` | Telemetry adapters |
| `packages/duron/src/action-job.ts` | Job spans (OTel) |
| `packages/duron-dashboard/src/DuronDashboard.tsx` | Dashboard root |
20 changes: 10 additions & 10 deletions CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Core Concepts

**Job** — A unit of work to be executed. Has a status (`created`, `active`, `completed`, `failed`, `expired`, `archived`), a timeout, optional expiry, and optional variables. Jobs are created via the client and processed by workers.
**Job** — A unit of work to be executed. Has a status (`created`, `active`, `completed`, `failed`, `cancelled`), a timeout, optional expiry, and optional variables. Jobs are created via the client and processed by workers. Expiry is not a status: recovery archives an expired job as `failed`. Archive is storage membership, not a status (see Archive).

**Step** — A discrete unit of work within a job's execution. Steps are created by action handlers via `ctx.step()`. Steps can be sequential, parallel, or nested. Each step has its own status and timing.

Expand All @@ -14,32 +14,32 @@

## Execution Model

**Sync Pattern** — How a client fetches jobs: `'push'` (listen for NOTIFY), `'pull'` (poll), or `'hybrid'` (both). Configured per-client.
**Sync Pattern** — How a client discovers jobs: `'pull'`, `'push'` or `'hybrid'`. Every mode runs periodic discovery every `pullInterval`; in `'push'` and `'hybrid'`, NOTIFY hints only make discovery faster. `false` makes no automatic claims. Configured per-client.

**Concurrency** — Maximum number of jobs a client processes simultaneously.
**Concurrency** — Several separate limits. A group's limit (see Group Key) applies across all workers at claim time. Per client, `actionConcurrencyLimit` or an action's `concurrency` caps running jobs per action, and `batchSize` caps the client's outstanding automatic claims.

**Heartbeat** — A periodic upsert to the `clients` table (`last_seen_at`) proving an instance is alive. Used for dead-client detection in recovery.
**Heartbeat** — A periodic upsert to the `clients` table (`last_seen_at`, written with SQL `now()`) proving an instance is alive. Used for dead-client detection in recovery.

**Recovery** — The process of detecting and requeuing jobs owned by dead clients (heartbeat older than `heartbeatTimeout`). Runs periodically and on startup.
**Recovery** — The process of detecting jobs owned by dead clients (heartbeat older than `heartbeatTimeout`): expired jobs are archived as `failed`, others are requeued as `created`. Runs on startup and during a worker discovery turn once `recoverJobsInterval` has elapsed; there is no separate recovery timer.

## Telemetry

**Telemetry (OpenTelemetry)** — Duron instruments all job and step execution with OTel spans via `@opentelemetry/api`. Users connect external collectors via `telemetry: { traceExporter }`.
**Telemetry (OpenTelemetry)** — Duron instruments all job and step execution with OTel spans via `@opentelemetry/api`, its only OpenTelemetry dependency (a peer dependency). Users enable it with `telemetry: { tracerProvider }`. Without it, telemetry is disabled; the global tracer provider is not used.

**TraceExporter** — An OpenTelemetry `SpanExporter` (or array of exporters) that receives completed spans. Users provide their own (e.g., `OTLPTraceExporter`).
**TracerProvider** — The OpenTelemetry `TracerProvider` (API interface) that the application creates with its own SDK, Resource and exporters, and passes to a Duron client. Duron gets its `duron` tracer from it and never registers, flushes or shuts it down. See ADR 0002.

## Data Model

**Archive** — Completed/failed/expired jobs are moved from `jobs_active` to `jobs_archive`. Steps follow their parent job.
**Archive** — Completed, failed and cancelled jobs are moved from `jobs_active` to `jobs_archive`. Steps follow their parent job. Time travel can restore an archived job to active storage, so a job with a terminal status can be in either table.

**Variables** — Key-value data attached to a job, accessible to action handlers via `ctx.variables`.

**Group Key** — A string used for rate limiting and deduplication. Jobs with the same group key are serialized.
**Group Key** — A string that groups jobs of one action for concurrency control. A group is an action name plus a group key; its limit comes from the latest unexpired job in the group and applies across workers when jobs are claimed. Jobs in a group run one at a time only when that limit is 1. It does not deduplicate enqueued jobs.

## Infrastructure

**Adapter** — Database abstraction layer. Implementations: `PostgresAdapter` (PostgreSQL), `PGLiteAdapter` (embedded PG).

**Advisory Lock** — PostgreSQL mechanism for coordinating workers. Used for serializing jobs with the same group key.
**Advisory Lock** — PostgreSQL session lock. Used only to coordinate scheduled archive pruning (key `42`, shared by all schemas in one database). Job claims do not use advisory locks: they row-lock candidates with `SKIP LOCKED` inside a `SERIALIZABLE` transaction.

**Client Liveness Table** — A `clients` table storing `client_id` and `last_seen_at`. Updated by heartbeat, queried by recovery to detect dead instances.
Loading
Loading