Skip to content

Add the Cron section and move notifications-cleanup to it - #2882

Merged
peterdrier merged 4 commits into
mainfrom
claude/project-thread-55zekn
Dec 2, 2026
Merged

peterdrier merged 4 commits into
mainfrom
claude/project-thread-55zekn

Conversation

@peterdrier

Copy link
Copy Markdown
Owner

Requested by Peter · project thread

What

First step of replacing Hangfire: a new Humans.Cron section runs scheduled jobs, keeps 90 days of runs, and shows them at /Cron. It runs two jobs: notifications-cleanup (moved from Hangfire) and its own cron-runs-prune. Hangfire keeps the other 33 and skips the moved ids.

Why

Hangfire owns tables nobody owns, takes database locks on a single server, and makes 19 projects reference it for one attribute. Peter chose a staged move: build Cron, move one job, prove it, then move the rest in batches; the last PR deletes Hangfire.

Existing surface checked

  • Reuses ISectionJobs / RecurringJobDescriptor / IRecurringJob as they are; no change to how sections contribute jobs.
  • New in Base: CronJobIds (the moved ids), temporary, deleted with Hangfire.
  • New package: Cronos 0.13.0 (MIT) for cron parsing; About page updated.
  • Page uses <page-header>, _StatTile, _Table, <status-badge>.

UI changes / screenshots

/Cron (job list, Run now for Admin, Hangfire jobs folded away) and /Cron/{id} (recent runs). Looked at locally on desktop and phone.

Checklist

  • Review tier: tier:standard.
  • No migration edited by hand: InitialCronSection from dotnet ef migrations add.
  • No NOT NULL column added to an existing table new table only.
  • Section labeled
  • Targeting main on peterdrier/Humans
  • Branched off origin/main
  • Issue refs are qualified
  • NuGet packages updated: Cronos added to About.
  • New project rule? none.
  • Reuse-first checked
  • Build + test pass locally (full suite)
  • Nav coverage: admin nav "Cron".
  • No magic strings
  • Dates/times via NodaTime, icons via Font Awesome 6.

Reviewer notes

  • One run per job at a time, held in process (one server). A scheduled tick that finds its job busy is recorded as Skipped.
  • A job that fell due while the app was down runs once at start-up, as Hangfire does today. A job that never ran waits for its schedule.
  • A run left as Running at start-up is marked Interrupted. Shutdown waits for runs in flight.
  • Only the exception type name is stored; messages can carry emails.
  • Test hosts set Cron:SchedulerEnabled=false.
  • Pending Peter's pick: whether a failed run is retried soon. Today it waits for its next schedule and shows red.

Closes

Part of #2807 (not closed: more batches follow).


Generated by Claude Code

