Scheduling Engine Spec

Weekly Temporal Scheduling & Overlap Scoring

Matching skills or hardware capacity is only half the battle in a decentralized barter network. Peers across London, Tokyo, and San Francisco must also find compatible hours to coordinate handoffs, review deliverables, or run live pairing sessions. NodeHash maps all recurring availability into a normalized weekly timeline in Coordinated Universal Time (UTC), making cross-border schedule matching fast and deterministic.

⏱️
The 10,080-Minute Weekly Interval Model

NodeHash tracks recurring weekly availability across 10,080 discrete minute intervals, calculated as 7 days × 24 hours × 60 minutes. Every week starts at index 0 on Sunday 00:00 UTC and terminates at index 10,079 on Saturday 23:59 UTC. This fixed integer coordinate system simplifies complex calendar lookups into lightweight numeric range intersections.

The 10,080-Minute Coordinate System

Instead of synchronizing bulky calendar feeds or querying external time services during matching, NodeHash projects each peer's working windows into integer minute offsets within a single standardized week:

Day Index Calendar Day UTC Minute Range Duration (Minutes)
0 Sunday 00000 to 01439 1,440
1 Monday 01440 to 02879 1,440
2 Tuesday 02880 to 04319 1,440
3 Wednesday 04320 to 05759 1,440
4 Thursday 05760 to 07199 1,440
5 Friday 07200 to 08639 1,440
6 Saturday 08640 to 10079 1,440

This numeric mapping gives the matching engine three distinct performance benefits:

  • Constant-Time Translation: Converting local times to UTC requires only basic integer multiplication and modulo arithmetic.
  • Compact Storage: A user's entire weekly schedule compresses down to an array of four-byte integer pairs.
  • Fast Intersections: Finding shared free time between candidates runs in linear time using a two-pointer sweep algorithm.

Timezone Normalization & Daylight Saving Adjustments

Because users live in different parts of the world, they submit their recurring availability using their local wall-clock time and IANA timezone name (for instance, America/New_York or Asia/Tokyo). The node engine converts each local window into normalized UTC intervals before candidate scoring.

Local to UTC Conversion Formula

Local minutes from the start of the week are calculated as:

localStart = (day * 1440) + (hours * 60) + minutes

Subtracting the local timezone offset yields the UTC equivalent:

utcStart = localStart - tzOffsetMinutes

The result is normalized with modulo 10,080:

normStart = ((utcStart % 10080) + 10080) % 10080

Weekly Boundary Wrapping

When a local window extends past midnight on Saturday, or when a negative timezone offset pushes a Sunday morning window backward, the interval wraps across the weekly boundary.

The engine detects if normEnd > 10080 and splits the span into two disjoint UTC intervals:

  • [normStart, 10080): Covers Saturday evening.
  • [0, normEnd - 10080): Covers Sunday morning.

Handling Daylight Saving Transitions

Hardcoding static offsets like UTC-5 or UTC+1 causes schedule desynchronization whenever daylight saving time begins or ends. To prevent missed handoffs, NodeHash evaluates timezone offsets dynamically.

When a matching loop is calculated, the system runs Intl.DateTimeFormat with the user's declared IANA timezone against the active timestamp. This inspects standard time and daylight saving time transitions on the fly, calculating the exact current offset in minutes without requiring manual profile updates.

🌐
Avoid Fixed Offset Strings

Always supply an official IANA identifier such as Europe/Berlin rather than ambiguous abbreviations like CET or fixed offsets like +01:00. IANA names let the matching engine automatically adjust your UTC schedule when regional clocks shift.

Setting Recurring Working Windows

You can define recurring availability on both your global profile and individual supply items. The JSON schema requires your IANA timezone identifier and an array of recurring windows:

Temporal Availability Schema (JSON)
{
  "time_zone": "America/Los_Angeles",
  "available_time_windows": [
    {
      "day_of_week": 1,
      "start_time": "09:00",
      "end_time": "17:00",
      "is_negotiable": false
    },
    {
      "day_of_week": 3,
      "start_time": "10:00",
      "end_time": "18:00",
      "is_negotiable": true
    },
    {
      "day_of_week": 5,
      "start_time": "13:00",
      "end_time": "16:00",
      "is_negotiable": true
    }
  ]
}

Each window object contains four essential properties:

  • day_of_week (Integer, 0 to 6): Specifies the calendar day, where 0 represents Sunday and 6 represents Saturday.
  • start_time (String, HH:MM): The beginning of your active window in 24-hour local wall-clock format.
  • end_time (String, HH:MM): The end of your active window. If earlier than start time, the window spans across local midnight.
  • is_negotiable (Boolean): Flags whether you are willing to shift this window during term negotiation. Setting this to true grants a scoring bonus during candidate matching.

Profile Update Command

Submit your availability to your node endpoint with a standard authenticated request:

cURL Command
curl -X PATCH https://api.nodehash.org/api/v1/users/profile \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "temporal": {
      "time_zone": "Europe/London",
      "available_time_windows": [
        {
          "day_of_week": 2,
          "start_time": "14:00",
          "end_time": "18:00",
          "is_negotiable": true
        }
      ]
    }
  }'

Overlap Scoring Mechanics

When scoring potential barter matches, the engine calculates mutual overlap between candidate schedules. The baseline threshold for full schedule compatibility is 5 hours (300 minutes).

Scoring Formula

The engine computes a base score proportional to shared free minutes:

baseScore = min(1.0, overlapMinutes / 300)

If any intersecting interval includes a window marked negotiable, the algorithm applies a flexibility bonus:

bonus = hasNegotiable ? 0.10 : 0.0

The final score is clamped to 1.0:

overlapScore = min(1.0, baseScore + bonus)

Why 5 Hours?

Five hours per week provides ample bandwidth for asynchronous coordination, status updates, and live troubleshooting.

Barter arrangements rarely require 40 hours of simultaneous real-time presence.

Setting the cap at 300 minutes rewards peers with sufficient overlap without penalizing individuals who work odd shifts or live across distant longitudes.

Overlap Duration Negotiable Flag Base Score Bonus Applied Final Overlap Score
0 minutes False 0.0000 0.0000 0.0000
60 minutes False 0.2000 0.0000 0.2000
150 minutes False 0.5000 0.0000 0.5000
150 minutes True 0.5000 +0.1000 0.6000
300 minutes False 1.0000 0.0000 1.0000
300+ minutes True 1.0000 +0.1000 1.0000 (Clamped)

Multi-Party Schedule Intersections (K ≤ 3)

In bilateral trades ($K = 2$), checking availability involves just one pair of schedules. In trilateral cycles ($K = 3$), all three peers must find a mutually compatible schedule window or agree to asynchronous delivery.

The matching engine evaluates multi-party intersections iteratively using a sweep-line algorithm:

  1. Sort & Merge: All individual windows for each peer are converted to UTC and merged to eliminate internal overlaps.
  2. Pairwise Sweep: The engine takes Participant A and Participant B, scanning sorted intervals with two pointers to compute their shared intersection set $I_{A,B}$.
  3. Sequential Pruning: If $I_{A,B}$ is empty, the cycle temporal score immediately drops to zero. The engine avoids wasting clock cycles on third-party calculations.
  4. Trilateral Intersection: If $I_{A,B}$ contains valid intervals, the engine intersects $I_{A,B}$ with Participant C's intervals to generate the final trilateral intersection $I_{A,B,C}$.
  5. Slot Formatting: The resulting UTC intervals are partitioned back into calendar days and converted to standard 24-hour strings for user presentation.
Intersect Evaluation Response (JSON)
{
  "success": true,
  "data": {
    "overlapMinutes": 240,
    "overlapScore": 0.9000,
    "commonSlots": [
      {
        "day_of_week": 2,
        "start_time": "14:00",
        "end_time": "16:00"
      },
      {
        "day_of_week": 4,
        "start_time": "14:00",
        "end_time": "16:00"
      }
    ]
  }
}

Once peers discover candidate matches with favorable temporal scores, they move into term negotiation to finalize milestones and schedule commitments.