Skip to content

fix: rewrite parseStance() and parseForcedDecision() with structured parsing (#96, #110)#116

Merged
justn-hyeok merged 1 commit intov2from
fix/96-110-parser-rewrite
Mar 18, 2026
Merged

fix: rewrite parseStance() and parseForcedDecision() with structured parsing (#96, #110)#116
justn-hyeok merged 1 commit intov2from
fix/96-110-parser-rewrite

Conversation

@justn-hyeok
Copy link
Copy Markdown
Collaborator

Summary

  • Critical bug fix: Replaces naive keyword counting in parseStance() and regex-only parsing in parseForcedDecision() with priority-based structured parsing
  • Both parsers now support: structured field patterns, JSON-like patterns, first-line keywords, weighted keyword scan
  • Adds Korean language support (동의/반대/중립) and SUGGESTION severity support
  • Exported both functions for testability
  • 29 comprehensive unit tests

Changes

File Change
src/l2/moderator.ts Rewrite parseStance() and parseForcedDecision() with 4-priority parsing
src/tests/l2-parser-rewrite.test.ts New: 29 tests covering structured, keyword, edge cases

Closes #96, Closes #110

Test Plan

  • Structured patterns: Stance: AGREE, Severity: CRITICAL
  • JSON patterns: "stance": "agree"
  • Korean patterns: 판단: 동의
  • First-line keyword detection
  • Weighted keyword scan (headings get 3x)
  • DISAGREE not confused with AGREE substring
  • "not critical" guard
  • SUGGESTION and DISMISSED severity support
  • Empty/unrecognized response defaults

…parsing (#96, #110)

Replace naive keyword counting with priority-based structured parsing:
1. Structured field patterns (Stance: X, Severity: X, Korean support)
2. JSON-like patterns ("stance": "agree")
3. First-line keyword detection
4. Weighted keyword scan (headings/bold get 3x weight)

Fixes misclassification of LLM responses that use natural language
instead of explicit keywords. Adds SUGGESTION support to parseForcedDecision.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@justn-hyeok justn-hyeok merged commit 2b8ed64 into v2 Mar 18, 2026
@justn-hyeok justn-hyeok deleted the fix/96-110-parser-rewrite branch March 18, 2026 17:56
@github-actions github-actions bot added the size/L <500 lines label Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L <500 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant