Skip to content

refactor(runtime-host): extract Peer Mesh control message codecs - #5006

Open
Totoro-qaq wants to merge 1 commit into
apache:mainfrom
Totoro-qaq:codex/refactor-peer-mesh-control-protocol
Open

refactor(runtime-host): extract Peer Mesh control message codecs#5006
Totoro-qaq wants to merge 1 commit into
apache:mainfrom
Totoro-qaq:codex/refactor-peer-mesh-control-protocol

Conversation

@Totoro-qaq

Copy link
Copy Markdown
Contributor

Summary

Separate Peer Mesh control-message types and object decoding from node lifecycle orchestration. The internal codec owns the five decoder entry points and their bounds, while node retains stream framing, timeouts, connection admission and state changes. Existing signed-record decoders are reused, and pagination and decoding share one evidence-page limit.

peer-mesh/node.ts shrinks from 3,103 to 2,835 lines. The new codec is 317 lines, so aggregate production code increases by 49 lines for module headers/imports. The result is an independently testable boundary in a large module, not a net deletion or performance improvement. Public package exports and wire formats are unchanged.

Fixes #5005

Refs #4726, A9.

Verification

Local macOS verification with Node 24.18.0 and npm 11.19.0:

  • Original Peer Mesh suite: 28/28 on baseline and candidate; existing test source unchanged. New codec tests: 9/9. All are included in the full Host result below.
  • Ten deliberate mutations were detected: one for each new test group, plus an existing public node join test with a removed response-decoder implementation. Candidate compiled output was restored byte-for-byte and the focused tests passed again.
  • AST equivalence: all 24 moved declarations and all retained node declarations are unchanged apart from module exports/source metadata; node.d.ts is byte-identical. No new package export or dependency cycle is introduced.
  • Full Runtime Host suite: 1,818 passed, 12 skipped, 0 failed or cancelled.
  • Full build, typecheck, lint, format, Desktop/UI knip, renderer architecture, staged ASF/header/protocol checks and diff checks pass. Staged checks used a temporary index containing the exact three-file patch.

Not run: other workspace test suites, a Windows execution matrix, or a multi-host native Peer Mesh deployment. The existing Peer Mesh integration tests use their original in-memory transport and real cryptographic helpers.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex inspected the existing seam, extracted the implementation, added boundary tests, ran local equivalence and regression checks, and prepared these drafts. DSH performed a separate read-only source review and ran the codec tests. Submitted with contributor approval; upstream review is pending.

Checklist

  • Tests cover the change and fail without the implementation they exercise
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Move control-message types, decoders and their validation helpers into a
package-internal module. Share the evidence page limit with node while
preserving framing, admission, lifecycle and existing signed-record checks.

Keep the extracted declarations and public node declarations equivalent.
Add codec boundary tests and retain the original Peer Mesh integration suite.

Refs: apache#4726
Generated-by: Codex
@github-actions github-actions Bot added the effort/L Under 1000 readable lines label Sep 8, 2026
@Totoro-qaq

Copy link
Copy Markdown
Contributor Author

@Astro-Han Could you take a look when you have a chance? This extracts the Peer Mesh control message codecs into peer-mesh/control-protocol.ts (#5005): pure refactor, no wire-format change, 12/12 CI checks green at 285a700f, and it still merges cleanly against current main (34 commits ahead, no overlapping files). Happy to rebase onto a fresh head if you'd prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/L Under 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(runtime-host): extract Peer Mesh control message codecs

1 participant