Skip to content

fix(hooks): keep a path's lone surrogates when a run log text is cut - #116

Merged
openjiuwen-release-bot[bot] merged 1 commit into
openJiuwen-ai:mainfrom
openjiuwenai:sync/pr-83
Oct 24, 2026
Merged

openjiuwen-release-bot[bot] merged 1 commit into
openJiuwen-ai:mainfrom
openjiuwenai:sync/pr-83

Conversation

@openjiuwen-sync-bot

@openjiuwen-sync-bot openjiuwen-sync-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Paired: GitHub #116 ↔ GitCode !83

Summary

!81 (GitHub #​111) merged the Hooks panel at e740b102, one push before its final head 3c2c0d33. This MR brings in that last push, which is three files:

  • service/hooks/run_log.py: _clip_text no longer decodes the cut with "ignore". That dropped every lone surrogate in a changed-arguments or block-reason text over 64 KB. A path that is not UTF-8 holds such surrogates. Now the cut only drops the character the limit splits: it backs up to that character's first byte and decodes with "surrogatepass".
  • tests/service/hooks/test_run_log_retention.py: the cap test now checks every unit, including a lone surrogate. The kept text must start the full text and end within 4 bytes of the limit.
  • tests/orchestration/engine/test_hook_run_reporting.py: removes a trailing wait_until that could not fail.

The tree is identical to 3c2c0d33, whose CI passed in full.

Test plan

  • test_changed_arguments_past_the_cap_are_cut_with_their_size_kept[lone-surrogate] fails against main and passes with this change.
  • Smart Test --paths on the three files: 12589 passed, 10 skipped; architecture 390 passed.
  • ruff check, ruff format --check, and ty check (linux, darwin, win32).
  • GitHub CI on this exact commit (de64d5eb, the closed GitHub #​115): all 17 checks passed.

The Hooks panel merged from the branch one push before its last, so a
cut of changed arguments or a block reason past 64 KB still decoded
with "ignore": it dropped every lone surrogate of the text (what a path
that is not UTF-8 holds), not only the character the cut splits. The
cut now backs up to the first byte of the character the limit splits
and decodes the rest with "surrogatepass".

The retention test checks, for every unit a lone surrogate included,
that the kept text starts the full text and ends within 4 bytes of the
limit. A trailing wait in the reporting test that could not fail is
removed.
@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: de64d5ebe720f6dd15eebaa07afbf11a45e8aaf1

变更摘要

本次变更修复了 _clip_text 在截断超长运行日志文本时丢失孤立代理字符(lone surrogate)的问题。此前对超过 64 KB 的变更参数或阻断原因文本按 "ignore" 解码,会把非 UTF-8 路径中包含的孤立代理字符全部丢弃;现在改为先回退到被限制切开的那个字符的首字节,再以 "surrogatepass" 解码,从而只丢弃被切开的那一个字符,其余内容原样保留。配套测试相应收紧了对截断结果长度与内容前缀的断言。

主要改动

  • _clip_text 截断逻辑: src/chrys/service/hooks/run_log.py 中的 _clip_text 不再使用 data[:limit].decode("utf-8", "ignore"),而是先把 cut 指针沿 10xxxxxx 续字节回退到被切开字符的首字节,再用 "surrogatepass" 解码,避免丢失文本中的孤立代理字符。
  • 函数文档说明更新: _clip_text 的 docstring 由「丢弃所有孤立代理字符」改为「保留非 UTF-8 路径携带的孤立代理字符」,与新行为保持一致。
  • 截断测试断言强化: tests/service/hooks/test_run_log_retention.py 的容量测试改为要求保留文本长度落在 HOOK_RUN_TEXT_MAX_BYTES - 4 到上限之间,并去掉对孤立代理字符用例的跳过,统一校验 full.startswith(kept)。
  • 清理无效等待断言: tests/orchestration/engine/test_hook_run_reporting.py 删除了尾部不会失败的 wait_until 断言,并移除对应导入。

@openjiuwen-collaboration-bot

openjiuwen-collaboration-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

head_sha: de64d5ebe720f6dd15eebaa07afbf11a45e8aaf1

代码审查

✅ 未发现问题

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: de64d5ebe720f6dd15eebaa07afbf11a45e8aaf1

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A

@openjiuwen-release-bot
openjiuwen-release-bot Bot merged commit 2bef27d into openJiuwen-ai:main Oct 24, 2026
34 checks passed
@openjiuwen-release-bot

Copy link
Copy Markdown
Contributor

🤖 This pull request has been merged, and the target branch is up to date.

openjiuwen-release-bot Bot pushed a commit that referenced this pull request Oct 24, 2026
fix(hooks): keep a path's lone surrogates when a run log text is cut

Created-by: Ox7c13
Commit-by: Jiaqi (0x7c13) Liu
Merged-by: Ox7c13
Description: Paired: [GitHub #116](#116) ↔ [GitCode !83](https://gitcode.com/openJiuwen/iCode/merge_requests/83)

## Summary

!81 (GitHub #111) merged the Hooks panel at `e740b102`, one push before its final head `3c2c0d33`. This MR brings in that last push, which is three files:

- **`service/hooks/run_log.py`:** `_clip_text` no longer decodes the cut with `"ignore"`. That dropped every lone surrogate in a changed-arguments or block-reason text over 64 KB. A path that is not UTF-8 holds such surrogates. Now the cut only drops the character the limit splits: it backs up to that character's first byte and decodes with `"surrogatepass"`.
- **`tests/service/hooks/test_run_log_retention.py`:** the cap test now checks every unit, including a lone surrogate. The kept text must start the full text and end within 4 bytes of the limit.
- **`tests/orchestration/engine/test_hook_run_reporting.py`:** removes a trailing `wait_until` that could not fail.

The tree is identical to `3c2c0d33`, whose CI passed in full.

## Test plan

- [x] `test_changed_arguments_past_the_cap_are_cut_with_their_size_kept[lone-surrogate]` fails against `main` and passes with this change.
- [x] Smart Test `--paths` on the three files: 12589 passed, 10 skipped; architecture 390 passed.
- [x] `ruff check`, `ruff format --check`, and `ty check` (linux, darwin, win32).
- [x] GitHub CI on this exact commit (`de64d5eb`, the closed GitHub #115): all 17 checks passed.

<!-- bot4-pr-sync-meta
schema_version: 1
source: gitcode
gitcode_repo: openJiuwen/iCode
gitcode_mr: 83
github_repo: openJiuwen-ai/iCode
github_pr: 116
github_branch: sync/pr-83
-->

See merge request: openJiuwen/iCode!83
@openjiuwenai
openjiuwenai deleted the sync/pr-83 branch October 24, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant