Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| df8ac61c9e | |||
| ace49338b2 | |||
| 076fb25eda | |||
| feac10618d |
+13
-2
@@ -63,8 +63,11 @@ description: AI 开发专家,负责 document_analyzer 项目的功能开发、
|
|||||||
4. 轮询内容(多轮递进):
|
4. 轮询内容(多轮递进):
|
||||||
a. `--action list --labels product-code` — 先捡带 `product-code` 标签的 Issue
|
a. `--action list --labels product-code` — 先捡带 `product-code` 标签的 Issue
|
||||||
b. `--action list` 无过滤,筛选 title 带 `[product]` 前缀的无标签 Issue
|
b. `--action list` 无过滤,筛选 title 带 `[product]` 前缀的无标签 Issue
|
||||||
c. 都无则分析无标签、无标识的 Issue,判断是否在 Dev 域内
|
c. `--action blocked-check` — 检查 blocked Issue,若阻塞已解除则自动移除 blocked 标签
|
||||||
5. 有 issue → 走完整闭环处理(分析 → 开发 → push → PR → CI → merge → 自行验证 → 关闭)
|
d. 都无则分析无标签、无标识的 Issue,判断是否在 Dev 域内
|
||||||
|
5. 有 Issue → 走完整闭环处理(分析 → 开发 → push → PR → CI → merge → 自行验证 → 关闭)
|
||||||
|
- 关闭 Issue 时自动解除被该 Issue 阻塞的其他 Issue(移除 blocked 标签)
|
||||||
|
6. 无 Issue → 报告 "main healthy,无待处理 Issue",等待下次轮询
|
||||||
6. 无 issue → 报告 "main healthy,无待处理 Issue",等待下次轮询
|
6. 无 issue → 报告 "main healthy,无待处理 Issue",等待下次轮询
|
||||||
7. 同时保持对话开放,随时响应用户指令
|
7. 同时保持对话开放,随时响应用户指令
|
||||||
|
|
||||||
@@ -86,6 +89,13 @@ python scripts/agent_poller.py --action list
|
|||||||
**第三轮:分析无标识 Issue**
|
**第三轮:分析无标识 Issue**
|
||||||
如果以上两轮都无结果,分析所有无标签、无 title 标识的 Issue,判断是否属于 Dev 域。
|
如果以上两轮都无结果,分析所有无标签、无 title 标识的 Issue,判断是否属于 Dev 域。
|
||||||
|
|
||||||
|
**blocked Issue 处理**:
|
||||||
|
- 不要直接跳过 `blocked` 标签的 Issue
|
||||||
|
- 运行 `--action blocked-check` 检查阻塞状态是否已解除
|
||||||
|
- 如果所有阻塞 Issue 已关闭 → blocked 标签自动移除 → 正常处理
|
||||||
|
- 如果仍有未解决的阻塞 → 跳过,等待阻塞解除
|
||||||
|
- 关闭 Issue 时会自动检查并解除被其阻塞的 Issue(auto-unblock)
|
||||||
|
|
||||||
**处理范围**:Dev-Agent 负责处理**所有非纯测试开发**相关的 Issue。具体来说:
|
**处理范围**:Dev-Agent 负责处理**所有非纯测试开发**相关的 Issue。具体来说:
|
||||||
|
|
||||||
| 处理 | 跳过 |
|
| 处理 | 跳过 |
|
||||||
@@ -252,6 +262,7 @@ QE-Agent 开 Issue (qe-feedback / bug / ci-failure)
|
|||||||
| `--action pr-status --pr N` | 查看 PR + CI 状态 | 5. 等 CI |
|
| `--action pr-status --pr N` | 查看 PR + CI 状态 | 5. 等 CI |
|
||||||
| `--action merge-pr --pr N` | Merge PR(自动检查 CI) | 6. Merge |
|
| `--action merge-pr --pr N` | Merge PR(自动检查 CI) | 6. Merge |
|
||||||
| `--action close-issue --issue N --body "..."` | 手动关闭 Issue | 6. 关闭 |
|
| `--action close-issue --issue N --body "..."` | 手动关闭 Issue | 6. 关闭 |
|
||||||
|
| `--action blocked-check` | 检查并清理已解除阻塞的 Issue | 4-6. 轮询 |
|
||||||
| `--action lifecycle --issue N` | 查看 Issue 完整生命周期 | 随时 |
|
| `--action lifecycle --issue N` | 查看 Issue 完整生命周期 | 随时 |
|
||||||
|
|
||||||
## 闭环完成检查清单
|
## 闭环完成检查清单
|
||||||
|
|||||||
+13
-4
@@ -19,10 +19,12 @@ description: QE Agent — 自动化验收测试开发与质量门禁。轮询 Gi
|
|||||||
4. 轮询内容(多轮递进):
|
4. 轮询内容(多轮递进):
|
||||||
a. `--action list --labels test-code` — 先捡带 `test-code` 标签的 Issue
|
a. `--action list --labels test-code` — 先捡带 `test-code` 标签的 Issue
|
||||||
b. `--action list` 无过滤,筛选 title 带 `[test]` 前缀的无标签 Issue
|
b. `--action list` 无过滤,筛选 title 带 `[test]` 前缀的无标签 Issue
|
||||||
c. 都无则分析无标签、无标识的 Issue,判断是否在 QE 域内
|
c. `--action blocked-check` — 检查 blocked Issue,若阻塞已解除则自动移除 blocked 标签
|
||||||
d. 同时检查 `--labels acceptance-failure`
|
d. 都无则分析无标签、无标识的 Issue,判断是否在 QE 域内
|
||||||
5. 有 issue → 走完整闭环处理(Step 2-8)
|
e. 同时检查 `--labels acceptance-failure`
|
||||||
6. 无 issue → 简短报告 "main healthy",等待下次轮询
|
5. 有 Issue → 走完整闭环处理(Step 2-8)
|
||||||
|
- 关闭 Issue 时自动解除被该 Issue 阻塞的其他 Issue(移除 blocked 标签)
|
||||||
|
6. 无 Issue → 简短报告 "main healthy",等待下次轮询
|
||||||
7. 同时保持对话开放,随时响应用户指令
|
7. 同时保持对话开放,随时响应用户指令
|
||||||
|
|
||||||
这样 QE-Agent 真正做到 **"默认轮询 + 随时互动"**。
|
这样 QE-Agent 真正做到 **"默认轮询 + 随时互动"**。
|
||||||
@@ -69,6 +71,13 @@ python scripts/agent_poller.py --action list
|
|||||||
**第三轮:分析无标识 Issue**
|
**第三轮:分析无标识 Issue**
|
||||||
如果以上两轮都无结果,分析所有无标签、无 title 标识的 Issue,判断是否属于 QE 域。
|
如果以上两轮都无结果,分析所有无标签、无 title 标识的 Issue,判断是否属于 QE 域。
|
||||||
|
|
||||||
|
**blocked Issue 处理**:
|
||||||
|
- 不要直接跳过 `blocked` 标签的 Issue
|
||||||
|
- 运行 `--action blocked-check` 检查阻塞状态是否已解除
|
||||||
|
- 如果所有阻塞 Issue 已关闭 → blocked 标签自动移除 → 正常处理
|
||||||
|
- 如果仍有未解决的阻塞 → 跳过,等待阻塞解除
|
||||||
|
- 关闭 Issue 时会自动检查并解除被其阻塞的 Issue(auto-unblock)
|
||||||
|
|
||||||
同时检查 `acceptance-failure` 标签的 issue:
|
同时检查 `acceptance-failure` 标签的 issue:
|
||||||
```bash
|
```bash
|
||||||
python scripts/agent_poller.py --action list --labels acceptance-failure
|
python scripts/agent_poller.py --action list --labels acceptance-failure
|
||||||
|
|||||||
+129
-3
@@ -16,6 +16,7 @@ Usage:
|
|||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import urllib.error
|
import urllib.error
|
||||||
@@ -73,6 +74,56 @@ def list_issues(labels: list[str] | None = None):
|
|||||||
return issues
|
return issues
|
||||||
|
|
||||||
|
|
||||||
|
def blocked_check():
|
||||||
|
"""Check all blocked issues: if blocking issues are now closed, unblock.
|
||||||
|
|
||||||
|
Used by agents during polling to ensure blocked label doesn't persist
|
||||||
|
after blocking issues are resolved.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
all_blocked = _req("GET", "/issues?state=open&labels=blocked")
|
||||||
|
except SystemExit:
|
||||||
|
print("No blocked issues found.")
|
||||||
|
return
|
||||||
|
|
||||||
|
if not all_blocked:
|
||||||
|
print("No blocked issues found.")
|
||||||
|
return
|
||||||
|
|
||||||
|
unblocked_count = 0
|
||||||
|
for issue in all_blocked:
|
||||||
|
body = issue.get("body", "")
|
||||||
|
if not body:
|
||||||
|
continue
|
||||||
|
|
||||||
|
blocking_nums = {int(m.group(1)) for m in re.finditer(r'#(\d+)', body)}
|
||||||
|
if not blocking_nums:
|
||||||
|
continue
|
||||||
|
|
||||||
|
all_resolved = True
|
||||||
|
for blk in blocking_nums:
|
||||||
|
try:
|
||||||
|
blk_issue = _req("GET", f"/issues/{blk}")
|
||||||
|
if blk_issue.get("state") != "closed":
|
||||||
|
all_resolved = False
|
||||||
|
break
|
||||||
|
except SystemExit:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if all_resolved:
|
||||||
|
current_label_names = [l["name"] for l in issue.get("labels", [])]
|
||||||
|
new_label_names = [l for l in current_label_names if l != "blocked"]
|
||||||
|
new_label_ids = _label_names_to_ids(new_label_names)
|
||||||
|
_req("PUT", f"/issues/{issue['number']}/labels", {"labels": new_label_ids})
|
||||||
|
print(f"Unblocked #{issue['number']}: {issue['title']}")
|
||||||
|
comment_issue(issue["number"],
|
||||||
|
f"阻塞已解除:所有阻塞 Issue 均已关闭。")
|
||||||
|
unblocked_count += 1
|
||||||
|
|
||||||
|
if unblocked_count == 0:
|
||||||
|
print(f"Checked {len(all_blocked)} blocked issue(s): still blocked.")
|
||||||
|
|
||||||
|
|
||||||
def get_issue(num):
|
def get_issue(num):
|
||||||
i = _req("GET", f"/issues/{num}")
|
i = _req("GET", f"/issues/{num}")
|
||||||
print(f"## #{i['number']}: {i['title']}")
|
print(f"## #{i['number']}: {i['title']}")
|
||||||
@@ -91,14 +142,66 @@ def comment_issue(num, body):
|
|||||||
|
|
||||||
|
|
||||||
def close_issue(num, body=None):
|
def close_issue(num, body=None):
|
||||||
"""Close an issue, optionally with a final comment (signature auto-appended)."""
|
"""Close an issue, optionally with a final comment (signature auto-appended).
|
||||||
|
|
||||||
|
After closing, automatically unblocks any issues that were blocked by this one
|
||||||
|
if no other blocking issues remain open.
|
||||||
|
"""
|
||||||
if body:
|
if body:
|
||||||
comment_issue(num, body) # comment_issue already appends AGENT_SIG
|
comment_issue(num, body) # comment_issue already appends AGENT_SIG
|
||||||
i = _req("PATCH", f"/issues/{num}", {"state": "closed"})
|
i = _req("PATCH", f"/issues/{num}", {"state": "closed"})
|
||||||
print(f"Issue #{num} closed")
|
print(f"Issue #{num} closed")
|
||||||
|
_unblock_issues_blocked_by(num)
|
||||||
return i
|
return i
|
||||||
|
|
||||||
|
|
||||||
|
def _unblock_issues_blocked_by(closed_num):
|
||||||
|
"""Check issues blocked by *closed_num* and unblock if all blockers resolved.
|
||||||
|
|
||||||
|
Finds open issues with 'blocked' label whose body references *closed_num*
|
||||||
|
via a '阻塞: #N' pattern. If all referenced blocking issues are now closed,
|
||||||
|
removes the 'blocked' label and comments on the unblocked issue.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
all_blocked = _req("GET", "/issues?state=open&labels=blocked")
|
||||||
|
except SystemExit:
|
||||||
|
return
|
||||||
|
if not all_blocked:
|
||||||
|
return
|
||||||
|
|
||||||
|
for issue in all_blocked:
|
||||||
|
body = issue.get("body", "")
|
||||||
|
if not body:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Extract all issue numbers from the body (e.g. #21, #40)
|
||||||
|
blocking_nums = {int(m.group(1)) for m in re.finditer(r'#(\d+)', body)}
|
||||||
|
if closed_num not in blocking_nums:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Check all referenced issues — are they all closed?
|
||||||
|
all_resolved = True
|
||||||
|
for blk in blocking_nums:
|
||||||
|
if blk == closed_num:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
blk_issue = _req("GET", f"/issues/{blk}")
|
||||||
|
if blk_issue.get("state") != "closed":
|
||||||
|
all_resolved = False
|
||||||
|
break
|
||||||
|
except SystemExit:
|
||||||
|
pass # Inaccessible → treat as resolved
|
||||||
|
|
||||||
|
if all_resolved:
|
||||||
|
current_label_names = [l["name"] for l in issue.get("labels", [])]
|
||||||
|
new_label_names = [l for l in current_label_names if l != "blocked"]
|
||||||
|
new_label_ids = _label_names_to_ids(new_label_names)
|
||||||
|
_req("PUT", f"/issues/{issue['number']}/labels", {"labels": new_label_ids})
|
||||||
|
print(f" -> Unblocked #{issue['number']}: all blocking issues resolved")
|
||||||
|
comment_issue(issue["number"],
|
||||||
|
f"阻塞已解除:#{closed_num} 及其他阻塞 Issue 均已关闭。")
|
||||||
|
|
||||||
|
|
||||||
def create_issue(title, body=None, labels=None):
|
def create_issue(title, body=None, labels=None):
|
||||||
"""Create a new Gitea issue.
|
"""Create a new Gitea issue.
|
||||||
|
|
||||||
@@ -110,7 +213,11 @@ def create_issue(title, body=None, labels=None):
|
|||||||
if body:
|
if body:
|
||||||
payload["body"] = body + AGENT_SIG
|
payload["body"] = body + AGENT_SIG
|
||||||
if labels:
|
if labels:
|
||||||
payload["labels"] = [l.strip() for l in labels.split(",") if l.strip()]
|
label_names = [l.strip() for l in labels.split(",") if l.strip()]
|
||||||
|
# Gitea 1.22 expects label IDs (int64). Resolve names → IDs.
|
||||||
|
label_ids = _label_names_to_ids(label_names)
|
||||||
|
if label_ids:
|
||||||
|
payload["labels"] = label_ids
|
||||||
i = _req("POST", "/issues", payload)
|
i = _req("POST", "/issues", payload)
|
||||||
issue_labels = [l["name"] for l in i.get("labels", [])]
|
issue_labels = [l["name"] for l in i.get("labels", [])]
|
||||||
print(f"Issue #{i['number']} created: {i['title']}")
|
print(f"Issue #{i['number']} created: {i['title']}")
|
||||||
@@ -120,6 +227,22 @@ def create_issue(title, body=None, labels=None):
|
|||||||
return i
|
return i
|
||||||
|
|
||||||
|
|
||||||
|
def _label_names_to_ids(names: list[str]) -> list[int]:
|
||||||
|
"""Resolve label names to Gitea label IDs. Returns empty list on failure."""
|
||||||
|
try:
|
||||||
|
all_labels = _req("GET", "/labels")
|
||||||
|
name_to_id = {l["name"]: l["id"] for l in all_labels}
|
||||||
|
ids = []
|
||||||
|
for name in names:
|
||||||
|
if name in name_to_id:
|
||||||
|
ids.append(name_to_id[name])
|
||||||
|
else:
|
||||||
|
print(f"Warning: label '{name}' not found, skipping", file=sys.stderr)
|
||||||
|
return ids
|
||||||
|
except SystemExit:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
# ── PR operations ────────────────────────────────────────────────────────────
|
# ── PR operations ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
def create_pr(issue_num, branch, body=None):
|
def create_pr(issue_num, branch, body=None):
|
||||||
@@ -234,7 +357,8 @@ def main():
|
|||||||
parser = argparse.ArgumentParser(description="Dev agent Gitea helper")
|
parser = argparse.ArgumentParser(description="Dev agent Gitea helper")
|
||||||
parser.add_argument("--action", required=True,
|
parser.add_argument("--action", required=True,
|
||||||
choices=["list", "get", "comment", "close-issue",
|
choices=["list", "get", "comment", "close-issue",
|
||||||
"create-issue", "create-pr", "pr-status", "merge-pr", "lifecycle"])
|
"create-issue", "create-pr", "pr-status", "merge-pr", "lifecycle",
|
||||||
|
"blocked-check"])
|
||||||
parser.add_argument("--issue", type=int)
|
parser.add_argument("--issue", type=int)
|
||||||
parser.add_argument("--pr", type=int)
|
parser.add_argument("--pr", type=int)
|
||||||
parser.add_argument("--title", help="Issue title (for 'create-issue' action)")
|
parser.add_argument("--title", help="Issue title (for 'create-issue' action)")
|
||||||
@@ -286,6 +410,8 @@ def main():
|
|||||||
print("--pr is required for 'merge-pr' action", file=sys.stderr)
|
print("--pr is required for 'merge-pr' action", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
merge_pr(args.pr)
|
merge_pr(args.pr)
|
||||||
|
elif args.action == "blocked-check":
|
||||||
|
blocked_check()
|
||||||
elif args.action == "lifecycle":
|
elif args.action == "lifecycle":
|
||||||
if not args.issue:
|
if not args.issue:
|
||||||
print("--issue is required for 'lifecycle' action", file=sys.stderr)
|
print("--issue is required for 'lifecycle' action", file=sys.stderr)
|
||||||
|
|||||||
@@ -291,6 +291,85 @@ def _measure_coverage(ir_data: dict, parsed_data: dict) -> dict:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_measure_coverage_excludes_zero_dimensions():
|
||||||
|
"""#36: dimensions with total=0 must not drag down the overall rate.
|
||||||
|
|
||||||
|
When diagram total=0, the overall should be computed from sections and tables
|
||||||
|
only, not include a 0% diagram entry that makes the goal unreachable.
|
||||||
|
"""
|
||||||
|
parsed_data = {
|
||||||
|
"sections": [
|
||||||
|
{"source": "3.1.1 功能A", "blocks": [
|
||||||
|
{"type": "table", "rows": [{"cell": "1"}, {"cell": "2"}]}
|
||||||
|
]}
|
||||||
|
],
|
||||||
|
"image_analysis": [], # no diagrams → total=0
|
||||||
|
}
|
||||||
|
# IR that covers the section but no table rows (table coverage = 0/2)
|
||||||
|
ir_data = {
|
||||||
|
"rules": [
|
||||||
|
{"sources": [{"section": "3.1.1"}]} # 1 section covered, 0 tables
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
cov = _measure_coverage(ir_data, parsed_data)
|
||||||
|
|
||||||
|
# Section: 1/1 = 100%, Table: 0/2 = 0%, Diagram: total=0 → excluded
|
||||||
|
assert cov["section_coverage"]["total"] == 1
|
||||||
|
assert cov["section_coverage"]["rate"] == 1.0
|
||||||
|
assert cov["table_coverage"]["total_rows"] == 2
|
||||||
|
assert cov["table_coverage"]["rate"] == 0.0
|
||||||
|
assert cov["diagram_coverage"]["total"] == 0
|
||||||
|
assert cov["diagram_coverage"]["rate"] == 1.0 # _safe_rate: 0/0 → 1.0
|
||||||
|
|
||||||
|
# Key assertion: diagram (total=0) is excluded from overall
|
||||||
|
# overall = (1.0 + 0.0) / 2 = 0.5
|
||||||
|
# NOT (1.0 + 0.0 + 1.0) / 3 = 0.667
|
||||||
|
assert cov["overall_rate"] == 0.5, (
|
||||||
|
f"Expected overall 0.5 (sections + tables only), got {cov['overall_rate']}. "
|
||||||
|
f"Zero-content dimension may be leaking into the average."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_measure_coverage_all_dimensions_have_content():
|
||||||
|
"""When all dimensions have content, all should be included."""
|
||||||
|
parsed_data = {
|
||||||
|
"sections": [
|
||||||
|
{"source": "3.1.1 功能A", "blocks": [
|
||||||
|
{"type": "table", "rows": [{"cell": "1"}]}
|
||||||
|
]}
|
||||||
|
],
|
||||||
|
"image_analysis": [{"type": "flowchart", "rid": "img_001"}],
|
||||||
|
}
|
||||||
|
ir_data = {
|
||||||
|
"rules": [
|
||||||
|
{"sources": [{"section": "3.1.1"}]},
|
||||||
|
{"sources": [{"type": "table", "section": "3.1.1", "row": 0}]},
|
||||||
|
{"sources": [{"type": "logic_tree", "image_id": "img_001"}]},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
cov = _measure_coverage(ir_data, parsed_data)
|
||||||
|
|
||||||
|
# All three dimensions have content → all included
|
||||||
|
assert cov["section_coverage"]["total"] == 1
|
||||||
|
assert cov["table_coverage"]["total_rows"] == 1
|
||||||
|
assert cov["diagram_coverage"]["total"] == 1
|
||||||
|
# overall = (1.0 + 1.0 + 1.0) / 3 = 1.0
|
||||||
|
assert cov["overall_rate"] == 1.0, (
|
||||||
|
f"Expected overall 1.0 (all covered), got {cov['overall_rate']}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_measure_coverage_no_content_returns_zero():
|
||||||
|
"""When no dimensions have content, overall should be 0.0."""
|
||||||
|
parsed_data = {"sections": [], "image_analysis": []}
|
||||||
|
ir_data = {"rules": []}
|
||||||
|
|
||||||
|
cov = _measure_coverage(ir_data, parsed_data)
|
||||||
|
assert cov["overall_rate"] == 0.0
|
||||||
|
|
||||||
|
|
||||||
def test_layer_b_coverage(
|
def test_layer_b_coverage(
|
||||||
ir_data: dict,
|
ir_data: dict,
|
||||||
parsed_data: dict | None,
|
parsed_data: dict | None,
|
||||||
|
|||||||
Reference in New Issue
Block a user