First step of replacing Hangfire (#2807): a Cron section
runs the jobs listed in CronJobIds on their cron schedules, keeps 90 days
of runs in cron_runs, and shows them at /Cron. Hangfire keeps every other
job and skips the moved ids.

- One run per job at a time (in-process lock); a busy tick is recorded
  as skipped. A job that fell due while the app was down runs once at
  start-up. Runs in flight are waited for on shutdown.
- notifications-cleanup moves over; its Hangfire attribute, metric call
  and wrapper tests go.
- cron-runs-prune deletes runs older than 90 days.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0186neA4aUHmCsNPH217ApRk
@peterdrier peterdrier self-assigned this Dec 2, 2026
@peterdrier

Copy link
Copy Markdown
Owner Author

@codex review


Generated by Claude Code

@github-actions github-actions Bot added db PR includes EF Core migration auto-merge: no Trial: what the agent would let merge itself (labels only) labels Dec 2, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T21:54:42.121022Z 69019c3 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

{
var (resolvedDeleted, staleDeleted, retiredDeleted) =
await notifications.PurgeExpiredAsync(cancellationToken);
var (resolvedDeleted, staleDeleted, retiredDeleted) = await notifications.PurgeExpiredAsync(cancellationToken);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARN — humans.job_runs_total loses its cleanup_notifications series

Ref: AGENTS.md "The Board can see what happened" / "Hit every surface".

This PR removes metrics.RecordJobRun("cleanup_notifications", "success"|"failure") and its tests, and nothing replaces it: CronRunner.ExecuteAsync never calls IHumansMetrics. Any dashboard or alert built on humans.job_runs_total for this job will just go quiet, and a failure will look the same as no data. Every job moved to Cron later will lose its metric the same way.

Fix: inject IHumansMetrics into CronRunner and call RecordJobRun(job.Id, "success"/"failure") in ExecuteAsync, so each Cron job gets the metric for free. Add a CronRunnerTests case for it. Or, if this metric is being retired on purpose, say so in the PR.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Retired on purpose: Peter decided no job-run metrics, and #2881 deletes the humans.job_runs_total counter. Cron's run history on /Cron (90 days, failures in red) is what shows a job's outcome now. No change.


Generated by Claude Code

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Reviewed commit 69019c3. 2 inline finding(s) posted.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 69019c3e36

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

PR Surface Report

Compared 5c9d601d...406bc62b. Scored with reforge 0.34.0.

Summary: 44 changed file(s) | EF migrations: 1 added file(s), max 1/1 per context

Reforge Surface Score

metric base head delta
total 77726 77865 +139
surface 17529 17568 +39

Section Deltas

section base head delta
Cron 0 208 +208
Email 864 858 -6
Holded 1551 1545 -6
Web 2421 2427 +6
Notifications 425 420 -5
Agent 1327 1324 -3
Backdoor 1282 1279 -3
Budget 1048 1045 -3
Consent 1222 1219 -3
Expenses 1994 1991 -3
Finance 5227 5224 -3
Google 4285 4282 -3
Governance 3764 3761 -3
Issues 832 829 -3
MailerLite 961 958 -3
Monitor 201 198 -3
Pleo 446 443 -3
Preapprovals 735 732 -3
Settings 390 387 -3
Stripe 665 662 -3
Surveys 2558 2555 -3
Teams 3616 3613 -3
Tickets 7552 7549 -3
Users 4458 4455 -3
Workgroups 1953 1950 -3
Base 4898 4900 +2

Section Size & Complexity Deltas

section LOC delta files delta classes delta cognitive p95 delta
Base +11 +1 +1 0
Cron +656 +17 +21 +4
Notifications -19 0 0 0
Web +6 0 0 0
Corpus +654 +18 +22 0

Corpus is the solution-wide rollup (same source as Corpus Size & Complexity below), not a sum of the section rows above - cognitive p95 in particular doesn't compose across sections.

Rule Deltas

rule base head delta
methodCount 19497 19548 +51
methodComplexity 22326 22373 +47
crossSectionReadInterface 4506 4518 +12
exportedWriteMethod 2460 2472 +12
internalWiderThanUse 942 950 +8
projectReference 1865 1870 +5
exportedUnusedExternally 782 784 +2
sectionSize 9805 9807 +2

Corpus Size & Complexity

metric base head delta
locProd 202694 203348 +654
methods 9092 9142 +50
classes 3663 3685 +22
files 2560 2578 +18
interfaces 376 378 +2

At head: largest class Service, most complex method Service.BookOneTransferAsync.

Published Write Surface

15 of 58 sections publish write capability, 47 interfaces (0).

Interface Surface

No new interfaces or interface members.

Diff Size

bucket added deleted
code 998 36
migrations 187 0
tests 228 63
docs 117 4
other 2 0

New Files

  • src/Humans.Base/Interfaces/CronJobIds.cs
  • src/Sections/Humans.Cron/Controllers/CronController.cs
  • src/Sections/Humans.Cron/CronAuditActions.cs
  • src/Sections/Humans.Cron/Data/Configurations/CronRunConfiguration.cs
  • src/Sections/Humans.Cron/Data/CronDbContext.cs
  • src/Sections/Humans.Cron/Data/CronDbContextFactory.cs
  • src/Sections/Humans.Cron/Data/ICronRepository.cs
  • src/Sections/Humans.Cron/Data/Migrations/20261202213401_InitialCronSection.Designer.cs
  • src/Sections/Humans.Cron/Data/Migrations/20261202213401_InitialCronSection.cs
  • src/Sections/Humans.Cron/Data/Migrations/CronDbContextModelSnapshot.cs
  • src/Sections/Humans.Cron/Data/Repository.cs
  • src/Sections/Humans.Cron/Docs/Cron.md
  • src/Sections/Humans.Cron/Docs/authorization.md
  • src/Sections/Humans.Cron/Docs/data-access.md
  • src/Sections/Humans.Cron/Domain/CronRun.cs
  • src/Sections/Humans.Cron/Humans.Cron.csproj
  • src/Sections/Humans.Cron/Jobs/CronRunsPruneJob.cs
  • src/Sections/Humans.Cron/Models/CronModels.cs
  • src/Sections/Humans.Cron/Properties/AssemblyInfo.cs
  • src/Sections/Humans.Cron/Section.cs
  • src/Sections/Humans.Cron/Services/CronHealthCheck.cs
  • src/Sections/Humans.Cron/Services/CronJobs.cs
  • src/Sections/Humans.Cron/Services/CronRunner.cs
  • src/Sections/Humans.Cron/Services/CronScheduler.cs
  • src/Sections/Humans.Cron/Services/CronService.cs
  • ... 8 more

EF Migrations (OK)

  • src/Sections/Humans.Cron/Data/Migrations/20261202213401_InitialCronSection.cs

Run now can start a job that deletes members' data, so the service
writes a CronJobRunByHand audit entry naming the admin and the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0186neA4aUHmCsNPH217ApRk
A due time that fell while Cron started could be missed by both the
catch-up and the first schedule pass. Run now buttons no longer use a
C# boolean attribute; the server already says when a job is running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0186neA4aUHmCsNPH217ApRk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0186neA4aUHmCsNPH217ApRk
@peterdrier
peterdrier merged commit 28f0f28 into main Dec 2, 2026
17 checks passed
@peterdrier
peterdrier deleted the claude/project-thread-55zekn branch December 2, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge: no Trial: what the agent would let merge itself (labels only) db PR includes EF Core migration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants