Repository navigation
refactor(zalouser): compile blocks from CommonMark IR - #113590
Conversation
|
Codex review: found issues before merge. Reviewed July 25, 2026, 6:18 AM ET / 10:18 UTC. ClawSweeper reviewWhat this changesThe PR replaces ZaloUser’s local Markdown block scanner with CommonMark parser metadata so headings, lists, containers, indentation, and code blocks render from one shared interpretation. Merge readinessKeep this PR open: its runtime rendering proof and broad validation are strong, but the proposed ZaloUser formatter still depends on hidden parser fields that are deliberately absent from the public Markdown IR contract. Likely related people: steipete is the visible author of the parser/ZaloUser refactor sequence (medium confidence). Priority: P2 Review scores
Verification
How this fits together
flowchart LR
A[Markdown input] --> B[CommonMark parser]
B --> C[Markdown IR]
C --> D[Plugin SDK text chunking]
D --> E[ZaloUser formatter]
E --> F[Zalo native style ranges]
F --> G[Outbound Zalo message]
Decision needed
Why: The patch intentionally preserves the existing public Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +1672, Tests +935. Total +2607 across 12 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the parser metadata owned by markdown-core, but expose ZaloUser’s required block/list view through an explicitly owned bundled-only facade or a deliberately approved typed SDK capability with focused contract coverage. Do we have a high-confidence way to reproduce the issue? Not applicable as a defect report: the supplied production formatter transcript demonstrates the intended after-change ZaloUser behavior, while the remaining concern is a code-boundary contract rather than a failing user scenario. Is this the best way to solve the issue? No. Replacing duplicate parsing is the right direction, but the local structural view of deliberately hidden metadata is not the narrowest maintainable boundary; use an owned facade or explicitly approved SDK capability. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against faaab9bd4819. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
3f3fcbb to
fa3d5e2
Compare
|
Addressed the latest ClawSweeper review on the corrected head:
The maintainer decision for this batch remains the shared CommonMark IR approach; there is no remaining product decision in the scoped behavior. |
|
ClawSweeper publisher exception for the final head
The last published substantive moves were not skipped silently: production Zalo formatter output is linked in the PR body, the bundled non-enumerable metadata coupling and lifecycle are documented at the type site, the public SDK/baseline widening was explicitly declined because it violates this batch's hard gates, and the false-positive storage/vector signal was explained. Since then, fresh full-branch autoreview found two real container regressions; both were fixed with focused tests, exact-head CI is green, the complete 13-shard channel matrix is green, full ZaloUser is green, and the final full-branch autoreview is clean. |
|
Merged via squash.
|
* refactor(zalouser): compile blocks from commonmark ir * refactor(markdown-core): keep block metadata internal * test(markdown-core): type hidden block metadata * refactor(zalouser): drop split-module leftovers * test(markdown-core): assert serialized metadata shape * refactor(zalouser): satisfy formatter lint contracts * refactor(zalouser): internalize source span helpers * fix(zalouser): preserve nested container semantics
* refactor(zalouser): compile blocks from commonmark ir * refactor(markdown-core): keep block metadata internal * test(markdown-core): type hidden block metadata * refactor(zalouser): drop split-module leftovers * test(markdown-core): assert serialized metadata shape * refactor(zalouser): satisfy formatter lint contracts * refactor(zalouser): internalize source span helpers * fix(zalouser): preserve nested container semantics
What Problem This Solves
ZaloUser still compiled headings, list/container ownership, indentation, and code blocks through a plugin-local scanner after emphasis had moved to the shared CommonMark parser. That duplicated parsing policy and diverged on deep, loose, wide-marker, lazy-continuation, and marker-only lists.
Why This Change Was Made
This extends
packages/markdown-corewith generic parser-owned block metadata: code origin/closure, container depth, heading ownership, and list marker/content source spans. The metadata is optional and non-enumerable, so the existing publicMarkdownIRtype, API manifest, serialized IR shape, transcript bytes, and current channel consumers remain unchanged.ZaloUser now consumes that shared metadata and keeps only transport concerns locally: zca
RANGEemission,lst_1/lst_2/ind_$encoding, Bold+Big heading mapping, and NBSP conversion. The old plugin-local list/fence/heading scanner and NBSP-list fallback path are deleted.The upstream zca-js style contract was checked at pinned commit
9479746040524a805cf5e9d4f5a5a8156384d3a7.User Impact
ZaloUser now follows shared CommonMark deep/loose list ownership. The authorized rendering changes are fully enumerated by golden before/after cases:
- parent\n - child: NBSP-prefixed literal child marker -> nested native unordered list.1. parent\n 1. child: flat ordered child -> indented native ordered child.10. parent\n - child: NBSP-prefixed literal child marker -> ordered parent with nested native unordered child.- parent\n continuation: separately indented continuation -> continuation owned by the same native list range.- first\n\n continuation\n- next: loose continuation outside the first range -> continuation owned by the first native item.- parent\n - [ ] child: literal nested task marker -> indented checkbox fallback without a native bullet.A standalone top-level four-space list-looking line remains an indented code block. No config, environment, schema, protocol, transcript/model-input, or other channel output changes are introduced.
Evidence
LOC (
git diff --numstat origin/main...HEAD): production+2227/-555; tests+1108/-173; total+3335/-728across 12 files. This capability batch is intentionally net-positive under the markdown-unification clean-architecture exception; it removes the old Zalo scanner path and adds shared generic metadata plus exhaustive golden coverage.73e272788c7500805746d3bbb2ec889773fb0d23: Blacksmith Testboxtbx_01kycc47ghy5z6j91dk63mjtzbpassed the complete markdown-core suite (223 tests), all 13 cross-channel formatter/chunking shards, and the full ZaloUser suite (26 files / 269 tests) in run 30154038529.node scripts/run-vitest.mjs packages/markdown-core/srcplusnode scripts/run-vitest.mjs packages/markdown-core/src/ir.block-metadata.test.ts: 22 files, 223 tests passed.node scripts/run-vitest.mjs extensions/zalouser/src/text-styles.test.ts extensions/zalouser/src/text-styles-blocks.test.ts extensions/zalouser/src/text-styles-containers.test.ts packages/markdown-core/src/ir.block-metadata.test.ts: 104 tests passed after the fresh-main rebase.pnpm test extensions/zalouseron Blacksmith Testboxtbx_01kyc8181qt8t2hnwftfm3gxap: 26 files, 268 tests passed (run 30152066394).tbx_01kyc9gkj84e9sh8v5msctfgdd: directly importedextensions/zalouser/src/text-styles.ts(no test harness) and printed the six authorized runtime outputs, including nativelst_1/lst_2plus nestedind_$ranges (run 30152786812). The formatter is the complete touched runtime boundary; network delivery and zca authentication are unchanged.node scripts/run-vitest.mjs extensions/telegram/src/format.test.ts extensions/telegram/src/format.wrap-md.test.ts extensions/telegram/src/send.chunks.test.ts extensions/slack/src/format.test.ts extensions/signal/src/format.test.ts extensions/signal/src/format.chunking.test.ts extensions/matrix/src/matrix/format.test.ts extensions/discord/src/chunk.test.ts extensions/discord/src/draft-chunking.test.ts extensions/feishu/src/markdown.test.ts extensions/feishu/src/docx-markdown.test.ts extensions/feishu/src/media-chunk-idle.test.ts extensions/whatsapp/src/text-runtime.test.ts extensions/qqbot/src/engine/utils/format.test.ts extensions/qqbot/src/engine/messaging/markdown-table-chunking.test.ts extensions/imessage/src/markdown-format.test.ts extensions/line/src/markdown-to-line.test.ts extensions/googlechat/src/format.test.ts extensions/msteams/src/format.test.ts extensions/clickclack/src/outbound.test.ts extensions/nextcloud-talk/src/send.cfg-threading.test.ts extensions/nextcloud-talk/src/send.fetch-timeout.test.ts extensions/sms/src/send.test.ts extensions/zalouser/src/text-styles.test.ts extensions/zalouser/src/text-styles-blocks.test.ts extensions/zalouser/src/text-styles-containers.test.ts.node scripts/check-changed.mjson Blacksmith Testboxtbx_01kyc6v5q2tfpwnts05dwxndq3: all core/extension typecheck, lint, API-manifest, boundary, ratchet, and guard lanes passed (run 30151478133).pnpm deadcode:dependencies && pnpm deadcode:exportson Blacksmith Testboxtbx_01kyc94xbcfxjn4g7wn2h2brzx: all production/full-tree/script unused-export scans passed with 0 entries after removing two stale split-module exports (run 30152609340)..agents/skills/autoreview/scripts/autoreview --mode uncommitted: clean, no accepted/actionable findings; rerun after each review-triggered correction..agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main: clean on the complete final diff, no accepted/actionable findings.