feat(wfe-core): human-friendly workflow names

Add a `name` field to both `WorkflowDefinition` (optional display name
declared in YAML, e.g. "Continuous Integration") and `WorkflowInstance`
(required, unique alongside the UUID primary key). Instance names are
auto-assigned as `{definition_id}-{N}` via a per-definition monotonic
counter so the 42nd run of `ci` becomes `ci-42`.

Persistence trait gains two methods:

* `get_workflow_instance_by_name` — name-based lookup for Get/Cancel/
  Suspend/Resume/Watch/Logs RPCs so callers can address instances
  interchangeably as either UUID or human name.
* `next_definition_sequence` — atomic per-definition counter used by
  the host at start time to allocate the next N.

This commit wires the in-memory test provider and touches the deno
bridge test helper; the real postgres/sqlite impls follow in the next
commit. UUIDs remain the primary key throughout — names are a second
unique index, never a replacement.
This commit is contained in:
2026-04-07 18:58:12 +01:00
parent 883471181d
commit d9b9c5651e
5 changed files with 92 additions and 28 deletions

View File

@@ -1,9 +1,7 @@
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use crate::models::{
Event, EventSubscription, ExecutionError, ScheduledCommand, WorkflowInstance,
};
use crate::models::{Event, EventSubscription, ExecutionError, ScheduledCommand, WorkflowInstance};
/// Persistence for workflow instances.
#[async_trait]
@@ -17,7 +15,15 @@ pub trait WorkflowRepository: Send + Sync {
) -> crate::Result<()>;
async fn get_runnable_instances(&self, as_at: DateTime<Utc>) -> crate::Result<Vec<String>>;
async fn get_workflow_instance(&self, id: &str) -> crate::Result<WorkflowInstance>;
async fn get_workflow_instance_by_name(&self, name: &str)
-> crate::Result<WorkflowInstance>;
async fn get_workflow_instances(&self, ids: &[String]) -> crate::Result<Vec<WorkflowInstance>>;
/// Atomically allocate the next sequence number for a given workflow
/// definition id. Used by the host to assign human-friendly names of the
/// form `{definition_id}-{N}` before inserting a new workflow instance.
/// Guaranteed monotonic per definition_id; no guarantees across definitions.
async fn next_definition_sequence(&self, definition_id: &str) -> crate::Result<u64>;
}
/// Persistence for event subscriptions.
@@ -79,9 +85,14 @@ pub trait ScheduledCommandRepository: Send + Sync {
async fn process_commands(
&self,
as_of: DateTime<Utc>,
handler: &(dyn Fn(ScheduledCommand) -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Result<()>> + Send>>
+ Send
+ Sync),
handler: &(
dyn Fn(
ScheduledCommand,
) -> std::pin::Pin<
Box<dyn std::future::Future<Output = crate::Result<()>> + Send>,
> + Send
+ Sync
),
) -> crate::Result<()>;
}