neighbor_rota

Explainable community care and volunteer scheduling engine

scheduling
rostering
community-care
constraint-solving
explainable
moon add zjk9993/neighbor_rota@0.1.0
Download zip
Author
Version
0.1.0
License
Apache-2.0
Last updated
4 days ago
Downloads
2
README

#NeighborRota

NeighborRota is an explainable community-care and volunteer scheduling engine implemented in MoonBit. It validates CSV or MoonBit-native inputs, evaluates skills, time windows, workloads, breaks and travel, constructs a deterministic schedule, explains infeasible visits and reschedules after operational events.

let request = @neighbor_rota.demo_request(@neighbor_rota.CommunityCare)
let schedule = @neighbor_rota.solve(request)
println(@neighbor_rota.schedule_summary(schedule))

The package includes a reusable API, native CLI, Wasm-GC build, 109 automated tests and three fictional demonstration scenarios. It is planning software only; it does not provide medical advice, employee monitoring, real-time tracking or automated operational control.

License: Apache-2.0.

#
Assignment

pub(all) struct Assignment {
visit_id : String
worker_id : String
start_minute : Int
end_minute : Int
travel_before_minutes : Int
score : Int
reasons : Array[String]
} derive(Eq,
Debug
)

One fixed assignment in a schedule.

#
AssignmentChange

pub(all) enum AssignmentChange {
Added(assignment~ : Assignment)
Removed(assignment~ : Assignment)
Reassigned(before~ : Assignment, after~ : Assignment)
Retimed(before~ : Assignment, after~ : Assignment)
ReassignedAndRetimed(before~ : Assignment, after~ : Assignment)
Unchanged(assignment~ : Assignment)
} derive(Eq,
Debug
)

One assignment-level difference between two schedules.

#
Candidate

pub(all) struct Candidate {
worker_id : String
visit_id : String
start_minute : Int
end_minute : Int
travel_before_minutes : Int
raw_score : Int
reasons : Array[String]
} derive(Eq,
Debug
)

One feasible placement before it becomes an assignment.

#
Candidate::to_assignment

fn Candidate::to_assignment(self : Candidate) -> Assignment

Convert one candidate to the public assignment representation.

#
CandidateSearch

pub(all) struct CandidateSearch {
candidates : Array[Candidate]
rejected : Array[FeasibilityResult]
} derive(Eq,
Debug
)

Candidate search result retains rejected evaluations for diagnostics.

#
ConstraintCode

pub(all) enum ConstraintCode {
WorkerUnavailable
WorkerForbidden
MissingSkill
OutsideAvailability
TimeConflict
InsufficientTravelBefore
InsufficientTravelAfter
BreakViolation
MaxMinutesExceeded
MaxVisitsExceeded
VisitWindowViolation
} derive(Eq,
Debug
)

Stable codes emitted when a worker cannot take one candidate visit.

#
ConstraintFailure

pub(all) struct ConstraintFailure {
code : ConstraintCode
message : String
worker_id : String
visit_id : String
} derive(Eq,
Debug
)

One failed hard constraint with a human explanation.

#
CsvDocument

pub(all) struct CsvDocument {
rows : Array[CsvRow]
diagnostics : Array[Diagnostic]
} derive(Eq,
Debug
)

Parsed CSV document with non-fatal syntax diagnostics.

#
CsvRow

pub(all) struct CsvRow {
line : Int
fields : Array[String]
} derive(Eq,
Debug
)

One lexical CSV row before domain conversion.

#
DemoScenario

pub(all) enum DemoScenario {
CommunityCare
CampusVolunteers
SuddenAbsence
} derive(Eq,
Debug
)

Named demonstration scenarios distributed with the package.

#
Diagnostic

pub(all) struct Diagnostic {
level : DiagnosticLevel
code : String
message : String
entity_id : String?
field : String?
} derive(Eq,
Debug
)

A validation or solver diagnostic suitable for machine processing.

#
Diagnostic::at_field

fn Diagnostic::at_field(self : Diagnostic, field : String) -> Diagnostic

Attach an input field name to a diagnostic.

#
Diagnostic::for_entity

fn Diagnostic::for_entity(self : Diagnostic, id : String) -> Diagnostic

Attach a domain entity identifier to a diagnostic.

#
DiagnosticLevel

pub(all) enum DiagnosticLevel {
Info
Warning
Error
} derive(Eq,
Debug
)

Severity attached to a stable diagnostic code.

#
FeasibilityResult

pub(all) struct FeasibilityResult {
feasible : Bool
failures : Array[ConstraintFailure]
travel_before_minutes : Int
travel_after_minutes : Int
} derive(Eq,
Debug
)

Complete feasibility result for one candidate placement.

#
Location

pub(all) struct Location {
id : String
x : Int
y : Int
zone : String
} derive(Eq,
Debug
)

Integer coordinates used for deterministic travel estimates.

#
Priority

pub(all) enum Priority {
Low
Normal
High
Critical
} derive(Eq,
Debug
)

Service urgency. Higher values receive stronger scheduling preference.

#
ReasonCount

pub(all) struct ReasonCount {
code : String
count : Int
} derive(Eq,
Debug
)

Frequency of one stable unassigned reason code.

#
RescheduleReport

pub(all) struct RescheduleReport {
baseline : Schedule
updated : Schedule
events : Array[ScheduleEvent]
changes : Array[AssignmentChange]
diagnostics : Array[Diagnostic]
changed_assignments : Int
preserved_assignments : Int
newly_unassigned : Int
score_change : Int
} derive(Eq,
Debug
)

Complete impact summary for an event-driven reschedule.

#
RotaEngine

pub(all) struct RotaEngine {
version : String
} derive(Eq,
Debug
)

Public stateless scheduling engine.

#
RotaEngine::solve

fn RotaEngine::solve(self : RotaEngine, request : ScheduleRequest) -> Schedule

Solve through the engine-style API used in the project application.

#
Schedule

pub(all) struct Schedule {
schema : String
assignments : Array[Assignment]
unassigned : Array[UnassignedVisit]
diagnostics : Array[Diagnostic]
score : ScheduleScore
feasible : Bool
} derive(Eq,
Debug
)

Complete auditable scheduling result.

#
ScheduleAnalytics

pub(all) struct ScheduleAnalytics {
total_visits : Int
required_visits : Int
assigned_visits : Int
assigned_required_visits : Int
optional_unassigned : Int
required_unassigned : Int
coverage_percent : Int
required_coverage_percent : Int
total_service_minutes : Int
total_travel_minutes : Int
travel_share_percent : Int
average_worker_utilization_percent : Int
busiest_worker_id : String?
busiest_worker_minutes : Int
zones_served : Array[String]
reason_counts : Array[ReasonCount]
} derive(Eq,
Debug
)

Aggregate acceptance metrics for one schedule and request.

#
ScheduleEvent

pub(all) enum ScheduleEvent {
WorkerAbsent(worker_id~ : String, from_minute~ : Int, to_minute~ : Int)
VisitCancelled(visit_id~ : String)
VisitDelayed(visit_id~ : String, delay_minutes~ : Int)
EmergencyVisit(visit~ : Visit)
WorkerCapacityChanged(worker_id~ : String, max_minutes~ : Int, max_visits~ : Int)
} derive(Eq,
Debug
)

Operational event applied after a baseline schedule has been published.

#
SchedulePolicy

pub(all) struct SchedulePolicy {
travel_minutes_per_unit : Int
cross_zone_penalty_minutes : Int
priority_weight : Int
preference_weight : Int
continuity_weight : Int
travel_weight : Int
fairness_weight : Int
disruption_weight : Int
allow_optional_unassigned : Bool
local_search_rounds : Int
} derive(Eq,
Debug
)

Policy weights and operational limits.

#
ScheduleRequest

pub(all) struct ScheduleRequest {
workers : Array[Worker]
visits : Array[Visit]
policy : SchedulePolicy
baseline : Schedule?
} derive(Eq,
Debug
)

All inputs required for a deterministic scheduling run.

#
ScheduleScore

pub(all) struct ScheduleScore {
total : Int
assigned_priority : Int
travel_penalty : Int
fairness_penalty : Int
continuity_bonus : Int
preference_bonus : Int
disruption_penalty : Int
} derive(Eq,
Debug
)

Aggregate dimensions used to compare schedules.

#
Skill

pub(all) struct Skill {
name : String
level : Int
} derive(Eq,
Debug
)

A capability that may be required by a service visit.

#
TimeWindow

pub(all) struct TimeWindow {
start_minute : Int
end_minute : Int
} derive(Eq,
Debug
)

