Skip to content

refactor(jobs): one nightly retention sweep, declared per collection - #1013

Merged
sydevs-bot merged 32 commits into
mainfrom
claude/refactor-987-retention-registry
Oct 26, 2026
Merged

sydevs-bot merged 32 commits into
mainfrom
claude/refactor-987-retention-registry

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • purgeSubmissions, sweepEventImports and cleanupJobs become one nightly task, cleanupCollections, over every collection that declares retention inline on its own config's custom.retention.
  • meditation-transcripts declares a seven-day orphan window, settling the policy question earlier rounds had parked.
  • Joined: the orphan sweep's dry run reported a sender as going whom the real sweep then kept. Fixed here, in the code this PR moves.
  • Joined: Payload ships payload-jobs hidden from everyone, so the Jobs UI an operator queues this task from answered 404 for every user, admins included. It is now admin-only rather than nobody's.
  • Joined: tests/PERF.md's unit-spec count was behind main. Re-pinned on the merged tree, with this branch's specs.

Change outline

Files — three job folders become one declaration per swept collection, inline

 src/jobs/
-├── PurgeSubmissions/        # slug, schemas, cron 04:00 + the users orphan sweep
-│   └── retention.ts         # PURGE_WINDOWS, DURABLE_TYPES
-├── SweepEventImports/       # slug, schemas, cron 04:30 + IMPORT_WINDOWS
-├── CleanupJobs/             # slug, schemas, cron Sun 05:00 + JOB_PURGE_WINDOWS
+├── CleanupCollections/
+│   ├── CleanupCollections.ts # the one task: slug, schemas, cron 04:00
+│   ├── entries.ts            # discovery: what the built config declares
+│   └── sweepCollection.ts    # the engine + dueWindows, nothing naming a collection
 └── …
-src/lib/retention/           # four files: vocabulary, discovery, cutoff, barrel
+src/types/retention.ts       # the vocabulary alone — what every declaring config needs

 # the windows, inline in the config that declares them, beside the fields they age
-src/collections/UserSubmissions/retention.ts
+src/plugins/formBuilder/index.ts               # where user-submissions is built
-src/plugins/eventImport/retention.ts
+src/plugins/eventImport/importCollection.ts
-src/collections/PayloadJobs/retention.ts
+src/collections/PayloadJobs/PayloadJobs.ts     # + the override, + admin.hidden
+src/collections/MeditationTranscripts/         # the orphan window, 7 days

Contract — the task an operator queues, the enum a deploy casts, and what a collection declares

 payload-jobs.taskSlug                                    the admin Jobs UI
-  purgeSubmissions   in { now, dryRun }  out { deletedSubmissions, deletedUsers }
-  sweepEventImports  in { now, dryRun }  out { deleted }
-  cleanupJobs        in { now, dryRun }  out { deletedJobs }
+  cleanupCollections in { now, dryRun, collection }
+                     out { deleted, dryRun, collections: [{ collection, deleted }] }
+    collection is free text, matched against what the built config declares; an
+      unknown one throws and names the collections that do declare retention
+    collections carries a row per collection swept, `users` included, and a row
+      for one that threw, carrying what its earlier windows deleted
 CollectionConfig.custom.retention            server-only: Payload strips `custom`
+  { windows, hooks? }    swept nightly         before the config reaches the browser
+  declaring nothing      not swept             no second way to say so
 CollectionConfig.admin.hidden                payload-jobs only
-  true                   nobody, routes included — so no operator could queue a sweep
+  ({ user }) => !isAdminManager(user)         admins reach the Jobs UI, nobody else
 jobs.jobsCollectionOverrides                 @experimental
+  the one seam that reaches `payload-jobs`.custom and .admin, since Payload builds
+  that collection itself. Mirrored in the test harness, which boots its own config.
 enum_payload_jobs_task_slug, enum_payload_jobs_log_task_slug
+  + 'cleanupCollections'
-  - 'cleanupJobs', 'purgeSubmissions', 'sweepEventImports'   -- rows deleted first, see Migration

