Skip to content

Sektion I — Plattform/Audit-Ansicht (Frontend, Teil 2) - #33

Merged
patricznr1 merged 2 commits into
mainfrom
feat/i-frontend-platform-audit
Jun 22, 2026
Merged

Sektion I — Plattform/Audit-Ansicht (Frontend, Teil 2)#33
patricznr1 merged 2 commits into
mainfrom
feat/i-frontend-platform-audit

Conversation

@patricznr1

@patricznr1 patricznr1 commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Was

Teil 2 der Sektion I: die Plattform-/Audit-Ansicht unter /platform (requireSection("I")) auf den gemergten Read-APIs (GET /api/v1/topology + GET /api/v1/audit, §22). Baut die ehrlich abgeleitete Teilmenge des [VISION]-Zielbilds §4I — kein erfundener Knoten, kein erfundener Live-Feed.

Teil A — Systemtopologie (ruhig, nicht-animiert)

  • Bespoke, token-getriebenes SVG (TopologyGraph, keine Charting-Lib): FOREMAN im Zentrum, Eingänge / Gedächtnis-Substrat / MCP-Grenze ringsum, die [VISION]-Knoten (ERP/Energie/ext. Sim) in einer abgesetzten, gestrichelten Zone ohne Konnektor — nie als reale Verbindung.
  • Eigener mehrkanaliger Verbindungsstatus (Farbe-Token + Form-Glyph + Wort) statt des Fcsm-StatusIndicator-Atoms, das kein unbekannt kennt. unbekannt bleibt ehrlich neutral (nie grün geraten); simulation als intern markiert; ein gestörter Konnektor klar, aber ruhig (kein Alarm-Rot, ISA-101).
  • Datenrichtung (liefert/liest/beides/keine) als Pfeil-Form, nicht Farbe.

Teil B — Audit-Tabelle (unveränderlich-lesend)

  • Chronologisch, jüngste zuerst; Spalten Zeit/Akteur/Aktion/Ziel/Herkunft/Detail. Filter + Pagination auf die realen Query-Params (action_type/target_kind/target_id/actor/machine_id/since/until/limit/offset).
  • IDs in monospace; actor ausschließlich als pseudonymer #hex6-Handle (nie Klartext, nie aufgelöst, §8); detail-JSONB defensiv gerendert. Rein lesend — keine Mutations-/Quittier-Affordance.

Rollen-Split (Matrix 3.1, ACCESS_MATRIX.I)

  • Manager: Topologie + Audit (Tabs, Topologie zuerst).
  • Schichtleiter: nur Topologie — der FE ruft GET /api/v1/audit für ihn gar nicht auf (Audit-Hook in seinem Zweig nie gemountet → kein 403).
  • Werker/Techniker: requireSection-Landing. Sichtbarkeit ≤ Server-Guard.

Drei Haltungen

HITL (liest nur, schaltet nie) · Hidden-Term (Substrat heißt außen nur „Gedächtnis-Substrat", eigener hidden-term.test.tsx) · Vorbehalt/Ehrlichkeit (Status nur wo messbar). Audit/Topologie sind kein KI-Output → keine KI-Kennzeichnung.

Bewusste Abweichungen vom Prompt (alle am realen Code belegt)

  1. Eigener Connection-Status statt FCSM-Zwang — StatusIndicator ist Fcsm-only und kennt kein unbekannt (vom Auftraggeber bestätigt).
  2. Kein eigener BFF-Handler — der generische Catch-all app/api/v1/[...path] genügt (wie alle Sektionen).
  3. ACCESS_MATRIX.I + /platform-Nav waren bereits beim FE-Fundament angelegt → additiv nichts nötig.
  4. Kein Playwright/E2E im Repo → volle Vitest-Abdeckung (Durchstich-Konvention §21.8).

Markierte Anschlusspunkte (bewusst, nicht erfunden)

Kein WS-Live-Feed für Sektion I → HTTP-Snapshot + manueller Refresh; die Substrat-Live-Probe schreibt einen Smoke-Marker → probe-Toggle. Per-Client-MCP-Attribution = [VISION] (ein geteilter Consumer) → MCP-Knoten zeigt ehrlich eine Grenze.

Qualität

Adversariale 6-Dimensionen-Review (Workflow, jeder Befund gegengeprüft): alle Dimensionen strukturell sauber; 3 a11y-Befunde gefixt (Pagination aria-live + Button-aria-label, Tab-Pfeiltasten-Test).

Gates lokal grün: tsc 0 · ESLint 0 · Vitest 629 (59 neu für I) · tokens:check synchron · next build ok (/platform 8,3 kB / 111 kB First Load — bespoke SVG ohne Lib). Hidden-Term-Scan sauber.

GROUND_TRUTH §21.6/§21.16/§21.17 + WALKTHROUGH im selben Commit (DoD).

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes – Plattform-/Audit-Sektion

  • New Features
    • Neue Plattform-/Audit-Ansicht mit rollenbasierter Sichtbarkeit (Manager: Topologie + Audit, Schichtleiter: nur Topologie, Werker/Techniker: kein Zugriff).
    • Topologie als SVG-Graph mit Statusanzeige; Substrat-Live-Prüfung per Toggle und nur mit manueller Aktualisierung (kein Live-Feed).
    • Audit-Trail schreibgeschützt, mit Rollenfilterung, Paginierung sowie einer Filterleiste (inkl. Zurücksetzen).
    • Tastaturbedienung für Tab-Umschaltung (Pfeiltasten).
  • Documentation
    • Spezifikationen/Walkthrough für die Plattform/Audit-UI aktualisiert.
  • Tests
    • Umfassende UI- und Logiktests für Rollen, Filter, Darstellung und Gatekeeping ergänzt.

Die Plattform-/Audit-Sicht unter /platform (requireSection("I")) auf den
fertigen Read-APIs (GET /api/v1/topology + /api/v1/audit, §22). Baut die
ehrlich abgeleitete Teilmenge des [VISION]-Zielbilds §4I — kein erfundener
Knoten, kein erfundener Live-Feed.

- lib/platform/: types (Vertrags-Spiegel), status (mehrkanaliges Status-/
  Richtungs-Mapping, "unbekannt" ehrlich neutral statt grün geraten),
  topology-/audit-view-model, audit-filter + url (reale Query-Params gegen
  den generischen BFF-Catch-all), roles, use-topology/use-audit
  (HTTP-Snapshot + manueller Refresh, kein WS-Feed), testing/fixtures.
- components/platform/: TopologyGraph (bespoke token-getriebenes SVG,
  FOREMAN-Zentrum, [VISION] abgesetzt/nie verbunden, gestörter Konnektor
  ruhig markiert), TopologyNodeMark, AuditTable/AuditRow (unveränderlich-
  lesend, IDs monospace, actor pseudonym #hex6), AuditFilters,
  PlatformView (Rollen-Split OHNE bedingte Hooks).
- Rollen: Manager Topologie+Audit (Tabs) · Schichtleiter nur Topologie
  (FE ruft /audit nie auf) · Werker/Techniker requireSection-Landing.
- Drei Haltungen: HITL (nur lesen, keine Aktorik) · Hidden-Term
  (Gedächtnis-Substrat, eigener hidden-term.test) · Vorbehalt/Ehrlichkeit.
- Bewusste Abweichungen (am realen Code belegt): eigener Connection-Status
  statt Fcsm-Zwang (kennt kein "unbekannt"); generischer BFF-Catch-all
  statt eigener Proxy-Routen; ACCESS_MATRIX.I + Nav bereits vorhanden;
  kein E2E (Vitest-Abdeckung wie §21.8).
- Adversariale 6-Dimensionen-Review (Workflow): alle Haltungen bestätigt,
  3 a11y-Befunde gefixt (Pagination aria-live + aria-label, Tab-Keyboard).

Gates lokal grün: tsc 0, ESLint 0, Vitest 629 (59 neu für I),
tokens:check synchron, next build ok (/platform 8,3 kB / 111 kB).
GROUND_TRUTH §21.6/§21.16/§21.17 + WALKTHROUGH im selben Commit (DoD).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 35c9fa14-0ded-45af-8185-0280e46bc90c

📥 Commits

Reviewing files that changed from the base of the PR and between 36c0b64 and fb74e87.

📒 Files selected for processing (6)
  • frontend/components/platform/platform-view.test.tsx
  • frontend/components/platform/platform-view.tsx
  • frontend/components/platform/topology-graph.tsx
  • frontend/lib/platform/url.test.ts
  • frontend/lib/platform/url.ts
  • frontend/lib/platform/use-topology.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • frontend/lib/platform/url.test.ts
  • frontend/components/platform/platform-view.test.tsx
  • frontend/components/platform/platform-view.tsx
  • frontend/components/platform/topology-graph.tsx

📝 Walkthrough

Walkthrough

Das PR ergänzt den vollständigen Frontend-Teil von Sektion I (Plattform/Audit): neue Typen, Status-/Richtungs-Normalisierung, Audit-Filter-Logik, URL-Builder, React-Hooks (useTopology, useAudit), SVG-Topologie-Graph, Audit-Tabelle/Filter-Komponenten, rollenbasierte PlatformView und deren Einbindung in platform/page.tsx. Dokumentation (GROUND_TRUTH, WALKTHROUGH) wird aktualisiert.

Änderungen

Sektion I Plattform/Audit Frontend

Layer / Datei(en) Zusammenfassung
Dokumentation aktualisiert
GROUND_TRUTH.md (Zeilen 685, 800–821), docs/WALKTHROUGH.md (Zeilen 871–881)
Tabellenzeile für Sektion I wird mit FE-Spezifikation (Rollen-Split, HTTP-Snapshot, kein WS-Feed, Audit-Maskierung) aktualisiert; Abschnitte 21.16 (Backend „Teil 1" steht) und 21.17 (FE „Teil 2" steht) präzisieren Backend-APIs, Writer-Pfade, Rollen-Matrix und View-State-Logik.
Typkontrakte und Status-/Richtungs-Präsentation
frontend/lib/platform/types.ts, frontend/lib/platform/status.ts, frontend/lib/platform/status.test.ts
Union-Types (ConnectionStatus, FlowDirection, NodeKind, AuditAction, AuditOrigin), rohe Backend-Spiegel (TopologyNodeRead, TopologyViewRead, AuditEntryRead) und abgeleitete View-Modelle (TopologyNodeModel, TopologyModel, AuditRowModel); Normalisierungs- und Präsentationsfunktionen mit mehrkanaligem Status-/Richtungs-Mapping und Testabdeckung.
Rollen-Logik und Test-Fixtures
frontend/lib/platform/roles.ts, frontend/lib/platform/roles.test.ts, frontend/lib/platform/testing/fixtures.ts
PlatformRoleView-Interface und statisches ROLE_VIEW-Mapping (manager/shift_lead/technician/worker) mit restriktivem DENY_VIEW-Fallback; Factory-Funktionen für Topologie-Knoten (makeNode, makeSubstrateNode, makeMcpNode, makeVisionNode, makeTopologyView) und Audit-Einträge (makeAuditEntry, makeMcpRetrievalEntry); Testabdeckung für Rollen-Sichtbarkeitsflags.
Audit-Filter-Logik und URL-Builder
frontend/lib/platform/audit-filter.ts, frontend/lib/platform/audit-filter.test.ts, frontend/lib/platform/url.ts, frontend/lib/platform/url.test.ts
AuditFilter-Interface, Pagination-Clamp-Logik (clampLimit, clampOffset), auditQueryEntries/activeFilterCount; topologyEndpoint (mit probe und optional fresh_within_minutes), auditEndpoint, fetchErrorKey; vollständige Testabdeckung für Filter-Validierung und Query-Serialisierung.
Topologie- und Audit-View-Modelle
frontend/lib/platform/topology-view-model.ts, frontend/lib/platform/topology-view-model.test.ts, frontend/lib/platform/audit-view-model.ts, frontend/lib/platform/audit-view-model.test.ts
assembleTopology (Knoten-Kategorisierung, Vision-Trennung), realNodeCount, nodeDetailChips (Detail-Flachlegung); detailPairs, assembleAuditRow (mit #hex6-Akteur-Maskierung), assembleAuditRows; je eigenständige Testsuiten für Kategorisierung, Status-Regeln, Detail-Übersetzung und Eingabe-Reihenfolge.
React-Hooks useTopology und useAudit
frontend/lib/platform/use-topology.ts, frontend/lib/platform/use-audit.ts
useTopology: tick-basiertes Refresh-Trigger, refreshing-Flag, AbortController, Degradation-Logik (transienter Fehler hält letzten Stand); useAudit: read-only Endpoint-Dependency, AbortController, DataState-Übergänge, Fehlerbehandlung ohne Mutation.
Topologie-Graph und Node-Mark Komponenten
frontend/components/platform/topology-graph.tsx, frontend/components/platform/topology-node-mark.tsx, frontend/components/platform/topology-graph.test.tsx
TopologyGraph: statischer SVG-Renderer mit ViewBox-Layout, Node-Boxen (Glyph + Status + Richtung), Konnektoren (gestrichelt bei nicht-verbunden), optionale [VISION]-Zone, ARIA-Attribute; TopologyNodeMark: StatusGlyph (16×16 SVG), DirectionArrow (28×12 Pfeil), formatActivity, Detail-Chips; Tests für ARIA, Status-Logik und Vision-Markierung.
Audit-Tabelle und Filter-Komponenten
frontend/components/platform/audit-table.tsx, frontend/components/platform/audit-row.tsx, frontend/components/platform/audit-filters.tsx, frontend/components/platform/audit-table.test.tsx
AuditRow: Read-only Zeile mit #hex6-Akteur, formatStamp, konditionale Detail-Pairs; AuditTable: Caption, Thead, Row-Map; AuditFilters: kontrolliertes Draft-Formular, Reset, Filter-Anzeige; Tests für Zeilenreihenfolge, Maskierung, Read-only-Zustand.
PlatformView, Tabs, Panels und Seitenintegration
frontend/components/platform/platform-view.tsx, frontend/components/platform/platform-view.test.tsx, frontend/components/platform/hidden-term.test.tsx, frontend/app/(app)/platform/page.tsx
PlatformView: Rollenbasiertes Gate, bedingte ManagerTabs/TopologyPanel; ManagerTabs: zwei Tabs mit ArrowLeft/ArrowRight-Navigation (roving tabindex), beide Panels gemountet; TopologyPanel: useTopology, Probe-Checkbox, Refresh-Button; AuditPanel: useAudit, Pagination, AuditFilters, Filter-State; page.tsx übergibt user an PlatformView statt SectionPlaceholder; Tests für Rollen-Split, Refresh, Probe, Hidden-Term-Scan.

Sequenzdiagramm

sequenceDiagram
  participant Browser as Browser (Manager)
  participant PlatformPage as platform/page.tsx
  participant PlatformView
  participant ManagerTabs
  participant TopologyPanel
  participant useTopology
  participant AuditPanel
  participant useAudit
  participant API as BFF /api/v1

  Browser->>PlatformPage: GET /platform
  PlatformPage->>PlatformView: user (role=manager)
  PlatformView->>ManagerTabs: canViewTopology=true, canViewAudit=true
  ManagerTabs->>TopologyPanel: render topology tab
  ManagerTabs->>AuditPanel: render audit tab
  TopologyPanel->>useTopology: probe=true
  useTopology->>API: GET /topology?probe=true
  API-->>useTopology: TopologyViewRead JSON
  useTopology->>useTopology: assembleTopology → DataState cached
  useTopology-->>TopologyPanel: state, refresh, refreshing
  TopologyPanel-->>Browser: TopologyGraph, ProvenanceStamp, NodeGroups
  AuditPanel->>useAudit: AuditFilter (empty init)
  useAudit->>API: GET /audit?limit=20&offset=0
  API-->>useAudit: AuditEntryRead[] JSON
  useAudit->>useAudit: assembleAuditRows → DataState cached
  useAudit-->>AuditPanel: state
  AuditPanel-->>Browser: AuditFilters, AuditTable, Pagination
Loading

Geschätzter Code-Review-Aufwand

🎯 4 (Komplex) | ⏱️ ~60 Minuten

Möglicherweise verwandte PRs

  • patricznr1/foreman#32: Der Backend-PR führt die Read-Endpoints (GET /api/v1/topology, GET /api/v1/audit) und deren Audit-Logik sowie Rollen-Guard ein; dieser PR konsumiert beide Endpoints und wendet die Backend-Rollen-Matrix in der Frontend-UI an.

Gedicht

🐇 Im Maschinenraum tippt das Kaninchen schnell,
Topologie-Knoten in SVG-Sternenhell.
Manager sieht alles – Audit mit #hex6 Hut,
Schichtleiter nur Graphen, das tut ihnen gut.
Kein WebSocket flüstert, nur ehrliche Snapshots im Licht –
FOREMAN im Zentrum hält alle Berichte im Pflicht! 🖥️✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Der Titel beschreibt präzise die Hauptänderung: Implementierung der Frontend-View (Teil 2) für Sektion I (Plattform/Audit). Er ist konkret, fokussiert und reflektiert das Kernziel des Changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/i-frontend-platform-audit

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/components/platform/platform-view.tsx`:
- Around line 102-105: The tab button element and the `<h2>` heading in the tab
layout are using duplicate IDs (both using `tab-${tab.id}`), which violates HTML
ID uniqueness requirements and breaks ARIA relationships for assistive
technology. Ensure that each element has a unique ID by renaming the `<h2>`
element's ID to something distinct (for example, `heading-${tab.id}` or similar)
while keeping the tab button's ID as `tab-${tab.id}`. Update any ARIA attributes
or references that depend on the heading's ID to point to the new unique
identifier. Apply this fix to all occurrences mentioned in the Manager branch
(including the sections at lines 121-123 and 139-141).

In `@frontend/components/platform/topology-graph.tsx`:
- Around line 142-145: The vision zone height in the topology-graph component is
hardcoded to 92 pixels, which causes nodes to overflow or be cut off when there
are 7 or more vision nodes arranged in a 3-column layout. Instead of using a
fixed value for visionH, calculate the actual height dynamically based on the
number of vision nodes and the column layout used in the rendering section
(lines 224-234). Determine how many rows are needed by dividing the
model.vision.length by the number of columns (3) and rounding up, then multiply
by the row height to get the true visionH value. This ensures the SVG and dashed
zone properly accommodate all vision nodes regardless of how many there are.

In `@frontend/lib/platform/url.ts`:
- Around line 27-29: The freshWithinMinutes value from options is being added to
the URL parameters without validating that it falls within the documented valid
range of 1 to 10080. Before setting the parameter in the params.set call within
the conditional block checking options.freshWithinMinutes !== undefined,
validate and clamp the value to ensure it is within the acceptable range of 1 to
10080 (similar to how audit pagination is defensively handled elsewhere in the
codebase). This will prevent invalid requests from being generated with
out-of-range values.

In `@frontend/lib/platform/use-topology.ts`:
- Around line 51-53: The error handling in the useTopology hook currently
discards the cached snapshot whenever a fetch fails by immediately setting the
state to error kind, but it should degrade gracefully by preserving the existing
cached data for transient errors and only transitioning to error state for
permanent failures. Modify both setState calls (at line 52 when res.ok is false
and at line 66) to check if there is already a cached snapshot available; if
yes, keep the cached state and only set to error kind when the failure is a
permanent load-failed condition, not for all fetch errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0774e10c-4f8c-42de-bdda-1157e29e4880

📥 Commits

Reviewing files that changed from the base of the PR and between c3e7690 and 36c0b64.

📒 Files selected for processing (29)
  • GROUND_TRUTH.md
  • docs/WALKTHROUGH.md
  • frontend/app/(app)/platform/page.tsx
  • frontend/components/platform/audit-filters.tsx
  • frontend/components/platform/audit-row.tsx
  • frontend/components/platform/audit-table.test.tsx
  • frontend/components/platform/audit-table.tsx
  • frontend/components/platform/hidden-term.test.tsx
  • frontend/components/platform/platform-view.test.tsx
  • frontend/components/platform/platform-view.tsx
  • frontend/components/platform/topology-graph.test.tsx
  • frontend/components/platform/topology-graph.tsx
  • frontend/components/platform/topology-node-mark.tsx
  • frontend/lib/platform/audit-filter.test.ts
  • frontend/lib/platform/audit-filter.ts
  • frontend/lib/platform/audit-view-model.test.ts
  • frontend/lib/platform/audit-view-model.ts
  • frontend/lib/platform/roles.test.ts
  • frontend/lib/platform/roles.ts
  • frontend/lib/platform/status.test.ts
  • frontend/lib/platform/status.ts
  • frontend/lib/platform/testing/fixtures.ts
  • frontend/lib/platform/topology-view-model.test.ts
  • frontend/lib/platform/topology-view-model.ts
  • frontend/lib/platform/types.ts
  • frontend/lib/platform/url.test.ts
  • frontend/lib/platform/url.ts
  • frontend/lib/platform/use-audit.ts
  • frontend/lib/platform/use-topology.ts

Comment thread frontend/components/platform/platform-view.tsx
Comment thread frontend/components/platform/topology-graph.tsx
Comment thread frontend/lib/platform/url.ts
Comment thread frontend/lib/platform/use-topology.ts
- platform-view: eindeutige Heading-ID im Manager-Tab (Topologie-h2 nicht
  mehr id="tab-topology" wie der Tab-Button → ARIA-Zuordnung eindeutig).
- topology-graph: [VISION]-Zonenhöhe aus der tatsächlichen Zeilenzahl
  berechnet (skaliert mit der Knotenanzahl statt fix 92 → kein Überlauf
  bei 7+ Knoten).
- url: freshWithinMinutes defensiv auf 1..10080 geklemmt (clampFresh-
  WithinMinutes), analog clampLimit — kein ungültiger Request.
- use-topology: Fehlerpfad hält bei transientem Fehler den letzten Snapshot
  (Degradation, wie im Kommentar versprochen); nur fatale Fehler
  (unauthorized/forbidden) überschreiben ihn.

Tests: +4 (clamp + Degradations-Hold + fataler 403). Gates grün:
tsc 0, ESLint 0, Vitest 633, next build ok (/platform 8,41 kB).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@patricznr1
patricznr1 merged commit 6f69d57 into main Jun 22, 2026
3 checks passed
@patricznr1
patricznr1 deleted the feat/i-frontend-platform-audit branch June 22, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant