@happyvertical/smrt-jobs 0.40.70 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +30 -0
- package/dist/chunks/{runner-Mmu7QMKw.js → runner-C68WD1zA.js} +431 -311
- package/dist/chunks/runner-C68WD1zA.js.map +1 -0
- package/dist/forge-projection.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +168 -63
- package/dist/retention.d.ts +87 -0
- package/dist/retention.d.ts.map +1 -0
- package/dist/runner.d.ts +13 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +1 -1
- package/dist/smrt-job-event.d.ts +25 -0
- package/dist/smrt-job-event.d.ts.map +1 -1
- package/dist/smrt-job.d.ts +26 -3
- package/dist/smrt-job.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +24 -5
- package/package.json +7 -7
- package/dist/chunks/runner-Mmu7QMKw.js.map +0 -1
package/AGENTS.md
CHANGED
|
@@ -135,6 +135,36 @@ change what the agents runtime will dispatch.
|
|
|
135
135
|
every sibling method. Adding the decorator to one method of an existing class
|
|
136
136
|
is therefore a behaviour change for the rest of it.
|
|
137
137
|
|
|
138
|
+
## Retention (#2375)
|
|
139
|
+
|
|
140
|
+
`_smrt_jobs` and `_smrt_job_events` are append-only in practice — `cleanup()`
|
|
141
|
+
existed but nothing ever called it, and job events (one row per log line and
|
|
142
|
+
progress tick) had no prune path at all. `src/retention.ts` contributes both to
|
|
143
|
+
the framework retention sweep in `@happyvertical/smrt-core`.
|
|
144
|
+
|
|
145
|
+
- `TaskRunner` starts a sweeper by default. `retention: false` opts out;
|
|
146
|
+
`retention: { intervalMs, policy, jobs }` tunes it. The **first sweep is one
|
|
147
|
+
interval after `start()`, never at start** — a crash-looping worker must not
|
|
148
|
+
become a delete loop, and a short-lived runner must exit having deleted
|
|
149
|
+
nothing. `stop()` only clears the timer — it does **not** unregister the job
|
|
150
|
+
tasks. The package entry point (`index.ts`) registers them unconditionally
|
|
151
|
+
on import, so "this process loaded `@happyvertical/smrt-jobs`" is the
|
|
152
|
+
contract that contributes them, not "a sweeper happens to be running";
|
|
153
|
+
`unregisterJobRetentionTasks()` is the explicit opt-out for callers that
|
|
154
|
+
want a clean registry (tests, teardown).
|
|
155
|
+
- Windows (`DEFAULT_JOB_RETENTION`): completed/cancelled 7 days, failed 30
|
|
156
|
+
days, events 30 days, 10 000 job rows per sweep. Events deliberately outlive
|
|
157
|
+
the jobs they describe, so a job row removed at 7 days still has a readable
|
|
158
|
+
log for another three weeks.
|
|
159
|
+
- `cleanup()` counts before deleting (`rowCount` is unreliable across engines)
|
|
160
|
+
and honours `dryRun`, which is what makes `smrt db:prune --dry-run` an exact
|
|
161
|
+
preview. Its `(status, completed_at)` predicate is indexed by
|
|
162
|
+
`ensureJobsSystemTableCompatibility()`, which this collection runs on every
|
|
163
|
+
`initialize()` — bootstrap cannot do it, because `_smrt_jobs` does not exist
|
|
164
|
+
yet when bootstrap runs.
|
|
165
|
+
- `cleanup({})` with no cutoff returns 0. It must never be read as "delete
|
|
166
|
+
everything".
|
|
167
|
+
|
|
138
168
|
## Gotchas
|
|
139
169
|
|
|
140
170
|
- **Cron not timezone-aware**: cron fields match the server's **local** time, not UTC (set `TZ` for UTC); no missed-run catch-up (fire-once-forward)
|