Flow — one handler over the config, with the hooks nested under the collection that owns them

 CleanupCollections.handler({ input, req })   src/jobs/CleanupCollections/CleanupCollections.ts
+  entries = retentionEntries(req.payload.config.collections)   # config order
+    or the one `collection` names    # declares none → throw, naming those that do
+  for each entry:
+    windows = dueWindows(entry.windows, now)   # resolved once, against one clock
+    hooks = entry.hooks?.({ dryRun, req, wheres })
+    try:
       sweepCollection({ collection, windows, beforeDelete, … })
-        per window: cutoff → beforeDelete(where) → count (dry run) or delete
+        per window: beforeDelete(where) → count (dry run) or delete
-          beforeDelete read whose users rows were about to be orphaned
+          user-submissions only: noteSenders fills touchedUsers
+          a throw carries the rows the earlier windows deleted
+      hooks.afterDelete()                     # the users orphan sweep, one count
+    catch: log, record the collection and what it deleted first, carry on
+  throw once if any collection failed

Preview

  • Queue a job — the task dropdown, where one Cleanup Collections replaces three rows, with dryRun and the collection input
  • Jobs list — the queued row's output, once you run one from the link above

⚠ Both links 404 on main and on every earlier commit of this branch, for every user. Payload ships its own jobs collection admin: { hidden: true }, which unregisters the routes as well as the nav entry — so the Jobs UI these links point at was reachable by nobody at all. The last push narrows that gate to admin managers, which is what makes the preview above usable and the four manual steps below possible.

Data: not seeded. This repo configures no preview seed command, and a retention sweep shows nothing without expired rows — queue the task from the first link with dryRun set and the output is the data. Sign in by asking for a link as PREVIEW_ADMIN_EMAIL.

Migration

Two files, and only the first carries DDL. Nothing in the latest round adds a third: custom, admin.hidden and a retention window are all config, so a probe pnpm db:migrations:create --skip-empty on the current tree writes no file.

  • src/migrations/20261021_152406_retention_registry.ts — both task-slug enums, and the finished job rows naming the three replaced slugs. No table, column, constraint or index is touched. The up deletes every payload_jobs and payload_jobs_log row naming cleanupJobs, purgeSubmissions or sweepEventImports, then recreates both enums with the label set the config declares. Without the delete, the USING "task_slug"::enum cast rejects such a row and aborts the boot migration — those rows survive the deploy by up to JOB_RETENTION_DAYS (7), and nothing reads them. Same shape as 20261019_182311_import_plugin.ts. Reversible: the down restores the previous member set and deletes the cleanupCollections rows for the mirrored reason.
  • src/migrations/20261021_165805_merge_1010_main_snapshot.ts — snapshot only, empty up and down. Merging main put fix(app-cards): localize the destination discriminator beside its targets #1010's 20261021_014535_localize_app_card_destination behind this branch's newer migration, so the newest-by-timestamp snapshot lacked the three localized app_cards destination columns and migrate:create re-emitted all twelve of its statements. Every one already ships in fix(app-cards): localize the destination discriminator beside its targets #1010's own migration, which also backfills English between its two halves, so a replay would drop the base columns a second time with nothing to carry. Keeping the .json — generated on the merged tree — is what heals the chain (src/migrations/AGENTS.md, "The out-of-order snapshot trap"). A probe migrate:create after it writes no files.

Measured on Postgres in a rolled-back transaction, with the three legacy rows seeded: the cast without the delete aborts with invalid input value for enum … "cleanupJobs", and the committed DDL applies in both directions.

Test results

  • Lean gate: ✓ .claude/skills/pr-prep/check.sh — lint, typecheck, typecheck:tests, 225 unit files / 2895 cases, 101 s. Run on every commit of this round's series, not only the tip.
  • pnpm format:check: ✓ (a CI gate since fix(build): pnpm generate:types rewrites payload-types.ts after prettier 3.9.10 #998)
  • Targeted specs: ✓ retention-jobs, retention-submissions, meditation-transcripts, payload-system-access, event-imports — 72 cases
  • Build: N/A — Railway builds the app; CI does not

Each new assertion was watched failing against the defect it names: a collection with no window, the output's per-collection shape, a collection that throws not costing the rest their run, a run reporting a count per collection, an unknown collection refusing by name, the orphan dry run over-reporting, a custom.retention carrying no windows being ignored, a failed collection reporting what it deleted before it threw, payload-jobs carrying the window its override puts there, and — this round — the transcript window with its parent clause removed (which would sweep every transcript, not only an orphan) and the Jobs UI with the admin override removed (hidden is then true, not a function).

Manual verification

  1. Queue Cleanup Collections from /admin/collections/payload-jobs/create with dryRun ticked, and confirm the output carries a count per collection and nothing is deleted.
  2. Queue it again naming one collection, and confirm only that collection is reported.
  3. Queue it naming a collection that declares no retention, and confirm it throws and names the ones that do.
  4. On a database with expired rows, queue it without dryRun and confirm each collection's rows go.
  5. Sign in as a non-admin manager and confirm payload-jobs is absent from the sidebar and its route 404s.

Notes for reviewer

The two renamed int specs are the old purge-submissions and cleanup-jobs files: tests/int/retention-submissions.int.spec.ts and tests/int/retention-jobs.int.spec.ts. The ticket's verification checklist names the old paths.

Every window is now declared inline in the config that owns it, as asked. The three retention.ts files are gone. user-submissions has no schema file of its own — the form-builder wrapper builds it — so its windows live there, beside the custom.retention that declares them. Its four constants stay exported, because the invariants that make them safe to change are pinned without a database: a contact row must outlive the screening window, and no window may select a durable type. The three retention unit specs still run in 2.5 s with the plugin in their import graph.

src/lib/retention/ is gone too. The discovery and the cutoff were the job's own and moved into src/jobs/CleanupCollections/; only the type vocabulary is genuinely shared, and it is in src/types/retention.ts, which is what that folder is for. Minimised on the way: RetentionEntry went with the discovery, and RetentionRun now hands a collection's hooks the resolved Wheres instead of the windows and a clock — so the orphan sweep no longer re-derives cutoffs the sweep had already computed, and the two halves of one run cannot read different clocks. lib-boundary.spec.ts no longer has anything to say about retention.

meditation-transcripts sweeps an orphan after seven days, and RetentionExclusion is gone. Declaring no custom.retention already says a collection is not swept, so the type, its export and the one declaration using it all went. ⚠ One thing is worth knowing about the window: it tests meditation exists: false, which only the foreign key can produce, and it ages on updatedAt — the last application write. A hard delete nulls the column in the database and bumps no timestamp, so an orphan last written over a week ago goes on the next sweep, and only a recently-written one waits out the rest of its week. That matches your "useless immediately after the parent is deleted" with a grace period for a transcript somebody is still working on. Both directions are asserted against a real hard delete in meditation-transcripts.int.spec.ts, because no unit case can reach that state.

Making the Jobs UI admin-only answers your question directly: yes, Payload supports it. admin.hidden takes { user }, so the override narrows the gate rather than lifting it. Access was already admin-only on every operation (restrictPayloadSystemEntities), so nobody gains a permission here — only an admin gains the page their permission already allowed. ⚠ accessPlugin never sees payload-jobs, so nothing composes project visibility over this the way createHidden does elsewhere.

The collection input is still free text. A field's options are fixed when the task is declared, and which collections carry retention is not known until buildConfig has run the plugins — so a select could only be a copy of the config. The guard answers a typo instead, and names what the config does declare. Say the word if you would rather have the dropdown back with a spec pinning its options against the booted config.

The orphaned-user sweep stays in the user-submissions hooks, as asked. The task is named CleanupCollections after review.

Dismissed review findings, each with its reason:

Detail
  • payload-jobs is swept nightly rather than weekly, so six more deletes a week. The ticket decided this explicitly; a per-collection cadence would restore the per-task cron the refactor exists to remove. The window, not the cadence, bounds what goes.
  • retries: 2 now replays every collection, not one. A replayed collection with nothing due is a delete matching no rows, so the cost is queries, not work. Per-collection isolation means a single bad collection no longer stops the others reaching their turn.
  • The collections now sweep in sequence on one req. The job runner gives the handler a req with transactionID: undefined and every operation opens its own transaction, so nothing holds a lock across collections. A partial sweep self-heals on the next run, as it already did between the submissions and users halves.
  • deleted and dryRun in the output are derivable. dryRun matches cleanupOrphanedMedia's own output schema, and without it the job row cannot be told from a quiet night; deleted is the number an operator reads first.
  • The two discovery cases live in the jobs int spec rather than the unit spec. Both exercise the real task against a live Payload; the unit spec boots none and builds its own config.
  • fieldNames in the discovery spec duplicates a local helper in login-plugin.spec.ts. No shared helper exists under tests/utils/, and adding one is not this PR's.

Security review ran (the diff touches src/payload.config.ts, a securityReview.triggerPattern path). Nothing reportable across the rounds: the collection input reaches no query, being only the left-hand side of an equality against what the config declares, and only a collection the config declares reaches a delete; collection-level custom is one of Payload's serverOnlyCollectionProperties, so the where closures and the hooks factory never reach the browser (admin.custom, which does, carries nothing of retention's); jobsCollectionOverrides spreads the collection Payload built and adds custom and admin.hidden alone, so no field, hook or access rule changes; both migrations' SQL is static with no interpolation, and the second has no SQL at all; the orphan sweep's changed branch is the dry run, which deletes nothing, and the real path still gates on the unfiltered remaining count; no new PII or secret is logged.

