Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions crates/buzz-core/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ impl FromStr for TaskStatus {

/// A row in the append-only `task_events` log.
///
/// Stored as free `TEXT` rather than a database enum so a new action can ship
/// across a rolling upgrade without a migration; this enum is the set the
/// relay itself writes.
/// Stored as free `TEXT` rather than a database enum. New spellings do not
/// require a constraint migration, but readers must understand a spelling
/// before writers emit it; parsing an unknown action intentionally fails.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TaskAction {
/// The task was created.
Expand All @@ -97,6 +97,10 @@ pub enum TaskAction {
Commented,
/// `title` changed.
TitleChanged,
/// `priority` changed.
PriorityChanged,
/// `due_at` changed or was cleared.
DueAtChanged,
/// An agent persisted its summary of the task. At most one per task.
SummaryPersisted,
}
Expand All @@ -110,6 +114,8 @@ impl TaskAction {
Self::Assigned => "assigned",
Self::Commented => "commented",
Self::TitleChanged => "title_changed",
Self::PriorityChanged => "priority_changed",
Self::DueAtChanged => "due_at_changed",
Self::SummaryPersisted => "summary_persisted",
}
}
Expand Down Expand Up @@ -138,6 +144,8 @@ impl FromStr for TaskAction {
"assigned" => Ok(Self::Assigned),
"commented" => Ok(Self::Commented),
"title_changed" => Ok(Self::TitleChanged),
"priority_changed" => Ok(Self::PriorityChanged),
"due_at_changed" => Ok(Self::DueAtChanged),
"summary_persisted" => Ok(Self::SummaryPersisted),
other => Err(format!("unknown task action: {other:?}")),
}
Expand Down Expand Up @@ -185,6 +193,8 @@ mod tests {
TaskAction::Assigned,
TaskAction::Commented,
TaskAction::TitleChanged,
TaskAction::PriorityChanged,
TaskAction::DueAtChanged,
TaskAction::SummaryPersisted,
] {
assert_eq!(action.as_str().parse::<TaskAction>(), Ok(action));
Expand Down Expand Up @@ -263,6 +273,8 @@ mod tests {
TaskAction::Assigned,
TaskAction::Commented,
TaskAction::TitleChanged,
TaskAction::PriorityChanged,
TaskAction::DueAtChanged,
] {
assert!(!action.is_singleton_per_task());
}
Expand Down
14 changes: 11 additions & 3 deletions crates/buzz-db/src/runtime/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,17 @@ mod postgres_tests {
migrations.sort_by_key(|migration| migration.version);

// upstream carries 44 (0032-0034 and 0040 adopted from our PRs);
// fork adds 0046_task_system (PR #6425 pending upstream) and
// 0047_agent_machine_homes (AGENT-HOMES-001 PR-3).
assert_eq!(migrations.len(), 46);
// fork adds 0046_task_system (PR #6425 pending upstream),
// 0047_agent_machine_homes (AGENT-HOMES-001 PR-3), and 0049 structured
// task history. All stay additive for existing deployments.
assert_eq!(migrations.len(), 47);
assert_eq!(migrations[44].version, 46);
assert_eq!(migrations[45].version, 47);
assert_eq!(migrations[46].version, 49);
let task_changes = migrations[46].sql.as_str();
assert!(task_changes.contains("ALTER TABLE task_events ADD COLUMN changes JSONB"));
assert!(task_changes.contains("ALTER COLUMN created_at SET DEFAULT clock_timestamp()"));
assert!(!migrations[44].sql.as_str().contains("ADD COLUMN changes"));
assert_eq!(migrations[0].version, 1);
assert_eq!(&*migrations[0].description, "initial schema");
assert!(migrations[0]
Expand Down
Loading
Loading