A half-open minute range [start, end) within one planning horizon.

#
TimeWindow::contains

fn TimeWindow::contains(self : TimeWindow, other : TimeWindow) -> Bool

Whether this window fully contains another window.

#
TimeWindow::duration

fn TimeWindow::duration(self : TimeWindow) -> Int

Duration of the window in minutes. Invalid windows report zero here.

#
TimeWindow::latest_start

fn TimeWindow::latest_start(self : TimeWindow, duration : Int) -> Int

Clamp a requested start so a service duration remains inside the window.

#
TimeWindow::overlaps

fn TimeWindow::overlaps(self : TimeWindow, other : TimeWindow) -> Bool

Whether two half-open windows overlap.

#
TravelLeg

pub(all) struct TravelLeg {
worker_id : String
from_location_id : String
to_location_id : String
depart_minute : Int
arrive_minute : Int
travel_minutes : Int
cross_zone : Bool
} derive(Eq,
Debug
)

Travel leg retained for route explanations and reports.

#
UnassignedVisit

pub(all) struct UnassignedVisit {
visit_id : String
reason_codes : Array[String]
details : Array[String]
} derive(Eq,
Debug
)

A visit that could not be placed, with stable reason codes.

#
Visit

pub(all) struct Visit {
id : String
recipient_id : String
title : String
location : Location
window : TimeWindow
duration_minutes : Int
required_skills : Array[Skill]
priority : Priority
preferred_worker_ids : Array[String]
forbidden_worker_ids : Array[String]
continuity_group : String?
required : Bool
} derive(Eq,
Debug
)

A visit requested by a community service recipient.

#
Visit::forbids

fn Visit::forbids(self : Visit, worker_id : String) -> Bool

Whether a worker identifier is explicitly forbidden for this visit.

#
Visit::prefers

fn Visit::prefers(self : Visit, worker_id : String) -> Bool

Whether a worker identifier is explicitly preferred for this visit.

#
VisitBatch

pub(all) struct VisitBatch {
visits : Array[Visit]
diagnostics : Array[Diagnostic]
} derive(Eq,
Debug
)

Visit import result. Valid rows remain available when other rows fail.

#
Worker

pub(all) struct Worker {
id : String
display_name : String
kind : WorkerKind
skills : Array[Skill]
availability : Array[TimeWindow]
home : Location
max_minutes : Int
max_visits : Int
min_break_minutes : Int
preferred_zones : Array[String]
unavailable : Bool
} derive(Eq,
Debug
)

A person who may be assigned one or more visits.

#
Worker::has_skill

fn Worker::has_skill(self : Worker, required : Skill) -> Bool

Whether the worker has a required skill at the requested level.

#
Worker::is_available

fn Worker::is_available(self : Worker, interval : TimeWindow) -> Bool

Whether the worker is available for an entire interval.

#
Worker::skill_level

fn Worker::skill_level(self : Worker, name : String) -> Int

Return the worker's level for a named skill, or zero when absent.

#
WorkerBatch

pub(all) struct WorkerBatch {
workers : Array[Worker]
diagnostics : Array[Diagnostic]
} derive(Eq,
Debug
)

Worker import result. Valid rows remain available when other rows fail.

#
WorkerKind

pub(all) enum WorkerKind {
Volunteer
CareWorker
Coordinator
} derive(Eq,
Debug
)

Worker classifications are useful for reporting and policy decisions.

#
WorkerLoad

pub(all) struct WorkerLoad {
worker_id : String
visit_count : Int
service_minutes : Int
travel_minutes : Int
utilization_percent : Int
} derive(Eq,
Debug
)

Per-worker load retained for fairness reports.

#
SCHEMA_VERSION

let SCHEMA_VERSION : String

Semantic version of the public scheduling model.

#
abs_int

fn abs_int(value : Int) -> Int

Integer absolute value without relying on target-specific helpers.

#
all_worker_loads

fn all_worker_loads(workers : Array[Worker], assignments : Array[Assignment]) -> Array[WorkerLoad]

Compute loads for all workers in input order.

#
analytics_summary

fn analytics_summary(value : ScheduleAnalytics) -> String

Human-readable analytics for acceptance reports.

#
analyze_schedule

fn analyze_schedule(schedule : Schedule, request : ScheduleRequest) -> ScheduleAnalytics

Compute transparent acceptance metrics from a schedule.

#
apply_event

fn apply_event(request : ScheduleRequest, event : ScheduleEvent) -> ScheduleRequest

Apply one validated event to a request without mutating the caller.

#
apply_events

fn apply_events(request : ScheduleRequest, events : Array[ScheduleEvent]) -> (ScheduleRequest, Array[Diagnostic])

Apply events sequentially after validating them against evolving state.

#
assigned_minutes

fn assigned_minutes(assignments : Array[Assignment], worker_id : String) -> Int

Total assigned service time for a worker.

#
assigned_priority_units

fn assigned_priority_units(assignments : Array[Assignment], visits : Array[Visit]) -> Int

Weighted assigned priority across the schedule.

#
assigned_zones

fn assigned_zones(assignments : Array[Assignment], visits : Array[Visit]) -> Array[String]

List service zones represented by assigned visits.

#
assignment_before

fn assignment_before(left : Assignment, right : Assignment) -> Bool

Stable assignment comparison for serialized schedules.

#
assignment_change_name

fn assignment_change_name(change : AssignmentChange) -> String

Stable name for assignment change categories.

#
assignment_change_visit_id

fn assignment_change_visit_id(change : AssignmentChange) -> String

Visit id affected by one change.

#
assignment_location

fn assignment_location(assignment : Assignment, visits : Array[Visit]) -> Location?

Resolve the visit location for an assignment.

#
assignment_to_json

fn assignment_to_json(value : Assignment) -> String

Render one assignment as a stable JSON object.

#
assignments_for_worker

fn assignments_for_worker(assignments : Array[Assignment], worker_id : String) -> Array[Assignment]

Select all assignments belonging to a worker.

#
assignments_to_csv

fn assignments_to_csv(values : Array[Assignment]) -> String

Serialize assignment rows for spreadsheet analysis.

#
audit_schedule

fn audit_schedule(schedule : Schedule, request : ScheduleRequest) -> Array[Diagnostic]

Verify every assignment independently from the solver implementation.

#
average_utilization

fn average_utilization(loads : Array[WorkerLoad]) -> Int

Average worker utilization from existing normalized loads.

#
busiest_worker

fn busiest_worker(loads : Array[WorkerLoad]) -> (String?, Int)

Determine the busiest worker by service minutes with stable id tie-break.

#
candidate_reasons

fn candidate_reasons(worker : Worker, visit : Visit, feasibility : FeasibilityResult) -> Array[String]

Explanations attached to one accepted candidate.

#
candidate_score

fn candidate_score(worker : Worker, visit : Visit, start_minute : Int, feasibility : FeasibilityResult, assignments : Array[Assignment], policy : SchedulePolicy) -> Int

Soft score for one feasible candidate.

#
candidate_start_minutes

fn candidate_start_minutes(visit : Visit, step_minutes? : Int) -> Array[Int]

Generate deterministic candidate start points for a visit.

#
clamp_int

fn clamp_int(value : Int, lower : Int, upper : Int) -> Int

Clamp an integer to an inclusive range.

#
constraint_code_name

fn constraint_code_name(code : ConstraintCode) -> String

Stable machine name for constraint codes.

#
constraint_details

fn constraint_details(results : Array[FeasibilityResult]) -> Array[String]

Collect failure descriptions while preserving evaluation order.

#
continuity_units

fn continuity_units(assignments : Array[Assignment], visits : Array[Visit], workers : Array[Worker]) -> Int

Reward additional visits in a group assigned to the same worker.

#
copy_array

fn[T] copy_array(values : Array[T]) -> Array[T]

Copy an array while preserving order.

#
count_assigned_required

fn count_assigned_required(assignments : Array[Assignment], visits : Array[Visit]) -> Int

Count assigned visits that are required.

#
count_diagnostics

fn count_diagnostics(diagnostics : Array[Diagnostic], level : DiagnosticLevel) -> Int

Count diagnostics at one severity.

#
count_required_visits

fn count_required_visits(visits : Array[Visit]) -> Int

Count required visits in a request.

#
count_string

fn count_string(values : Array[String], target : String) -> Int

Count exact string matches.

#
count_unassigned_reasons

fn count_unassigned_reasons(unassigned : Array[UnassignedVisit]) -> Array[ReasonCount]