This round's own exposure is the admin.hidden change, and it widens nothing: admin.hidden is the admin panel's nav and routes, never an access boundary, and the collection's access already denied every operation to everyone but an admin manager. A non-admin manager and an anonymous caller both read true from the new function, which is what they got from Payload's true. The transcript window's where reaches only meditation-transcripts, selects on a null relationship and a timestamp, and deletes rows whose only remaining content is a transcript nothing can play.

/code-review high plus four cleanup lenses ran over the whole branch diff. comment-lint.mjs reports no banned comment added.

Closes #987

🤖 Generated with Claude Code

https://claude.ai/code/session_013omVn6xbHvMg1aASCykUQn

`purgeSubmissions`, `sweepEventImports` and `cleanupJobs` called one engine
and differed only in their declaration: three slugs, three input schemas,
three output schemas and three crons around one loop. They are now rows in
`src/jobs/SweepRetention/registry.ts`, one per collection, each with its
windows and the reason each window is the length it is in its own file under
`entries/`. Adding a collection to retention is a row, not a job folder.

`NO_RETENTION` beside the registry records a collection deliberately left
out, with the reason. `meditation-transcripts` is its one entry: an orphaned
row keeps the full spoken word and its R2 key, and how long it may is a
policy decision this refactor takes no position on.

One task carries one schedule, so the `payload-jobs` sweep moves from
Sundays 05:00 to the nightly 04:00 run. `JOB_RETENTION_DAYS` is unchanged
and still bounds what goes — a row simply stops surviving the extra nought
to seven days until the next Sunday. That entry's docblock says so.

The engine moves out of `src/lib/retention/` with the three call sites: one
consumer in `src/` would fail `tests/unit/lib-boundary.spec.ts`, and
single-owner code belongs in its owner's folder. It is renamed
`sweepCollection`, since the task is now the retention sweep.

A registry cannot name its counters in a static `outputSchema`, so the
output carries one count per collection it touched — `users` included, which
no entry of its own sweeps. The `collection` input replaces the three
separately queueable rows the admin Jobs UI used to show, so an operator can
still dry-run one collection; an unknown one throws rather than sweeping
nothing and reporting success.

