Skip to content

docs: S23.13 implementer, facade and consumer relationship diagrams#622

Merged
DavidCozens merged 2 commits into
mainfrom
docs/s23-13-relationship-diagrams
Jul 15, 2026
Merged

docs: S23.13 implementer, facade and consumer relationship diagrams#622
DavidCozens merged 2 commits into
mainfrom
docs/s23-13-relationship-diagrams

Conversation

@DavidCozens

@DavidCozens DavidCozens commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Follow-on to S23.12 (#619): the reverse of the "realised by" diagrams, plus the facade/config composition views and a link-grammar fix — all generated from the headers at docs-build time.

What's new

  • Reverse (implementer) view — for each concrete class, the role it realises (up) and the roles it uses (down), with UML multiplicity (0..1 / 1..* / 0..*).
  • @optional marker — a Doxygen alias in the config doc-comments drives the multiplicity lower bound and renders an "Optional:" badge on the API page; read from the field's trailing comment.
  • Facade views — the SolidSyslog class with direct arrows to the interfaces it uses (Config a linked sidecar), and the SolidSyslogConfig struct with its interface members.
  • Combined role view — clients above the interface, implementers below.
  • Canonical-page link grammar — every node links to the compound page where a struct exists, else the file page (opaque handles), and each diagram is injected on that same page, so a name-click in prose and a click in a diagram land on the same page.

Verification

  • mkdocs build --strict green.
  • clang-format (CI image) clean on the two touched headers.
  • MISRA: no suppressions target the edited headers, and the header edits are net-zero line changes, so nothing shifted.
  • Navigated the built site: every diagram node link resolves to a page carrying its diagram; facade ↔ config both ways; opaque Address/facade stay on file pages.

Closes #621

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Clarified optional configuration fields in the generated API docs, including processing order.
    • Documented that omitting the security policy disables per-record integrity trailers.
  • Improvements
    • Enhanced relationship diagrams to provide combined role views, implementer reverse views, and facade/config wiring.
    • Improved diagram injection, navigation, and link targets for defined versus forward-declared roles.
  • Chores
    • Updated documentation generation to recognise @optional consistently for diagram build-time inference.

Extend the generated post-it relationship diagrams (S23.12) with the
reverse and composition views, and fix the link grammar so a name-click
always lands on a page carrying its diagram.

- reverse view on each implementer page: the role it realises (up) plus
  the roles it uses (down), with UML multiplicity labels
- @optional doc-comment marker (a Doxygen alias) drives the lower bound
  0..1 / 0..*; read from the field's trailing comment, so it also renders
  an "Optional:" badge on the API page
- facade class view (SolidSyslog -> the interfaces it uses, with its
  Config as a linked sidecar) and the config view (Config -> its members)
- combined role view: clients above the interface, implementers below
- canonical-page grammar: every node links to the compound page where a
  struct exists, else the file page (opaque handles), and each diagram is
  injected on that same page, so text-clicks and diagram-clicks agree

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 02656a25-c6e9-4234-a301-0c9c131541be

📥 Commits

Reviewing files that changed from the base of the PR and between 1039c5d and a57fb0e.

📒 Files selected for processing (2)
  • hooks/relationship_data.py
  • hooks/relationship_render.py

Walkthrough

The PR expands documentation-time relationship diagrams with reverse implementer, facade, consumer, and combined role views. It adds canonical page-link resolution, optional multiplicity metadata, cached SVG generation, and updated public-header documentation.

Changes

Relationship diagram generation

Layer / File(s) Summary
Relationship metadata and optionality
Core/Interface/*.h, mkdocs.yml, hooks/relationship_data.py
Header comments and Doxygen configuration define optional collaborators; relationship extraction resolves concrete structs, canonical pages, implementers, facades, and consumers.
Relationship SVG renderers
hooks/relationship_render.py
Rendering supports combined role views, reverse implementer views, facade views, consumer links, and multiplicity-aware layout.
Cached diagram injection
hooks/relationship_diagrams.py
MkDocs builds a cached page-to-SVG map and prepends matching diagrams to API pages.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MkDocs
  participant on_page_markdown
  participant relationship_data
  participant relationship_render
  participant APIPage
  MkDocs->>on_page_markdown: process API page
  on_page_markdown->>relationship_data: build relationship metadata
  relationship_data-->>on_page_markdown: return graphs and page targets
  on_page_markdown->>relationship_render: render applicable SVG
  relationship_render-->>on_page_markdown: return inline SVG
  on_page_markdown->>APIPage: prepend diagram
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is useful, but it does not follow the required template sections for Purpose, Change Description, Test Evidence and Areas Affected. Rewrite it using the repository template headings and fill in Purpose, Change Description, Test Evidence and Areas Affected.
Docstring Coverage ⚠️ Warning Docstring coverage is 68.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the PR's main doc change: relationship diagrams for implementers, facades and consumers.
Linked Issues check ✅ Passed The diff covers the issue requirements: reverse, facade, combined role, optional marker, and canonical-page link handling.
Out of Scope Changes check ✅ Passed No clear out-of-scope changes are evident; the edits stay within docs-generation, diagram rendering, and supporting config for #621.
✨ 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 docs/s23-13-relationship-diagrams

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

@github-actions

Copy link
Copy Markdown
Contributor

☀️   Quality Summary

   🚦   build-linux-gcc: 100% successful (✔️ 1522 passed)
   🚦   build-freertos-host-tdd-plustcp: 100% successful (✔️ 1873 passed)
   🚦   build-linux-clang: 100% successful (✔️ 1453 passed)
   🚦   sanitize-linux-gcc: 100% successful (✔️ 1453 passed)
   🚦   integration-linux-openssl: 100% successful (✔️ 16 passed)
   🚦   integration-linux-mbedtls: 100% successful (✔️ 14 passed)
   🚦   integration-windows-openssl: 100% successful (✔️ 16 passed)
   🚦   bdd-linux-syslog-ng: 94% successful (✔️ 49 passed, 🙈 3 skipped)
   🚦   bdd-windows-otel: 88% successful (✔️ 46 passed, 🙈 6 skipped)
   🚦   bdd-freertos-qemu-plustcp: 87% successful (✔️ 45 passed, 🙈 7 skipped)
   🚦   bdd-freertos-qemu-lwip: 87% successful (✔️ 45 passed, 🙈 7 skipped)
   🚦   build-windows-msvc: 100% successful (✔️ 1298 passed)
   🚦   build-linux-tunable-override: 100% successful (✔️ 1453 passed)
   ⚠️   Clang-Tidy: No warnings
   ⚠️   CPPCheck: No warnings


Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
hooks/relationship_data.py (2)

59-92: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Redundant full header-tree rescans across build_graph, _defined_structs, build_reverse, build_facade. None of these memoize, and _diagrams() composes them without sharing results, so a single doc build ends up re-globbing and re-regexing every header roughly 5 times over.

  • hooks/relationship_data.py#L59-L92: add @functools.lru_cache(maxsize=None) to build_graph, _defined_structs, build_reverse, and build_facade (all pure functions of root) so repeated calls within one build are free.
  • hooks/relationship_diagrams.py#L27-L46: no change needed once the builders are memoized — build_consumers/build_graph/build_reverse/build_facade can keep being called independently here.
🤖 Prompt for 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.

In `@hooks/relationship_data.py` around lines 59 - 92, Memoize the pure root-based
builders build_graph, _defined_structs, build_reverse, and build_facade with
functools.lru_cache(maxsize=None) so repeated calls reuse results within a
documentation build. In hooks/relationship_data.py lines 59-92, add the
decorators and required functools import; hooks/relationship_diagrams.py lines
27-46 requires no direct change because its independent builder calls will then
benefit from caching.

43-198: 📐 Maintainability & Code Quality | 🔵 Trivial

Bundle of low-value Ruff hints (non-blocking).

Several private helpers lack return-type annotations (_defined_structs L43, _canonical L52, _balanced L100, _region L119, _collaborators L128 — ANN202), and three open(...) calls pass the redundant default "r" mode (L47, L135, L198 — UP015). Worth a ruff --fix pass at some point; not urgent for a doc-build script.

🤖 Prompt for 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.

In `@hooks/relationship_data.py` around lines 43 - 198, The private helpers
_defined_structs, _canonical, _balanced, _region, and _collaborators need
explicit return-type annotations; add accurate annotations without changing
behavior. Remove the redundant "r" mode arguments from the open calls in
_defined_structs, _collaborators, and build_facade, relying on open’s default
text-read mode.

Source: Linters/SAST tools

🤖 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 `@hooks/relationship_render.py`:
- Around line 102-297: Apply Ruff’s safe automatic fixes across the affected
helpers, including converting eligible `.format()` calls to f-strings and adding
`strict=` to the `zip()` calls in `_place_collaborators` and related code.
Address boolean positional-argument warnings with explicit keywords where
supported, and replace intentionally unused unpacked values such as `fac_page`
and `cfg_page` with `_` while preserving the current rendering behavior.
- Around line 353-378: The width calculation around cons_cx and all_cx does not
account for the leftmost consumer boundary, so wide consumer rows can be
clipped. Recompute the horizontal layout origin using both implementer and
consumer extents, or shift all related x-coordinates right, then derive width
from the resulting leftmost and rightmost bounds so every consumer and
implementer remains inside the viewBox.

---

Outside diff comments:
In `@hooks/relationship_data.py`:
- Around line 59-92: Memoize the pure root-based builders build_graph,
_defined_structs, build_reverse, and build_facade with
functools.lru_cache(maxsize=None) so repeated calls reuse results within a
documentation build. In hooks/relationship_data.py lines 59-92, add the
decorators and required functools import; hooks/relationship_diagrams.py lines
27-46 requires no direct change because its independent builder calls will then
benefit from caching.
- Around line 43-198: The private helpers _defined_structs, _canonical,
_balanced, _region, and _collaborators need explicit return-type annotations;
add accurate annotations without changing behavior. Remove the redundant "r"
mode arguments from the open calls in _defined_structs, _collaborators, and
build_facade, relying on open’s default text-read mode.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d89ed99d-354d-407b-865b-4d84de1dcc03

📥 Commits

Reviewing files that changed from the base of the PR and between 399e25d and 1039c5d.

📒 Files selected for processing (6)
  • Core/Interface/SolidSyslogBlockStore.h
  • Core/Interface/SolidSyslogConfig.h
  • hooks/relationship_data.py
  • hooks/relationship_diagrams.py
  • hooks/relationship_render.py
  • mkdocs.yml

Comment thread hooks/relationship_render.py
Comment thread hooks/relationship_render.py
- fix consumer-row clipping in the combined role view: shift all x so the
  leftmost box (consumer or interface) sits at the margin, and derive width
  from both the left and right extents rather than the rightmost box alone
- convert .format() calls to f-strings across the render module (ruff UP032)
- memoize the pure header-scanning builders with lru_cache so a build's
  repeated calls collapse to one header rescan
- drop redundant open() "r" modes, prefix the unused unpacked page vars,
  add zip(strict=True) to the equal-length pairings

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@DavidCozens

Copy link
Copy Markdown
Collaborator Author

Thanks @coderabbitai — addressed the review in a57fb0e:

Functional (major): consumer-row clipping in the combined role view — fixed by shifting all x-coordinates so the leftmost box sits at the margin and computing width from both extents. Verified with a synthetic wide-consumer case; real roles are byte-identical.

Maintainability (render module): applied f-strings (UP032), redundant open mode (UP015), unused-unpack prefixes (RUF059), and zip(strict=True) (B905). Rendered output confirmed byte-identical.

Performance (data module): memoized build_graph, _defined_structs, build_reverse, and build_facade with functools.lru_cache — a build's repeated calls now collapse to a single header rescan.

Consciously deferred (nitpicks): ANN202 return-type annotations and FBT003 boolean-positional on internal helpers of a build-time script — non-blocking, and I've kept them out to avoid noise.

mkdocs build --strict is green; the two touched Tier-1 headers pass clang-format and touch no MISRA-suppressed lines.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
git log --oneline -5
git show --stat a57fb0e 2>&1 | head -50

Length of output: 1581


🏁 Script executed:

#!/bin/bash
git show a57fb0e -- hooks/relationship_render.py | head -200

Length of output: 14087


🏁 Script executed:

#!/bin/bash
git show a57fb0e -- hooks/relationship_data.py
echo "-----render clipping-----"
git show a57fb0e -- hooks/relationship_render.py | grep -n "leftmost\|margin\|width\|render_role_combined" | head -60

Length of output: 10843


🏁 Script executed:

#!/bin/bash
sed -n '330,410p' hooks/relationship_render.py

Length of output: 3960


The commit checks out. a57fb0e correctly:

  • Clipping fix: render_role_combined now builds a single boxes list (implementer stickies, the base interface box, and consumer subjects), computes shift = _MARGIN - min(left-edge), and applies it uniformly to top_cx/bot_cx/cons_cx/base_cx/span_min/span_max, with width derived from the true max right-edge post-shift. That's the correct fix for the wide-consumer-row spill-left case.
  • UP032: .format() → f-strings confirmed across _sticky, _interface_box, _subject_box, render_reverse, _place_collaborators, render_facade_class, _pod_box, _facade_open, render_facade_stacked.
  • UP015: open(path, "r", encoding=...)open(path, encoding=...) in _defined_structs, build_graph, _collaborators, build_facade.
  • RUF059: fac_page_fac_page in render_facade_class where it's unused.
  • B905: zip(col_cx, collabs)zip(col_cx, collabs, strict=True) in _place_collaborators.
  • Performance: @functools.lru_cache(maxsize=None) added to _defined_structs, build_graph, build_reverse, build_facade, with a docstring note on the read-only contract for callers.

One thing worth double-checking on your side since it's not visible from the diff: lru_cache on functions keyed by root (a string) is fine, but if anything mutates the returned dict in-place anywhere downstream (e.g. build_consumers augmenting build_reverse's output), that would corrupt the cache across calls. Given MISRA-adjacent rigour here — worth a quick rg for in-place mutation of the cached return values to be certain, but I'll take your word that it's clean given the strict build passed.

No further action needed on my side — this addresses all four points raised.

(=^・ω・^=) tidy work, David

@github-actions

Copy link
Copy Markdown
Contributor

☀️   Quality Summary

   🚦   build-linux-gcc: 100% successful (✔️ 1522 passed)
   🚦   build-freertos-host-tdd-plustcp: 100% successful (✔️ 1873 passed)
   🚦   build-linux-clang: 100% successful (✔️ 1453 passed)
   🚦   sanitize-linux-gcc: 100% successful (✔️ 1453 passed)
   🚦   integration-linux-openssl: 100% successful (✔️ 16 passed)
   🚦   integration-linux-mbedtls: 100% successful (✔️ 14 passed)
   🚦   integration-windows-openssl: 100% successful (✔️ 16 passed)
   🚦   bdd-linux-syslog-ng: 94% successful (✔️ 49 passed, 🙈 3 skipped)
   🚦   bdd-windows-otel: 88% successful (✔️ 46 passed, 🙈 6 skipped)
   🚦   bdd-freertos-qemu-plustcp: 87% successful (✔️ 45 passed, 🙈 7 skipped)
   🚦   bdd-freertos-qemu-lwip: 87% successful (✔️ 45 passed, 🙈 7 skipped)
   🚦   build-windows-msvc: 100% successful (✔️ 1298 passed)
   🚦   build-linux-tunable-override: 100% successful (✔️ 1453 passed)
   ⚠️   Clang-Tidy: No warnings
   ⚠️   CPPCheck: No warnings


Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result.

@DavidCozens
DavidCozens merged commit 839e7b2 into main Jul 15, 2026
29 of 30 checks passed
@DavidCozens
DavidCozens deleted the docs/s23-13-relationship-diagrams branch July 15, 2026 13:32
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.

S23.13: implementer, facade and consumer relationship diagrams

1 participant