Aggregate unassigned reason codes into stable sorted counters.

#
default_policy

fn default_policy() -> SchedulePolicy

Balanced policy for the built-in demonstrations.

#
demo_request

fn demo_request(scenario : DemoScenario) -> ScheduleRequest

Build a complete request for a named scenario.

#
demo_scenario_name

fn demo_scenario_name(value : DemoScenario) -> String

Stable name for a demonstration scenario.

#
describe_assignment_change

fn describe_assignment_change(change : AssignmentChange) -> String

Concise human explanation of one schedule change.

#
describe_travel

fn describe_travel(from : Location, to : Location, policy : SchedulePolicy) -> String

Route description suitable for CLI and Markdown output.

#
diagnostic_level_name

fn diagnostic_level_name(level : DiagnosticLevel) -> String

Stable human-readable name for diagnostic levels.

#
diagnostics_have_errors

fn diagnostics_have_errors(diagnostics : Array[Diagnostic]) -> Bool

True when any diagnostic blocks scheduling.

#
diff_schedules

fn diff_schedules(baseline : Schedule, updated : Schedule) -> Array[AssignmentChange]

Compute assignment changes in stable visit-id order.

#
disruption_units

fn disruption_units(assignments : Array[Assignment], baseline : Schedule?) -> Int

Count assignments changed relative to an optional baseline schedule.

#
earliest_containing_start

fn earliest_containing_start(worker : Worker, interval : TimeWindow) -> Int?

Earliest start of an availability window that contains an interval.

#
error_diagnostic

fn error_diagnostic(code : String, message : String) -> Diagnostic

Build an error diagnostic.

#
evaluate_feasibility

fn evaluate_feasibility(worker : Worker, visit : Visit, start_minute : Int, assignments : Array[Assignment], visits : Array[Visit], policy : SchedulePolicy) -> FeasibilityResult

Evaluate a candidate against all hard constraints.

#
event_kind

fn event_kind(event : ScheduleEvent) -> String

Stable event kind used by logs and JSON reports.

#
fairness_deviation

fn fairness_deviation(loads : Array[WorkerLoad]) -> Int

Sum absolute deviations from the average assigned service time.

#
find_assignment

fn find_assignment(assignments : Array[Assignment], visit_id : String) -> Assignment?

Find an assignment for a visit.

#
find_visit

fn find_visit(visits : Array[Visit], id : String) -> Visit?

Find a visit by identifier.

#
find_worker

fn find_worker(workers : Array[Worker], id : String) -> Worker?

Find a worker by identifier.

#
improve_schedule

fn improve_schedule(schedule : Schedule, request : ScheduleRequest) -> Schedule

Improve a constructive schedule without sacrificing determinism.

#
info_diagnostic

fn info_diagnostic(code : String, message : String) -> Diagnostic

Build an informational diagnostic.

#
interval_conflicts

fn interval_conflicts(assignments : Array[Assignment], worker_id : String, interval : TimeWindow) -> Bool

Whether an interval overlaps any existing worker assignment.

#
location

fn location(id : String, x : Int, y : Int, zone : String) -> Location

Create a location in a named service zone.

#
location_distance

fn location_distance(left : Location, right : Location) -> Int

Manhattan distance is deterministic, integer-only and easy to audit.

#
max_int

fn max_int(left : Int, right : Int) -> Int

Return the larger integer.

#
min_int

fn min_int(left : Int, right : Int) -> Int

Return the smaller integer.

#
missing_skills

fn missing_skills(worker : Worker, visit : Visit) -> Array[Skill]

Check every required skill and retain all missing requirements.

#
new_rota_engine

fn new_rota_engine() -> RotaEngine

Construct the stable NeighborRota scheduling engine.

#
next_assignment

fn next_assignment(assignments : Array[Assignment], worker_id : String, end_minute : Int) -> Assignment?

Find the assignment immediately after a proposed end.

#
parse_availability

fn parse_availability(input : String, entity_id : String) -> (Array[TimeWindow], Array[Diagnostic])

Parse start-end|start-end availability declarations.

#
parse_csv_bool

fn parse_csv_bool(input : String) -> Bool?

Parse common CSV boolean spellings.

#
parse_csv_document

fn parse_csv_document(input : String) -> CsvDocument

Parse commas, quoted cells, doubled quotes and LF/CRLF line endings.