The `users` orphan sweep keeps both halves. They are a per-run hooks factory
rather than two functions, because a sender set held at module scope would
carry a dry run's senders into the real sweep after it.

Co-authored-by: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L8FT4pY6kwRfY9E2mXzzrU
…eplaces

`migrate:create` drops `cleanupJobs`, `purgeSubmissions` and
`sweepEventImports` from both task-slug enums, then casts the column back with
`USING "task_slug"::enum`. `deleteJobOnComplete: false` plus
`JOB_RETENTION_DAYS = 7` means a finished row still naming one of the three
survives up to a week past this deploy, and that cast rejects a value the new
enum lacks — aborting the boot migration rather than failing a row. So the up
keeps all three labels, and the down keeps `sweepRetention` for the mirrored
reason. The retention sweep is what removes the rows; the labels go with the
next regeneration of these enums.

Measured on Postgres before committing, in a rolled-back transaction with the
three legacy rows seeded: the generated DDL aborts with `invalid input value
for enum ... "cleanupJobs"`, and this DDL applies in both directions with
every row intact.

`--` comments only, no backticks: a backtick inside the `sql` template closes
it, which `tsc` reports as `TS1005: ',' expected` on the comment line.

Co-authored-by: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L8FT4pY6kwRfY9E2mXzzrU
…n by subtraction

From the review pass over the branch.

Three tasks could not fail each other; one task could. An entry that throws is
now logged, the entries after it still run, and the run ends failed once every
entry has had its turn — so a broken window query no longer leaves
`payload-jobs`, which nothing else bounds, growing while the failure reads as
one collection's. The job runner hands the handler a `req` carrying no
transaction, so a failed statement leaves the next entry's reads working.

The orphan sweep's dry run reported a sender as going whenever no durable row
pinned them, which was never the question the real sweep asks: a second contact
message not yet due pins the row too, and the dry run then disagreed with the
sweep that followed it. It now subtracts what the windows selected from what
the sender has, which is the same rule the real path reads off `remaining`.
The durable types no longer come into it, which also un-cycles the module.

The rest is subtraction the review asked for: one `types.ts` owns the entry
vocabulary, so `registry.ts` and the entry files no longer import types from
each other in a cycle, and the `beforeDelete` contract is declared once rather
than spelled on both sides of the call. `beforeDelete` loses the `window` no
implementation read, `afterDelete` reports one count rather than a one-element
array, and `RetentionRun.now` — dead before — is what the dry-run subtraction
reads its cutoffs from. `NO_RETENTION` is keyed on `CollectionSlug`, so a
renamed collection cannot sit there misspelled while reading as settled.
`deletedIn` takes the generated `TaskOutput<'sweepRetention'>` instead of a
hand-written shape, per `taskRunner.ts`'s own rule.

The migration keeps its DDL and gains the breadcrumb the review earned: the
committed snapshot omits the three retained labels, so the next migration
touching a task slug recreates the enums without them, and must not land while
a row still names one. The pre-flight query is in the comment.

Each new assertion was watched failing against the defect it names.

Co-authored-by: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L8FT4pY6kwRfY9E2mXzzrU
`tests/unit/perf-figures-pinned.spec.ts` holds `tests/PERF.md`'s count to the
specs on disk, and this branch adds one. The figure was already one behind on
`main` — 215 recorded against 216 files — so the lane is now 217 files and
2795 cases, measured on this branch's gate run. The three consumer docs quoting
the counts move with it; the timings are unchanged and unmeasured here.

Co-authored-by: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L8FT4pY6kwRfY9E2mXzzrU
@railway-app

railway-app Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-1013 environment in sahajcloud

Service Status Web Updated
SahajCloud ◻️ Removed (View Logs) Web Oct 25, 2026 at 7:52 pm UTC
1 service not affected by this PR
  • mailpit

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 question for the reviewer, one per thread.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 21, 2026
@sydevs-bot

sydevs-bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running
CI fix 2

