feat(jupyter,quarto-core): cell-options facility + error policy (bd-ohvl879u)#363
Merged
Merged
Conversation
…ailing cell aborts the render unless error: true (bd-ohvl879u) Add quarto-core/src/cell_options: language-aware `#|` option-block partitioning (Q1 kLangCommentChars registry) with exact source attribution (SourceInfo::concat of per-line substrings into quarto-yaml), plus scoped resolution: cell options merge over the document's execute metadata via ConfigValue (cell wins). The jupyter engine now consumes it: option lines are stripped from kernel input and echo (Q1/knitr parity), and a raising cell fails the render with an original-file-located diagnostic unless the cell (#| error: true) or the document (execute: error: true) allows it — closing the error-policy divergence with knitr. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #360 (bd-gthycd33). Fixes bd-ohvl879u: q2's jupyter engine unconditionally embedded a failing cell's error as
.cell-output-erroroutput and reported success, while knitr fails the whole render (Q1's defaultexecute: error: falsepolicy). The fix rides on a new shared cell-options facility — the design center of this PR.The facility:
quarto-core/src/cell_options/q2's single implementation of identifying and extracting the
#|-style YAML options block at the head of an executable code cell (Q1 grew four divergent copies; q2 had two partial ad-hoc ones — the crossref shorthand's string matcher and the LSP's highlight-onlydirective_tokens):kLangCommentChars:#|for python/R,--|for lua/sql,//|for js/rust,%|matlab, block-comment forms (/*| … */for C,(*| … *)OCaml,*| … ;SAS); unknown →#.partition-cell-options.ts: leading-run only, column-0 anchored,prefix + ws + | + one optional space, suffix required+elided for block-comment languages.SourceInfo::concatof per-line substrings; for prefix-only languages the ranges run through each line's newline, so every byte of the reassembled YAML is a real source byte —map_offseton any parsed node resolves exactly. Parsed withquarto_yaml::parse_with_parent.ConfigValue(pampa::yaml_to_config_value) and merge over the document's already-mergedexecutemetadata (MergedConfig, cell wins) — the start of scoped document-metadata resolution in cell options, a longstanding Q1 limitation.The engine consumer
text_execute.rsnow partitions each cell and:.cell-code(Q1/knitr parity — verified empirically that knitr strips them; cell magics would otherwise break);error:via the scoped merge: per-cell#| error: true⇒ embed error output; documentexecute: error: true⇒ default-allow; cellerror: falseoverrides a document allow; absent everywhere ⇒ the render fails (knitr/Q1 parity), halting before later cells run;Diagnostics resolve to original-file coordinates through
ExecutionContext.source_info(no new plumbing needed), e.g.:Tests
engine_error_policy.rs: 7 kernel-gated integration tests covering the full policy matrix.engine_output_parity.rsgains a behavioral parity case (both engines must fail identically on un-annotated errors); all bd-gthycd33 fences unchanged and green.cargo xtask verifypassed; clippy/lint/fmt clean.q2 render), plus aq2 previewbrowser spot-check (directive-bearing healthy cell: stripped echo, spliced output) after the full WASM chain rebuild.Follow-ups filed (discovered-from bd-ohvl879u): bd-eizgnxlx (migrate crossref shorthand to the facility), bd-1gty7f7o (LSP reuse), bd-2xkpy5ra (body-only
CodeBlockSourceInfo), bd-moef1ec4 (evaloption), bd-2lc8qu6e (guessChunkOptionsFormat).Plan with full evidence:
claude-notes/plans/2026-07-02-bd-ohvl879u-cell-options-error-policy.md.🤖 Generated with Claude Code