Skip to content

fix(renderer): classify and format authoring failures at their source - #396

Merged
tt-a1i merged 5 commits into
devfrom
codex/legacy-render-diagnostics
Sep 16, 2026
Merged

tt-a1i merged 5 commits into
devfrom
codex/legacy-render-diagnostics

Conversation

@tt-a1i

@tt-a1i tt-a1i commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

Problem and behavior

A missing input, invalid JSON, or failed output write can produce a raw Node stack or be classified under the wrong operation. Classify expected filesystem failures at the read/write boundary and syntax errors around JSON.parse. Human-mode errors show their diagnostic code and supported repair. Unexpected implementation exceptions keep their stack and exit 1; an earlier layout diagnostic cannot disguise a later unrelated exception.

Scope and integration

The shared path serves all five renderers, including public CLI and direct renderer scripts. This revision integrates current dev, retains #418's import-safe boundary installation inside loadDiagram, and preserves #374's complete synchronous JSON stderr transport. No schema, geometry, Viewer, success stdout, or receipt-shape change. Rendering still writes directly; transactional preservation remains the deliver command's responsibility.

Validation

Candidate 935a768, based on dev e1c27ee; local macOS with official Node 22.23.2:

  • 93 focused tests passed, zero failed/skipped: render-failure diagnostics, renderer import isolation, workflow compiler call contract, renderer diagnostic boundary, CLI, and output-path types.
  • The same fixed inputs in architecture, workflow, sequence, dataflow, and lifecycle produce byte-identical HTML before and after this change, using the integrated maintenance source at da85751 as the dev-equivalent baseline.
  • Rebuilt canonical archify.zip from the merged source; git diff --check passed.
  • Full hosted CI must pass on this updated head. Historical results on the earlier draft are not current-head validation.

Visual review is not required for this failure-reporting change; the successful five-mode output comparison is byte-identical. Existing regressions cover filesystem operation classification, empty or unrelated diagnostic metadata, unexpected implementation errors, human/JSON modes, and the standalone doctor boundary.

@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 598b616c-1885-416d-8dde-f2471e6c5885

📥 Commits

Reviewing files that changed from the base of the PR and between e1c27ee and 935a768.

⛔ Files ignored due to path filters (1)
  • archify.zip is excluded by !**/*.zip
📒 Files selected for processing (5)
  • CHANGELOG.md
  • archify/references/delivery-contract.md
  • archify/renderers/shared/cli.mjs
  • archify/renderers/shared/diagnostics.mjs
  • archify/test/render-failure-diagnostics.test.mjs

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


📝 Summary

Renderer failures now classify filesystem and JSON errors at read/write boundaries. Human output includes diagnostic codes and repair guidance, while unexpected exceptions preserve debugging information. Prior layout diagnostics no longer mask later internal failures, and output classification requires confirmed filesystem errors.

The shared behavior covers the CLI and five direct renderers. Success output, schemas, geometry, receipts, and writes remain unchanged. Reviewed base/head, author-reported validation, reused evidence revisions, and checked CI revision are not supplied, so revision-specific status cannot be verified. The supplied report states 93 focused tests passed, but does not establish browser or perceptual acceptance.

Walkthrough

The renderer now classifies input read, JSON parse, output filesystem, schema, and layout failures. Human mode formats classified diagnostics without Node stacks. Unclassified implementation errors retain native debugging details. Machine receipts continue through validate --json and deliver --json. New tests cover CLI and direct renderer behavior, output preservation, successful artifact parity, diagnostic ordering, and formatter parity.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 935a7

The renderer diagnostic changes preserve classified authoring failures and native unexpected-error debugging behavior without a supported merge-blocking risk.

🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Contribution Scope ⚠️ Warning The PR is focused and explains the user problem, intended behavior, compatibility impact, and failure/rollback behavior. The implementation matches that scope: it changes shared renderer diagnostics, … Link the issue that authorizes the new renderer failure contract, or record a maintainer scope decision. Keep the decision specific to the new input/read, input/json-parse, and output/write behavior and its compatibility boundaries.
✅ Passed checks (1 passed)
Check name Status Explanation
Validation Evidence ✅ Passed Evidence coverage is sufficient for reviewed head 935a768, against base e1c27ee. The added regression suite covers all five renderers, public and direct entry points, input read/JSON parse, output wri…
Full details: Contribution Scope

Explanation

The PR is focused and explains the user problem, intended behavior, compatibility impact, and failure/rollback behavior. The implementation matches that scope: it changes shared renderer diagnostics, adds focused regression tests, updates the delivery contract, changelog, and generated archive. However, the PR adds a new command-level failure contract in archify/references/delivery-contract.md and introduces the corresponding user-visible behavior without linking an issue or recording a maintainer scope decision for that contract. The description references #418 and #374 for integration details, but neither reference establishes scope for this new failure 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.

@sunsunsun-java

Copy link
Copy Markdown
Collaborator

审核中发现两个错误分类边界还需要处理:

1. 真正的程序错误可能被前面的诊断掩盖

如果渲染过程中先记录了一个布局问题,随后代码本身又发生意外异常,当前 JSON receipt 只会显示前面的布局问题,看不到真正导致程序失败的内部错误。

这样用户可能会一直修改图表,但实际上需要修复的是程序代码。

建议调整为:只有最终抛出的异常本身带有明确诊断时,才使用已记录的诊断;否则应报告 internal/unclassified,保留真正的内部错误。

2. 部分程序错误会被误报成“输出路径不可写”

现在只要异常带有字符串形式的 code,throwOutputError() 就会把它归类为 output/write。但 Node 自身的一些程序错误也有 code,例如参数类型错误。

例如 outPath 意外变成 undefined 时,本来应该显示程序堆栈,当前却会告诉用户“请选择可写的 HTML 路径”。这个建议与真正原因无关,也会隐藏实现缺陷。

建议只把确定来自文件系统操作的异常归类为 output/write,例如检查 syscall 或 errno;其他异常继续保留原始堆栈。

非阻塞建议

diagnostics.mjs 新增的 formatDiagnostics() 与 CLI 中已有的实现基本相同。以后修改其中一处时,两边的输出格式可能不一致。

这项不阻塞当前修复。如果不方便抽成共享模块,建议至少增加一致性测试,同时继续保证 doctor 在 renderer 文件缺失时仍能正常启动。

本地聚焦回归 31/31 通过,GitHub 最终头提交的 Node 18/20/22/24、三平台包冒烟和 ZIP 新鲜度检查也均通过;上面两个问题属于当前测试没有覆盖到的异常组合。

NaCr05 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Hi @tt-a1i — following up on the workflow library proposal in #222 to coordinate the diagnostic entrypoint.

At 80187faf511740005c8982e4a2514f132e08e40b, shared/cli.mjs still installs the process-level boundary at module initialization, and the workflow compiler imports that module for SVG helpers. The new human-mode handler makes it especially useful to keep installation explicit for CLI use before adding an in-process library entrypoint.

Would you prefer moving installation into loadDiagram() (or an explicit CLI bootstrap) here, or handling that as a small preparatory follow-up after #396 lands? I can take the follow-up and host-isolation regressions while preserving this PR's input/output error classification. The stderr transport work in #351/#374 would remain separate.

I have a private experiment on a07fa1d5 that moves initialization into the loader and preserves the five renderers' successful output and tested failure diagnostics; its results and limitations are in the linked comment. I have not tested that change against this PR's head yet. The broader workflow adapter remains subject to agreement with you and joesaby in #222.

NaCr05 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Hi @tt-a1i — #418 is now synchronized with main d15010a at 8ae0d45. The PR still contains only the import-isolation fix, its two test files, and the ZIP; its diff against current main is byte-for-byte identical to the previously validated patch.

I propose landing #418 first, then updating #396 on top. The import-side-effect fix is independently useful and does not change this PR's error classifications. When updating #396, please preserve boundary installation at the start of loadDiagram(); the two standalone diagnostic probes in render-failure-diagnostics.test.mjs need to call installRendererDiagnosticBoundary() explicitly because they bypass the loader. Their assertions can stay intact. The combined ZIP should then be rebuilt and #396's checks rerun.

The earlier local rehearsal against your unchanged head 80187fa, with those two probe adaptations, passed 28 targeted checks. That remains historical compatibility evidence, not a full test of #396 merged with today's main. For the synchronized #418 head, Linux Node 22.23.2 full tests pass: 1333 passed, 0 failed, 48 skipped; ZIP freshness also passes. New-head CI is running.

Does this order work for you, or would you prefer #396 first? If #396 should land first, I can adapt #418 afterward, including the explicit probe initialization. #418 remains Draft pending that coordination.

…gration

# Conflicts:
#	CHANGELOG.md
#	archify.zip
#	archify/renderers/shared/diagnostics.mjs
@tt-a1i
tt-a1i marked this pull request as ready for review September 16, 2026 16:04
@tt-a1i
tt-a1i merged commit 5d1014e into dev Sep 16, 2026
13 checks passed
@tt-a1i
tt-a1i deleted the codex/legacy-render-diagnostics branch September 17, 2026 09:24
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