Skip to content

refactor(protocol): clarify child parsing ownership - #1436

Merged
jlucaso1 merged 2 commits into
mainfrom
refactor/protocol-node-child-contract
Sep 5, 2026
Merged

refactor(protocol): clarify child parsing ownership#1436
jlucaso1 merged 2 commits into
mainfrom
refactor/protocol-node-child-contract

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

The protocol architecture documentation described ProtocolNode as if the derive supported child fields, while the derive only accepts attributes. This patch records the actual boundary and why child-bearing nodes remain explicit.

Evidence/Design

The trait supports nodes with attributes and children. The derive generates attribute-only implementations; 16 concrete implementations in the IQ layer parse children manually through borrowed NodeRef helpers, making required/optional, repeated, ordering, duplicate and error behavior visible. No macro syntax or protocol implementation was added, and no IQ was migrated.

Cost

No runtime or generated-code cost. The documentation and one derive rustdoc comment add no executable code.

Validation

cargo fmt --all passed.
cargo test -p wacore-derive passed: 0 unit tests, 3 ignored doctests.
cargo check -p wacore --lib passed.
cargo nextest run -p wacore --lib and wacore-binary were not rerun because this patch changes no implementation; the unchanged baseline suites are outside the affected contract.

Migration: none. Existing derive users and manual child parsers keep the same API and borrowed parsing behavior.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T01:09:35.738035Z 0db12fa New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Team

Run ID: e9f4eea7-bd11-4dc6-a896-66be6261433d

📥 Commits

Reviewing files that changed from the base of the PR and between 9ed4383 and 0db12fa.

📒 Files selected for processing (2)
  • agent_docs/protocol_architecture.md
  • wacore/derive/src/lib.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Team

Run ID: 0cc7bf98-c66a-4ea6-abe2-abc96d592a5a

📥 Commits

Reviewing files that changed from the base of the PR and between 0aa87c6 and 9ed4383.

📒 Files selected for processing (2)
  • agent_docs/protocol_architecture.md
  • wacore/derive/src/lib.rs

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Documentation
    • Clarified that ProtocolNode derive support currently applies only to attribute-only nodes.
    • Documented that nodes with child fields use explicit implementations to preserve visibility into presence, repetition, ordering, duplicate handling, and parse errors.
    • Updated the derive reference table and macro documentation accordingly.

Walkthrough

The PR documents that ProtocolNode derive support is attribute-only. It explains why nodes with children use explicit implementations and shared parsing helpers.

Changes

ProtocolNode documentation

Layer / File(s) Summary
Document derive scope
agent_docs/protocol_architecture.md, wacore/derive/src/lib.rs
The documentation states that child fields are not supported by the derive. It directs child-bearing nodes to explicit implementations and shared parsing helpers.

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

Merge Risk: ⚪ Minimal · up to 9ed43

This change documents the attribute-only scope of ProtocolNode derive and the explicit parsing model for child-bearing nodes. It does not alter protocol behavior or runtime code and is ready to merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: clarifying ownership of child parsing in the protocol implementation.
Description check ✅ Passed The description accurately explains the documentation-only change, the derive boundary, the explicit child parsing design, and validation results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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 refactor/protocol-node-child-contract

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.

@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown

Greptile Summary

Clarifies the ownership boundary between the ProtocolNode trait and derive macro:

  • Documents that the trait supports attributes and children while the derive remains attribute-only.
  • States that child-bearing nodes retain explicit implementations.
  • Consolidates the detailed rationale into the derive rustdoc to avoid duplicating it across documentation.

Confidence Score: 5/5

The documentation-only changes appear safe to merge, with no outstanding actionable findings.

The previously duplicated rationale now has a single location in the derive rustdoc, while the architecture guide retains only the capability boundary. The other two prior threads were manually resolved without explanation.

Important Files Changed

Filename Overview
agent_docs/protocol_architecture.md Corrects the derive capability table and removes duplicated child-parsing rationale.
wacore/derive/src/lib.rs Documents the derive's attribute-only boundary and centralizes the rationale for explicit child parsing.

Reviews (3): Last reviewed commit: "docs(protocol): clarify child node deriv..." | Re-trigger Greptile

Comment thread agent_docs/protocol_architecture.md Outdated
Comment thread wacore/derive/src/lib.rs Outdated
@codspeed-hq

codspeed-hq Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 8.14%

⚠️ 1 benchmark measured no execution time

Nothing ran under measurement, usually because the compiler removed the code under test. This result is not comparable, so it counts as unchanged.

Preventing compiler optimizations

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 785 untouched benchmarks
⏩ 12 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation sweep_idle_no_ttl[512] 2.2 µs 2 µs +8.14%
⚠️ Simulation bench_jid_push_phash_form < 1 ns < 1 ns N/A

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing refactor/protocol-node-child-contract (0db12fa) with main (bf0fc76)2

Open in CodSpeed

Footnotes

  1. 12 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (ccafa13) during the generation of this report, so bf0fc76 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

📦 Binary size report

Metric main PR Δ
bin size (stripped) 10.46 MiB 10.46 MiB 0
bin .text 8.41 MiB 8.41 MiB 0
bin allocated (text+data+bss) 10.46 MiB 10.46 MiB 0
llvm-lines wacore 575,305 575,305 0
llvm-lines wacore copies 18,850 18,850 0
llvm-lines whatsapp-rust lib 827,702 827,702 0
llvm-lines whatsapp-rust lib copies 26,577 26,577 0
deps crates (Cargo.lock) 468 468 0
.text per crate
Crate main PR Δ
.text whatsapp_rust 1.98 MiB 1.97 MiB -4.96 KiB (-0.24%) 🔽
.text wacore 757.49 KiB 756.89 KiB -615 B (-0.08%) 🔽
.text wacore_binary 84.13 KiB 84.13 KiB 0
.text wacore_libsignal 191.09 KiB 191.09 KiB 0
.text wacore_appstate 28.34 KiB 28.34 KiB 0
.text wacore_noise 21.48 KiB 21.48 KiB 0
.text waproto 1.74 MiB 1.74 MiB 0
.text whatsapp_rust_sqlite_storage 588.04 KiB 588.04 KiB 0
.text whatsapp_rust_tokio_transport 40.52 KiB 40.52 KiB 0
.text whatsapp_rust_ureq_http_client 12.68 KiB 12.68 KiB 0
.text std 1.02 MiB 1.02 MiB 0
.text other deps 1.95 MiB 1.95 MiB +5.56 KiB (+0.28%) 🔺
Top movers (cargo-bloat attribution)
Crate main PR Δ
whatsapp_rust 1.98 MiB 1.97 MiB -4.96 KiB (-0.24%)
metrics_exporter_prometheus (absent) 4.96 KiB +4.96 KiB

Baseline: ccafa1323 (latest main run) · Head: e792d14f8 · Graphs

@jlucaso1
jlucaso1 force-pushed the refactor/protocol-node-child-contract branch from 9ed4383 to 3791e32 Compare September 5, 2026 00:32
Comment thread wacore/derive/src/lib.rs
Comment on lines +36 to +40
/// Child fields are intentionally not accepted by this derive. Child
/// cardinality and duplicate handling differ across protocol responses, so
/// child-bearing nodes use an explicit implementation, optionally reusing the
/// shared parsing helpers, instead of hiding those decisions in generated code.
///

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Duplicated design rationale

This rustdoc repeats the child-cardinality and duplicate-handling rationale already recorded in protocol_architecture.md. The repository requires a decision's rationale to live at a single point so that duplicated explanations do not drift. Keep the capability boundary here, but consolidate the detailed rationale before merging.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: wacore/derive/src/lib.rs
Line: 36-40

Comment:
**Duplicated design rationale**

This rustdoc repeats the child-cardinality and duplicate-handling rationale already recorded in `protocol_architecture.md`. The repository requires a decision's rationale to live at a single point so that duplicated explanations do not drift. Keep the capability boundary here, but consolidate the detailed rationale before merging.

**Context Used:** AGENTS.md ([source](https://github.com/oxidezap/whatsapp-rust/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3791e3261f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread wacore/derive/src/lib.rs
Comment on lines +36 to +39
/// Child fields are intentionally not accepted by this derive. Child
/// cardinality and duplicate handling differ across protocol responses, so
/// child-bearing nodes use an explicit implementation, optionally reusing the
/// shared parsing helpers, instead of hiding those decisions in generated code.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep the child-parsing rationale in one place

This repeats the rationale already added in agent_docs/protocol_architecture.md lines 9–11, even though AGENTS.md requires a decision's “why” to live at a single point so it cannot go stale. Keep the support boundary in both places if useful, but retain the cardinality/duplicate-policy explanation in only one and reference it from the other.

AGENTS.md reference: AGENTS.md:L47-L47

Useful? React with 👍 / 👎.

Comment thread agent_docs/protocol_architecture.md Outdated
| --- | --- |
| `EmptyNode` | Nodes that are only a tag |
| `ProtocolNode` | Nodes with attributes and children |
| `ProtocolNode` | Nodes with attributes and children; derive support is currently attribute-only |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove children from the derive's advertised use

The table's For column still says the ProtocolNode derive is for nodes with children, while the same cell's qualifier and the newly added macro documentation say child fields are unsupported. Because this architecture guide is the repository-designated reference for choosing stanza derives, the contradictory entry can still send implementers toward a derive that will not compile for their child fields; describe it as attribute-only and discuss the broader trait separately.

AGENTS.md reference: AGENTS.md:L53-L56

Useful? React with 👍 / 👎.

Describe the broad ProtocolNode trait separately from the attribute-only derive, and keep the child implementation guidance factual without repeating macro rationale.
@jlucaso1
jlucaso1 merged commit be35168 into main Sep 5, 2026
38 of 39 checks passed
@jlucaso1
jlucaso1 deleted the refactor/protocol-node-child-contract branch September 5, 2026 02:15
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