Implementation sequence for Hermes modularization
Proposed work order, 21 November 2026. Start with the value returned by session routing, then separate capability decisions from hardware discovery. Work on ownership transfer only after a test can observe cleanup. Run the first mcpp experiment on the extracted routing component. That gives the reviewer separate evidence for the cost of changing the routing rules and the cost of building them.
The source reference for this plan is workstream commit 24f68ce. Its Build Hermes workflow succeeded using the existing build. All changes and trials below are proposals. The branch inventory and ownership review describe the implementation that exists today.
First three reviewable changes
| Change | Scope and caller | Evidence for review |
|---|---|---|
| 1. Characterize routing on the intended integration base. | Add cases around proc::resolve_session_route. Pin the expected result for primary, unknown methods/layouts, empty commands and explicit overrides. Record that HTTPS first checks permissions assuming a display may be requested, then evaluates the actual prepared launch. | Show each revision's expected result. With a default app method, requested virtual display, nonempty command and global gamescope, primary yields an isolated app on this workstream and a shared host on the pinned release line. Preserve the release expectation when integrating there. Existing route tests · Source comparison and call sites |
| 2. Extract the decision under the current build. | Keep the existing proc::resolve_session_route adapter and its default argument. Feed a small production unit the relevant app preferences, booleans and method. Return the existing route meaning. Keep Hestia preparation, permissions, config reads, launching and cleanup at their current call sites. | A focused target executes the decision using the pinned GoogleTest without linking RTSP, process management, capture or a compositor. The ordinary host and its GoogleTest binary still compile the adapter. Both HTTPS evaluations and the process profile chooser retain their inputs. Process API · Process profile selection · HTTPS launch |
| 3. Try mcpp on that exact revision. | Start with the conventional implementation under both tools. Then try one private named C++23 module with an implementation unit and a header-facing consumer. Build each variant in an isolated directory. The release package continues to use the established target. | Report clean install, implementation edit, public interface edit, failure diagnostics and editor navigation. Include both raw timings and dependency acquisition. Compare like-for-like compiler settings before comparing each tool's defaults. Experiment protocol · mcpp adoption options |
Changes 1 and 2 can be reviewed and integrated independently of change 3. Once routing is characterized, the build pilot and the following source work can progress on different reviews. If the module variant loses useful debug symbols or creates incompatible definitions, revert that variant and keep the tested extraction.
Next boundaries, in dependency order
1. Separate capability policy from live probes
Start with video::choose_capture_readiness_mode. Its four boolean inputs select a codec/mode or return no safe combination. Exercise SDR fallback, HEVC preference when both HDR codecs are available, AV1 fallback, and refusal when the client/output combination is unsafe. Keep encoder probing, last-result storage, logging and HTTP diagnostics with their present owners. A focused test should run without constructing an encoder. Verify the full host still calls the decision with the same observed capabilities. Decision and probe caller · Existing mode cases
Next consider VDISPLAY::assessSession(const SessionFacts&). The code already separates collecting compositor/driver facts from producing feature reports, although both live in the large virtual-display translation unit. Move the decision with the types that its callers actually need. Keep probeSessionFacts and all device access Linux-specific. Reuse the synthetic KWin, Mutter, wlroots and Hyprland cases. Compare feature IDs, readiness, explanations and remediation text because they reach diagnostics. A protocol being present in a fixture establishes policy behavior. It takes a live session to establish that a compositor actually drives an output. Facts and report types · Probe and assessment · Assessment cases
2. Characterize pending launch ownership before changing it
A pending launch can expire, lose a cancellation race, collide with another pending launch, or hand a display over to an active stream. Write a deterministic test around these transitions before moving the cleanup code. Observe the identity of the resource released, the operation performed and how often it runs. Keep the existing locking order. RTSP lifecycle · Launch flags and mutex · Stream allocation/destruction
| Scenario for the characterization | Observable invariant |
|---|---|
| A second launch arrives while one is pending. | Refusal cleans the incoming launch's pending resources. The original launch retains its resources and can still complete. |
| Timeout or successful cancellation wins before ANNOUNCE. | The pending owner releases its resource once. An ANNOUNCE on an already-cancelled launch cannot start it. |
| ANNOUNCE allocates a stream and start subsequently fails. | Allocation has cleared pending cleanup. The stream removal/destruction path deals with the transferred resource. Releasing it a second time from RTSP is a failure. |
| A client disconnects from an isolated session and reconnects. | Where session policy permits resume, disconnect preserves the runtime, its seat and the client's identity. Explicit termination still tears down the correct runtime. |
The first implementation change here should cover one handoff, with enough instrumentation in the test to catch double release. Keep wire response codes, retry timing and the difference between shared displays and isolated runtimes under characterization. Leave registry reorganization for a separate review if the handoff still exposes an ownership problem. Process teardown · HTTPS cancellation
3. Narrow platform interfaces one consumer at a time
| Area | First bounded change | Proof before expanding |
|---|---|---|
| Display layout and input geometry | Pass the existing logical geometry and session/output identity across the capture-to-input boundary. Keep compositor-specific mode application on its current side. | Exercise rotated heads, fractional/scaled coordinates as applicable, a negative desktop origin, two outputs, and a reconnect. Use the headless Wayland geometry tests. Then change only the compositor on the same distro/GPU to isolate live differences. Geometry cases · Input consumer |
| Session broker, input and audio | Keep the broker executable and its socket protocol separate. Reuse the existing deadline-bounded transport. Treat seat access and the session audio server as runtime-owned resources. | Check partial replies and timeouts with the broker fixture. Exercise two isolated audio graphs, resume, teardown and host-device preservation on the private-audio workflow. Broker transport · Broker cases · Audio cases |
| Config and Hestia protocol | Expose the few resolved options a consumer needs while preserving stored keys, defaults, migrations and client-visible JSON. Leave serialization at the existing boundary. | Run the capability schema checks and config consistency suite. The latter scans src/config.cpp with regular expressions and compares it with UI/docs/locales. If parsing moves, make the check inspect the new source of truth and demonstrate that it still catches a missing option. Schema check · Config consistency |
These areas can be picked according to whichever callers are actively changing on the integration branch. There is no requirement to create a library or a C++ named module for every row. An existing interface with a clear owner and a focused test can already serve the purpose.
4. Tackle frame ownership and encoders with hardware evidence
Begin with one Hermes-KMS frame on the GPU descriptor path. Trace the producer's sequence, plane FDs, pitches, offsets, modifier, color metadata and sync-file through acquisition, fence handling, import and cleanup. In the current success path the image descriptor receives the plane FDs, the source slots are cleared, and closing the frame releases the fence and any surplus FDs. Compare that with timeout, failed fence and rejected layout. A proposed owner must preserve all of those outcomes, including recycling, without adding a wait, allocation or copy per frame. Frame contract · Descriptor transfer and error paths
Test a known Hermes-KMS/AMD VAAPI setup first if available. Repeat on another compositor on the same machine before changing distros, then qualify Intel VAAPI, NVIDIA NVENC and the EVDI/software paths affected by the change. Keep the codec, scene, mode and driver fixed for each before/after pair. Record unsupported and untested combinations individually. A successful software fallback can keep a stream playable while hiding a GPU import regression, so record the selected encoder and actual transfer path. Compatibility record · Encoder orchestration
Use the existing /api/metrics rolling capture-to-encode and encode averages and frame/drop counters as a first comparison. Those averages cannot establish p95/p99 or zero-copy. Use a per-frame trace for tail latency and import/copy evidence for the path taken, or mark those measurements unavailable. For a sensitive change, also exercise repeated stop/resume and check for growth in open FDs and memory. Published metric fields · Metrics handler
How a change lands
- Architectural changes. Compare the target base immediately before integration. Record the caller that lost a dependency, the owner of the resource, and the test that would fail if the old mistake returned. Bring back one self-contained change at a time. A changing release branch is a reason to re-run characterization, especially for routing and display layouts.
- Language and tool changes. Trial one compiler or language feature at a time on a target that benefits. Retain C++23 for the initial host pilot and the existing standards of helpers and CUDA. If a C++26 feature or newer toolchain solves a named problem, compare it in its own experiment. A reviewer should be able to accept the extracted component while deferring that toolchain choice.
- Adoption and rollback. Scope the result explicitly to contributor builds, host compilation, or shipped packages. Record the tested revision, maintainer willing to support it, open distro/hardware gaps and how to reproduce the reference build. Keep the shared production source and tests when retiring an experimental manifest. Qualify a release-tool switch through the package and runtime plan before retiring the reference path.
For the next review, the smallest useful deliverable is the routing characterization, including the integration base's primary expectation. Its result gives both the architecture work and Usman's build proposal the same starting point.