recent dispatches
  • 06:50Z resolve-conflicts · attempt 1 · session · done
  • 06:50Z resolve-conflicts · attempt 1 · session
  • 20:19Z resolve-conflicts · attempt 1 · session · done
  • 20:19Z resolve-conflicts · attempt 1 · session
  • 16:38Z fix-ci · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

Four conflicts. Three were the unit lane's file and test counts, which both
sides had just re-pinned: neither side's number survives a merge that brings
both new specs, so the lane was re-measured on the merged tree — 218 files,
2799 tests — and PERF.md plus its three consumers carry that.

src/migrations/index.ts had both sides' new migrations. All four are kept, in
timestamp order.

The merge also put main's #981 localization migrations behind this branch's
newer one, leaving 20261021_020011's snapshot on the pre-#981 schema. A
migrate:create run then re-emitted main's whole localization move, which
replays on a Railway boot and aborts the migration. 20261021_023926 heals the
chain: its .json is generated on the merged tree and its up/down are empty,
since 20261020_170450 and 20261020_185917 already ship every statement. A
probe after it writes no files.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018VcchzPLHjQevQtqszjhX9
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1013 October 21, 2026 02:52 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged origin/main in and resolved four conflicts.

Three were the same figure — both sides re-pinned the unit lane's counts, and neither number survives the merge, which brings both new specs. Re-measured on the merged tree: 218 files / 2799 tests, written into tests/PERF.md and its three consumers.

src/migrations/index.ts: both sides added migrations, so all four are kept, in timestamp order.

One thing the merge broke that no hunk shows. It put main's #981 localization migrations behind this branch's newer one, leaving 20261021_020011's snapshot holding the pre-#981 schema — so migrate:create re-emitted main's entire localization move, which would abort the boot migration on deploy. 20261021_023926_merge_987_main_snapshot heals it: the .json generated on the merged tree, up/down empty, since 20261020_170450 and 20261020_185917 already ship every statement. A probe run after it writes no files.

Lean gate green: lint, both typechecks, 218 unit files / 2799 tests in 44 s.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 21, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The registry the ticket asked for is here, and every acceptance criterion is met — including the two judgement calls (meditation-transcripts recorded in NO_RETENTION; the payload-jobs cadence change stated at its own entry). Moving the engine out of src/lib/retention/ departs from the ticket, and is right: lib-boundary.spec.ts fails a lib module with one consumer.

It does not shrink the code, though. Excluding comments and blanks: 293 → 335 lines, 5 → 8 files. The ~150 lines of repeated declaration the ticket priced did collapse; the saving went on the registry's own vocabulary and on the two items the ticket listed as costs. "A row rather than a job folder" is the whole return.

Nothing blocks.

Findings

  • should-fix — a thrown entry reports no count and loses the deletes it already made — SweepRetention.ts:114.
  • should-fix — collection is free text guarded by a runtime throw; Payload has select — SweepRetention.ts:42.
  • should-fix — the body's test counts and migration list predate the conflict merge — src/migrations/index.ts:581.
  • consider — users is swept but is no registry row — registry.ts:19.

What was checked

#987 against the diff. All 8 SweepRetention/ files whole. lib-boundary.spec.ts (the move is forced) and src/types/AGENTS.md (types.ts is in convention). Both migrations' DDL and both .json snapshots: neither carries the three legacy labels, as the open question thread says. payload-types.ts slug union. Grep for the three old slugs over src scripts seeds tests docs — only new docblocks name them. architecture.md, src/AGENTS.md, COVERAGE.md, PERF.md, testing-reqs.md all follow the rename. Preview answers 200; no sign-in, since this run holds no PREVIEW_ADMIN_EMAIL, so collection was read from inputSchema rather than the UI.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/jobs/CleanupCollections/registry.ts Resolved
Comment thread src/migrations/index.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 21, 2026
`sweepCollection` returned its count only on success, so a throw in the
second window discarded the first window's deletes and left the entry
absent from the run's report — which reads as zero, the same answer a
collection with nothing due gets.

