Kanalkonfigurator und Prozess-Tester auf Schablonenbasis

Geschäftsentscheidungen zuerst (Schablonen je Bereich, Voreinstellungen A3–A5), Einzelschritte
eingeklappt, Auswirkungsanalyse beim Schablonenwechsel, unbestätigte Portal-Fähigkeiten gekennzeichnet.
Tester-Bericht nennt Schablonen, unabhängig laufende Schritte und fehlende Nachweise; alle vier
Kombinationen sind als Szenario getestet. Doku: SCHABLONEN.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-05 10:56:51 +01:00
1 parent e95ba4f986
commit c46f4a032b
12 files changed
+810 -10

No files matched your search

@@ -11,6 +11,7 @@
use App\Enums\ProcessSetting;
use App\Enums\Responsibility;
use App\Models\Channel;
use App\Process\Models\ExternalBookingModel;
use App\Process\Models\ProcessModel;
use App\Process\Models\Responsibilities;
use App\Process\Templates\FunctionTemplate;
@@ -181,6 +182,24 @@ public function templateOptions(Channel $channel, ProcessModel $model, ?array $c
return $options;
}
/**
* The templates in force for new cases of the channel and intake kind (key@version per area): the saved choice of a
* model with slots, otherwise the combination a legacy archetype reproduces (empty when there is none).
*
* @return array<string, string>
*/
public function currentTemplates(Channel $channel, IntakeKind $intake): array
{
$current = $this->current($channel, $intake);
$model = $this->catalogue->model($current['model']);
if ($model->slots() !== []) {
return $this->composer->resolve($model, $current['templates']);
}
return $model::presetTemplates() === [] ? [] : $this->composer->resolve($this->catalogue->model(ExternalBookingModel::key()), $model::presetTemplates());
}
/**
* The templates a draft uses for the model slots (chosen ones, otherwise the model defaults) as key@version.
*
@@ -239,6 +258,14 @@ public function conflicts(Channel $channel, IntakeKind $intake, string $modelKey
'text' => $setting->question().' Bisher eingestellt: „'.$setting->describe($value).'“. Das Modell „'.$modelKey.'“ erlaubt: „'.$allowed.'“.'];
}
// A model with slots does not narrow the guest communication itself: the portal's capability does.
$messages = $model->slots() === [] ? null : (app(ChannelCapabilities::class)->resolve($channel)[ChannelCapabilities::MESSAGES_GUEST] ?? null);
$storedMessages = ProcessSetting::GuestMessages->normalize($stored[ProcessSetting::GuestMessages->value] ?? null);
if ($messages !== null && $messages->isKnown() && $messages->value === false && $storedMessages === Responsibility::Portal->value) {
$conflicts[] = ['setting' => ProcessSetting::GuestMessages, 'stored' => ProcessSetting::GuestMessages->describe($storedMessages), 'fixed' => ProcessSetting::GuestMessages->describe(Responsibility::Landlord->value),
'text' => ProcessSetting::GuestMessages->question().' Bisher eingestellt: „'.ProcessSetting::GuestMessages->describe($storedMessages).'“. Laut Fähigkeit des Portals schreibt es den Gast aber nicht an; künftig: „'.ProcessSetting::GuestMessages->describe(Responsibility::Landlord->value).'“.'];
}
return $conflicts;
}
+59 -1
View File
@@ -6,6 +6,7 @@
use App\Enums\IntakeKind;
use App\Models\Channel;
use App\Process\Modules\ModuleDefinition;
use App\Process\Templates\TemplateComposer;
/**
* Rule-based comparison of a configuration draft (docs/Prozessarchitektur/MODUL_KONFIGURATIONSMATRIX.md §5): for every
@@ -15,7 +16,7 @@
*/
final class ConfigurationImpact
{
public function __construct(private ProcessCatalogue $catalogue, private ChannelProcessConfiguration $configuration) {}
public function __construct(private ProcessCatalogue $catalogue, private ChannelProcessConfiguration $configuration, private TemplateComposer $composer) {}
/**
* @param array<string, mixed> $draft
@@ -61,6 +62,63 @@ public function of(Channel $channel, IntakeKind $intake, array $draft): array
return $impacts;
}
/**
* What a change of function templates means (docs/Prozessarchitektur/SCHABLONEN.md): per changed area the modules that
* drop out, join or stay, the responsibility that changes, the stored switches and settings that no longer apply and
* what the new template still needs or does not build yet. Compared with the templates in force for new cases. Pure:
* nothing is changed, nothing is dropped silently – the landlord sees every consequence before saving.
*
* @param array<string, mixed> $draft
* @return list<array{area: string, from: ?string, to: string, removed: list<string>, added: list<string>, kept: list<string>, responsibility: ?array{from: string, to: string}, switches_lost: list<string>, settings_replaced: list<string>, needs: list<string>, extensions: list<string>}>
*/
public function ofTemplates(Channel $channel, IntakeKind $intake, array $draft): array
{
$model = $this->catalogue->model((string) ($draft['model'] ?? ''));
if ($model->slots() === []) {
return [];
}
$current = $this->configuration->currentTemplates($channel, $intake);
$target = $this->composer->resolve($model, (array) ($draft['templates'] ?? []));
$stored = (array) (($channel->process_overrides ?? [])[$intake->value] ?? []);
$labelOf = fn (string $module): string => ($this->catalogue->hasModule($module) ? $this->catalogue->modules()[$module]::definition()->label : $module);
$impacts = [];
foreach ($model->slots() as $area) {
$from = $current[$area->value] ?? null;
$to = $target[$area->value] ?? null;
$toClass = $to === null ? null : $this->catalogue->templateClass($to);
if ($toClass === null || $from === $to) {
continue;
}
$fromClass = $from === null ? null : $this->catalogue->templateClass($from);
$before = $fromClass === null ? [] : $fromClass::modules();
$after = $toClass::modules();
$removed = array_values(array_diff($before, $after));
$setting = $area->setting();
$storedValue = $setting->normalize($stored[$setting->value] ?? null);
$impacts[] = [
'area' => $area->label(),
'from' => $fromClass === null ? null : $fromClass::label(),
'to' => $toClass::label(),
'removed' => array_map($labelOf, $removed),
'added' => array_map($labelOf, array_values(array_diff($after, $before))),
'kept' => array_map($labelOf, array_values(array_intersect($after, $before))),
'responsibility' => $fromClass !== null && $fromClass::responsibility() !== $toClass::responsibility()
? ['from' => $setting->describe($fromClass::responsibility()->value), 'to' => $setting->describe($toClass::responsibility()->value)]
: null,
'switches_lost' => array_map($labelOf, array_values(array_filter($removed, fn (string $module): bool => ($stored['steps'][$module]['on'] ?? true) === false))),
'settings_replaced' => $storedValue !== null && (string) $storedValue !== $toClass::responsibility()->value
? [$setting->question().' Bisher gespeichert: „'.$setting->describe($storedValue).'“, künftig durch die Schablone: „'.$setting->describe($toClass::responsibility()->value).'“. Der gespeicherte Wert muss beim Speichern ausdrücklich entfernt werden.']
: [],
'needs' => array_map(fn (string $result): string => 'Voraussetzung: '.$result, $toClass::requires()),
'extensions' => $toClass::extensions(),
];
}
return $impacts;
}
/**
* The results that stay necessary although the step is off: what the steps depending on it still need.
*
+55 -2
View File
@@ -8,8 +8,10 @@
use App\Models\Channel;
use App\Models\Property;
use App\Models\Tenant;
use App\Process\Capability;
use App\Process\CaseActivities;
use App\Process\CaseContext;
use App\Process\ChannelCapabilities;
use App\Process\ProcessCatalogue;
use App\Process\ProcessPlan;
use App\Process\ProcessProfile;
@@ -37,6 +39,9 @@ final class ProcessSandboxDriver
private int $ledgerSeen = 0;
/** @var list<string> labels of the activities that were done after the previous event */
private array $doneBefore = [];
/** @var list<Email> every mail of the run (simulated: the only mailer is `array`) */
private array $sent = [];
@@ -98,7 +103,7 @@ public function run(array $input): array
return [
'scenario' => ['key' => $scenario::key(), 'label' => $scenario::label(), 'inputs' => $context->inputs, 'available_events' => count($scenario->events($context->inputs))],
'plan' => $booking === null ? null : $this->plan($booking),
'plan' => $booking === null ? null : $this->plan($booking, $channel),
'timeline' => $timeline,
'result' => $booking === null ? null : ['status' => $booking->status->getLabel(), 'situation' => CaseActivities::situation($booking), 'next' => CaseActivities::next($booking)?->label],
'violations' => EffectLedger::violations(),
@@ -122,7 +127,7 @@ private function assertSandbox(): void
/**
* @return array<string, mixed>
*/
private function plan(Booking $booking): array
private function plan(Booking $booking, Channel $channel): array
{
$plan = ProcessPlan::of($booking);
$profile = $booking->process();
@@ -134,10 +139,49 @@ private function plan(Booking $booking): array
'variant' => $plan->variant,
'modules' => $plan->modules,
'case_type' => strtoupper($profile->caseType->value),
'templates' => $this->templates($plan, $channel),
'configuration' => collect(ProcessSetting::cases())->map(fn ($setting): array => ['question' => $setting->question(), 'value' => $setting->describe($profile->value($setting)), 'source' => ProcessProfile::sourceLabel($profile->source($setting))])->all(),
];
}
/**
* The function templates the case follows: what each stands for, its modules and the portal capabilities it relies on
* with their origin – a capability that is only suggested or derived is shown as not confirmed, never as proven.
*
* @return list<array{area: string, label: string, reference: string, responsibility: string, modules: list<string>, capabilities: list<array{label: string, required: string, source: string, confirmed: bool}>}>
*/
private function templates(ProcessPlan $plan, Channel $channel): array
{
$catalogue = app(ProcessCatalogue::class);
$capabilities = app(ChannelCapabilities::class)->resolve($channel);
$rows = [];
foreach ($plan->templates as $area => $reference) {
$class = $catalogue->templateClass($reference);
if ($class === null) {
continue;
}
$rows[] = [
'area' => $class::area()->label(),
'label' => $class::label(),
'reference' => $reference,
'responsibility' => $class::responsibility()->getLabel(),
'modules' => array_values(array_map(fn (string $module): string => $plan->labels[$module] ?? $module, $class::modules())),
'capabilities' => array_values(array_map(function (string $key, bool $required) use ($capabilities): array {
$capability = $capabilities[$key] ?? null;
return [
'label' => ChannelCapabilities::definitions()[$key]['question'],
'required' => $required ? 'ja' : 'nein',
'source' => $capability?->sourceLabel() ?? 'noch nicht bekannt',
'confirmed' => $capability?->source === Capability::CONFIRMED,
];
}, array_keys($class::capabilityRequirements()), $class::capabilityRequirements())),
];
}
return $rows;
}
/**
* The case after one event: its course, the skipped steps, the simulated mails and effects.
*
@@ -172,9 +216,18 @@ private function capture(SandboxContext $context): array
}
}
$activities = CaseActivities::for($booking);
$waiting = array_values(array_map(fn ($activity): string => $activity->label, array_filter($activities, fn ($activity): bool => $activity->state->value === 'waiting')));
$done = array_values(array_map(fn ($activity): string => $activity->label, array_filter($activities, fn ($activity): bool => in_array($activity->state->value, ['done', 'external'], true))));
// Steps that came to an end in this event while others wait: they do not hold each other up.
$independent = $waiting === [] ? [] : array_values(array_diff($done, $this->doneBefore));
$this->doneBefore = $done;
return [
'status' => $booking->status->getLabel(),
'situation' => CaseActivities::situation($booking),
'waiting' => $waiting,
'independent' => $independent,
'activities' => array_map(fn ($activity): array => ['label' => $activity->label, 'state' => $activity->state->getLabel(), 'state_key' => $activity->state->value, 'detail' => $activity->detail], CaseActivities::for($booking)),
'skipped' => $skipped,
'calendar' => ['occupying' => Booking::query()->occupying()->whereKey($booking->id)->exists(), 'hold_until' => $booking->isHoldActive() ? $booking->hold_expires_at->format('d.m.Y H:i') : null],