Skip to content

fix(events): eager-deploy EndDate must be end-of-rotation-day, not midnight#815

Merged
renemadsen merged 2 commits into
stablefrom
fix/eager-deploy-enddate-end-of-day
May 14, 2026
Merged

fix(events): eager-deploy EndDate must be end-of-rotation-day, not midnight#815
renemadsen merged 2 commits into
stablefrom
fix/eager-deploy-enddate-end-of-day

Conversation

@renemadsen
Copy link
Copy Markdown
Member

Summary

Companion fix to PR #813 (eager-deploy of future events). When EnsureDeployedAsync ran on a TODAY rotation, the SDK case was never created because of a stale mainElement.EndDate value:

  • mainElement.EndDate = rotationDate (parsed as midnight UTC)
  • Downstream guard: if (mainElement.EndDate > DateTime.UtcNow) skips CaseCreate
  • Today's deploy fires after 00:00 UTC → guard fails → _sdkCore.CaseCreate is silently skipped
  • Compliance row written anyway with MicrotingSdkCaseId=0 (from the unmodified planningCaseSite.MicrotingSdkCaseId)
  • Result: UploadPhoto / CompleteEvent for these rotations fail with FailedPrecondition

Fix: use rotationDate.AddDays(1).AddTicks(-1) (end-of-rotation-day UTC) so the guard passes any time the deploy fires within the rotation day.

Why this slipped past PR #814's tests

PR #814's 5 tests covered: empty window, past rotation, IsFromCompliance filter, idempotence guard, cancellation. None drove a today rotation through to the EndDate guard, because doing so cleanly requires the full Planning+AreaRulePlanning+Area+Property+eForm graph that we deferred (the SKIPPED tests #5/#6/#8 in the test file).

Regression test included

EnsureDeployedAsync_TodayRotation_AdmittedByCandidateFilter — pins that today's rotation is admitted by the candidate filter at line 131 (rotationDate >= todayUtc). A future refactor that accidentally narrowed this to > todayUtc would silently exclude today's rotations again. The test comment is honest about what it does and doesn't cover (doesn't directly exercise the EndDate guard — that needs the full graph).

Verification

  • Pre-push dual-subagent gate (code-reviewer + code-simplifier).
  • Code-reviewer initially flagged the test name oversold its scope; consolidation commit 7031c567 renamed to be honest about what's pinned vs deferred.
  • dotnet build clean (0 errors).

Also worth knowing: two existing Compliance rows in the local DB (420_eform-backend-configuration-plugin.Compliances IDs 10219 + 10222) have MicrotingSdkCaseId=0 from before the fix. They need to be soft-deleted (WorkflowState='Removed') so the next eager deploy creates them properly. That's a runtime data-cleanup task, not part of this code change.

🤖 Generated with Claude Code

renemadsen and others added 2 commits May 14, 2026 16:45
mainElement.EndDate was set to rotationDate (00:00 UTC). The downstream
guard `if (mainElement.EndDate > DateTime.UtcNow)` then silently skipped
_sdkCore.CaseCreate for any today-rotation deploy that ran after 00:00 UTC,
leaving Compliance rows with MicrotingSdkCaseId=0. Now uses
rotationDate.AddDays(1).AddTicks(-1) so the SDK case is created on any
same-day deploy. Adds a regression test that pins the contract.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Rename today-rotation test to AdmittedByCandidateFilter; previous
  name oversold a tautology (the assertion fires at planning-lookup,
  not at the EndDate guard the fix touched).
- Update stale comment at EventDeployService.cs:325-328 — the new
  end-of-day EndDate value satisfies the guard; the candidate filter
  is no longer the mechanism.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 14, 2026 14:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Companion fix to PR #813. The eager-deploy path set mainElement.EndDate = rotationDate (midnight UTC), so the downstream guard if (mainElement.EndDate > DateTime.UtcNow) skipped CaseCreate for any same-day deploy fired after 00:00 UTC, leaving Compliance rows with MicrotingSdkCaseId=0. The fix shifts EndDate to end-of-rotation-day UTC so the guard passes throughout the rotation day, and adds a regression test pinning that today's rotations are admitted by the candidate filter.

Changes:

  • Set mainElement.EndDate = rotationDate.AddDays(1).AddTicks(-1) and update surrounding comments to document the rationale.
  • Add integration test EnsureDeployedAsync_TodayRotation_AdmittedByCandidateFilter that verifies a today-dated rotation reaches the planning-lookup step.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Services/EventDeployService/EventDeployService.cs Use end-of-rotation-day UTC for mainElement.EndDate so the same-day deploy guard passes.
eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn.Integration.Test/EventDeployServiceTest.cs Adds regression test pinning that the candidate filter admits today's rotation.

@renemadsen renemadsen merged commit d2e064e into stable May 14, 2026
21 checks passed
@renemadsen renemadsen deleted the fix/eager-deploy-enddate-end-of-day branch May 14, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants