Skip to content

Comments

Add scheduler job name uniqueness and prereqs for SQLite executor#297

Merged
NodeJSmith merged 3 commits intomainfrom
264-sqlite-prereq-changes
Feb 22, 2026
Merged

Add scheduler job name uniqueness and prereqs for SQLite executor#297
NodeJSmith merged 3 commits intomainfrom
264-sqlite-prereq-changes

Conversation

@NodeJSmith
Copy link
Owner

Summary

Prerequisite changes for the SQLite command executor (#264):

  • App.app_key property — exposes the app's configuration key from its manifest, needed for SQLite row identification
  • Scheduler job name uniqueness — enforces unique names per scheduler instance via _jobs_by_name dict tracking. Adds if_exists parameter ("error" | "skip") to add_job() and all run_* methods for idempotent registration. ScheduledJob.matches() compares callable, trigger, repeat, args, and kwargs to determine if an existing job is logically identical
  • Trigger equality__eq__/__hash__ on IntervalTrigger (compares interval) and CronTrigger (compares cron expression) for configuration-based comparison, excluding runtime state like start
  • ExecutionResult renamestarted_atmonotonic_start to clarify it stores a monotonic clock value, not a wall-clock timestamp
  • StateProxy disconnect fixon_disconnect() now calls scheduler.remove_job() instead of job.cancel() to properly free the name slot, and subscribe_to_events() uses if_exists="skip" for idempotent reconnection

Breaking changes

  • Scheduler raises ValueError on duplicate job names (previously allowed)
  • ExecutionResult.started_at renamed to monotonic_start

Closes #264

Copilot AI review requested due to automatic review settings February 22, 2026 01:43
NodeJSmith added a commit that referenced this pull request Feb 22, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces prerequisite changes needed for the SQLite command executor feature (#264). The changes focus on job name uniqueness validation, idempotent job registration, clearer naming for timing metrics, and improved reconnection handling.

Changes:

  • Added App.app_key property for accessing the app's configuration key from its manifest
  • Enforced job name uniqueness per scheduler instance with if_exists parameter ("error" | "skip") for idempotent registration
  • Renamed ExecutionResult.started_at to monotonic_start to clarify it stores monotonic clock values, not wall-clock timestamps
  • Implemented __eq__/__hash__ on trigger classes for configuration-based comparison
  • Fixed StateProxy disconnect to use scheduler.remove_job() instead of job.cancel() to properly free the job name slot

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/hassette/app/app.py Added app_key property that delegates to app_manifest.app_key
src/hassette/utils/execution.py Renamed started_at to monotonic_start in ExecutionResult
src/hassette/scheduler/scheduler.py Added _jobs_by_name tracking, if_exists parameter on all run methods, and name uniqueness validation
src/hassette/scheduler/classes.py Added ScheduledJob.matches() method and __eq__/__hash__ to IntervalTrigger and CronTrigger
src/hassette/core/state_proxy.py Changed disconnect to use remove_job() instead of cancel() and added if_exists="skip" to polling job
tests/unit/test_scheduler_job_names.py Comprehensive tests for job name uniqueness and if_exists behavior
tests/unit/test_func_utils.py Tests for callable_name() and callable_short_name() edge cases
tests/unit/test_app_key.py Test for App.app_key property
tests/unit/test_execution.py Updated tests for monotonic_start rename
tests/integration/test_scheduler.py Added explicit job names to prevent uniqueness conflicts
CHANGELOG.md Documented all changes including breaking changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Prerequisite changes for SQLite command executor (#264):
- Add App.app_key property delegating to app_manifest
- Enforce job name uniqueness per Scheduler instance with if_exists
  parameter ("error"|"skip") on all run_* methods
- Add ScheduledJob.matches() and __eq__/__hash__ on trigger classes
  for configuration-based comparison
- Rename ExecutionResult.started_at to monotonic_start
- Fix StateProxy.on_disconnect to use remove_job() instead of cancel()
  so the name slot is freed for reconnection
- Add tests for callable_name/callable_short_name edge cases
app_manifest is a ClassVar annotation with no default value — it only
exists at runtime when set by the app registry. With random test ordering
in CI, patch.object fails if no other test has set the attribute first.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Feb 22, 2026

Codecov Report

❌ Patch coverage is 76.19048% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.81%. Comparing base (e55adfd) to head (072a896).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/hassette/scheduler/classes.py 50.00% 6 Missing and 1 partial ⚠️
src/hassette/scheduler/scheduler.py 85.71% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #297      +/-   ##
==========================================
+ Coverage   79.63%   79.81%   +0.17%     
==========================================
  Files         131      131              
  Lines        9297     9325      +28     
  Branches      927      931       +4     
==========================================
+ Hits         7404     7443      +39     
+ Misses       1526     1520       -6     
+ Partials      367      362       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@NodeJSmith NodeJSmith merged commit 1489482 into main Feb 22, 2026
11 of 12 checks passed
@NodeJSmith NodeJSmith deleted the 264-sqlite-prereq-changes branch February 22, 2026 02:09
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.

Add prerequisite code changes for SQLite command executor

1 participant