Skip to content

Instantly share code, notes, and snippets.

@lmmx
Last active March 10, 2025 09:31
Show Gist options
  • Save lmmx/14eaf5f6ae5c62e34dfc89a34920cab8 to your computer and use it in GitHub Desktop.
Save lmmx/14eaf5f6ae5c62e34dfc89a34920cab8 to your computer and use it in GitHub Desktop.
Intents for Time Scheduler (`generate_schedule` crate) https://github.com/lmmx/timed-scheduler/

Time Constraint Scheduling Library - User Intents (Expanded)

I'll provide 5 distinct intents for each symbol to better cover the full functionality and use cases.

Cargo.toml

Project Dependencies

  1. I want to solve time-based constraints using the clock-zones library
  2. I want to create colorful terminal output for debugging and visualization
  3. I want to parse complex constraint expressions with regex patterns
  4. I want to serialize my entities and constraints to JSON or other formats
  5. I want to deserialize saved schedules back into my application

README.md

Library Purpose

  1. I want to express time constraints in a specialized language
  2. I want to generate feasible schedules that satisfy all my constraints
  3. I want to understand how the library modules interact with each other
  4. I want to see the supported constraint syntax for my scheduling needs
  5. I want to model real-world scheduling problems with time dependencies

lib.rs

Re-exports

  1. I want to access all essential types from a single import
  2. I want to see which modules are available in the library
  3. I want to use the library without understanding its internal organization
  4. I want to integrate this library into my own scheduling application
  5. I want to extend the library while maintaining access to its core features

example() Function

  1. I want to see a complete example of how to use the library
  2. I want to understand the workflow from data input to schedule output
  3. I want to copy-paste a working example to start my own project
  4. I want to see what constraints work together in a feasible schedule
  5. I want to understand the expected input and output formats

types/entity.rs

Entity Struct

  1. I want to create a schedulable item with specific properties
  2. I want to define an item with a name, category, and frequency
  3. I want to associate multiple constraints with a single entity
  4. I want to track optional properties like amount, split, and notes
  5. I want to differentiate between entities of different categories

Entity::new() Method

  1. I want to construct an entity from raw string data
  2. I want to parse frequency strings into appropriate enum values
  3. I want to convert constraint strings into constraint expressions
  4. I want to handle optional fields that might be null
  5. I want to validate that my entity definition is well-formed

types/frequency.rs

Frequency Enum

  1. I want to specify that an entity occurs once daily
  2. I want to specify that an entity occurs twice daily
  3. I want to specify that an entity occurs three times daily
  4. I want to specify that an entity occurs every X hours
  5. I want to specify custom occurrence times for an entity

Frequency::from_str() Method

  1. I want to parse "daily" into a Frequency::Daily enum
  2. I want to parse "2x daily" into a Frequency::TwiceDaily enum
  3. I want to parse "every 4 hours" into a Frequency::EveryXHours enum
  4. I want to handle various ways to express the same frequency
  5. I want to get error messages for unrecognized frequency formats

Frequency::get_instances_per_day() Method

  1. I want to calculate how many daily occurrences an entity has
  2. I want to know how many clock variables to allocate for an entity
  3. I want to convert "every X hours" into a concrete number of instances
  4. I want to handle custom frequency specifications
  5. I want to support scheduling algorithms that need instance counts

types/time_unit.rs

TimeUnit Enum

  1. I want to work with minute-based time values
  2. I want to work with hour-based time values
  3. I want to compare different time units for equality
  4. I want to serialize and deserialize time units
  5. I want to represent different granularities of time

TimeUnit::from_str() Method

  1. I want to parse "m" into TimeUnit::Minute
  2. I want to parse "h" into TimeUnit::Hour
  3. I want to handle variations like "min", "minute", "minutes"
  4. I want to handle variations like "hr", "hour", "hours"
  5. I want to get clear error messages for unknown time units

TimeUnit::to_minutes() Method

  1. I want to convert hours to minutes for internal calculations
  2. I want to keep minute values unchanged
  3. I want to normalize all time values to a single unit
  4. I want to prepare values for clock zone constraints
  5. I want to handle potentially large time values correctly

types/constraints.rs

ConstraintType Enum

  1. I want to specify that something must happen before something else
  2. I want to specify that something must happen after something else
  3. I want to specify that things must be separated by a minimum time
  4. I want to specify minimum separation between instances of the same entity
  5. I want to select different constraint behaviors in my constraint expressions

ConstraintExpression Struct

  1. I want to define a complete constraint with time, unit, type, and reference
  2. I want to represent constraints like "≥30m before food"
  3. I want to represent constraints like "≥2h after medication"
  4. I want to represent constraints like "≥1h apart from category"
  5. I want to represent constraints like "≥8h apart" for multiple instances

ConstraintReference Enum

  1. I want to reference a specific entity by name
  2. I want to reference all entities in a category
  3. I want to create a constraint between instances of the same entity
  4. I want to handle references that need to be resolved later
  5. I want to distinguish between external and internal references

ConstraintExpression::parse() Method

  1. I want to parse a string like "≥1h before food" into a constraint
  2. I want to parse a string like "≥30m after medication"
  3. I want to parse a string like "≥2h apart from category"
  4. I want to parse a string like "≥6h apart" for recurring instances
  5. I want to get detailed error messages for malformed constraints

parser/table_parser.rs

parse_from_table() Function

  1. I want to convert a table of strings into Entity objects
  2. I want to parse optional fields that might contain "null"
  3. I want to extract constraint expressions from JSON-like array strings
  4. I want to handle different data types in my table (strings, numbers)
  5. I want to get specific error messages for format problems

compiler/clock_info.rs

ClockInfo Struct

  1. I want to associate a clock variable with an entity name
  2. I want to track which instance number a clock represents
  3. I want to maintain a link between variables and their meaning
  4. I want to find entity information from a variable reference
  5. I want to organize multiple clocks for the same entity

compiler/compiler.rs

TimeConstraintCompiler Struct

  1. I want to compile a set of entities and constraints into a schedule
  2. I want to organize entities by name and category
  3. I want to maintain a mapping between clock IDs and variables
  4. I want to track the current state of the constraint zone
  5. I want to debug the compilation process when needed

TimeConstraintCompiler::new() Method

  1. I want to initialize a compiler with my list of entities
  2. I want to automatically group entities by category
  3. I want to calculate the total clock variables needed
  4. I want to create an unconstrained initial zone
  5. I want to enable debug mode for troubleshooting

TimeConstraintCompiler::compile() Method

  1. I want to execute the complete compilation process
  2. I want to allocate clocks for all entity instances
  3. I want to apply daily bounds to limit schedule times
  4. I want to apply frequency and entity-specific constraints
  5. I want to check if my constraint set is feasible

TimeConstraintCompiler::allocate_clocks() Method

  1. I want to create a unique clock variable for each entity instance
  2. I want to assign incrementing variable indices to clocks
  3. I want to track which entity and instance each clock represents
  4. I want to see debug information about created clocks
  5. I want to maintain a mapping of clock IDs to their information

TimeConstraintCompiler::set_daily_bounds() Method

  1. I want to restrict all events to happen within a 24-hour period
  2. I want to set lower bounds of 0 minutes for all clocks
  3. I want to set upper bounds of 1440 minutes for all clocks
  4. I want to see debug information about the bounds being set
  5. I want to ensure all events happen on the same day

TimeConstraintCompiler::apply_frequency_constraints() Method

  1. I want to enforce proper ordering of entity instances
  2. I want to apply minimum spacing between instances
  3. I want to group clocks by their entity names
  4. I want to handle entities with only one instance
  5. I want to see debug information about frequency constraints

TimeConstraintCompiler::apply_entity_constraints() Method

  1. I want to handle "apart" constraints between instances
  2. I want to handle "before" constraints between entities
  3. I want to handle "after" constraints between entities
  4. I want to handle "apart from" constraints between entities
  5. I want to collect constraint operations for safe application

TimeConstraintCompiler::resolve_reference() Method

  1. I want to handle "or" expressions in entity references
  2. I want to find clock variables for an entity by name
  3. I want to find clock variables for all entities in a category
  4. I want to combine multiple reference resolutions
  5. I want to get appropriate errors for unresolvable references

TimeConstraintCompiler::extract_schedule() Method

  1. I want to generate concrete times from a feasible constraint zone
  2. I want to handle the case when the zone is empty
  3. I want to calculate a time within the feasible range for each clock
  4. I want to create a mapping of clock IDs to specific minutes
  5. I want to extract a schedule that satisfies all constraints

TimeConstraintCompiler::format_schedule() Method

  1. I want to convert a raw schedule into a human-readable format
  2. I want to sort events chronologically
  3. I want to group events by entity
  4. I want to see time in HH:MM format
  5. I want to include entity details like amount and unit in the output

TimeConstraintCompiler::diagnose_infeasibility() Method

  1. I want to identify which constraints make my schedule infeasible
  2. I want to test basic daily bounds for feasibility
  3. I want to test ordering constraints for feasibility
  4. I want to test spacing constraints for feasibility
  5. I want to identify problematic entity-specific constraints

TimeConstraintCompiler::add_constraint_safely() Method

  1. I want to test if adding a constraint would make the schedule infeasible
  2. I want to add constraints only if they preserve feasibility
  3. I want to see debug information about constraint additions
  4. I want to see which constraints cannot be added
  5. I want to ensure my schedule remains feasible as constraints are added

main.rs

main() Function

  1. I want to run the scheduling example
  2. I want to see a success message if scheduling works
  3. I want to see an error message if scheduling fails
  4. I want to handle the result of the example function
  5. I want to execute the library functionality from a binary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment