Skip to content

fix(coven): check occurrence-history order by instant, not text - #332

Merged
BunsDev merged 1 commit into
mainfrom
fix/coven-history-instant-order
Sep 27, 2026
Merged

BunsDev merged 1 commit into
mainfrom
fix/coven-history-instant-order

Conversation

@BunsDev

@BunsDev BunsDev commented Sep 27, 2026

Copy link
Copy Markdown
Member

Follow-up to #331, part of #80.

Copilot found on OpenCoven/coven#1158 that manual occurrences store nanosecond RFC 3339 and scheduled ones millisecond. Raw text order therefore misplaces rows within one millisecond: .123Z sorts above .123100000Z. The producer now orders and pages by the instant, padding the fraction to nine digits and breaking equal instants by id.

#331's newest-first check compared raw scheduledFor bytes, so it would refuse those correct mixed pages. This PR compares the same key the producer's SQL builds, character for character, with id still breaking equal instants.

Verification

  • pnpm verify passed (3034 tests, lint, coverage, stress, contracts, package).
  • The new test covers ms vs ns within one millisecond, an equal-instant pair ordered by id, and a whole-second value, and checks that the reversed pairs are refused.
  • Mutation check: restoring the raw byte comparison fails it.
  • The API surface is unchanged (the helper is private), so no baseline change.

🤖 Generated with Claude Code

Scheduled occurrences store millisecond and manual ones nanosecond
RFC 3339, so byte order refused valid mixed pages. Compare the producer's
sort key (fraction padded to nine digits) instead, with id breaking equal
instants, matching OpenCoven/coven#1158.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 27, 2026 11:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

All reviewed changes are covered by tests and no unresolved blocking issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Updates occurrence-history validation to match producer ordering by normalized timestamp instant, with id tie-breaking.

Changes:

  • Normalize timestamp fractions to nanoseconds.
  • Add regression coverage for mixed precision and equal instants.
  • Update documentation and release changeset.
File Description
tests/​coven-automations.spec.ts Tests corrected ordering behavior.
packages/​coven/​src/​automations-occurrences.ts Implements normalized instant ordering.
packages/​coven/​README.md Documents instant-based ordering.
.changeset/​coven-history-instant-order.md Records the patch release.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@BunsDev
BunsDev merged commit 3ad9290 into main Sep 27, 2026
9 checks passed
@BunsDev
BunsDev deleted the fix/coven-history-instant-order branch September 27, 2026 11:15
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