AP1.14: Plan-Snapshot und Plan/Ist-Overlay in Kontrolle.
Deploy Development / deploy (push) Successful in 47s
Test Suite / pytest-backend (push) Failing after 2m18s
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 3s
Test Suite / compose-smoke (push) Has been skipped

Revisionen mit Audit, getrennte Soll/Ist/Diff-Ansicht unter Kontrolle/Plan-Ist; API plan-ist-view und plan-snapshots.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-07-11 08:10:15 +02:00
1 parent 1fa61b2dac
commit 064779e187
14 files changed
+987

No files matched your search

+1
View File
@@ -79,6 +79,7 @@ function AppRoutes() {
<Route path="/control" element={<ControlLayout />}>
<Route index element={<ControlIndexRedirect />} />
<Route path="status" element={<MODE_ROUTE_COMPONENTS.controlStatus />} />
<Route path="plan-ist" element={<MODE_ROUTE_COMPONENTS.controlPlanIst />} />
<Route path="journey" element={<MODE_ROUTE_COMPONENTS.controlJourney />} />
</Route>
+15
View File
@@ -16,6 +16,21 @@ export function listInitiativeRoadmapGraphState(initiativeId) {
return apiFetch(`/api/initiatives/${initiativeId}/roadmap/graph-state`)
}
export function getInitiativePlanIstView(initiativeId) {
return apiFetch(`/api/initiatives/${initiativeId}/roadmap/plan-ist-view`)
}
export function listInitiativePlanSnapshots(initiativeId) {
return apiFetch(`/api/initiatives/${initiativeId}/roadmap/plan-snapshots`)
}
export function createInitiativePlanSnapshot(initiativeId, body) {
return apiFetch(`/api/initiatives/${initiativeId}/roadmap/plan-snapshots`, {
method: 'POST',
body: JSON.stringify(body),
})
}
export function createInitiativeRoadmapItem(initiativeId, body) {
return apiFetch(`/api/initiatives/${initiativeId}/roadmap/items`, {
method: 'POST',
+272
View File
@@ -0,0 +1,272 @@
import { useCallback, useEffect, useState } from 'react'
import { Link } from 'react-router-dom'
import {
getInitiativePlanIstView,
createInitiativePlanSnapshot,
} from '../api/roadmap.js'
import { gatePath } from '../utils/routes.js'
import {
CRITERION_STATUS_LABELS,
MILESTONE_STATUS_LABELS,
ROADMAP_ITEM_TYPE_LABELS,
} from '../constants/status.js'
import { LoadingState } from './LoadingState.jsx'
import { ErrorState } from './ErrorState.jsx'
import { Modal } from './Modal.jsx'
import { EmptyState } from './EmptyState.jsx'
const DIFF_KIND_LABELS = {
gate_added: 'Gate neu',
gate_removed: 'Gate entfernt',
gate_modified: 'Gate geändert',
edge_added: 'Kante neu',
edge_removed: 'Kante entfernt',
criterion_added: 'Kriterium neu',
criterion_removed: 'Kriterium entfernt',
criterion_modified: 'Kriterium geändert',
ist_gate_status: 'Ist-Status Gate',
ist_gate_at_risk: 'Gate gefährdet',
ist_criterion_waived: 'Kriterium ausgelassen',
ist_criterion_deferred: 'Kriterium verschoben',
ist_criterion_failed: 'Kriterium fehlgeschlagen',
}
function formatPct(ratio) {
if (ratio == null) return null
return `${Math.round(ratio * 100)}%`
}
export function PlanIstPanel({ initiativeId, canManage = false }) {
const [view, setView] = useState(null)
const [loading, setLoading] = useState(true)
const [error, setError] = useState(null)
const [tab, setTab] = useState('plan')
const [busy, setBusy] = useState(false)
const [showRevision, setShowRevision] = useState(false)
const [revisionReason, setRevisionReason] = useState('')
const load = useCallback(async () => {
if (!initiativeId) return
setLoading(true)
setError(null)
try {
setView(await getInitiativePlanIstView(initiativeId))
} catch (err) {
setError(err.message)
} finally {
setLoading(false)
}
}, [initiativeId])
useEffect(() => {
load()
}, [load])
async function handleCreateRevision(e) {
e.preventDefault()
setBusy(true)
setError(null)
try {
await createInitiativePlanSnapshot(initiativeId, {
reason: revisionReason.trim(),
})
setRevisionReason('')
setShowRevision(false)
await load()
} catch (err) {
setError(err.message)
} finally {
setBusy(false)
}
}
if (loading) return <LoadingState message="Plan/Ist wird geladen…" />
if (error && !view) return <ErrorState message={error} onRetry={load} />
if (!view) return null
const planItems = view.plan?.items || []
const istItems = view.ist?.items || []
const diffs = view.diff || []
return (
<section className="card plan-ist-panel">
<div className="section-header">
<div>
<h2>Plan vs. Ist</h2>
<p className="section-lead muted">
Soll-Graph und Ist-Overlay parallel — Abweichungen sichtbar, Plan-Revision mit Audit.
</p>
{view.latest_snapshot ? (
<p className="muted plan-ist-panel__snapshot-meta">
Baseline: Revision {view.latest_snapshot.revision_number}
{view.latest_snapshot.reason ? ` — ${view.latest_snapshot.reason}` : ''}
</p>
) : (
<p className="muted plan-ist-panel__snapshot-meta">
Noch keine Plan-Revision — aktueller Plan = live. Revision festhalten vor größeren
Änderungen.
</p>
)}
</div>
{canManage && (
<button
type="button"
className="btn btn-primary btn-sm"
onClick={() => setShowRevision(true)}
disabled={busy}
>
Plan-Revision
</button>
)}
</div>
{error && <p className="error">{error}</p>}
<div className="plan-ist-panel__tabs" role="tablist" aria-label="Plan Ist Diff">
{['plan', 'ist', 'diff'].map((key) => (
<button
key={key}
type="button"
role="tab"
aria-selected={tab === key}
className={
'plan-ist-panel__tab' + (tab === key ? ' plan-ist-panel__tab--active' : '')
}
onClick={() => setTab(key)}
>
{key === 'plan' ? 'Plan (Soll)' : key === 'ist' ? 'Ist' : `Diff (${diffs.length})`}
</button>
))}
</div>
{tab === 'plan' && (
<div className="plan-ist-panel__pane">
{planItems.length === 0 && (
<EmptyState message="Kein Plan — Zielzustände unter Planen anlegen." />
)}
<ul className="item-list">
{planItems.map((item) => (
<li key={item.id} className="list-item card-list-item">
<div className="list-item-main">
<strong>
<Link to={gatePath(item.id)}>{item.title}</Link>
</strong>
<p className="muted list-item-sub">
{ROADMAP_ITEM_TYPE_LABELS[item.item_type] || item.item_type}
{item.target_date ? ` · Ziel ${item.target_date}` : ''}
</p>
{item.goal_description && (
<p className="list-item-desc">{item.goal_description}</p>
)}
</div>
</li>
))}
</ul>
{view.plan_source === 'snapshot' && view.current_plan && (
<p className="muted plan-ist-panel__hint">
Live-Plan weicht von Revision ab — siehe Diff.
</p>
)}
</div>
)}
{tab === 'ist' && (
<div className="plan-ist-panel__pane">
{view.ist?.graph_state?.initiative_fulfillment_ratio != null && (
<p className="plan-ist-panel__fulfillment muted">
Erfüllungsgrad:{' '}
{formatPct(view.ist.graph_state.initiative_fulfillment_ratio)}
</p>
)}
<ul className="item-list">
{istItems.map((item) => (
<li key={item.id} className="list-item card-list-item">
<div className="list-item-main">
<strong>
<Link to={gatePath(item.id)}>{item.title}</Link>
</strong>
<p className="muted list-item-sub">
{MILESTONE_STATUS_LABELS[item.status] || item.status}
{item.fulfillment_ratio != null
? ` · ${formatPct(item.fulfillment_ratio)} Kriterien`
: ''}
</p>
{item.criteria?.length > 0 && (
<ul className="plan-ist-panel__criteria muted">
{item.criteria.map((crit) => (
<li key={crit.id}>
{crit.title}:{' '}
{CRITERION_STATUS_LABELS[crit.status] || crit.status}
</li>
))}
</ul>
)}
</div>
</li>
))}
</ul>
</div>
)}
{tab === 'diff' && (
<div className="plan-ist-panel__pane">
{diffs.length === 0 && (
<EmptyState message="Keine Abweichungen — Plan und Ist sind konsistent." />
)}
<ul className="item-list">
{diffs.map((entry, index) => (
<li key={`${entry.kind}-${entry.item_id}-${index}`} className="list-item card-list-item">
<div className="list-item-main">
<span className="status-pill plan-ist-panel__diff-kind">
{DIFF_KIND_LABELS[entry.kind] || entry.kind}
</span>
<strong>{entry.title || entry.message}</strong>
<p className="muted list-item-desc">{entry.message}</p>
</div>
{entry.item_id && (
<div className="list-item-meta">
<Link to={gatePath(entry.item_id)} className="btn btn-secondary btn-sm">
Gate
</Link>
</div>
)}
</li>
))}
</ul>
</div>
)}
<Modal open={showRevision} title="Plan-Revision festhalten" onClose={() => setShowRevision(false)}>
<form className="form workspace-form" onSubmit={handleCreateRevision}>
<p className="muted form-hint">
Speichert Topologie, Kanten und Kriterien-Definitionen als Soll-Baseline — Ist-Status
bleibt getrennt.
</p>
<label>
Begründung (optional)
<textarea
value={revisionReason}
onChange={(e) => setRevisionReason(e.target.value)}
rows={3}
maxLength={2000}
placeholder="z. B. Scope-Freeze vor Release 1"
/>
</label>
<div className="form-actions">
<button type="submit" className="btn btn-primary" disabled={busy}>
{busy ? 'Speichern …' : 'Revision anlegen'}
</button>
<button
type="button"
className="btn btn-secondary"
onClick={() => setShowRevision(false)}
disabled={busy}
>
Abbrechen
</button>
</div>
</form>
</Modal>
</section>
)
}
+1
View File
@@ -8,6 +8,7 @@
/** @type {ModeNavItem[]} */
export const CONTROL_NAV_ITEMS = [
{ key: 'status', to: '/control/status', label: 'Steuerung' },
{ key: 'plan-ist', to: '/control/plan-ist', label: 'Plan / Ist' },
{ key: 'journey', to: '/control/journey', label: 'Nachvollziehbarkeit' },
]
+1
View File
@@ -5,6 +5,7 @@ import { resolveWorkNavActiveKey } from '../config/workNav.js'
describe('controlNav', () => {
it('resolves active control sub-route', () => {
expect(resolveControlNavActiveKey('/control/status')).toBe('status')
expect(resolveControlNavActiveKey('/control/plan-ist')).toBe('plan-ist')
expect(resolveControlNavActiveKey('/control/journey')).toBe('journey')
expect(resolveControlNavActiveKey('/control')).toBe(null)
})
@@ -0,0 +1,24 @@
import { RequireInitiativeScope } from '../../components/RequireInitiativeScope.jsx'
import { ScopedInitiativeProvider } from '../../layout/ScopedInitiativeProvider.jsx'
import { PlanIstPanel } from '../../components/PlanIstPanel.jsx'
import { useInitiativeOperations } from '../../context/InitiativeOperationsContext.jsx'
function PlanIstContent() {
const { initiativeId, capabilities } = useInitiativeOperations()
return (
<PlanIstPanel
initiativeId={initiativeId}
canManage={capabilities.has('kairo.milestone.manage')}
/>
)
}
export function ControlPlanIstPage() {
return (
<RequireInitiativeScope lead="Plan/Ist-Vergleich braucht ein Vorhaben im Scope.">
<ScopedInitiativeProvider>
<PlanIstContent />
</ScopedInitiativeProvider>
</RequireInitiativeScope>
)
}
+2
View File
@@ -11,6 +11,7 @@ import { PlanProfilePage } from '../pages/modes/PlanProfilePage.jsx'
import { PlanPortfolioPage } from '../pages/modes/PlanPortfolioPage.jsx'
import { ControlLayout, ControlIndexRedirect } from '../pages/modes/ControlLayout.jsx'
import { ControlStatusPage } from '../pages/modes/ControlStatusPage.jsx'
import { ControlPlanIstPage } from '../pages/modes/ControlPlanIstPage.jsx'
import { ControlJourneyPage } from '../pages/modes/ControlJourneyPage.jsx'
import { TeamPage } from '../pages/modes/TeamPage.jsx'
import { InitiativesPage } from '../pages/InitiativesPage.jsx'
@@ -135,6 +136,7 @@ export const MODE_ROUTE_COMPONENTS = {
planInbox: PlanInboxPage,
planWork: PlanWorkPage,
controlStatus: ControlStatusPage,
controlPlanIst: ControlPlanIstPage,
controlJourney: ControlJourneyPage,
}
+38
View File
@@ -1813,6 +1813,44 @@
font-size: 0.875rem;
}
.plan-ist-panel__tabs {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-bottom: 1rem;
}
.plan-ist-panel__tab {
padding: 0.35rem 0.75rem;
border: 1px solid var(--jk-border-strong, #c5ced8);
border-radius: 999px;
background: transparent;
cursor: pointer;
font-size: 0.875rem;
}
.plan-ist-panel__tab--active {
background: var(--jk-surface-muted, #eef2f6);
font-weight: 600;
}
.plan-ist-panel__snapshot-meta,
.plan-ist-panel__hint,
.plan-ist-panel__fulfillment {
font-size: 0.875rem;
margin-top: 0.35rem;
}
.plan-ist-panel__criteria {
margin: 0.35rem 0 0;
padding-left: 1.1rem;
font-size: 0.8125rem;
}
.plan-ist-panel__diff-kind {
margin-right: 0.5rem;
}
.gate-map-view__node-title {
fill: var(--jk-text, #1a1a1a);
font-size: 14px;