Repository navigation
fix(options): read same-line and nested markers as the web parser does - #38684
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. One rider is there only to mirror the web parser: the 256-head cap. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: make Slack, Discord and the other channels read same-line and nested
[FIRST-PRINCIPLES-REVIEWED] c858a7c Description read[DESCRIPTION-READ] d535798d0d71fafce34596b77a23e885fb60666180fa0841e975d4160407df6b That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the channel matcher now reads a whole line the way the web parser does, and every channel reader gets the result through the same Notes
[DESIGN-REVIEWED] c858a7c Description read[DESCRIPTION-READ] 91277e0ec3c67f4c01cbdf956d053290579390501c8d7220d1a8232406a8349e That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 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: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
3edd361 to
192cfe3
Compare
|
Rebased: main moved in src/kiro_crew/cli_setup.py, src/kiro_crew/config/loader_builders.py, src/kiro_crew/context.py, src/kiro_crew/validation.py and src/kiro_crew/validation_parts/messaging_session_schemas.py since this head went green (c7799d2 -> 6c0cc77); CI re-running. The same push fixes the red Backend Tests (3.12, 6) shard: constants.py now imports the line walk only when a marker is parsed, so test_mcp_listing_import_budget's module ceilings hold again. |
192cfe3 to
c858a7c
Compare
|
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 14% chance that this change introduces a defect, above the 12% limit for approving on its own. The Python channel matcher now walks each marker line the way the web parser's markersBefore does (optionMarker.ts): it refuses a marker inside an unclosed head and joins sibling markers into one MarkerRun that carries the last marker's labels. The only intended difference is that siblings join only when the last marker offers a label, and the PR documents this. I checked every consumer of OPTIONS_RE_LINE/OPTIONS_RE_TRAILER (Slack format/stream, dashboard slot_transcript/member_waiting, preview_text, renderer, whatsapp, the glued-marker relocation, split_trailing_protocol_suffix). They only use group("labels")/group(0)/start/end/span, all of which MarkerRun provides. Slack streaming and delivery now agree more often than on main; the walk is bounded per line; there is no trust-boundary change. The new tests drive every reader and would fail on main, and CI is green. Tier: 2, held for a person: the automated review did not clear it. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approving. On this head the review checked that markers_before is a one-to-one port of the web parser's markersBefore, including the typed stack, the comma rule for closers, the link-close handling and HEAD_CAP. It also checked every caller of OPTIONS_RE_LINE and OPTIONS_RE_TRAILER (Slack, dashboard, renderer, WhatsApp, the streaming hold). Each one reads only start, end, span, group and groupdict, and MarkerRun provides all five. With the production hunk reverted, 10 of the 39 tests in the changed files fail, and all 39 pass at c858a7c. The walk stays linear on inputs of 10k to 40k repeats. Every shape that changes from main now shows as visible text and never deletes prose.
Done well: test_options_marker_same_line.py runs every case through the Slack, dashboard and renderer readers at once, and the linearity test counts characters read instead of timing them, so it stays deterministic.
Optional:
- The
.replace("|", "")half of the guard atconstants.py:827has no test. With it removed, all marker tests still pass, but[OPTIONS: A] [OPTIONS: |]then becomes an empty message. You could parametrizetest_siblings_stay_when_the_last_marker_offers_nothingover[OPTIONS:],[OPTIONS: |]and[OPTIONS: | ]. - The Backwards compatibility section does not list messages with more than 256 heads, where a marker that parsed on main now parses nothing. The Proof line also names a commit that is not in this PR's history.
- The
HEAD_CAPcomment says the cap bounds per-message work, but the Python walk is already linear. The real reason is parity with the web parser's cap, and the comment could say that.
Problem / Motivation
Goal: Slack, Discord and the other channels read same-line and nested
[OPTIONS:]markers the way the web dashboard does, and never delete text the user should see.Part of #38650
#30465 changed how the web dashboard reads option markers. The Python grammar that every channel uses was left as it was, so one reply now reads two ways:
Body [OPTIONS: A] [OPTIONS: B]B[OPTIONS: dropped [OPTIONS: A | B]A,BWhy it matters
A Slack or Discord user sees raw marker text the dashboard hides, or gets pills from a marker the dashboard treats as prose. The same turn looks different on every surface.
Not a goal
[OPTIONS:]) is shown on a channel.What changed (motivation → approach → change)
The channel matcher (
OPTIONS_RE_LINE/OPTIONS_RE_TRAILERinconstants.py) now reads a whole line, as the web parser does:Body [OPTIONS: A] [OPTIONS: B]Body [OPTIONS: A], pillBBody, pillB[OPTIONS: dropped [OPTIONS: A | B]A,B[OPTIONS: A] [OPTIONS:][OPTIONS: A]That last row is the one shape where channels and the web differ. The web strips both markers and then keeps a row whose pills render nothing; a channel has no such row rule, so joining there would post an empty message.
The regex still needs the line end, so it finds only a line's last marker. A new module,
option_marker_scan.py, walks the rest of that line once, with no regex. It finds heads by case-folded comparison against a small head table and tracks brackets with the existingMARKER_OPENERS/MARKER_CLOSERStables. A head that never closed refuses the marker inside it. Sibling markers that run up to the last one join it as one match, so every reader strips them together and takes the last marker's pills. A message with more than 256 heads parses no marker, the same cap the web parser has.constants.pyimports the walk only when a marker is parsed, so an MCP server that only lists its tools does not load it.The
Use [OPTIONS: A | B], then pick [OPTIONS: Yes | No]row from the issue already read the same on both surfaces; a test now pins it.Backwards compatibility
Compatible: a line that parsed before still parses with the same pills; the only lines that change are chains, which now lose their raw sibling text, and markers inside an unclosed head, which now stay as text.
Removes nothing: no key, function or record is removed;
OPTIONS_RE_LINEandOPTIONS_RE_TRAILERkeep theirsearch,finditerandsubmembers.Tests
test/test_options_marker_same_line.pyruns the web parser's same-line, nesting and chain cases through the Slack, dashboard and renderer readers.test_the_line_walk_stays_linear_on_comma_followed_closerscounts every character the walk reads, searches or copies on a line of comma-followed closers and caps it at a multiple of the line length, so a quadratic walk fails it.test/test_marker_probe_agreement.pytreats a closed head followed by a new head as a sibling chain, not a nested head, and checks the streaming split holds the whole chain back.test/test_options_marker_line_scan.pycompares the line-limited candidate scan with the whole-text scan, and a second property test checks thatsubremoves exactly the balanced spansfinditeryields.Proof: PROVEN test/test_marker_probe_agreement.py::TestTheNestedHeadGuardAgreesWithTheBody::test_a_sibling_chain_is_held_from_its_first_head, test/test_options_marker_same_line.py::test_a_same_line_chain_strips_every_marker_and_the_last_offers[Body [OPTIONS: A] [OPTIONS: B]-Body-options0], test/test_options_marker_same_line.py::test_a_same_line_chain_strips_every_marker_and_the_last_offers[[OPTIONS: A] [OPTIONS: B] [OPTIONS: C]--options1], test/test_options_marker_same_line.py::test_a_same_line_chain_strips_every_marker_and_the_last_offers[[OPTIONS: A] [OPTIONS: B then arr[0]]--options2], test/test_options_marker_same_line.py::test_a_same_line_chain_strips_every_marker_and_the_last_offers[Body OPTIONS: A [OPTIONS: B]-Body-options3] (head a834b21af474)
Manual verification
N/A — unit coverage sufficient: the change is a pure text function, and the new tests drive each channel reader directly.
Related Issues
Part of #38650
Sibling sweep
Swept: git grep -nE "OPTIONS_RE_LINE|OPTIONS_RE_TRAILER|_RAW_OPTIONS_RE" -- src/
Sibling: src/kiro_crew/constants.py -- changed here
Sibling: src/kiro_crew/slack/format.py -- not affected -- reads markers only through the shared matcher
Sibling: src/kiro_crew/messaging/renderer.py -- not affected -- reads markers only through the shared matcher
Pattern harvest
Not generalizable: two parsers of one grammar drifted because one PR changed only one of them; the fix is the parity test, not a lint rule.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)