Merge branch 'feature/kitchen-domain-invariants' into development

This commit is contained in:
José René White Enciso 2026-02-25 18:18:13 -06:00
commit 2a1d056823
10 changed files with 86 additions and 0 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
.tasks/ .tasks/
.agile/ .agile/
**/bin/
**/obj/

10
Directory.Build.props Normal file
View File

@ -0,0 +1,10 @@
<Project>
<PropertyGroup>
<Authors>AgileWebs</Authors>
<Company>AgileWebs</Company>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>http://192.168.68.156:3000/AgileWebs/kitchen-domain</RepositoryUrl>
<PackageProjectUrl>http://192.168.68.156:3000/AgileWebs/kitchen-domain</PackageProjectUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
</PropertyGroup>
</Project>

5
Kitchen.Domain.slnx Normal file
View File

@ -0,0 +1,5 @@
<Solution>
<Folder Name="/src/">
<Project Path="src/Kitchen.Domain/Kitchen.Domain.csproj" />
</Folder>
</Solution>

View File

@ -0,0 +1,3 @@
namespace Kitchen.Domain.Conventions;
public interface IKitchenDomainPackageContract;

View File

@ -0,0 +1,8 @@
using Kitchen.Domain.Models;
namespace Kitchen.Domain.Decisions;
public sealed record DispatchDecision(
IReadOnlyCollection<WorkItemId> Selected,
IReadOnlyCollection<WorkItemId> Deferred,
string Reason);

View File

@ -0,0 +1,9 @@
using Kitchen.Domain.Models;
namespace Kitchen.Domain.Decisions;
public interface IKitchenWorkflowDecisionService
{
bool CanTransition(KitchenWorkflowState currentState, KitchenWorkflowState targetState);
DispatchDecision SelectForExecution(IReadOnlyCollection<WorkItemId> candidates, int availableCapacity);
}

View File

@ -0,0 +1,24 @@
using Kitchen.Domain.Models;
namespace Kitchen.Domain.Decisions;
public sealed class KitchenWorkflowDecisionService : IKitchenWorkflowDecisionService
{
public bool CanTransition(KitchenWorkflowState currentState, KitchenWorkflowState targetState)
{
return currentState switch
{
KitchenWorkflowState.Queued => targetState is KitchenWorkflowState.Preparing or KitchenWorkflowState.Failed,
KitchenWorkflowState.Preparing => targetState is KitchenWorkflowState.ReadyForPickup or KitchenWorkflowState.Failed,
KitchenWorkflowState.ReadyForPickup => targetState is KitchenWorkflowState.Delivered,
_ => false
};
}
public DispatchDecision SelectForExecution(IReadOnlyCollection<WorkItemId> candidates, int availableCapacity)
{
var selected = candidates.Take(Math.Max(availableCapacity, 0)).ToArray();
var deferred = candidates.Skip(selected.Length).ToArray();
return new DispatchDecision(selected, deferred, "Selected by available capacity.");
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,10 @@
namespace Kitchen.Domain.Models;
public enum KitchenWorkflowState
{
Queued = 0,
Preparing = 1,
ReadyForPickup = 2,
Delivered = 3,
Failed = 4
}

View File

@ -0,0 +1,6 @@
namespace Kitchen.Domain.Models;
public readonly record struct WorkItemId(string Value)
{
public override string ToString() => Value;
}