Open
fix(workflow): retain incomplete log records for the next poll #240
fix(workflow): retain incomplete log records for the next poll #240
Open
tianjunAdd on Oct 30
tianjun
tianjun
Oct 30

描述

工作流日志末行尚未写完时,轮询会提前持久化该行偏移,补全后丢失完整事件;分段UTF-8还会导致未捕获异常。此修复通过增量UTF-8解码保留不完整尾字节,并只推进已完成记录的行偏移。完整的无换行JSON仍立即展示,已换行的坏JSON仍原文展示。仅修改poll_workflow.py和现有test_poll_workflow.py,0新增源码文件,保留原版权。

关联的Issue

Fixes #126。

测试

源提交 7057da3ac72dc3330e595c47af07b56ac5887933,父提交17025af5a8a50e9a0d5d83e0e14b1577b0c7d554。
Linux aarch64、Python3.11.4;在工作树和全新干净提交树运行:
python3 -m pytest harness/workflow-orchestrator/tests/test_poll_workflow.py -q

同一37项完整CLI测试,原版6失败/31通过,修复和干净提交树均37通过、0跳过。覆盖真实半JSON追加、UTF-8第一/第二字节分段、完整前缀、无末尾换行的完整JSON、CRLF、非对象JSON、坏记录和完整非法UTF-8;原有28项用例保留。真实truncate/文件替换轮转的5场景、三版本各15次CLI对照,输出/退出码/偏移完全一致。轮转仍沿用既有行偏移语义,未增加inode跟踪。

全部适用原生pre-commit、正常提交钩子、干净树检查和OAT实际2文件通过。测试使用真实文件和完整CLI子进程,没有调用真实agent CLI、外部模型、kernel构建或NPU。

文档更新

在现有poll_workflow.py说明中明确尾记录等待、完整无换行JSON及坏记录的处理边界。

类型标签

CodeCheck 跟进

将现有测试类的私有辅助方法移到公开测试方法之后,并复用公共子图fixture消除13行重复。保留全部37项测试名称和断言,生产文件字节保持不变;工作与干净树同套37通过,原生hooks及OAT通过。

likedislike
Merge blocked
tianjuntianjun
Oct 30 Created pull request, commit 0789ad34
tianjuntianjun
Oct 30 Associated issue: [Bug-Report|缺陷反馈]: 工作流轮询提前消费未写完的日志行,补全后丢失事件
CANN-robotCANN-robotCollaborators
Oct 30 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Oct 30 Comments:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)

Module Approval Details

module lgtm status approve status
harness ❌ (0/2)(You can also ask: qq_37913898, dengguojie, 宋恺, benwallace52, 金炯) ❌ (0/1)(You can also ask: 宋恺, 周奇龙)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

Ethan_Zou, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robotCollaborators
Oct 30 Set qq_37913898,w00934874,dengguojie,jon_jin,zhou-qilong,rxtfeng,songkai111,xutianze,pingchuantang,hanrui22,wangzheng97,hedi0515,benwallace52,linghuis,OpSphere,zihengwang2 as approver
62 messages are collapsed here。 See more
tianjuntianjun
9 days ago Pre merge succeeded (commit_id: ab3e118ab86ae993e5cefe9a57f68e7ac8e8ba78)
CANN-robot
CANN-robotCollaborators
9 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
9 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
9 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
9 days ago Added label: ci-pipeline-passed