Skip to content

refactor(providers): consolidate error text predicates (EN | ZH)#754

Merged
DonPrus merged 2 commits intonullclaw:mainfrom
manelsen:refactor/error-helpers-dry-v3
Apr 17, 2026
Merged

refactor(providers): consolidate error text predicates (EN | ZH)#754
DonPrus merged 2 commits intonullclaw:mainfrom
manelsen:refactor/error-helpers-dry-v3

Conversation

@manelsen
Copy link
Copy Markdown
Contributor

EN:

Extract isRateLimitedText, isContextExhaustedText, isVisionUnsupportedText,
sliceEqlAsciiFold, and containsAsciiFold into a neutral text_helpers.zig
module shared by both error_classify.zig and reliable.zig.

Changes:

  • New: src/providers/text_helpers.zig (88 lines — neutral module, no provider imports)
  • refactor: src/providers/error_classify.zig (445 → 357 lines, now imports reliable.zig)
  • refactor: src/providers/reliable.zig (1555 → 1537 lines, delegates to text_helpers)

Why: Both files implemented the same text-matching predicates for error
classification. error_classify.zig used containsAsciiFold byte-by-byte; reliable.zig
used a single lowercase buffer. unified into one source of truth.

ZH:

将 isRateLimitedText、isContextExhaustedText、isVisionUnsupportedText、
sliceEqlAsciiFold 和 containsAsciiFold 提取到中立的 text_helpers.zig 模块,
由 error_classify.zig 和 reliable.zig 共同引用。

变更:

  • 新增:src/providers/text_helpers.zig(88 行——中立模块,无 provider 导入)
  • 重构:src/providers/error_classify.zig(445 → 357 行,现从 reliable.zig 导入)
  • 重构:src/providers/reliable.zig(1555 → 1537 行,委托至 text_helpers)

**原因:**两个文件实现了相同的错误分类文本匹配断言。error_classify.zig
逐字节使用 containsAsciiFold;reliable.zig 使用单次小写转换缓冲。
统一为单一事实来源。

Validation:

zig build                    # clean
zig build test --summary all # 6098 passed, 11 skipped

manelsen and others added 2 commits March 30, 2026 23:53
Extract isRateLimitedText, isContextExhaustedText, isVisionUnsupportedText,
sliceEqlAsciiFold, and containsAsciiFold into a neutral text_helpers.zig module.
Both error_classify.zig and reliable.zig now import from it, removing ~140
lines of duplicated logic.

error_classify.zig: 445 → 357 lines (-88)
reliable.zig: 1555 → 1537 lines (-18)
@DonPrus DonPrus merged commit 5d0c05d into nullclaw:main Apr 17, 2026
3 checks passed
@manelsen manelsen deleted the refactor/error-helpers-dry-v3 branch April 17, 2026 17:50
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