Repository navigation
Conversation
UX Review (Fable 5) — ✅ PASSUX-level review of The diff changes only parser regex constants and tests — no new UI controls, strings, components, or states. The user-facing effect is that CJK-bracket UX-Verdict: PASS Pure parser fix: CJK-bracket option labels now render as the existing pills instead of raw marker text; no new control, string, or state to misread. [UX-REVIEWED] 8d51c8f |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Positional pairing pays a tracked cost (#9375) without reopening #9284's greedy body; every trade-off is pinned at the consumer on both surfaces. [DESIGN-REVIEWED] 8d51c8f |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of All claims verified: First-Principles-Verdict: PASS Verify the one declared narrowing: mixed-bracket interiors like What this change shipsInventory (8 items) — 8 justifiedIntent: FIX — a label written in CJK punctuation lost its option pills because the closer set accepted lookalikes the opener rule could not match.
[FIRST-PRINCIPLES-REVIEWED] 8d51c8f |
GPT 5.6 Review — 🔴 changes requested (blocking)GPT 5.6 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/constants.py:408 -- matched pairs can backtrack into bare openers and consume trailing prose
Adjudication (Opus 4.8) — is blocking on each finding proportionate?The adjudicable block is empty (0 findings). One fenced finding, F1, to annotate. F1 — False positive or not applicable? A repository writer can comment: |
Opus 4.8 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
5a3f163 to
bed4ab4
Compare
bed4ab4 to
c16def1
Compare
c16def1 to
82c04a2
Compare
…S labels
A closer is readmitted to an `[OPTIONS:]` label when an opener earlier in the
same label MATCHES it. "Matches" was decided against ASCII `[` alone, while
`MARKER_CLOSERS` already accepted three lookalikes -- so a label written wholly
in CJK punctuation had a `】` with no recognised opener:
[OPTIONS: 见【表1】说明 | 跳过]
The body ended at that `】`, the line anchor rejected the remainder, and the
whole marker leaked into the message as literal text with no pills. That was an
enumerated, tested cost of the closer-continuation rule (#9284); this pays it.
`MARKER_OPENERS` is zipped POSITIONALLY with `MARKER_CLOSERS` to emit one
matched-pair branch per pair. The pairing is the load-bearing half: one branch
accepting any opener followed by any closer would make `【表1]` a pair, which is
#9284's greedy body back through a side door -- the label would end at a closer
whose opener never appeared, so the body could again run past the marker's real
terminator and delete the prose after it. The mismatched shapes are asserted as
explicitly as the matched ones.
Two consequences worth review in their own right:
- The body's catch-all class now excludes EVERY bracket, not just the closers.
Leaving `【` in it would give that character two parses -- the pair branch and
the catch-all -- costing the disjointness the linearity argument rests on.
- `MARKER_CLOSERS` can no longer be widened alone. Continuation readmits all
four codepoints at once; the pair form readmits one per branch. A fifth closer
with no opener beside it would be admitted by continuation and nothing else,
and `zip` is silent on a length mismatch -- so the two constants are guarded by
an import-time assert, in the style of `sandbox.py`.
The frontend pattern stays ONE regex literal, with the body spelled twice and the
four pair branches spelled out in each. Composing it from named fragments reads
far better, and was the first attempt -- but every fragment is a module-scope
STRING literal, and `eslint.i18n.strict.config.js` reports those as untranslated
user-visible copy. The exemption the gate offers is by shape, and that config
argues at length against widening a shape for one file ("A path this narrow
cannot exempt a future file"); a hole cut for regex fragments is one real copy
could sit in later. A regex literal contains no string literal, so it needs no
hole. The duplication is guarded instead by the `.source` pin in
`AssistantMessage.test.tsx`, which is BUILT from per-pair pieces, so the two
copies cannot drift from each other or from the backend silently. Every lookalike
is written as a `\uXXXX` escape, never the character: `]` and `]` are
indistinguishable at a glance, so a literal class would be unreviewable.
Two existing cost pins flipped to assert the new behaviour rather than being
deleted, one per surface, each kept in its original suite as the row that left
it. The remaining two costs (unmatched with no opener at all, nesting deeper
than one level) are asserted so the table cannot quietly grow or shrink.
Fixes #9375
Review round 1 (GPT first-principles), three findings, all applied:
- An UNDECLARED narrowing: the pair interior excludes every bracket, so a pair
whose interior holds a different bracket kind (`[OPTIONS: See [a【b] ref |
Skip]`) loses its pair parse where base admitted it. Verified against base by
execution -- 4 shapes, all failing toward a VISIBLE marker. Kept the behaviour,
because admitting `【` there would let the ASCII branch consume a character the
`【` branch could also open on, giving a span two parses and costing the
single-parse property the linearity argument reads off the pattern. Declared
and pinned in `TestAMixedBracketInterior`; the cost table is three rows now.
The description had claimed the table could not grow while this grew it.
- `zip(..., strict=True)` replaces the hand-written length assert: it is the
language guarantee for the same invariant, and it holds under `python -O`,
which strips asserts.
- `MARKER_OPENERS` / `MARKER_BRACKETS` are private. `MARKER_CLOSERS` is public
because `messaging/renderer.py` reads it; the opener set has no consumer
outside `constants.py` and its tests, so mirroring the twin was not a reason
to export it.
Review round 2, two findings, both applied:
- BLOCKING, and correct: the pair interior admitted `|`, and
`split_options_trailer` splits the captured label group on `|` with no notion of
nesting. `[OPTIONS: 见【表1|表2】说明 | 跳过]` -- an ordinary CJK phrase -- was
captured whole and then torn into ['见【表1', '表2】说明', '跳过']: three choices
with unbalanced brackets, echoed back as the user's reply when tapped. Measured
against base, which DECLINES that shape, so the corruption was introduced here.
The interior now refuses `|`; `,` is not excluded, because the splitter does not
split on commas and the exclusion tracks what the consumer actually does. The
mistake behind it: round 1 asserted what the REGEX captured and never asked what
the consumer did with the capture, which is the same lesson this grammar's own
pattern-harvest already carried.
One shape improves beyond base as a side effect: `[OPTIONS: See [a|b] c | Skip]`
corrupted identically on base and now declines, so a pre-existing corruption
becomes a visible marker.
- Stale documentation: `constants.py` still carried the OLD four-row residual-cost
table, including a lookalike-PAIR row this change makes parse and an "opener set
this grammar does not have" clause it makes false. Rewritten to the current five
rows, and `_MARKER_LABEL_PAIR`'s opening sentence no longer says the interior
excludes only `[` and the closers.
Review round 3, one finding, applied:
- BLOCKING, and correct again: excluding only `|` from the pair interior fixed
half the problem. The frontend's `parseOptions` picks its delimiter as
`labels.includes('|') ? '|' : ','` (options.ts:38), so a COMMA is load-bearing
exactly when no pipe is present -- and `[OPTIONS: 见【表1,表2】说明, 跳过]` was
captured whole and comma-split into ['见【表1', '表2】说明', '跳过']. Measured on
the frontend, which is where the fallback lives; the backend splitter does not
fall back, which is why a backend-only check said commas were safe. The interior
now refuses both separators on both surfaces.
Root cause of getting this wrong twice: round 2 verified the claim against the
BACKEND consumer and a frontend shape that happened to contain a pipe, so the
fallback branch was never exercised. When two surfaces have to agree, a claim
about "the consumer" has to be measured on each of them.
The excluded set is now exactly what `_MARKER_LABEL_CONTINUES` /
`CONTINUES_LABELS_RE` treat as separators, and that correspondence is the
invariant to hold: a character that ends a label for the continuation rule must
not be swallowable into a pair, or the two rules disagree about where a label
ends.
Review round 4, two advisories, both applied -- and the second reverses part of
round 3:
- Opus: excluding `,` from EVERY pair interior declined
`[OPTIONS: Fix dict[str, Any] now | Skip]` and
`[OPTIONS: Refactor arr[i, j] now | Skip]`, which parse on main. Ordinary labels,
regressed for a corruption that only the lookalike branches can reach. The
exclusion is now per-branch: lookalike interiors refuse both separators, the
ASCII interior does not. Each half is chosen against what it would break -- the
ASCII branch has history to protect, the lookalike branches are new here.
- GPT: the comment claimed the interior exclusion prevents the corruption. It does
not, and the counter-example is measurable on main as well as here:
`[OPTIONS: 见【表1|表2】 | 跳过]` is admitted by the CONTINUATION form, whose
lookahead does not care what preceded the closer, so it reaches the splitter and
splits into three either way. The exclusion is a mitigation on the matched-pair
path only; closing the class needs a nesting-aware splitter, which is out of
scope. Comment, tests and cost table now say that, and the continuation-path
behaviour is pinned as unchanged rather than left implicit.
82c04a2 to
8d51c8f
Compare
|
Closing this in favour of fixing #10058 first. The opener set is the right fix for #9375, but it cannot land safely on top of a defect it makes newly reachable. What the review round actually foundGPT's last blocking finding was right, and chasing it down changed my understanding of the whole change. The reported shape: I first read that as "the matched-pair rule lets the body run on". It is not about pairs at all. Measured on So the real defect is: an unterminated What this branch does is remove an accidental partial mitigation. On Why closing rather than patching againThe trade is bad in its current form. #9375's symptom is benign: a CJK-pair label fails to a visible marker with nothing deleted. This PR converts that into a path that silently deletes prose. For the shapes involved, the fix is worse than the bug. It is also not fixable inside the pair rule. Four review rounds each produced a locally-correct patch that exposed the next reachable path:
The correct terminator condition is "the closer is not nested", which is bracket balance and not something a regex expresses. That is #10058's problem to solve, and once it is solved this change becomes small and safe. What is worth keeping from hereThe branch
Three review findings from this round are also worth carrying regardless of what happens to the opener set: Corrections to this PR's own descriptionTwo claims in earlier revisions were wrong and are worth flagging so nobody inherits them:
|
Problem / Motivation
A closer is readmitted to an
[OPTIONS:]label when an opener earlier in the same label matches it. "Matches" was decided against ASCII[alone, whileMARKER_CLOSERSalready accepted three lookalikes (】U+3011,]U+FF3D,〕U+3015). A model writing a label in CJK punctuation writes both halves in it:That
】had no opener the rule recognised, so the body ended there, the line anchor rejected the remainder, and the whole marker reached the reader as literal text with no pills.Why it matters
This is the affordable half of a cost that was accepted knowingly: the shape fails toward a visible marker, not toward deleted prose. So it is a rendering failure, not data loss — but it is a rendering failure that hits Chinese, Japanese and Korean output specifically, on the surface that decides whether a turn has buttons at all. It was row 3 of the four-row cost table in #9341, pinned by tests in both languages, and #9375 was filed to track paying it.
What changed
_MARKER_OPENERS = "[【[〔"is zipped positionally withMARKER_CLOSERSto emit one matched-pair branch per pair. It is private, unlike its public twin:MARKER_CLOSERSis public becausemessaging/renderer.pyreads it, and review counted zero consumers outsideconstants.pyfor the opener set, so symmetry alone was not a reason to export it.The pairing is the load-bearing part, not a detail
One branch accepting any opener followed by any closer would make
【表1]a pair — and that is #9284's greedy body reached by a side door. The label would end at a closer whose opener never appeared, so the body could again run past the marker's real terminator and delete the prose after it. So the mismatched shapes are asserted as explicitly as the matched ones:[OPTIONS: 见【表1】说明 | 跳过]【pairs with】[OPTIONS: 见【表1] 说明 | 跳过][OPTIONS: 见[表1】 说明 | 跳过][OPTIONS: 见【表1〕 说明 | 跳过】Two consequences that deserve review in their own right
The catch-all class now excludes every bracket, not just the closers. Leaving
【in it would give that character two parses — the pair branch and the catch-all — costing the disjointness the linearity argument rests on.TestLinearityreads the exclusion off the compiled pattern so the claim cannot drift from the comment, and exercises the shape that would blow up if it did.MARKER_CLOSERSis no longer widenable on its own. Continuation readmits all four codepoints at once; the pair form readmits exactly one per branch, its own opener's partner. A fifth closer with no opener beside it would be admitted by continuation and by nothing else — a real shape, but not the matched one. The two constants are zipped withstrict=True, so a length mismatch raises at import. That replaced a hand-writtenassertafter review pointed out the obvious:strict=Trueis the language guarantee for exactly this, and anassertis stripped bypython -Owhile the zip is not.The frontend stays one regex literal, deliberately
Composing the pattern from named fragments reads far better and was the first attempt. But every fragment is a module-scope string literal, and
eslint.i18n.strict.config.jsreports those as untranslated user-visible copy — 11 findings,[added-lines]zero-tolerance. The exemption the gate offers is by shape ineslint.i18n.config.js, and that config argues at length against widening a shape for one file ("A path this narrow cannot exempt a future file"). A hole cut for regex fragments is one real copy could sit in later, so I did not cut it. A regex literal contains no string literal and needs no hole.The duplication that costs is guarded instead: the
.sourcepin inAssistantMessage.test.tsxis built from per-pair pieces, so the two copies of the body cannot drift from each other, or from the backend, without the test naming the difference. Every lookalike is written as a\uXXXXescape rather than the character itself —]and]are indistinguishable at a glance, so a literal class would be unreviewable and a wrong codepoint would read as correct.This NARROWS one shape, and that is a cost the table has to carry
Raised by review, and correct: the pair interior excludes every bracket, both classes, so a pair whose interior holds a bracket of a different kind loses its pair parse. On base the interior excluded only
[and the closers, so【was ordinary interior content and these parsed:All three fail toward a visible marker — verified,
subleaves the text byte-identical — so it is the same affordable class as the other rows, and the same shape still parses when a separator follows the closer ([OPTIONS: See [a【b] | Skip]), because then continuation admits it. The cost is the tail, not the interior.I kept the behaviour rather than admitting openers into the interior. Admitting
【there would let the ASCII branch consume a character the【branch could also open on, so a span would have two parses — and single-parse-per-span is exactly whatTestLinearityreads off the compiled pattern and what the ReDoS profile rests on. Trading a shape that degrades to visible text for an ambiguity in the body is the wrong way round.My first draft of this description claimed the table "cannot quietly grow or shrink" while this PR grew it. That accounting error is fixed here and pinned in
TestAMixedBracketInterior.The pair interior also refuses BOTH separators, and that is about the CONSUMER
Raised by review as blocking — twice, and correct both times. Admitting a pair whole is only safe if what receives the capture can keep it whole, and neither splitter has any notion of nesting. So a pair carrying an internal separator, which is an ordinary CJK phrase, was captured and then torn apart:
The corruption was introduced by this PR — base declines that shape — so it was mine to fix, not a pre-existing condition.
|alone was not enough.parseOptionspicks its delimiter aslabels.includes('|') ? '|' : ','(options.ts:38), so a comma is load-bearing exactly when no pipe is present. The backend splitter has no such fallback, so a check against the backend plus a frontend shape that happened to contain a pipe reported commas as safe. They were not.But excluding
,from every interior was too much, and review caught that too. It declined[OPTIONS: Fix dict[str, Any] now | Skip]and[OPTIONS: Refactor arr[i, j] now | Skip]— labels a model writes constantly, which parse onmain. So the exclusion is now per branch:[…]dict[str, Any]andarr[i, j]parse today; nothing may regress【…】,[…],〔…〕Each half is chosen against what it would break, and both are pinned.
It is a mitigation, not a guarantee — and that matters for how the row reads. The continuation form admits a closer followed by a separator regardless of what precedes it, so
[OPTIONS: 见【表1|表2】 | 跳过]reaches the splitter and splits into three. Measured onmainas well as here: identical. Closing that class needs a nesting-aware splitter, not a tighter interior, and it is out of scope; the continuation-path behaviour is pinned as unchanged so the interior rule is not read as more than it is.The mistakes worth naming, since all three were mine: round 1 asserted what the regex captured and never asked what the consumer did with it — the lesson this grammar's own pattern harvest already carried from #9341. Round 2 verified the fix against one of two consumers. Round 3 then over-corrected and regressed ordinary ASCII labels. Every cost row is now asserted at the consumer on both surfaces, and the shapes that must keep parsing are pinned alongside the ones that must not.
The remaining costs, and what is still out of scope
The cost table is now four rows, all asserted at the consumer on both surfaces so it cannot quietly change: an unmatched closer with no opener at all (
[OPTIONS: Fix ]x logging | Skip]), nesting deeper than one level ([OPTIONS: Fix list[dict[str, Any]] now | S]), the mixed-bracket interior, and the separator in a lookalike interior above. The first two need bracket matching to arbitrary depth, which a regex is the wrong tool for; the last two are interior exclusions taken deliberately, each for a reason recorded beside the pair rule.A comma outside a pair is unaffected —
[OPTIONS: 见【表1】说明, 跳过]still parses to two clean choices. The separator-tail form (…| Wait], details in CHANGELOG[1]) is unchanged and still out of scope, for the reason #9341 gave:],genuinely does continue the list.Two cost pins flipped rather than deleted
One per surface —
test_options_marker_label_closers.pyandoptionsMarkerLabelClosers.test.ts— each kept in its original suite, now asserting the parse instead of the decline, because the rule under test there is what decides the outcome.Tests
test/test_options_marker_lookalike_openers.pyandwebsite/src/test/optionsMarkerLookalikeOpeners.test.ts.test_*option*,test_*marker*,test_*renderer*,test_slack*,test_whatsapp*,test_parse_options..sourcepin.OPTIONS_RE_LINEandOPTION_MARKER_RE. Both surfaces have to agree or a marker parses to buttons on one and to text on the other.[OPTIONS:+【a】 |× N) stays linear — 0.5 ms at 2 KB, 1.7 ms at 8 KB, 4.1 ms at 20 KB — and a long mismatched run, the worst case for a pair form since every branch is attempted and every one fails, is pinned too.Manual verification
N/A, and the reason is the same as #9341's: the trigger is what the model happens to emit, not an input a user can type. Both surfaces are exercised at the parser level, which is the only code the marker passes through, and the end-to-end assertion goes through
split_options_trailer/parseOptionsrather than the regex alone.Related Issues
Fixes #9375
Follow-up to #9341 / #9284, which established the matched-or-continues rule and enumerated this as one of its four accepted costs.
Overlaps #6823. That PR carries
MARKER_OPENERSwith the same name and the same value, added for a different reason ("a citation[1]must not cancel an open marker head"). If it lands first this becomes a one-line dedupe; if this lands first, #6823's copy is redundant. #6823 also touchesconstants.pyandoptionMarker.tsand is currently labelledmerge conflict, so a conflict there is expected either way and is not caused by this PR alone. Flagged rather than resolved, since that PR is its author's to sequence.Pattern harvest
Rule candidate: review-prompt
Pattern: when a grammar admits a delimiter conditionally on some earlier context, check that the test for "earlier context" ranges over the same alphabet as the delimiter set. Widening one side alone is silent:
MARKER_CLOSERSgrew three codepoints while "what can match a closer" stayed ASCII, so a whole script's worth of input fell through a rule that looked complete. The tell is a constant naming one half of a pair with no constant naming the other. Two general follow-ons: when you pair two ordered constants byzip, assert their lengths at import, becauseziptruncates silently and the only symptom is one shape quietly failing; and when a fix adds alternatives to a regex body, re-audit the catch-all class — an alternative that can also be consumed by the catch-all gives that character two parses and silently costs whatever linearity argument the body relied on.