A `SweepFailure` carries the partial count past the throw, and the
handler pushes the entry's row from it. `afterDelete` still throws past
that branch, its entry's row already recorded.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018edbTgVRrCoQ3Eb3REKn9f
`collection` was free text, guarded by a runtime throw and described by
a list hand-built from the registry. A `select` over the same registry
gives the operator the three rows the three replaced tasks used to show,
and generates a union the specs type against.

The guard stays: a queue call in code reaches the handler with whatever
it was handed, and no field validates that path.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018edbTgVRrCoQ3Eb3REKn9f
"One entry per collection" did not cover `users`, which the task sweeps
through the `user-submissions` entry's hooks and reports as a collection
with no row of its own.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018edbTgVRrCoQ3Eb3REKn9f
Two assertions land with this branch's threads, so the lane is 2801
tests over the same 218 files. `perf-figures-pinned.spec.ts` holds every
consumer to PERF.md's figure.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018edbTgVRrCoQ3Eb3REKn9f
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1013 October 21, 2026 03:21 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Four review threads adopted, one commit each, pushed as 865c4ce.

Nothing rebutted. The migration question thread stays open — it waits on you.

Gate green on this head: lint, both typechecks, 2801 unit tests, 98 s. 45 int cases across retention-jobs, retention-submissions, event-imports.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 21, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 21, 2026 03:37
@sydevs-bot
sydevs-bot requested a review from Ardnived October 21, 2026 03:37
@sydevs-bot sydevs-bot added awaiting bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed awaiting labels Oct 23, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

CI is red only in the smoke step, and the cause is outside this repo. The preview deploy failed, so all 9 e2e specs got 502 from /api/managers/request-magic-link. Lint, format, typechecks and the unit + integration lanes passed.

