openpencil/packages
Fini 39aeb0c30e fix(pen-core): reject invalid level in buildHeading with a clear error
ab-v4 partial sweep (2026-05-01) caught gpt-5.4 emitting
`add_heading_v0({"content":"Pending invitations","level":"caption"})`
as the 12th tag of a 13-tag composite multi-tool response. Even
though the MCP tool def has `enum: ['display','h1','h2','h3']`, the
ab-corpus harness and the in-process production dispatcher both call
buildHeading() with raw JSON args (no jsonschema gate), so the model's
invented "caption" reached the preset lookup. LATIN_PRESETS["caption"]
is undefined, and the next line `fontSize: preset.fontSize` crashed
the WHOLE batch with `undefined is not an object (evaluating
'preset.fontSize')` — the 11 valid tags ahead of it never landed.

Adds an entry-point validation in buildHeading: if `level` is set and
not in the {display, h1, h2, h3} set, throw with a clear message.
The dispatch loops in apps/web/element-tools-dispatcher and
scripts/ab-corpus/apply both catch per-shape and keep running the
remaining tags, so a single bad level on tag 12 no longer kills tags
1-11 + 13.

3 new edge-case tests in element-builders-edge-cases.test.ts
cover the throw + the four valid levels + the omitted-default case.
3772 vitest pass (+3), format clean, tsc silent.

Other element builders likely have the same pattern (preset lookup
on a string enum without runtime validation) — separate sweep, not
shotgunning here.
2026-04-29 09:49:54 +08:00
..
agent-native@e1f90cab96 chore(agent): bump agent-native to v0.4.0 release 2026-04-17 19:04:15 +08:00
pen-acp chore(release): bump to v0.8.0 2026-04-27 08:20:00 +08:00
pen-ai-skills feat(ab-corpus): per-domain cookbook filter (Phase 2 of token diet) 2026-04-29 09:49:49 +08:00
pen-core fix(pen-core): reject invalid level in buildHeading with a clear error 2026-04-29 09:49:54 +08:00
pen-engine chore(release): bump to v0.8.0 2026-04-27 08:20:00 +08:00
pen-figma chore(release): bump to v0.8.0 2026-04-27 08:20:00 +08:00
pen-mcp fix(ai): step-card marker clips overflow + tighten doc to short index 2026-04-28 08:55:00 +08:00
pen-react chore(release): bump to v0.8.0 2026-04-27 08:20:00 +08:00
pen-renderer chore(release): bump to v0.8.0 2026-04-27 08:20:00 +08:00
pen-sdk chore(release): bump to v0.8.0 2026-04-27 08:20:00 +08:00
pen-types chore(release): bump to v0.8.0 2026-04-27 08:20:00 +08:00
CLAUDE.md V0.7.0 (#95) 2026-04-11 23:25:13 +08:00