#
parse_csv_int

fn parse_csv_int(input : String) -> Int?

Parse a base-10 integer without accepting decimal or exponent notation.

#
parse_demo_scenario

fn parse_demo_scenario(name : String) -> DemoScenario?

Parse a scenario name accepted by the CLI.

#
parse_pipe_list

fn parse_pipe_list(input : String) -> Array[String]

Split a pipe-delimited list, trimming and discarding empty items.

#
parse_skills

fn parse_skills(input : String, entity_id : String) -> (Array[Skill], Array[Diagnostic])

Parse name:level|name:level skill declarations.

#
parse_visits_csv

fn parse_visits_csv(input : String) -> VisitBatch

Parse the documented visit CSV format.

#
parse_workers_csv

fn parse_workers_csv(input : String) -> WorkerBatch

Parse the documented worker CSV format.

#
preference_units

fn preference_units(assignments : Array[Assignment], visits : Array[Visit]) -> Int

Count assignments that satisfy explicit worker preferences.

#
previous_assignment

fn previous_assignment(assignments : Array[Assignment], worker_id : String, start_minute : Int) -> Assignment?

Find the assignment immediately before a proposed start.

#
previous_location

fn previous_location(worker : Worker, assignments : Array[Assignment], visits : Array[Visit], start_minute : Int) -> Location

Location occupied immediately before a proposed visit.

#
priority_name

fn priority_name(priority : Priority) -> String

Stable human-readable name for priority values.

#
priority_value

fn priority_value(priority : Priority) -> Int

Numeric priority used by deterministic ordering and scoring.

#
push_unique_string

fn push_unique_string(values : Array[String], value : String) -> Unit

Insert a string only when it is not already present.

#
replace_assignment

fn replace_assignment(assignments : Array[Assignment], replacement : Assignment) -> Array[Assignment]

Replace one assignment by visit id while preserving all others.

#
request_from_csv

fn request_from_csv(workers_csv : String, visits_csv : String) -> (ScheduleRequest, Array[Diagnostic])

Parse both input documents and construct a validated request.

#
reschedule

fn reschedule(baseline : Schedule, request : ScheduleRequest, events : Array[ScheduleEvent]) -> RescheduleReport

Re-solve after operational events while penalizing unnecessary changes.

#
reschedule_summary

fn reschedule_summary(report : RescheduleReport) -> String

Deterministic summary for logs and the CLI.

#
reschedule_to_markdown

fn reschedule_to_markdown(value : RescheduleReport) -> String

Markdown impact report for an event-driven update.

#
run_absence_demo

fn run_absence_demo() -> RescheduleReport

Run the absence demonstration and return its impact report.

#
run_demo

fn run_demo(scenario : DemoScenario) -> Schedule

Solve one built-in demonstration.

#
schedule_request

fn schedule_request(workers : Array[Worker], visits : Array[Visit]) -> ScheduleRequest

Create a request without a previous schedule.

#
schedule_summary

fn schedule_summary(value : Schedule) -> String

Compact terminal summary.

#
schedule_to_json

fn schedule_to_json(value : Schedule) -> String

Serialize a schedule for API consumers and reproducibility tests.

#
schedule_to_markdown

fn schedule_to_markdown(value : Schedule) -> String

Human-oriented Markdown report.

#
score_schedule

fn score_schedule(assignments : Array[Assignment], workers : Array[Worker], visits : Array[Visit], policy : SchedulePolicy, baseline : Schedule?) -> ScheduleScore

Build a transparent multi-dimensional schedule score.

#
score_summary

fn score_summary(value : ScheduleScore) -> String

Short deterministic score summary.

#
search_candidates

fn search_candidates(visit : Visit, workers : Array[Worker], assignments : Array[Assignment], visits : Array[Visit], policy : SchedulePolicy) -> CandidateSearch

Search every worker and start point for one visit.

#
skill

fn skill(name : String, level : Int) -> Skill

Create a named skill with a positive proficiency level.

#
solve

fn solve(request : ScheduleRequest) -> Schedule

Main scheduling function: validate, construct and locally improve.

#
solve_constructive

fn solve_constructive(request : ScheduleRequest) -> Schedule

Build a deterministic schedule with urgency-first constructive search.

#
sort_assignments_by_time

fn sort_assignments_by_time(values : Array[Assignment]) -> Array[Assignment]

Sort a worker's assignments by start minute and then visit id.

#
sort_candidates

fn sort_candidates(values : Array[Candidate]) -> Array[Candidate]

Sort by descending score with stable worker, start and visit tie breakers.

#
sort_schedule_assignments

fn sort_schedule_assignments(values : Array[Assignment]) -> Array[Assignment]

Sort schedule assignments for reproducible output.

#
sort_strings

fn sort_strings(values : Array[String]) -> Array[String]

Sort strings lexicographically without mutating the caller's array.

#
sort_visits_for_scheduling

fn sort_visits_for_scheduling(values : Array[Visit]) -> Array[Visit]

Stable urgency ordering used by the constructive solver.

#
string_array_contains

fn string_array_contains(values : Array[String], target : String) -> Bool

Whether a string occurs in an array.

#
subtract_window

fn subtract_window(available : TimeWindow, absent : TimeWindow) -> Array[TimeWindow]

Subtract an absence window from one availability window.

#
time_window

fn time_window(start_minute : Int, end_minute : Int) -> TimeWindow

Construct a time window without silently normalizing invalid values.

#
total_schedule_travel

fn total_schedule_travel(assignments : Array[Assignment]) -> Int

Total travel minutes represented by a schedule.

#
travel_before_candidate

fn travel_before_candidate(worker : Worker, visit : Visit, assignments : Array[Assignment], visits : Array[Visit], policy : SchedulePolicy, start_minute : Int) -> Int

Estimated travel before a proposed assignment.

#
travel_leg

fn travel_leg(worker_id : String, from : Location, to : Location, depart_minute : Int, policy : SchedulePolicy) -> TravelLeg

Construct a travel leg from a departure time.

#
travel_minutes

fn travel_minutes(left : Location, right : Location, policy : SchedulePolicy) -> Int

Estimated travel minutes between two locations under one policy.

#
unassigned_breakdown

fn unassigned_breakdown(unassigned : Array[UnassignedVisit], visits : Array[Visit]) -> (Int, Int)

Count required and optional unassigned visits separately.

#
unique_constraint_codes

fn unique_constraint_codes(results : Array[FeasibilityResult]) -> Array[String]

Collect unique failure codes from several rejected candidates.

#
validate_event

fn validate_event(event : ScheduleEvent, request : ScheduleRequest) -> Array[Diagnostic]

Validate one operational event against the current request.

#
validate_location

fn validate_location(value : Location) -> Array[Diagnostic]

Validate location identity and coordinate bounds.

#
validate_policy

fn validate_policy(value : SchedulePolicy) -> Array[Diagnostic]

Validate policy weights and search limits.

#
validate_request

fn validate_request(request : ScheduleRequest) -> Array[Diagnostic]

Validate a complete scheduling request before solving.

#
validate_skill

fn validate_skill(value : Skill, entity_id : String) -> Array[Diagnostic]

Validate skill name and level.

#
validate_time_window

fn validate_time_window(window : TimeWindow, entity_id : String, field : String) -> Array[Diagnostic]

Validate one time window and retain an entity context.

#
validate_visit

fn validate_visit(value : Visit) -> Array[Diagnostic]

Validate one requested visit independently.

#
validate_worker

fn validate_worker(value : Worker) -> Array[Diagnostic]

Validate one worker independently from other request entities.

#
visit

fn visit(id : String, recipient_id : String, title : String, location : Location, window : TimeWindow, duration_minutes : Int) -> Visit

Construct a visit with no skill or continuity requirements.

#
visit_before

fn visit_before(left : Visit, right : Visit) -> Bool

Compare visits by required status, priority, flexibility, duration and id.

#
warning_diagnostic

fn warning_diagnostic(code : String, message : String) -> Diagnostic

Build a warning diagnostic.

#
without_assignment

fn without_assignment(assignments : Array[Assignment], visit_id : String) -> Array[Assignment]

Remove one assignment by visit id.

#
worker

fn worker(id : String, display_name : String, kind : WorkerKind, home : Location) -> Worker

Construct a worker with conservative defaults.

#
worker_kind_name

fn worker_kind_name(kind : WorkerKind) -> String

Stable human-readable name for worker kinds.

#
worker_load

fn worker_load(worker : Worker, assignments : Array[Assignment]) -> WorkerLoad

Compute a worker's load from schedule assignments.