The preview is still down — /api/health → 502, Application failed to respond. [Failed deployment](https://railway.com/project/bdff2c72-5af2-4da3-9e2c-913f5e9d1b0f/service/1edee955-6c1f-4d8e-9cef-41737f981187?id=24cf4748-dbc3-4fd7-a8a3-a833eb14ee29&environmentId=f58d53f5-ddca-4517-8647-d88ff6e334a5).

No log reached this run: RAILWAY_TOKEN answers Not Authorized for buildLogs, deploymentLogs and deployment.

Verified on 71581f9, ruling out the repo:

  • pnpm build green — CI never runs it, so only Railway catches a build fault
  • all 99 migrations apply from an empty database, this branch's two included
  • the endpoint smoke failed on answers 200 {"ok":true}
  • /admin/collections/payload-jobs answers 200

This needs an attended redeploy, which a routine may not do. Nothing pushed: no commit changes it.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot added awaiting bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. awaiting labels Oct 23, 2026
#1027 landed `20261024_005319_submission_location` on `main`, which
conflicted with this branch's two migrations in `src/migrations/index.ts`.
Both sides are additive, so all three are registered in timestamp order.

That merge re-armed the out-of-order snapshot trap. #1027's snapshot is now
newest by timestamp but was generated on `main`, where `task_slug` still
names `cleanupJobs`, `purgeSubmissions` and `sweepEventImports` — so
`migrate:create` re-emitted both enum rebuilds that
`20261021_152406_retention_registry` already ships. The re-emission omits
that migration's `DELETE` of the rows naming the dropped slugs, so replaying
it would abort the boot migration on the first legacy row. Healed the
documented way: `20261024_161437_merge_1027_main_snapshot` keeps its `.json`,
generated on the merged tree, with empty `up` and `down`.

`src/plugins/formBuilder/index.ts` merged cleanly and carries both sides —
this branch's `custom.retention` and #1027's `resolveProposalRegion` hook.
#1027 adds no submission type, so `DURABLE_TYPES` is unchanged, and the purge
windows select on `type`, `status` and `createdAt`, none of which it touches.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SPqGrb2pbaKRL5f1PFAyT8
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1013 October 24, 2026 16:21 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged main. One conflict, src/migrations/index.ts — both sides only add migrations, so all three are registered in timestamp order.

The merge re-armed the out-of-order snapshot trap. #1027's snapshot is newest by timestamp but was generated on main, so migrate:create re-emitted both task_slug enum rebuilds 20261021_152406_retention_registry already ships — without its DELETE of the rows naming the dropped slugs, so a replay would abort the boot migration. 20261024_161437_merge_1027_main_snapshot keeps that .json and empties the DDL.

src/plugins/formBuilder/index.ts merged clean and carries both sides: this branch's custom.retention and #1027's resolveProposalRegion hook. #1027 adds no submission type, so DURABLE_TYPES is unchanged, and the purge windows select on type, status and createdAt — none of which it touches.

Gate green. Int specs: retention-jobs, retention-submissions, meditation-transcripts, payload-system-access, event-imports, plus #1027's own atlas-submission-routing — 86 cases.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot added awaiting bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. awaiting labels Oct 24, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

CI is red only in smoke, and nothing in this head reproduces it. The preview crashed, so all 9 e2e specs got 502. Lint, format, typechecks and the unit + int lanes passed.

New since the last run: Railway is healthy. #1020's preview deployed at 16:25, seven minutes before this one crashed at 16:32. So the fault is specific to SahajCloud-pr-1013, not an outage. Railway reports Crashed, not a failed build.

Verified on 84dcb81:

  • pnpm build green, and the built app boots — /api/health answers 200
  • migrations apply under three histories: from empty, from 71581f9's chain, and from the chain before 1059d10 deleted two already-deployed migrations — the feat(access): add embed metadata and canonical ownership to Clients #633 trap src/migrations/AGENTS.md says a clean-database test cannot catch

No log reached this run: RAILWAY_TOKEN answers Not Authorized for buildLogs, deploymentLogs and deployment.

This needs an attended environment reset (railway environment delete SahajCloud-pr-1013 --yes), which a routine may not do. Nothing pushed: no commit changes it.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Four Markdown conflicts, all test-count figures that both sides re-pinned.
`main` re-measured Tier 1's slowest per-edit selection on 2026-10-23 and
explained why the config-importing spec dominates it, so those rows
supersede this branch's older importGraph measurement. The session table
keeps both sides' rows, as `tests/PERF.md` asks, renumbered.

The counts themselves belonged to neither side: the merged tree carries
227 unit spec files and 2911 cases, measured here.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TTTFj1cX5mx7urq9fX39Qx
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged main. All four conflicts were test-count figures, and the counts belonged to neither side: the merged tree is 227 unit files / 2911 cases, measured here. Lean gate green (51.65 s lane, 135 s total).

Two hunks were a real choice. Tier 1's slowest per-edit selection took main's rows — it re-measured on 2026-10-23 and explains why the config-importing spec dominates, superseding this branch's older 8.0 s importGraph figure. The tests/PERF.md session table kept both sides' rows, renumbered, as that file asks.

main added no migration, so the newest-by-timestamp snapshot is still this branch's 20261024_161437 and the chain stays healed. The body's Test results line predates this merge.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Three Markdown conflicts, all the same figures both sides re-pinned.
`main` re-measured the warm lean gate at 112 s on 2026-10-25, so that
row supersedes this branch's 103 s. The session table keeps both sides'
rows — this branch's sixteenth and `main`'s own 227 / 2909 from #1034.

The counts belonged to neither side: #1034 adds a unit spec, so the
merged tree carries 228 files and 2918 cases, measured here inside the
gate. `perf-figures-pinned.spec.ts` is what refuses the stale pair, and
why the four consumer docs move with it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QLYiYBabKtcYdEPm1qE81C
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged main (6f5dc82). Three conflicts, all Markdown, all the same measurement figures.

Lean gate green on the merge: lint, format, typecheck, typecheck:tests, 228 files / 2918 cases, 120 s.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

refactor(jobs): one nightly retention sweep over a collection registry

3 participants