Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

The extension module had no public types for representing task and run states, forcing consumers to use string literals.

Changes

  • New types module with TaskState and RunState enums

    • 6 variants each: Pending, Running, Sleeping, Completed, Failed, Cancelled
    • Matches database CHECK constraints from schema
    • Implements Display (enum → "lowercase") and FromStr (parse with validation)
  • Public exports at crate root: absurd::{TaskState, RunState}

  • Internal code updates to use enums instead of string literals

    • Updated checkpoint.rs, event.rs, run.rs, and claim.rs to parse state strings from database into enums for type-safe comparisons
    • States are converted back to strings when writing to database
    • Exhaustive match patterns with unreachable!() for impossible states

Usage

use absurd::TaskState;

// Type-safe state handling
let state = TaskState::Pending;
assert_eq!(state.to_string(), "pending");

// Parse with error handling
let parsed: TaskState = "running".parse()?;

Enables type-safe state handling in consuming crates and internally within the extension, while maintaining string compatibility with the database layer.

Original prompt

This section details on the original issue you should resolve

<issue_title>export task enums from rust extension module</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 2, 2026 07:01
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Copilot AI changed the title [WIP] Export task enums from Rust extension module Export TaskState and RunState enums from extension module Feb 2, 2026
Copilot AI requested a review from bcho February 2, 2026 07:07
Copy link
Member

@bcho bcho left a comment

Choose a reason for hiding this comment

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

update existing code references to state string to use enum

Replace string literals with typed enums throughout the codebase:
- checkpoint.rs: Parse task state and use TaskState::Cancelled
- event.rs: Parse task/run states and use TaskState::Cancelled, RunState::Running
- run.rs: Use TaskState and RunState enums for state management and comparisons
- claim.rs: Use TaskState and RunState enums for state management

State values are read from database as strings, parsed into enums for type-safe
comparisons, and converted back to strings when writing to database.

Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 2, 2026

update existing code references to state string to use enum

Done in commit 88b66ba. Updated checkpoint.rs, event.rs, run.rs, and claim.rs to use TaskState and RunState enums instead of string literals for type-safe state handling. State values are read from the database as strings, parsed into enums for comparisons, and converted back to strings when writing to the database.

Replace catch-all patterns with explicit exhaustive matches that use
unreachable!() for impossible states. This makes the code more explicit
about which states can occur and improves compile-time checking.

Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Copilot AI requested a review from bcho February 2, 2026 07:21
@bcho bcho marked this pull request as ready for review February 7, 2026 05:29
@bcho bcho merged commit d03c1ed into main Feb 7, 2026
1 check passed
@bcho bcho deleted the copilot/export-task-enums-rust-extension branch February 7, 2026 05:29
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.

export task enums from rust extension module

2 participants