Skip to content

Parse Yaml compact nested sequences and multiline quoted flow scalars - #10279

Closed
effect-bot wants to merge 5 commits into
agent/nelson-effect-bot/eff-3232-stage3-hardeningfrom
agent/nelson-effect-bot/eff-3232-stage4-grammar
Closed

effect-bot wants to merge 5 commits into
agent/nelson-effect-bot/eff-3232-stage3-hardeningfrom
agent/nelson-effect-bot/eff-3232-stage4-grammar

Conversation

@effect-bot

@effect-bot effect-bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Stage 4 of the YAML expansion adds two pieces of YAML grammar that Yaml.parse used to reject.

Behavior

  • Compact nested sequences (YAML 1.2.2 §8.2.1). A sequence entry can start another sequence on the same line (- - 1), nested to any depth up to the existing 1000-level limit. The nested sequence is indented to its first dash, so - - 1 also works. An entry inside it can itself be a compact mapping, an anchor or alias, a flow collection or a block scalar. A dash on a more indented continuation line is still part of a plain scalar (- - 1 followed by - 2 gives [["1 - 2"]]), and a less indented entry still fails.

  • Multiline quoted scalars in flow collections (YAML 1.2.2 §7.3). Single- and double-quoted items and keys inside [...] and {...} can span lines. They fold the same way as quoted block values:

    • blank lines become line breaks
    • an escaped line break joins the lines
    • spaces and tabs around a line break are dropped
    • a # inside the quotes is content

    A continuation at the parent's indentation, or across a document marker, still fails. The scan continues from where it stopped, so long scalars stay linear: 16,000 continuation lines take about 44 ms.

  • key: - value fails. A block sequence can't start on the same line as a mapping key or anchor. It used to be read as the string "- value". yaml rejects it too.

Docs

  • The module header lists both features as supported and no longer lists them as unsupported. It also says a block sequence can't follow a key on the same line.
  • .changeset/yaml-compact-sequences.md is minor.

Validation

  • Yaml.test.ts: 246 of 246. That includes the 22 stage 4 tests, YAML 1.2.2 example 8.15, and the former "rejects compact nested sequences" table, now changed to expect a parse.

  • YAML, CLI, Skills, ai-codegen and openapi-generator tests: 890 passed, 3 skipped.

  • I compared 19 extra edge cases with yaml 2.9.1. They covered:

    • comments after compact entries
    • four levels of nesting
    • quoted items followed by comments or commas on the next line
    • an escaped quote before a line break
    • an escaped space after a line break
    • blank lines
    • document markers

    All match, except the tab case below.

  • 1000 nested compact sequences parse; 1001 and 2000 fail with the depth error.

  • pnpm lint, pnpm jsdocs --check and the Yaml.ts doctests pass.

  • pnpm check reports one error, the apiStabilityLeak in cluster/ShardingRegistrationEvent.ts, which also occurs on v4/next-minor.

Known difference, not changed here: a tab after a sequence dash (-\t1, - -\t1) is still read as plain text, while yaml treats the tab as separation. This was already the case at the top level before this stage.

Stack

These PRs form one stack. Each targets the PR before it, so its diff shows only its own stage. Merge them in this order:

  1. Add Yaml.parseAll and return Result from Yaml.parse #10271: Yaml.parseAll and Result from Yaml.parse (merged)
  2. Reject Yaml tags and explicit keys, resolve alias keys, and keep non-space white space #10276: parser hardening, based on v4/next-minor
  3. Parse Yaml compact nested sequences and multiline quoted flow scalars #10279: compact nested sequences and multiline quoted flow scalars, based on Reject Yaml tags and explicit keys, resolve alias keys, and keep non-space white space #10276 (this PR)
  4. Treat a tab after a Yaml sequence dash as separation #10282: tab after a sequence dash, based on Parse Yaml compact nested sequences and multiline quoted flow scalars #10279
  5. Accept escaped literal tabs in Yaml double-quoted scalars #10283: escaped literal tabs, based on Treat a tab after a Yaml sequence dash as separation #10282
  6. Reject Yaml flow plain scalars starting with a dash and separation #10284: flow plain scalars starting with a dash, based on Accept escaped literal tabs in Yaml double-quoted scalars #10283
  7. Resolve Yaml core schema tags #10285: core schema tags, based on Reject Yaml flow plain scalars starting with a dash and separation #10284
  8. Add Yaml.stringify and Yaml.stringifyAll #10272: Yaml.stringify and Yaml.stringifyAll, based on Resolve Yaml core schema tags #10285
  9. Harden and extend Yaml parsing and add Yaml.stringify #10287: printer round-trip through Yaml.parse, based on Add Yaml.stringify and Yaml.stringifyAll #10272

After a PR in the stack is squash-merged, the next one has to be rebased onto the squash commit and retargeted to v4/next-minor before it can merge.

Closes EFF-3232

@changeset-bot

changeset-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d62543e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 33 packages
Name Type
effect Minor
@effect/opentelemetry Minor
@effect/vitest Minor
@effect/ai-anthropic Minor
@effect/ai-cloudflare Minor
@effect/ai-openai-compat Minor
@effect/ai-openai Minor
@effect/ai-openrouter Minor
@effect/ai-typesafe Minor
@effect/atom-react Minor
@effect/atom-solid Minor
@effect/atom-vue Minor
@effect/platform-browser Minor
@effect/platform-bun Minor
@effect/platform-deno Minor
@effect/platform-node-shared Minor
@effect/platform-node Minor
@effect/sql-clickhouse Minor
@effect/sql-d1 Minor
@effect/sql-libsql Minor
@effect/sql-mssql Minor
@effect/sql-mysql2 Minor
@effect/sql-pg Minor
@effect/sql-pglite Minor
@effect/sql-sqlite-bun Minor
@effect/sql-sqlite-do Minor
@effect/sql-sqlite-node Minor
@effect/sql-sqlite-react-native Minor
@effect/sql-sqlite-wasm Minor
@effect/docgen Minor
@effect/doctest Minor
@effect/graphql-generator Minor
@effect/openapi-generator Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 39.41 KB 39.41 KB 0.00 KB (0.00%)
basic.ts 7.23 KB 7.23 KB 0.00 KB (0.00%)
batching.ts 11.08 KB 11.08 KB 0.00 KB (0.00%)
brand.ts 6.87 KB 6.87 KB 0.00 KB (0.00%)
cache.ts 11.54 KB 11.54 KB 0.00 KB (0.00%)
config.ts 22.84 KB 22.84 KB 0.00 KB (0.00%)
differ.ts 22.00 KB 22.00 KB 0.00 KB (0.00%)
http-client.ts 27.12 KB 27.12 KB 0.00 KB (0.00%)
http-router.ts 37.04 KB 37.04 KB 0.00 KB (0.00%)
logger.ts 12.01 KB 12.01 KB 0.00 KB (0.00%)
metric.ts 9.47 KB 9.47 KB 0.00 KB (0.00%)
optic.ts 7.10 KB 7.10 KB 0.00 KB (0.00%)
pubsub.ts 16.02 KB 16.02 KB 0.00 KB (0.00%)
queue.ts 12.89 KB 12.89 KB 0.00 KB (0.00%)
schedule.ts 11.80 KB 11.80 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.14 KB 14.14 KB 0.00 KB (0.00%)
schema-binary.ts 41.99 KB 41.99 KB 0.00 KB (0.00%)
schema-class.ts 21.73 KB 21.73 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 29.60 KB 29.60 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.99 KB 27.99 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.35 KB 15.35 KB 0.00 KB (0.00%)
schema-string.ts 12.34 KB 12.34 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.27 KB 16.27 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 38.95 KB 38.95 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 26.15 KB 26.15 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 20.90 KB 20.90 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.05 KB 21.05 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.14 KB 21.14 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.17 KB 26.17 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.23 KB 21.23 KB 0.00 KB (0.00%)
schema.ts 20.82 KB 20.82 KB 0.00 KB (0.00%)
stm.ts 14.20 KB 14.20 KB 0.00 KB (0.00%)
stream.ts 10.38 KB 10.38 KB 0.00 KB (0.00%)

@effect-bot
effect-bot force-pushed the v4/next-minor branch 7 times, most recently from 97a1ee1 to 10d44ad Compare November 3, 2026 22:52
@effect-bot
effect-bot force-pushed the agent/nelson-effect-bot/eff-3232-stage4-grammar branch from 4d196cf to aa5ba2d Compare November 3, 2026 23:14
@effect-bot
effect-bot force-pushed the agent/nelson-effect-bot/eff-3232-stage4-grammar branch from aa5ba2d to c63e47d Compare November 3, 2026 23:39
@effect-bot
effect-bot changed the base branch from v4/next-minor to agent/nelson-effect-bot/eff-3232-stage3-hardening November 3, 2026 23:40
@effect-bot
effect-bot changed the base branch from agent/nelson-effect-bot/eff-3232-stage3-hardening to v4/next-minor November 3, 2026 23:40
@effect-bot
effect-bot changed the base branch from v4/next-minor to agent/nelson-effect-bot/eff-3232-stage3-hardening November 3, 2026 23:42
A sequence entry may start a nested sequence on its own line, quoted
scalars inside flow collections may span lines, and a block sequence on
a mapping key's line fails instead of being read as text.
Avoids quadratic growth from appending to and indexing one string, keeps
an escaped trailing space before a quoted flow line break, and applies
quoted-content indentation rules while a flow quote is open.
Reuse closingQuote and endsWithEscape to scan each line of a quoted flow
scalar instead of a second hand-written quote scanner, and decide a
sequence entry's shape once instead of testing it three times.
@effect-bot
effect-bot force-pushed the agent/nelson-effect-bot/eff-3232-stage4-grammar branch from c63e47d to d62543e Compare November 3, 2026 23:43
@effect-bot
effect-bot force-pushed the agent/nelson-effect-bot/eff-3232-stage3-hardening branch from 5608c22 to a8cf572 Compare November 3, 2026 23:43
@effect-bot

Copy link
Copy Markdown
Contributor Author

Superseded by #10287, which now holds the rest of the YAML expansion as one PR against v4/next-minor. This PR's commits are included there unchanged.

@effect-bot effect-bot closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant