Skip to content

Build a deterministic time-window eligibility engine for GuildPass rules #380

Description

@Lakes41

Difficulty: Advanced
Type: Feature
Recommended labels (if available in this repo): policy, backend, consistency, advanced

Background

GuildPass rules may need to apply only during defined time windows, for example temporary access grants, campaign eligibility, governance periods or reward qualification windows.

This issue introduces a generic time-window evaluator that remains independent of any particular GuildPass domain feature.

Problem

Time-based rules are easy to implement inconsistently. Boundary inclusivity, timezone handling and overlapping intervals can produce different results across modules if there is no common primitive.

Expected Outcome

Implement a pure time-window engine that evaluates whether an instant falls inside one or more configured windows using explicit and deterministic boundary semantics.

Suggested Implementation

A window may resemble:

interface TimeWindow {
  startsAt: Date;
  endsAt: Date;
  startInclusive: boolean;
  endInclusive: boolean;
}

The engine should:

  • validate that start is not after end;
  • support explicit inclusive or exclusive boundaries;
  • evaluate a timestamp against a single window;
  • evaluate against multiple windows using any and all semantics where useful;
  • normalise comparisons to UTC instants rather than local timezone strings;
  • optionally merge overlapping windows through a separate pure helper;
  • reject invalid dates;
  • accept an injectable clock for current-time evaluation;
  • avoid real-time sleeps in tests;
  • remain free of database and API dependencies.

Acceptance Criteria

  • Inclusive and exclusive start boundaries are tested.
  • Inclusive and exclusive end boundaries are tested.
  • Instants inside a window evaluate correctly.
  • Instants outside a window evaluate correctly.
  • Invalid reversed windows are rejected.
  • Invalid dates are rejected safely.
  • UTC-equivalent instants evaluate identically regardless of source timezone representation.
  • Multiple-window semantics are deterministic and documented.
  • Tests cover exact boundary timestamps.
  • Current-time evaluation can use an injected clock.
  • pnpm typecheck passes.
  • pnpm build passes.
  • pnpm test passes.
  • No membership, reward, governance or persistence integration is included.

Likely Affected Files/Directories

packages/time-window/ or equivalent isolated package
unit tests

Independence Requirement

This issue must remain a generic rule-evaluation primitive and must not depend on another policy or domain issue.

Activity

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

Metadata

Metadata

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesThird CampaignOfficial FWC26 campaign issue — eligible for campaign scoring and rewardsadvancedAdvanced difficulty tasks requiring significant domain knowledge and implementation effortbackendBackend services, application logic, persistence integration, and server-side functionalityconsistencyPattern and convention standardization across the codebase for uniformitypolicyPolicy definition, evaluation, rule engines, and deterministic access decision logic

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions