Skip to content

fix(options): read same-line and nested markers as the web parser does - #38684

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/38650-python-option-marker-scan
Nov 17, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/38650-python-option-marker-scan

Conversation

@rnoack1

@rnoack1 rnoack1 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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:

Input Web dashboard Channels before this PR
Body [OPTIONS: A] [OPTIONS: B] both markers removed, pill B first marker stays as raw text
[OPTIONS: dropped [OPTIONS: A | B] nothing parsed, shown as written inner marker parses, pills A, B

Why 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

  • No change to the marker regexes on main. They are neither widened nor rewritten.
  • No change to how a lone empty marker ([OPTIONS:]) is shown on a channel.
  • No change to the web parser.

What changed (motivation → approach → change)

The channel matcher (OPTIONS_RE_LINE / OPTIONS_RE_TRAILER in constants.py) now reads a whole line, as the web parser does:

Line Before After
Body [OPTIONS: A] [OPTIONS: B] text Body [OPTIONS: A], pill B text Body, pill B
[OPTIONS: dropped [OPTIONS: A | B] pills A, B nothing parsed, text kept
[OPTIONS: A] [OPTIONS:] text [OPTIONS: A] same: siblings join only when the last marker offers a pill

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 existing MARKER_OPENERS / MARKER_CLOSERS tables. 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.py imports 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_LINE and OPTIONS_RE_TRAILER keep their search, finditer and sub members.

Tests

  • test/test_options_marker_same_line.py runs 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_closers counts 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.py treats 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.py compares the line-limited candidate scan with the whole-text scan, and a second property test checks that sub removes exactly the balanced spans finditer yields.

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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@rnoack1
rnoack1 requested review from a team and KiroCrewCaptain as code owners November 17, 2026 18:03
@rnoack1
rnoack1 requested a review from cruisercohen November 17, 2026 18:03
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision c858a7c3c9e582acf5b6087bb76b85319d92f7ca touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of c858a7c3c9e582acf5b6087bb76b85319d92f7ca — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. One rider is there only to mirror the web parser: the 256-head cap.

Notes

  • Item 3 — inherited: the only support is "the same cap the web parser has". The Python walk already looks at each line once, from the line start up to that line's last candidate, and test_the_line_walk_stays_linear_on_comma_followed_closers pins that it stays linear. So the cap doesn't bound any work. Its only visible effect is that a message with more than 256 heads loses every marker.
    Subtraction: delete HEAD_CAP, head_count and the if head_count(text) > HEAD_CAP: return guard in _MarkerMatcher.finditer.

What this change ships

Inventory (6 items) — 5 justified

Intent: make Slack, Discord and the other channels read same-line and nested [OPTIONS:] markers the way the web dashboard does. This is a FIX.

  1. On a channel, sibling markers on one line are all removed and the last marker's pills are shown — justified
  2. On a channel, a marker inside an unclosed head stays as text instead of making pills — justified
  3. A channel message with more than 256 marker heads shows no pills at all — inherited (mirrors the web cap; the walk is already linear)
  4. Lowercase [options: and [OPTION: heads now count as unclosed heads in front of a marker — justified
  5. [OPTIONS: A] [OPTIONS:] keeps its first marker as text, on purpose — justified
  6. The line-scan property test now compares the raw candidates and pins the sub/finditer spans separately — justified

[FIRST-PRINCIPLES-REVIEWED] c858a7c

Description read

[DESCRIPTION-READ] d535798d0d71fafce34596b77a23e885fb60666180fa0841e975d4160407df6b

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of c858a7c3c9e582acf5b6087bb76b85319d92f7ca — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 search/finditer/sub calls as before.

Notes

  • MarkerRun copies only part of re.Match: start, end, span, group, groupdict and string. Today's readers (slack/format.py, slot_transcript.py, renderer.py, preview_text.py, whatsapp/turn_renderer.py, slack/handler_runtime/stream.py) use nothing else. A later caller that reaches for .groups(), .expand() or .re would only fail when it hits a chain line, so declare the narrowed type at the matcher boundary instead of leaving the alias behind TYPE_CHECKING.
  • HEAD_CAP applies to the whole message, so 257 heads anywhere stop the last line's real marker from parsing. That matches the web parser and can be reverted, but it is a failure mode on a long transcript-style reply that no test shows from the channel side.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed c858a7c3c9e582acf5b6087bb76b85319d92f7ca — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] c858a7c

Verdict parsed from the review's SHA-scoped output markers for commit c858a7c3c9e582acf5b6087bb76b85319d92f7ca.

False positive or not applicable? A repository writer can comment:
/ai-review override fable c858a7c3c9e582acf5b6087bb76b85319d92f7ca false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of c858a7c3c9e582acf5b6087bb76b85319d92f7ca and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c858a7c

False positive or not applicable? A repository writer can comment:
/ai-review override gpt c858a7c3c9e582acf5b6087bb76b85319d92f7ca false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 17, 2026
@rnoack1
rnoack1 force-pushed the fix/38650-python-option-marker-scan branch from 3edd361 to 192cfe3 Compare November 17, 2026 19:12
@rnoack1

rnoack1 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

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.

@rnoack1
rnoack1 force-pushed the fix/38650-python-option-marker-scan branch from 192cfe3 to c858a7c Compare November 17, 2026 19:49
@rnoack1

rnoack1 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=9a9b56f5dc4c Comma-followed closers make the line scan quadratic

fixed in c858a7c: closer_continues now walks forward by index from the comma to the first bracket or newline, with no line-end search and no slice, so each scan stops at the next bracket and no two scans overlap.
Test: test_the_line_walk_stays_linear_on_comma_followed_closers counts every character the walk reads, searches or copies on a 400-repeat line of a], and caps it at 8x the line length; the old walk reads 655,659 characters against a cap of 12,976.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 17, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: 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 c858a7c3c9 · 430 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 17, 2026 21:45

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 at constants.py:827 has no test. With it removed, all marker tests still pass, but [OPTIONS: A] [OPTIONS: |] then becomes an empty message. You could parametrize test_siblings_stay_when_the_last_marker_offers_nothing over [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_CAP comment 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.

@KiroCrewCaptain
KiroCrewCaptain merged commit a6bf911 into main Nov 17, 2026
102 of 103 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/38650-python-option-marker-scan branch November 17, 2026 21:46
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants