feat(AP2.2b, UX): Linear E2E, Composition-Kernel und Steering-Paritaet
Deploy Development / deploy (push) Successful in 47s
Test Suite / pytest-backend (push) Successful in 4m24s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 12s

AP2.2b: Integrationstests Neue-Kueche-Happy-Path, Truth Table und Execution Plan abgeschlossen. UX Composition Kernel (Control/Plan/Cockpit-Slots), CriticalPathPanel aus Kernel-Read-Model mit Gate-Horizont, Next Action elementgesteuert ohne Snapshot-Doppelung, Product-Continuous-Copy und Plan/Arbeit ueber Kernel planning_debt.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-07-27 13:34:13 +02:00
1 parent b6434bcc50
commit 43d33d0edb
22 files changed
+1527 -243

No files matched your search

@@ -0,0 +1,19 @@
import { getProviderComponent } from './providerComponents.jsx'
/**
* Rendert alle Provider-Instanzen eines UI-Slots.
* @param {{ slotKey: string, providers?: import('./resolveSteeringComposition.js').ResolvedProvider[], className?: string }} props
*/
export function CompositionSlot({ slotKey, providers = [], className }) {
if (!providers.length) return null
return (
<div className={className} data-composition-slot={slotKey}>
{providers.map((provider) => {
const Component = getProviderComponent(provider.componentKey)
if (!Component) return null
return <Component key={provider.instanceKey} {...provider.props} />
})}
</div>
)
}
@@ -0,0 +1,60 @@
import { useMemo } from 'react'
import { CompositionSlot } from './CompositionSlot.jsx'
import { resolveSteeringComposition } from './resolveSteeringComposition.js'
import { getCompositionSurface } from './uiSlotRegistry.js'
/**
* Rendert alle Slots einer Composition-Surface.
* @param {{
* surfaceKey: string,
* scope?: 'portfolio' | 'initiative',
* operatingContext?: object | null,
* steeringSnapshot?: object | null,
* capabilities?: Set<string> | string[],
* filterContext?: Record<string, unknown>,
* opsContext?: object | null,
* slotClassName?: string,
* wrapperClassName?: string,
* }} props
*/
export function CompositionSurface({
surfaceKey,
scope = 'initiative',
operatingContext = null,
steeringSnapshot = null,
capabilities = new Set(),
filterContext = {},
opsContext = null,
slotClassName,
wrapperClassName,
}) {
const composition = useMemo(
() =>
resolveSteeringComposition({
surfaceKey,
scope,
operatingContext,
steeringSnapshot,
capabilities,
filterContext,
opsContext,
}),
[surfaceKey, scope, operatingContext, steeringSnapshot, capabilities, filterContext, opsContext],
)
const surface = getCompositionSurface(surfaceKey)
if (!surface) return null
return (
<div className={wrapperClassName} data-composition-surface={surfaceKey}>
{surface.slotKeys.map((slotKey) => (
<CompositionSlot
key={slotKey}
slotKey={slotKey}
providers={composition.slots[slotKey] || []}
className={slotClassName}
/>
))}
</div>
)
}
@@ -0,0 +1,62 @@
import { useMemo } from 'react'
import { useInitiativeOperations } from '../context/InitiativeOperationsContext.jsx'
import { CompositionSurface } from './CompositionSurface.jsx'
/**
* Composition-Surface mit InitiativeOperationsContext — für scoped Plan/Control-Pages.
* @param {{
* surfaceKey: string,
* filterContext?: Record<string, unknown>,
* onAcceptBacklogProposal?: (itemId: string, options?: object) => Promise<void> | void,
* slotClassName?: string,
* wrapperClassName?: string,
* }} props
*/
export function InitiativeCompositionSurface({
surfaceKey,
filterContext = {},
onAcceptBacklogProposal,
slotClassName,
wrapperClassName,
}) {
const ops = useInitiativeOperations()
const opsContext = useMemo(
() => ({
initiativeId: ops.initiativeId,
actions: ops.actions,
steeringSnapshotLoading: ops.steeringSnapshotLoading,
steeringSnapshotError: ops.steeringSnapshotError,
steeringMethods: ops.steeringMethods,
handleMethodChange: ops.handleMethodChange,
methodBusy: ops.methodBusy,
formBusy: ops.formBusy,
onAcceptBacklogProposal,
}),
[
ops.initiativeId,
ops.actions,
ops.steeringSnapshotLoading,
ops.steeringSnapshotError,
ops.steeringMethods,
ops.handleMethodChange,
ops.methodBusy,
ops.formBusy,
onAcceptBacklogProposal,
],
)
return (
<CompositionSurface
surfaceKey={surfaceKey}
scope="initiative"
operatingContext={ops.operatingContext}
steeringSnapshot={ops.steeringSnapshot}
capabilities={ops.capabilities}
filterContext={filterContext}
opsContext={opsContext}
slotClassName={slotClassName}
wrapperClassName={wrapperClassName}
/>
)
}
@@ -0,0 +1,135 @@
/**
* AP-UX-1 — Composition-Provider-Registry.
* Provider hängen an UI-Slots; Aktivierung über steering_elements, proposals, widgets, …
*/
import { WIDGETS } from '../registry/widgetRegistry.js'
/**
* @typedef {'steering_element' | 'proposal' | 'agent_slots' | 'widget' | 'core' | 'conditional'} ProviderKind
*/
/**
* @typedef {Object} CompositionProviderDefinition
* @property {string} key
* @property {ProviderKind} kind
* @property {string[]} slotKeys
* @property {string} componentKey
* @property {number} [order]
* @property {string} [requiresCapability]
* @property {('portfolio' | 'initiative')[]} [scopeTypes]
* @property {string} [steeringElement]
* @property {string} [proposalKey]
* @property {string} [widgetKey]
* @property {string} [predicateKey]
*/
const WIDGET_PROVIDERS = WIDGETS.filter((w) => w.area === 'workspace').map((widget) => ({
key: `widget.${widget.key}`,
kind: /** @type {ProviderKind} */ ('widget'),
widgetKey: widget.key,
slotKeys: ['cockpit.main'],
componentKey: 'WidgetHost',
order: widget.defaultOrder,
}))
/** @type {CompositionProviderDefinition[]} */
export const COMPOSITION_PROVIDERS = [
...WIDGET_PROVIDERS,
// —— Control / Status ——
{
key: 'core.steering_snapshot',
kind: 'core',
slotKeys: ['control.status.core'],
componentKey: 'SteeringSnapshotPanel',
requiresCapability: 'kairo.initiative.read',
scopeTypes: ['initiative'],
order: 0,
},
{
key: 'steering.critical_path',
kind: 'steering_element',
steeringElement: 'critical_path',
slotKeys: ['control.status.steering'],
componentKey: 'CriticalPathPanel',
requiresCapability: 'kairo.action.read',
scopeTypes: ['initiative'],
order: 10,
},
{
key: 'steering.next_action',
kind: 'steering_element',
steeringElement: 'next_action_primary',
slotKeys: ['control.status.steering'],
componentKey: 'NextActionWidget',
requiresCapability: 'kairo.workspace.read',
scopeTypes: ['initiative'],
order: 20,
},
{
key: 'agent.slots',
kind: 'agent_slots',
slotKeys: ['control.status.agent'],
componentKey: 'AgentSlotsPanel',
requiresCapability: 'kairo.initiative.read',
scopeTypes: ['initiative'],
order: 0,
},
{
key: 'conditional.roadblockers',
kind: 'conditional',
predicateKey: 'hasRoadblockers',
slotKeys: ['control.status.alerts'],
componentKey: 'RoadblockersStrip',
scopeTypes: ['initiative'],
order: 0,
},
// —— Plan / Proposals ——
{
key: 'proposal.intake_triage',
kind: 'proposal',
proposalKey: 'intake_triage',
slotKeys: ['plan.inbox.proposals'],
componentKey: 'SteeringProposalsPanel',
requiresCapability: 'kairo.initiative.read',
scopeTypes: ['initiative'],
order: 0,
},
{
key: 'proposal.sprint_commit',
kind: 'proposal',
proposalKey: 'sprint_commit',
slotKeys: ['plan.sprint.proposals'],
componentKey: 'SteeringProposalsPanel',
requiresCapability: 'kairo.initiative.read',
scopeTypes: ['initiative'],
order: 0,
},
{
key: 'proposal.gate_next_actions',
kind: 'proposal',
proposalKey: 'gate_next_actions',
slotKeys: ['plan.gates.proposals'],
componentKey: 'SteeringProposalsPanel',
requiresCapability: 'kairo.initiative.read',
scopeTypes: ['initiative'],
order: 0,
},
]
/**
* @param {string} slotKey
*/
export function getProvidersForSlot(slotKey) {
return COMPOSITION_PROVIDERS.filter((p) => p.slotKeys.includes(slotKey))
.sort((a, b) => (a.order ?? 0) - (b.order ?? 0))
}
/**
* @param {string} key
*/
export function getProviderByKey(key) {
return COMPOSITION_PROVIDERS.find((p) => p.key === key) || null
}
@@ -0,0 +1,49 @@
import { Link } from 'react-router-dom'
import { scopedPath } from '../utils/routes.js'
import { SteeringSnapshotPanel } from '../components/SteeringSnapshotPanel.jsx'
import { CriticalPathPanel } from '../components/CriticalPathPanel.jsx'
import { AgentSlotsPanel } from '../components/AgentSlotsPanel.jsx'
import { SteeringProposalsPanel } from '../components/SteeringProposalsPanel.jsx'
import { NextActionWidget } from '../widgets/NextActionWidget.jsx'
/** Roadblocker-Strip — extrahiert aus InitiativeOverviewPage für Composition. */
export function RoadblockersStrip({ initiativeId, actionsBlocked = 0, blockersOpen = 0 }) {
if (actionsBlocked <= 0 && blockersOpen <= 0) return null
return (
<section className="card initiative-summary-strip">
<h2 className="card-title">Roadblocker</h2>
<p className="muted">
{actionsBlocked > 0 && <span>{actionsBlocked} blockierte Arbeitspakete</span>}
{actionsBlocked > 0 && blockersOpen > 0 && ' · '}
{blockersOpen > 0 && <span>{blockersOpen} offene Blocker</span>}
</p>
<Link to={scopedPath('/work/today', { initiativeId })} className="btn btn-secondary btn-sm">
Zur Ausführung
</Link>
</section>
)
}
export function WidgetHost({ widget }) {
if (!widget?.component) return null
const Component = widget.component
return <Component key={widget.key} />
}
/** @type {Record<string, import('react').ComponentType<any>>} */
export const PROVIDER_COMPONENTS = {
SteeringSnapshotPanel,
CriticalPathPanel,
NextActionWidget,
AgentSlotsPanel,
SteeringProposalsPanel,
RoadblockersStrip,
WidgetHost,
}
/**
* @param {string} componentKey
*/
export function getProviderComponent(componentKey) {
return PROVIDER_COMPONENTS[componentKey] || null
}
@@ -0,0 +1,257 @@
/**
* AP-UX-1 — UX Composition Resolver (Frontend-Spiegel des Steering Kernels).
*/
import { hasSteeringElement, steeringElementUi } from '../registry/steeringElementRegistry.js'
import { getWidgetByKey } from '../registry/widgetRegistry.js'
import { filterSprintProposals } from '../utils/steeringProposals.js'
import { COMPOSITION_PROVIDERS, getProvidersForSlot } from './compositionProviders.js'
import { COMPOSITION_SURFACES, getCompositionSurface, surfaceKeyFor } from './uiSlotRegistry.js'
/** @typedef {import('./compositionProviders.js').CompositionProviderDefinition} CompositionProviderDefinition */
/**
* @typedef {Object} CompositionInput
* @property {string} [surfaceKey]
* @property {string} [mode]
* @property {string | null} [routeKey]
* @property {'portfolio' | 'initiative'} [scope]
* @property {string[] | null} [steeringElements]
* @property {object | null} [operatingContext]
* @property {object | null} [steeringSnapshot]
* @property {Set<string> | string[]} [capabilities]
* @property {Record<string, unknown>} [filterContext]
* @property {object | null} [opsContext]
*/
/**
* @typedef {CompositionProviderDefinition & { instanceKey: string, props: Record<string, unknown> }} ResolvedProvider
*/
const CONDITIONAL_PREDICATES = {
hasRoadblockers(ctx) {
const counts = ctx.steeringSnapshot?.counts || {}
return (counts.actions_blocked || 0) > 0 || (counts.blockers_open || 0) > 0
},
}
/**
* @param {Set<string> | string[] | undefined} capabilities
* @param {string | undefined} required
*/
function hasCapability(capabilities, required) {
if (!required) return true
const capSet = capabilities instanceof Set ? capabilities : new Set(capabilities || [])
return capSet.has(required)
}
/**
* @param {CompositionInput} input
*/
function resolveSteeringElements(input) {
if (Array.isArray(input.steeringElements)) return input.steeringElements
return input.operatingContext?.steering_elements || []
}
/**
* @param {CompositionInput} input
*/
function resolveKernelProposals(input) {
return input.steeringSnapshot?.steering_kernel?.proposals || {}
}
/**
* @param {CompositionInput} input
*/
function resolveAgentSlots(input) {
return (
input.steeringSnapshot?.agent_slots
|| input.steeringSnapshot?.steering_kernel?.agent_slots
|| []
)
}
/**
* Next-Action-Überschriften: kritischster passender steering_element (Priorität).
* @param {string[]} elements
* @param {object | null | undefined} steeringSnapshot
*/
export function resolveNextActionUi(elements, steeringSnapshot) {
const priority = ['critical_path', 'work_cycle_scope', 'gate_fulfillment', 'queue_inbox']
const hasActiveSprint = Boolean(steeringSnapshot?.active_work_cycle)
for (const key of priority) {
if (key === 'work_cycle_scope' && !hasActiveSprint) continue
const ui = steeringElementUi(elements, key)
if (ui?.nextActionTitle) return ui
}
return null
}
/**
* @param {CompositionProviderDefinition} provider
* @param {CompositionInput} input
*/
function isProviderActive(provider, input) {
const scope = input.scope || 'portfolio'
const scopeTypes = provider.scopeTypes || ['portfolio', 'initiative']
if (!scopeTypes.includes(scope)) return false
if (!hasCapability(input.capabilities, provider.requiresCapability)) return false
const elements = resolveSteeringElements(input)
const proposals = resolveKernelProposals(input)
const agentSlots = resolveAgentSlots(input)
switch (provider.kind) {
case 'steering_element':
return hasSteeringElement(elements, provider.steeringElement)
case 'proposal': {
const key = provider.proposalKey
if (!key) return false
let items = proposals[key] || []
if (key === 'sprint_commit' && input.filterContext?.workCycleId) {
items = filterSprintProposals(items, input.filterContext.workCycleId)
}
return items.length > 0
}
case 'agent_slots':
return agentSlots.length > 0
case 'widget': {
const widget = getWidgetByKey(provider.widgetKey)
if (!widget) return false
return hasCapability(input.capabilities, widget.requiredCapability)
}
case 'conditional': {
const fn = CONDITIONAL_PREDICATES[provider.predicateKey]
return typeof fn === 'function' ? fn(input) : false
}
case 'core':
default:
return true
}
}
/**
* @param {CompositionProviderDefinition} provider
* @param {CompositionInput} input
*/
export function buildProviderProps(provider, input) {
const ops = input.opsContext || {}
const proposals = resolveKernelProposals(input)
const agentSlots = resolveAgentSlots(input)
const elements = resolveSteeringElements(input)
const capabilities = input.capabilities instanceof Set
? input.capabilities
: new Set(input.capabilities || [])
switch (provider.componentKey) {
case 'SteeringSnapshotPanel':
return {
snapshot: input.steeringSnapshot,
loading: ops.steeringSnapshotLoading,
error: ops.steeringSnapshotError,
methods: ops.steeringMethods,
canManageMethod: capabilities.has('kairo.initiative.manage'),
onMethodChange: ops.handleMethodChange,
methodBusy: ops.methodBusy,
showGateHorizon: hasSteeringElement(elements, 'gate_fulfillment'),
}
case 'CriticalPathPanel': {
const kernel = input.steeringSnapshot?.steering_kernel
return {
initiativeId: ops.initiativeId,
actions: ops.actions || [],
graphState: kernel?.read_models?.execution_graph ?? null,
graphLoading: ops.steeringSnapshotLoading,
scopeRoadmapItemId: kernel?.horizon?.gate_roadmap_item_id ?? null,
}
}
case 'NextActionWidget': {
const nextActionUi = resolveNextActionUi(elements, input.steeringSnapshot)
return {
scope: 'initiative',
initiativeId: ops.initiativeId,
items: input.steeringSnapshot?.next_actions,
loading: ops.steeringSnapshotLoading,
embedded: true,
title: nextActionUi?.nextActionTitle,
subtitle: nextActionUi?.nextActionSubtitle,
}
}
case 'AgentSlotsPanel':
return {
slots: agentSlots,
loading: ops.steeringSnapshotLoading,
}
case 'RoadblockersStrip': {
const counts = input.steeringSnapshot?.counts || {}
return {
initiativeId: ops.initiativeId,
actionsBlocked: counts.actions_blocked || 0,
blockersOpen: counts.blockers_open || 0,
}
}
case 'SteeringProposalsPanel':
return {
proposalsByKey: proposals,
proposalKeys: provider.proposalKey ? [provider.proposalKey] : undefined,
filterContext: input.filterContext || {},
backlogVocabulary: input.operatingContext?.backlog_vocabulary,
canManage: capabilities.has('kairo.backlog.manage'),
onAcceptBacklogProposal: ops.onAcceptBacklogProposal,
busy: ops.formBusy,
}
case 'WidgetHost': {
const widget = getWidgetByKey(provider.widgetKey)
return { widget }
}
default:
return {}
}
}
/**
* @param {CompositionProviderDefinition} provider
* @param {CompositionInput} input
* @returns {ResolvedProvider | null}
*/
export function resolveProviderInstance(provider, input) {
if (!isProviderActive(provider, input)) return null
return {
...provider,
instanceKey: `${provider.key}:${provider.slotKeys[0]}`,
props: buildProviderProps(provider, input),
}
}
/**
* @param {string} slotKey
* @param {CompositionInput} input
* @returns {ResolvedProvider[]}
*/
export function resolveSlotComposition(slotKey, input) {
return getProvidersForSlot(slotKey)
.map((provider) => resolveProviderInstance(provider, input))
.filter(Boolean)
}
/**
* @param {CompositionInput} input
*/
export function resolveSteeringComposition(input) {
const surfaceKey = input.surfaceKey
|| surfaceKeyFor(/** @type {import('./uiSlotRegistry.js').CompositionMode} */ (input.mode), input.routeKey ?? null)
const surface = getCompositionSurface(surfaceKey)
if (!surface) {
return { surfaceKey, slots: {} }
}
/** @type {Record<string, ResolvedProvider[]>} */
const slots = {}
for (const slotKey of surface.slotKeys) {
slots[slotKey] = resolveSlotComposition(slotKey, input)
}
return { surfaceKey, slots }
}
/** Exported for tests */
export { COMPOSITION_PROVIDERS, isProviderActive, CONDITIONAL_PREDICATES }
@@ -0,0 +1,235 @@
import { describe, expect, it } from 'vitest'
import { COMPOSITION_PROVIDERS } from './compositionProviders.js'
import {
resolveSteeringComposition,
resolveSlotComposition,
buildProviderProps,
} from './resolveSteeringComposition.js'
import { COMPOSITION_SURFACES, UI_SLOTS } from './uiSlotRegistry.js'
const CAPS = new Set([
'kairo.initiative.read',
'kairo.action.read',
'kairo.workspace.read',
'kairo.backlog.manage',
])
describe('uiSlotRegistry', () => {
it('defines MVP surfaces', () => {
expect(COMPOSITION_SURFACES['control.status']).toBeTruthy()
expect(COMPOSITION_SURFACES['plan.inbox']).toBeTruthy()
expect(COMPOSITION_SURFACES.cockpit).toBeTruthy()
})
it('has unique slot keys', () => {
const keys = UI_SLOTS.map((s) => s.key)
expect(new Set(keys).size).toBe(keys.length)
})
})
describe('compositionProviders', () => {
it('registers widget providers from widgetRegistry', () => {
const widgets = COMPOSITION_PROVIDERS.filter((p) => p.kind === 'widget')
expect(widgets.length).toBeGreaterThanOrEqual(8)
expect(widgets.some((p) => p.widgetKey === 'kairo.initiative_portfolio')).toBe(true)
})
it('registers proposal providers for plan surfaces', () => {
expect(COMPOSITION_PROVIDERS.some((p) => p.proposalKey === 'intake_triage')).toBe(true)
expect(COMPOSITION_PROVIDERS.some((p) => p.proposalKey === 'sprint_commit')).toBe(true)
expect(COMPOSITION_PROVIDERS.some((p) => p.proposalKey === 'gate_next_actions')).toBe(true)
})
})
describe('resolveSteeringComposition', () => {
it('resolves cockpit widgets by capability', () => {
const result = resolveSteeringComposition({
surfaceKey: 'cockpit',
scope: 'portfolio',
capabilities: CAPS,
})
const main = result.slots['cockpit.main'] || []
expect(main.length).toBeGreaterThan(0)
expect(main.some((p) => p.widgetKey === 'kairo.initiative_portfolio')).toBe(true)
})
it('filters cockpit widgets without capability', () => {
const result = resolveSteeringComposition({
surfaceKey: 'cockpit',
scope: 'portfolio',
capabilities: ['kairo.initiative.read'],
})
const main = result.slots['cockpit.main'] || []
expect(main.some((p) => p.widgetKey === 'kairo.my_open_actions')).toBe(false)
expect(main.some((p) => p.widgetKey === 'kairo.initiative_portfolio')).toBe(true)
})
it('activates critical_path and next_action_primary on control.status', () => {
const result = resolveSteeringComposition({
surfaceKey: 'control.status',
scope: 'initiative',
capabilities: CAPS,
steeringElements: ['critical_path', 'next_action_primary'],
steeringSnapshot: { counts: {}, next_actions: [] },
opsContext: { initiativeId: 'init-1', actions: [] },
})
const steering = result.slots['control.status.steering'] || []
expect(steering.some((p) => p.key === 'steering.critical_path')).toBe(true)
expect(steering.some((p) => p.key === 'steering.next_action')).toBe(true)
})
it('skips next_action when next_action_primary inactive', () => {
const result = resolveSteeringComposition({
surfaceKey: 'control.status',
scope: 'initiative',
capabilities: CAPS,
steeringElements: ['critical_path'],
steeringSnapshot: { counts: {}, next_actions: [] },
opsContext: { initiativeId: 'init-1', actions: [] },
})
const steering = result.slots['control.status.steering'] || []
expect(steering.some((p) => p.key === 'steering.next_action')).toBe(false)
})
it('skips critical_path when element inactive', () => {
const result = resolveSteeringComposition({
surfaceKey: 'control.status',
scope: 'initiative',
capabilities: CAPS,
steeringElements: ['next_action_primary'],
steeringSnapshot: { counts: {}, next_actions: [] },
opsContext: { initiativeId: 'init-1', actions: [] },
})
const steering = result.slots['control.status.steering'] || []
expect(steering.some((p) => p.key === 'steering.critical_path')).toBe(false)
expect(steering.some((p) => p.key === 'steering.next_action')).toBe(true)
})
it('activates proposal provider when kernel has items', () => {
const result = resolveSteeringComposition({
surfaceKey: 'plan.inbox',
scope: 'initiative',
capabilities: CAPS,
steeringSnapshot: {
steering_kernel: {
proposals: {
intake_triage: [{ scope_type: 'backlog_item', scope_id: 'b1', title: 'Bug', rank: 1 }],
},
},
},
opsContext: { formBusy: false },
})
const proposals = result.slots['plan.inbox.proposals'] || []
expect(proposals).toHaveLength(1)
expect(proposals[0].proposalKey).toBe('intake_triage')
})
it('filters sprint proposals by workCycleId', () => {
const slot = resolveSlotComposition('plan.sprint.proposals', {
scope: 'initiative',
capabilities: CAPS,
filterContext: { workCycleId: 'wc-1' },
steeringSnapshot: {
steering_kernel: {
proposals: {
sprint_commit: [
{ scope_type: 'backlog_item', scope_id: 'b1', title: 'A', rank: 1, work_cycle_id: 'wc-1' },
{ scope_type: 'backlog_item', scope_id: 'b2', title: 'B', rank: 2, work_cycle_id: 'wc-2' },
],
},
},
},
opsContext: {},
})
expect(slot).toHaveLength(1)
expect(slot[0].props.proposalKeys).toEqual(['sprint_commit'])
})
it('shows roadblockers strip when counts indicate blockers', () => {
const result = resolveSteeringComposition({
surfaceKey: 'control.status',
scope: 'initiative',
capabilities: CAPS,
steeringElements: [],
steeringSnapshot: { counts: { actions_blocked: 2, blockers_open: 1 } },
opsContext: { initiativeId: 'init-1' },
})
const alerts = result.slots['control.status.alerts'] || []
expect(alerts.some((p) => p.key === 'conditional.roadblockers')).toBe(true)
})
it('activates agent slots provider when slots present', () => {
const result = resolveSteeringComposition({
surfaceKey: 'control.status',
scope: 'initiative',
capabilities: CAPS,
steeringSnapshot: {
steering_kernel: {
agent_slots: [{ slot_key: 'review.due', title: 'Review fällig', scope_id: 'r1' }],
},
},
opsContext: {},
})
const agent = result.slots['control.status.agent'] || []
expect(agent.some((p) => p.key === 'agent.slots')).toBe(true)
})
it('buildProviderProps passes critical path UI to NextActionWidget', () => {
const provider = COMPOSITION_PROVIDERS.find((p) => p.key === 'steering.next_action')
const props = buildProviderProps(provider, {
steeringElements: ['critical_path', 'next_action_primary'],
steeringSnapshot: { next_actions: [] },
opsContext: { initiativeId: 'x', steeringSnapshotLoading: false },
capabilities: CAPS,
})
expect(props.title).toContain('kritischen Pfad')
})
it('buildProviderProps uses continuous product next-action copy', () => {
const provider = COMPOSITION_PROVIDERS.find((p) => p.key === 'steering.next_action')
const props = buildProviderProps(provider, {
steeringElements: ['next_action_primary', 'gate_fulfillment'],
steeringSnapshot: { next_actions: [] },
opsContext: { initiativeId: 'x', steeringSnapshotLoading: false },
capabilities: CAPS,
})
expect(props.title).toContain('Nächster sinnvoller Schritt')
})
it('buildProviderProps passes kernel execution graph to CriticalPathPanel', () => {
const provider = COMPOSITION_PROVIDERS.find((p) => p.key === 'steering.critical_path')
const props = buildProviderProps(provider, {
steeringElements: ['critical_path'],
steeringSnapshot: {
steering_kernel: {
horizon: { gate_roadmap_item_id: 'gate-1' },
read_models: {
execution_graph: { critical_path: ['a1'], ready_actions: ['a1'] },
},
},
},
opsContext: { initiativeId: 'init-1', actions: [], steeringSnapshotLoading: false },
capabilities: CAPS,
})
expect(props.graphState?.critical_path).toEqual(['a1'])
expect(props.scopeRoadmapItemId).toBe('gate-1')
})
it('buildProviderProps gates milestone horizon in snapshot panel', () => {
const provider = COMPOSITION_PROVIDERS.find((p) => p.key === 'core.steering_snapshot')
const withGate = buildProviderProps(provider, {
steeringElements: ['gate_fulfillment', 'next_action_primary'],
steeringSnapshot: { counts: {} },
opsContext: {},
capabilities: CAPS,
})
const withoutGate = buildProviderProps(provider, {
steeringElements: ['next_action_primary'],
steeringSnapshot: { counts: {} },
opsContext: {},
capabilities: CAPS,
})
expect(withGate.showGateHorizon).toBe(true)
expect(withoutGate.showGateHorizon).toBe(false)
})
})
@@ -0,0 +1,93 @@
/**
* AP-UX-0 — UI-Slot-Registry: benannte Flächen pro Modus/Route.
* @see docs/architecture/ADP_UX_Composition_Kernel_v0.1.md
*/
/** @typedef {'cockpit' | 'control' | 'plan' | 'work' | 'team'} CompositionMode */
/**
* @typedef {Object} UiSlotDefinition
* @property {string} key
* @property {CompositionMode} mode
* @property {string | null} routeKey
* @property {string} label
* @property {number} order
*/
/** @type {UiSlotDefinition[]} */
export const UI_SLOTS = [
{ key: 'cockpit.main', mode: 'cockpit', routeKey: null, label: 'Cockpit-Hauptfläche', order: 0 },
{ key: 'control.status.core', mode: 'control', routeKey: 'status', label: 'Steuerungs-Snapshot', order: 0 },
{ key: 'control.status.steering', mode: 'control', routeKey: 'status', label: 'Steuerungselemente', order: 10 },
{ key: 'control.status.agent', mode: 'control', routeKey: 'status', label: 'Agent-Slots', order: 20 },
{ key: 'control.status.alerts', mode: 'control', routeKey: 'status', label: 'Roadblocker', order: 30 },
{ key: 'plan.inbox.proposals', mode: 'plan', routeKey: 'inbox', label: 'Triage-Vorschläge', order: 0 },
{ key: 'plan.sprint.proposals', mode: 'plan', routeKey: 'sprint', label: 'Sprint-Vorschläge', order: 0 },
{ key: 'plan.gates.proposals', mode: 'plan', routeKey: 'gates', label: 'Gate-Vorschläge', order: 0 },
]
/**
* @typedef {Object} CompositionSurfaceDefinition
* @property {CompositionMode} mode
* @property {string | null} routeKey
* @property {string[]} slotKeys
*/
/** Surfaces = zusammengehörige Slots für eine Page. */
/** @type {Record<string, CompositionSurfaceDefinition>} */
export const COMPOSITION_SURFACES = {
cockpit: {
mode: 'cockpit',
routeKey: null,
slotKeys: ['cockpit.main'],
},
'control.status': {
mode: 'control',
routeKey: 'status',
slotKeys: [
'control.status.core',
'control.status.steering',
'control.status.agent',
'control.status.alerts',
],
},
'plan.inbox': {
mode: 'plan',
routeKey: 'inbox',
slotKeys: ['plan.inbox.proposals'],
},
'plan.sprint': {
mode: 'plan',
routeKey: 'sprint',
slotKeys: ['plan.sprint.proposals'],
},
'plan.gates': {
mode: 'plan',
routeKey: 'gates',
slotKeys: ['plan.gates.proposals'],
},
}
/**
* @param {string} surfaceKey
*/
export function getCompositionSurface(surfaceKey) {
return COMPOSITION_SURFACES[surfaceKey] || null
}
/**
* @param {string} slotKey
*/
export function getUiSlot(slotKey) {
return UI_SLOTS.find((s) => s.key === slotKey) || null
}
/**
* @param {CompositionMode} mode
* @param {string | null} [routeKey]
*/
export function surfaceKeyFor(mode, routeKey = null) {
return routeKey ? `${mode}.${routeKey}` : mode
}
@@ -0,0 +1,65 @@
import { useMemo } from 'react'
import { useInitiativeOperations } from '../context/InitiativeOperationsContext.jsx'
import { resolveSteeringComposition } from './resolveSteeringComposition.js'
/**
* Hook: baut Composition-Input aus InitiativeOperationsContext.
* @param {string} surfaceKey
* @param {Record<string, unknown>} [options]
*/
export function useSteeringComposition(surfaceKey, options = {}) {
const ops = useInitiativeOperations()
const {
filterContext = options.filterContext || {},
scope = 'initiative',
} = options
const opsContext = useMemo(
() => ({
initiativeId: ops.initiativeId,
actions: ops.actions,
steeringSnapshotLoading: ops.steeringSnapshotLoading,
steeringSnapshotError: ops.steeringSnapshotError,
steeringMethods: ops.steeringMethods,
handleMethodChange: ops.handleMethodChange,
methodBusy: ops.methodBusy,
formBusy: ops.formBusy,
onAcceptBacklogProposal: options.onAcceptBacklogProposal,
}),
[
ops.initiativeId,
ops.actions,
ops.steeringSnapshotLoading,
ops.steeringSnapshotError,
ops.steeringMethods,
ops.handleMethodChange,
ops.methodBusy,
ops.formBusy,
options.onAcceptBacklogProposal,
],
)
return useMemo(
() =>
resolveSteeringComposition({
surfaceKey,
scope,
steeringElements: ops.steeringElements,
operatingContext: ops.operatingContext,
steeringSnapshot: ops.steeringSnapshot,
capabilities: ops.capabilities,
filterContext,
opsContext,
}),
[
surfaceKey,
scope,
ops.steeringElements,
ops.operatingContext,
ops.steeringSnapshot,
ops.capabilities,
filterContext,
opsContext,
],
)
}