Skip to content

Add Mermaid diagrams illustrating event workflow and supervisor internals - #1

Merged
alexcvc merged 1 commit into
mainfrom
claude/readme-mermaid-diagrams-uqj7ui
Jul 25, 2026
Merged

Add Mermaid diagrams illustrating event workflow and supervisor internals#1
alexcvc merged 1 commit into
mainfrom
claude/readme-mermaid-diagrams-uqj7ui

Conversation

@alexcvc

@alexcvc alexcvc commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a component/architecture overview diagram to "Core Concepts" showing how external threads, EventSupervisor, EventDescriptor, IEventSender, and the remote controller relate.
  • Add a stateDiagram-v2 for the descriptor's internal Debounce/Heartbeat phase machine under "Timing Behavior," matching the actual transitions in EventDescriptor::trigger()/tick().
  • Add a sequence diagram under "Thread Safety" walking through a debounced cable flap followed by a heartbeat resend.
  • Add a startup/lifecycle flow diagram (registerDescriptor → emitInitialSnapshot → start → running → stop) before the Example section.

No code changes — documentation only, README.md.

Test plan

  • Read EventDescriptor.hpp and EventSupervisor.hpp in full to confirm diagram transitions/labels match actual code behavior.
  • Rendered all 4 Mermaid blocks locally with @mermaid-js/mermaid-cli (mmdc) to confirm valid syntax (fixed one escaped-quote issue found this way).
  • Re-read the full updated README.md to confirm diagrams are placed logically next to the prose they illustrate and don't contradict it.

Generated by Claude Code

Summary by CodeRabbit

  • Documentation
    • Added architecture diagrams illustrating the event system’s components, state transitions, debounce and heartbeat behavior, and startup lifecycle.
    • Clarified descriptor registration and initial snapshot requirements before system startup.

…nals

Adds a component overview, the descriptor Debounce/Heartbeat state
machine, a trigger()/tick() sequence diagram (debounced flap +
heartbeat resend), and a startup/lifecycle flow diagram to README.md,
placed alongside the existing prose they illustrate.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

README.md adds architecture diagrams for event routing, descriptor debounce and heartbeat behavior, and supervisor startup lifecycle constraints.

Changes

Event system documentation

Layer / File(s) Summary
Component architecture
README.md
Documents event sources, supervisor and descriptor components, configuration and metrics, and sender routing.
Descriptor timing behavior
README.md
Describes debounce and heartbeat state transitions, trigger handling, suppression, and resend behavior.
Startup and lifecycle constraints
README.md
Documents pre-start registration and snapshot operations, start(), and lock-free runtime iteration.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding Mermaid diagrams documenting the event workflow and supervisor internals.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/readme-mermaid-diagrams-uqj7ui

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@alexcvc
alexcvc marked this pull request as ready for review July 25, 2026 16:49
@alexcvc alexcvc self-assigned this Jul 25, 2026
@alexcvc
alexcvc requested a review from Copilot July 25, 2026 16:50
@alexcvc
alexcvc merged commit 202ef89 into main Jul 25, 2026
1 of 2 checks passed

@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: 3

🤖 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 `@README.md`:
- Around line 181-188: Update the sequence diagram to add an EventSupervisor
participant and route the external trigger through
EventSupervisor::trigger(EventId, EventValue) before it invokes
EventDescriptor::trigger(). Replace the direct Ext-to-Desc trigger interaction
while preserving the existing descriptor activation and debounce state notes.
- Around line 92-110: Update the README state-machine diagram so OneShot
transitions from Debounce to an idle/disarmed state rather than terminal [*],
allowing a later trigger() to begin a new cycle. Add the missing Debounce
transition for Interval mode with delay == 0, showing an immediate changed-value
send followed by entry into Heartbeat.
- Around line 253-255: Update the README lifecycle description for
registerDescriptor() and emitInitialSnapshot() to call assert() a debug-time
precondition rather than production enforcement, or add an always-on runtime
guard in the corresponding implementation paths. Ensure post-start calls cannot
mutate the descriptor collection while the supervisor iterates it.
🪄 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: b1d9e818-4d05-4761-ab8e-5140a4f43321

📥 Commits

Reviewing files that changed from the base of the PR and between 60a56bc and 6f246b3.

📒 Files selected for processing (1)
  • README.md

Comment thread README.md
Comment on lines +92 to +110
Debounce --> Debounce : trigger()\n(delay > 0: re-arm timer)
Debounce --> Debounce : tick() before ArmedAt elapses\n(no-op)
Debounce --> Heartbeat : tick() at ArmedAt, mode=Interval\n(fireIfChangedLocked, then arm +interval)
Debounce --> [*] : tick() at ArmedAt, mode=OneShot\n(fireIfChangedLocked, then disarm)

Heartbeat --> Heartbeat : tick() at ArmedAt\n(unconditional resend, re-arm +interval)
Heartbeat --> Debounce : trigger()\n(delay > 0: re-arm timer, even from Heartbeat)
Heartbeat --> Heartbeat : trigger()\n(delay == 0: send if changed, stay in Heartbeat)

note right of Debounce
fireIfChangedLocked():
pending_ != image_ -> send, Raised++
pending_ == image_ -> Suppressed++
end note
```

Two shapes fall out of this one machine:
- **OneShot**: `Debounce -> [*]` — fires at most once per trigger cycle, then
goes idle (no heartbeat loop).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Align the state machine with the actual descriptor lifecycle.

Debounce -> [*] incorrectly makes OneShot terminal; the implementation only disarms the timer, so a later trigger() can begin another cycle. The diagram also omits the Interval, delay == 0 transition from Debounce to immediate send/Heartbeat.

🤖 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 `@README.md` around lines 92 - 110, Update the README state-machine diagram so
OneShot transitions from Debounce to an idle/disarmed state rather than terminal
[*], allowing a later trigger() to begin a new cycle. Add the missing Debounce
transition for Interval mode with delay == 0, showing an immediate changed-value
send followed by entry into Heartbeat.

Comment thread README.md
Comment on lines +181 to +188
participant Ext as External Thread\n(netlink callback)
participant Desc as EventDescriptor
participant Worker as Worker Thread
participant Sender as IEventSender

Ext->>Desc: trigger(true)
activate Desc
Note over Desc: pending_=true, Phase=Debounce\narm delay timer

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Route external triggers through EventSupervisor.

The actual API is EventSupervisor::trigger(EventId, EventValue), which finds the descriptor before invoking EventDescriptor::trigger(). Showing Ext->>Desc bypasses that routing and contradicts the component diagram; add a supervisor participant to the sequence.

🤖 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 `@README.md` around lines 181 - 188, Update the sequence diagram to add an
EventSupervisor participant and route the external trigger through
EventSupervisor::trigger(EventId, EventValue) before it invokes
EventDescriptor::trigger(). Replace the direct Ext-to-Desc trigger interaction
while preserving the existing descriptor activation and debounce state notes.

Comment thread README.md
Comment on lines +253 to +255
`registerDescriptor()` and `emitInitialSnapshot()` are only valid before
`start()` (enforced by `assert`) — this is what lets the supervisor iterate
its descriptor collection without a lock once running.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Do not describe the lifecycle guard as production enforcement.

assert() is disabled in release builds. A post-start() registration can therefore mutate the descriptor vector while the worker iterates it, so this is a precondition/debug check rather than an enforced runtime guarantee. Clarify the wording or add a release-mode guard in the implementation.

🤖 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 `@README.md` around lines 253 - 255, Update the README lifecycle description
for registerDescriptor() and emitInitialSnapshot() to call assert() a debug-time
precondition rather than production enforcement, or add an always-on runtime
guard in the corresponding implementation paths. Ensure post-start calls cannot
mutate the descriptor collection while the supervisor iterates it.

Copilot AI 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.

Pull request overview

This PR updates README.md to add Mermaid diagrams that explain the event system’s architecture and runtime behavior, helping readers understand how EventSupervisor, EventDescriptor, and IEventSender interact (including debounce + heartbeat semantics and the startup lifecycle).

Changes:

  • Added a component/architecture Mermaid graph under Core Concepts.
  • Added a Mermaid stateDiagram-v2 describing the descriptor Debounce/Heartbeat phase machine under Timing Behavior.
  • Added Mermaid sequence + lifecycle flow diagrams to illustrate thread-safety interactions and startup order.
Comments suppressed due to low confidence (2)

README.md:189

  • To match the real call flow, the external thread should invoke EventSupervisor::trigger(EventId, EventValue) and the supervisor should forward to the descriptor’s trigger(value) (the descriptor is not typically reachable by external threads).
    Ext->>Desc: trigger(true)
    activate Desc
    Note over Desc: pending_=true, Phase=Debounce\narm delay timer
    deactivate Desc

README.md:194

  • Same as above: show EventSupervisor::trigger(id, value) dispatching to the descriptor, rather than the external thread calling the descriptor directly.
    Ext->>Desc: trigger(false)  (cable flap, within delay)
    activate Desc
    Note over Desc: pending_=false, Phase=Debounce\nre-arm delay timer
    deactivate Desc

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md

Netlink -- "trigger(EventId, EventValue)" --> Supervisor
NtpClient -- "trigger(EventId, EventValue)" --> Supervisor
Supervisor -- "owns 1..32" --> Descriptor
Comment thread README.md
Comment on lines +181 to +184
participant Ext as External Thread\n(netlink callback)
participant Desc as EventDescriptor
participant Worker as Worker Thread
participant Sender as IEventSender
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.

3 participants