AP2.4: Steuerungselement-Registry und Methoden-Vertrag.
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Failing after 3m17s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped

MethodDefinition traegt steering_elements/ui_features/graph_profile; operating-context und FE-Registry ohne Archetyp-Ifs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-07-25 11:27:59 +02:00
1 parent ac475ab92c
commit d3bf3c36e0
25 files changed
+837 -118

No files matched your search

+5 -2
View File
@@ -1,7 +1,10 @@
import { apiFetch } from './client.js'
export function listSteeringMethods() {
return apiFetch('/api/steering/methods')
export function listSteeringMethods(archetypeKey = null) {
const qs = archetypeKey
? `?archetype_key=${encodeURIComponent(archetypeKey)}`
: ''
return apiFetch(`/api/steering/methods${qs}`)
}
export function updateInitiativeSteeringMethod(initiativeId, methodKey) {
@@ -998,6 +998,7 @@ export function InitiativeOperationsProvider({ children, initiativeId: initiativ
)
const uiFeatures = operatingProfile.uiFeatures || {}
const steeringElements = operatingProfile.steeringElements || []
const value = {
initiativeId: id,
@@ -1031,6 +1032,7 @@ export function InitiativeOperationsProvider({ children, initiativeId: initiativ
operatingContext,
dataSlices: operatingContext?.data_slices || [],
uiFeatures,
steeringElements,
operatingProfile,
methodBusy,
loading,
@@ -4,11 +4,14 @@ import { useInitiativeOperations } from '../../context/InitiativeOperationsConte
import { SteeringSnapshotPanel } from '../../components/SteeringSnapshotPanel.jsx'
import { CriticalPathPanel } from '../../components/CriticalPathPanel.jsx'
import { NextActionWidget } from '../../widgets/NextActionWidget.jsx'
import {
hasSteeringElement,
steeringElementUi,
} from '../../registry/steeringElementRegistry.js'
export function InitiativeOverviewPage() {
const {
initiativeId,
initiative,
actions,
error,
steeringSnapshot,
@@ -18,11 +21,12 @@ export function InitiativeOverviewPage() {
methodBusy,
capabilities,
handleMethodChange,
uiFeatures,
steeringElements,
} = useInitiativeOperations()
const counts = steeringSnapshot?.counts || {}
const showCriticalPath = Boolean(uiFeatures.criticalPathControl)
const showCriticalPath = hasSteeringElement(steeringElements, 'critical_path')
const criticalPathUi = steeringElementUi(steeringElements, 'critical_path')
return (
<>
@@ -51,16 +55,8 @@ export function InitiativeOverviewPage() {
items={steeringSnapshot?.next_actions}
loading={steeringSnapshotLoading}
embedded
title={
showCriticalPath
? 'Nächster Schritt am kritischen Pfad'
: undefined
}
subtitle={
showCriticalPath
? 'Empfehlung aus sequential_dependency — bereite Arbeitspakete zuerst.'
: undefined
}
title={criticalPathUi?.nextActionTitle}
subtitle={criticalPathUi?.nextActionSubtitle}
/>
)}
@@ -36,7 +36,10 @@ export const SLICE_LOADERS = {
workCycles: await listInitiativeWorkCycles(initiativeId),
activeWorkCycle: await getActiveWorkCycle(initiativeId).catch(() => null),
}),
steering_methods: () => listSteeringMethods(),
steering_methods: async (initiativeId) => {
const initiative = await getInitiative(initiativeId)
return listSteeringMethods(initiative?.archetype_key || null)
},
steering_snapshot: (initiativeId) => getInitiativeSteeringSnapshot(initiativeId),
}
@@ -1,5 +1,5 @@
/**
* AP2.3b/f — Operating Profile Resolver (API-first, methodUiDefaults nur als Fallback).
* AP2.3b/f / AP2.4 — Operating Profile Resolver (API-first, methodUiDefaults nur als Fallback).
*/
import { PLAN_OUTLINE_NODES } from '../plan/planOutlineNodes.js'
import { WORK_NAV_ITEMS } from '../config/workNav.js'
@@ -20,9 +20,14 @@ import {
* archetype_key?: string | null,
* method_key?: string | null,
* method_profile_key?: string | null,
* ui_profile?: Partial<MethodUiDefaults & { uiFeatures?: Record<string, boolean>, workDefaultRouteWithoutActiveWorkCycle?: string }> | null,
* ui_profile?: Partial<MethodUiDefaults & { workDefaultRouteWithoutActiveWorkCycle?: string }> | null,
* data_slices?: string[],
* om_capabilities?: string[],
* method_capabilities?: object,
* steering_elements?: string[],
* ui_features?: Record<string, boolean>,
* graph_profile?: { enforce_gate_blocking?: boolean, emphasize_fulfillment?: boolean },
* compatible_methods?: object[],
* }} OperatingContextResponse
* @typedef {{
* archetypeKey?: string | null,
@@ -40,20 +45,21 @@ const EMPTY_PROFILE = {
planOutlineKeys: null,
workNavKeys: null,
uiFeatures: {},
steeringElements: [],
}
/** Methoden-Features ergänzen Archetyp-Profil (bis MethodDefinition ui_features trägt). */
const METHOD_UI_FEATURES = {
sequential_dependency: { criticalPathControl: true },
continuous_product: {
continuousProductWorkMode: true,
steeringSnapshotOnWorkSprint: true,
},
function resolveUiFeatures(context, profileFeatures) {
if (context?.ui_features && Object.keys(context.ui_features).length) {
return { ...(context.ui_features || {}) }
}
return { ...(profileFeatures || {}) }
}
function mergeUiFeatures(profileFeatures, methodKey) {
const methodFeatures = METHOD_UI_FEATURES[methodKey] || {}
return { ...methodFeatures, ...(profileFeatures || {}) }
function resolveSteeringElements(context) {
if (Array.isArray(context?.steering_elements)) {
return [...context.steering_elements]
}
return []
}
function resolveWorkDefaultRoute(profile, options = {}) {
@@ -67,7 +73,6 @@ function resolveWorkDefaultRoute(profile, options = {}) {
/**
* @param {OperatingContextResponse | null | undefined} context
* @param {{ hasActiveSprint?: boolean }} [options]
* @returns {MethodUiDefaults & { dataSlices: string[], uiFeatures: Record<string, boolean> }}
*/
export function resolveOperatingProfile(context, options = {}) {
if (context?.ui_profile) {
@@ -81,7 +86,8 @@ export function resolveOperatingProfile(context, options = {}) {
planOutlineKeys: profile.planOutlineKeys ?? null,
workNavKeys: profile.workNavKeys ?? null,
dataSlices: context.data_slices || profile.dataSlices || [],
uiFeatures: mergeUiFeatures(profile.uiFeatures, context?.method_key),
uiFeatures: resolveUiFeatures(context, profile.uiFeatures),
steeringElements: resolveSteeringElements(context),
}
}
@@ -93,13 +99,13 @@ export function resolveOperatingProfile(context, options = {}) {
return {
...fallback,
dataSlices: context?.data_slices || [],
uiFeatures: mergeUiFeatures({}, context?.method_key),
uiFeatures: resolveUiFeatures(context, {}),
steeringElements: resolveSteeringElements(context),
}
}
/**
* @param {ResolveOperatingProfileInput} input
* @returns {MethodUiDefaults & { dataSlices: string[], uiFeatures: Record<string, boolean> }}
*/
export function resolveOperatingProfileFromInput(input = {}) {
if (input.operatingContext) {
@@ -112,7 +118,7 @@ export function resolveOperatingProfileFromInput(input = {}) {
methodKey: input.methodKey || null,
hasActiveSprint: input.hasActiveSprint,
})
return { ...fallback, dataSlices: [], uiFeatures: {} }
return { ...fallback, dataSlices: [], uiFeatures: {}, steeringElements: [] }
}
/**
@@ -5,6 +5,7 @@ import {
resolveOperatingProfileFromInput,
resolveRedirectForDisallowedRoute,
} from './resolveOperatingProfile.js'
import { hasSteeringElement } from './steeringElementRegistry.js'
const PRODUCT_CONTEXT = {
initiative_id: 'test-id',
@@ -23,6 +24,11 @@ const PRODUCT_CONTEXT = {
workNavKeys: ['sprint', 'today', 'mine'],
},
data_slices: ['backlog', 'actions', 'roadmap', 'work_cycles', 'projects'],
steering_elements: ['next_action_primary', 'work_cycle_scope', 'gate_fulfillment'],
ui_features: {
continuousProductWorkMode: true,
steeringSnapshotOnWorkSprint: true,
},
}
const SUPPORT_QUEUE_CONTEXT = {
@@ -37,6 +43,8 @@ const SUPPORT_QUEUE_CONTEXT = {
workNavKeys: ['today', 'mine'],
},
data_slices: ['backlog', 'actions', 'blockers'],
steering_elements: ['next_action_primary', 'queue_inbox'],
ui_features: {},
}
describe('resolveOperatingProfile', () => {
@@ -75,24 +83,28 @@ describe('resolveOperatingProfile', () => {
expect(isRouteAllowedForProfile('/plan/sprint', input)).toBe(true)
})
it('liefert uiFeatures aus Archetyp-Profil', () => {
const profile = resolveOperatingProfile({
...PRODUCT_CONTEXT,
ui_profile: {
...PRODUCT_CONTEXT.ui_profile,
uiFeatures: { continuousProductWorkMode: true },
},
})
it('liefert uiFeatures aus Methoden-Vertrag (API)', () => {
const profile = resolveOperatingProfile(PRODUCT_CONTEXT)
expect(profile.uiFeatures.continuousProductWorkMode).toBe(true)
expect(profile.uiFeatures.steeringSnapshotOnWorkSprint).toBe(true)
})
it('sequential_dependency ergänzt criticalPathControl', () => {
it('liefert steeringElements aus Methoden-Vertrag (API)', () => {
const profile = resolveOperatingProfile({
archetype_key: 'initiative.generic',
archetype_key: 'initiative.linear_project',
method_key: 'sequential_dependency',
ui_profile: { uiFeatures: {} },
data_slices: ['actions'],
ui_profile: PRODUCT_CONTEXT.ui_profile,
steering_elements: ['critical_path', 'next_action_primary'],
ui_features: { criticalPathControl: true },
})
expect(hasSteeringElement(profile.steeringElements, 'critical_path')).toBe(true)
expect(profile.uiFeatures.criticalPathControl).toBe(true)
})
})
describe('steeringElementRegistry', () => {
it('hasSteeringElement erkennt aktive Elemente', () => {
expect(hasSteeringElement(['critical_path'], 'critical_path')).toBe(true)
expect(hasSteeringElement(['queue_inbox'], 'critical_path')).toBe(false)
})
})
@@ -0,0 +1,33 @@
/**
* AP2.4 — Steuerungselement-Registry (Element → UI-Semantik).
*/
/** @type {Record<string, { nextActionTitle?: string, nextActionSubtitle?: string }>} */
export const STEERING_ELEMENT_UI = {
critical_path: {
nextActionTitle: 'Nächster Schritt am kritischen Pfad',
nextActionSubtitle:
'Empfehlung aus sequenzieller Abhängigkeit — bereite Arbeitspakete zuerst.',
},
queue_inbox: {
nextActionTitle: 'Nächster Schritt aus der Queue',
nextActionSubtitle: 'Pull-Empfehlung aus dem Eingang.',
},
}
/**
* @param {string[] | undefined | null} elements
* @param {string} key
*/
export function hasSteeringElement(elements, key) {
return Array.isArray(elements) && elements.includes(key)
}
/**
* @param {string[] | undefined | null} elements
* @param {string} key
*/
export function steeringElementUi(elements, key) {
if (!hasSteeringElement(elements, key)) return null
return STEERING_ELEMENT_UI[key] || null
}