源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
Creator App Tests / PR Spam Gate (push) Skipped
Frontend Tests / PR Spam Gate (push) Skipped
NPM Format (website & console) / PR Spam Gate (push) Skipped
Pre-commit Checks / PR Spam Gate (push) Skipped
QwenPaw Creator Plugin Release / check-version (push) Canceled after 0s
QwenPaw Creator Plugin Release / upload-oss (push) Canceled after 0s
Tests / PR Spam Gate (push) Skipped
CodeQL / CodeQL (python) (push) Canceled after 0s
CodeQL / CodeQL (typescript) (push) Canceled after 0s
Creator App Tests / Creator Backend Tests (push) Canceled after 0s
Creator App Tests / Creator UI Build & Tests (push) Canceled after 0s
E2E Smoke Tests / Playwright UI Smoke (push) Canceled after 0s
Frontend Tests / Detect console changes (push) Canceled after 0s
NPM Format (website & console) / website format check (push) Canceled after 0s
NPM Format (website & console) / console format check (push) Canceled after 0s
Pre-commit Checks / Pre-commit (push) Canceled after 0s
QwenPaw Data Plugin Release / check-version (push) Canceled after 0s
Tests / Detect code changes (push) Canceled after 0s
Frontend Tests / Vitest Unit Tests (push) Canceled after 0s
Frontend Tests / Frontend Summary (push) Canceled after 0s
QwenPaw Data Plugin Release / upload-oss (push) Canceled after 0s
Tests / Maintainer Approval (push) Canceled after 0s
Tests / Unit Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - fallback (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p2 (push) Canceled after 0s
Tests / Coverage Report (push) Canceled after 0s
Tests / Test Summary (push) Canceled after 0s

This commit is contained in:
agent-radar
2026-09-01 20:01:50 +08:00
commit 1a3a4ccde1
4652 changed files with 1891610 additions and 0 deletions
@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
from pathlib import Path
import yaml
REPO_ROOT = Path(__file__).resolve().parents[3]
WORKFLOW_PATH = REPO_ROOT / ".github" / "workflows" / "pr-ai-review.yml"
def _load_workflow() -> dict:
return yaml.safe_load(WORKFLOW_PATH.read_text(encoding="utf-8"))
def test_ai_reviewer_and_publisher_have_separate_permissions() -> None:
workflow = _load_workflow()
jobs = workflow["jobs"]
assert workflow["permissions"] == {}
assert jobs["review-gate"]["permissions"] == {}
assert jobs["ai-review"]["permissions"] == {
"contents": "read",
"pull-requests": "read",
}
assert jobs["publish-review"]["permissions"] == {
"actions": "read",
"pull-requests": "write",
}
def test_ai_reviewer_and_publisher_capabilities_are_isolated() -> None:
jobs = _load_workflow()["jobs"]
analysis_steps = str(jobs["ai-review"]["steps"])
assert "createComment" not in analysis_steps
assert "addLabels" not in analysis_steps
assert "removeLabel" not in analysis_steps
publisher = jobs["publish-review"]
publisher_steps = str(publisher["steps"])
assert all("run" not in step for step in publisher["steps"])
assert "review_runner.py" not in publisher_steps
assert "Start QwenPaw server" not in publisher_steps
def test_publisher_rejects_a_stale_review_before_writing() -> None:
publisher_steps = _load_workflow()["jobs"]["publish-review"]["steps"]
publish_step = next(
step
for step in publisher_steps
if step["name"] == "Post review comment and manage labels"
)
publish_script = publish_step["with"]["script"]
assert "context.payload.pull_request.head.sha" in publish_script
assert "pulls.get" in publish_script
assert "currentPull.data.head.sha" in publish_script
assert publish_step["env"]["REVIEW_VERDICT"] == (
"${{ needs.ai-review.outputs.verdict }}"
)
assert "needs.ai-review.outputs.verdict" not in publish_script
@@ -0,0 +1,187 @@
# -*- coding: utf-8 -*-
"""Unit tests for real_behavior_proof_check.py CI entry point.
Covers event payload parsing, missing fields, and label API failure
paths that the pure-policy tests do not exercise.
"""
# pylint: disable=protected-access,redefined-outer-name,unused-argument
# pylint: disable=wrong-import-position,line-too-long,unused-import
# flake8: noqa: E501
from __future__ import annotations
import json
import os
import sys
from pathlib import Path
from unittest import mock # noqa: E402
# Add scripts/github to path.
sys.path.insert(
0,
str(Path(__file__).resolve().parents[3] / "scripts" / "github"),
)
import real_behavior_proof_check as check_mod # noqa: E402
def _write_event(tmp_path: Path, pr_data: dict) -> str:
"""Write a GitHub Actions event payload to a temp file and return
its path."""
event = {"pull_request": pr_data}
path = tmp_path / "event.json"
path.write_text(json.dumps(event), encoding="utf-8")
return str(path)
class TestEventPayloadParsing:
"""Verify that main() correctly reads PR fields from the GitHub
Actions event payload."""
@staticmethod
def test_passes_with_valid_body(tmp_path: Path):
event_path = _write_event(
tmp_path,
{
"body": "## Description\n\nFixed a bug.\n\n## Evidence\n\npytest passed.",
"author_association": "CONTRIBUTOR",
"user": {"login": "contributor", "type": "User"},
"labels": [],
"number": 42,
"html_url": "https://github.com/test/repo/pull/42",
},
)
with mock.patch.dict(os.environ, {"GITHUB_EVENT_PATH": event_path}):
assert check_mod.main() == 0
@staticmethod
def test_fails_with_missing_evidence(tmp_path: Path):
event_path = _write_event(
tmp_path,
{
"body": "## Description\n\nFixed a bug.",
"author_association": "CONTRIBUTOR",
"user": {"login": "contributor", "type": "User"},
"labels": [],
"number": 42,
},
)
with mock.patch.dict(os.environ, {"GITHUB_EVENT_PATH": event_path}):
assert check_mod.main() == 1
@staticmethod
def test_skips_maintainer(tmp_path: Path):
event_path = _write_event(
tmp_path,
{
"body": "",
"author_association": "MEMBER",
"user": {"login": "maint", "type": "User"},
"labels": [],
"number": 1,
},
)
with mock.patch.dict(os.environ, {"GITHUB_EVENT_PATH": event_path}):
assert check_mod.main() == 0
@staticmethod
def test_skips_bot(tmp_path: Path):
event_path = _write_event(
tmp_path,
{
"body": "",
"author_association": "NONE",
"user": {"login": "bot", "type": "Bot"},
"labels": [],
"number": 1,
},
)
with mock.patch.dict(os.environ, {"GITHUB_EVENT_PATH": event_path}):
assert check_mod.main() == 0
class TestMissingFields:
"""Verify graceful handling of missing or empty PR fields."""
@staticmethod
def test_handles_missing_body(tmp_path: Path):
event_path = _write_event(
tmp_path,
{
"author_association": "CONTRIBUTOR",
"user": {"login": "c", "type": "User"},
"labels": [],
},
)
with mock.patch.dict(os.environ, {"GITHUB_EVENT_PATH": event_path}):
# Missing body → missing sections → exit 1
assert check_mod.main() == 1
@staticmethod
def test_handles_none_body(tmp_path: Path):
event_path = _write_event(
tmp_path,
{
"body": None,
"author_association": "CONTRIBUTOR",
"user": {"login": "c", "type": "User"},
"labels": [],
},
)
with mock.patch.dict(os.environ, {"GITHUB_EVENT_PATH": event_path}):
assert check_mod.main() == 1
@staticmethod
def test_handles_missing_pull_request_key(tmp_path: Path):
"""When GITHUB_EVENT_PATH points to a file with no
pull_request key (e.g. push event)."""
path = tmp_path / "event.json"
path.write_text(json.dumps({"ref": "refs/heads/main"}))
with mock.patch.dict(os.environ, {"GITHUB_EVENT_PATH": str(path)}):
# No PR data → empty body → missing → exit 1
assert check_mod.main() == 1
@staticmethod
def test_handles_missing_event_file(tmp_path: Path):
"""When GITHUB_EVENT_PATH doesn't exist (e.g. local run)."""
with mock.patch.dict(
os.environ,
{"GITHUB_EVENT_PATH": str(tmp_path / "nonexistent.json")},
):
# No event file → empty pr dict → missing → exit 1
assert check_mod.main() == 1
class TestLabelParsing:
"""Verify label extraction from PR payload."""
@staticmethod
def test_reads_labels_from_event(tmp_path: Path):
event_path = _write_event(
tmp_path,
{
"body": "## Description\n\nx.\n\n## Evidence\n\ny.",
"author_association": "CONTRIBUTOR",
"user": {"login": "c", "type": "User"},
"labels": [
{"name": "proof: sufficient"},
{"name": "bug"},
],
},
)
with mock.patch.dict(os.environ, {"GITHUB_EVENT_PATH": event_path}):
# proof: sufficient label → skipped
assert check_mod.main() == 0
@staticmethod
def test_handles_empty_labels_list(tmp_path: Path):
event_path = _write_event(
tmp_path,
{
"body": "## Description\n\nx.\n\n## Evidence\n\ny.",
"author_association": "CONTRIBUTOR",
"user": {"login": "c", "type": "User"},
"labels": [],
},
)
with mock.patch.dict(os.environ, {"GITHUB_EVENT_PATH": event_path}):
assert check_mod.main() == 0
@@ -0,0 +1,274 @@
# -*- coding: utf-8 -*-
"""Unit tests for the real-behavior-proof policy.
Ported from openclaw's ``real-behavior-proof-policy.test.ts`` and adapted
to QwenPaw's Python implementation.
"""
# pylint: disable=protected-access,redefined-outer-name,unused-argument
# pylint: disable=wrong-import-position,line-too-long
# flake8: noqa: E501
from __future__ import annotations
import sys
from pathlib import Path
# Add scripts/github to path so we can import the policy module.
sys.path.insert(
0,
str(Path(__file__).resolve().parents[3] / "scripts" / "github"),
)
from real_behavior_proof_policy import ( # noqa: E402
NEEDS_PR_CONTEXT_LABEL,
PROOF_SUFFICIENT_LABEL,
ProofStatus,
_has_real_content,
_mask_html_comments,
evaluate_pull_request_context,
labels_for_pull_request_context,
)
def _external_pr(body: str, **overrides) -> dict:
pr = {
"body": body,
"author_association": "CONTRIBUTOR",
"author_type": "User",
"labels": [],
}
pr.update(overrides)
return pr
def _proof_body(
evidence: str,
problem: str = "The gateway crashed on startup.",
) -> str:
return f"""## Description
{problem}
## Evidence
{evidence}
"""
class TestExternalPrPass:
"""External PRs with real evidence should pass."""
@staticmethod
def test_passes_with_screenshot_evidence():
ev = evaluate_pull_request_context(
**_external_pr(
_proof_body(
"![after](https://github.com/user-attachments/assets/abc123)",
),
),
)
assert ev.status == ProofStatus.PASSED
assert labels_for_pull_request_context(ev) == [PROOF_SUFFICIENT_LABEL]
@staticmethod
def test_passes_with_terminal_transcript():
ev = evaluate_pull_request_context(
**_external_pr(
_proof_body(
"Terminal transcript:\n```text\n$ pytest -q\n4 passed\n```",
),
),
)
assert ev.status == ProofStatus.PASSED
@staticmethod
def test_passes_with_fenced_evidence_only_no_prose():
# Regression for #6626: an Evidence section that contains ONLY a
# fenced transcript (no prose outside the fence) must still pass.
# The old _strip_code_fences deleted the whole block, leaving
# Evidence empty -> MISSING. The fence-aware section extractor keeps
# the fenced content so the section has real authored content.
ev = evaluate_pull_request_context(
**_external_pr(
_proof_body(
"```text\n$ pytest -q\n4 passed\n```",
),
),
)
assert ev.status == ProofStatus.PASSED
@staticmethod
def test_fenced_heading_does_not_start_section():
# Regression for #6626: a heading-like line INSIDE a fenced block
# must not be treated as a real section boundary (and must not
# truncate the surrounding Evidence section).
ev = evaluate_pull_request_context(
**_external_pr(
_proof_body(
"```bash\n$ pytest -q\n## NOT A HEADING\n4 passed\n```",
),
),
)
assert ev.status == ProofStatus.PASSED
# The fake heading inside the fence must not register as a section.
assert not ev.missing_sections
@staticmethod
def test_passes_with_test_output():
ev = evaluate_pull_request_context(
**_external_pr(_proof_body("pytest passed: 4 files, 67 cases.")),
)
assert ev.status == ProofStatus.PASSED
@staticmethod
def test_passes_with_ci_artifact_link():
ev = evaluate_pull_request_context(
**_external_pr(
_proof_body(
"CI artifact: https://github.com/agentscope-ai/QwenPaw/actions/runs/123/artifacts/456",
),
),
)
assert ev.status == ProofStatus.PASSED
class TestMissingSections:
"""PRs missing required sections should be flagged."""
@staticmethod
def test_fails_without_any_context():
ev = evaluate_pull_request_context(
**_external_pr("## Summary\n\n- Fixed a bug."),
)
assert ev.status == ProofStatus.MISSING
assert "What Problem This Solves" in ev.missing_sections
assert "Evidence" in ev.missing_sections
assert NEEDS_PR_CONTEXT_LABEL in labels_for_pull_request_context(ev)
@staticmethod
def test_fails_without_evidence():
ev = evaluate_pull_request_context(
**_external_pr("## Description\n\nFixed the cron DOW bug."),
)
assert ev.status == ProofStatus.MISSING
assert "Evidence" in ev.missing_sections
@staticmethod
def test_fails_with_template_comment_only():
ev = evaluate_pull_request_context(
**_external_pr(
"<!-- Describe what this PR does and why -->\n## Evidence\n\n<!-- paste result -->",
),
)
assert ev.status == ProofStatus.MISSING
@staticmethod
def test_fails_with_not_tested():
ev = evaluate_pull_request_context(
**_external_pr(_proof_body("not tested")),
)
assert ev.status == ProofStatus.MISSING
assert "Evidence" in ev.missing_sections
@staticmethod
def test_fails_with_none_evidence():
ev = evaluate_pull_request_context(
**_external_pr(_proof_body("None")),
)
assert ev.status == ProofStatus.MISSING
@staticmethod
def test_fails_with_separator_only():
ev = evaluate_pull_request_context(
**_external_pr(_proof_body("---", problem="***")),
)
assert ev.status == ProofStatus.MISSING
class TestSkipRules:
"""Maintainer and bot PRs should be skipped."""
@staticmethod
def test_skips_member():
ev = evaluate_pull_request_context(
**_external_pr("", author_association="MEMBER"),
)
assert ev.status == ProofStatus.SKIPPED
@staticmethod
def test_skips_owner():
ev = evaluate_pull_request_context(
**_external_pr("", author_association="OWNER"),
)
assert ev.status == ProofStatus.SKIPPED
@staticmethod
def test_skips_bot():
ev = evaluate_pull_request_context(
**_external_pr("", author_type="Bot"),
)
assert ev.status == ProofStatus.SKIPPED
@staticmethod
def test_skips_proof_sufficient_label():
ev = evaluate_pull_request_context(
**_external_pr("", labels=[PROOF_SUFFICIENT_LABEL]),
)
assert ev.status == ProofStatus.SKIPPED
class TestHtmlCommentMasking:
"""HTML comments should be masked so commented template text doesn't count."""
@staticmethod
def test_html_comment_does_not_count_as_content():
ev = evaluate_pull_request_context(
**_external_pr(
"## Description\n\n<!-- Describe what this PR does and why -->\n## Evidence\n\n<!-- paste result -->",
),
)
assert ev.status == ProofStatus.MISSING
@staticmethod
def test_real_content_alongside_html_comments_passes():
ev = evaluate_pull_request_context(
**_external_pr(
"## Description\n\n<!-- old -->Fixed the DOW bug.\n## Evidence\n\n<!-- old -->pytest passed.",
),
)
assert ev.status == ProofStatus.PASSED
class TestHelperFunctions:
@staticmethod
def test_has_real_content_rejects_empty():
assert not _has_real_content("")
@staticmethod
def test_has_real_content_rejects_none():
assert not _has_real_content("None")
assert not _has_real_content("none")
assert not _has_real_content("N/A")
assert not _has_real_content("n/a")
@staticmethod
def test_has_real_content_rejects_not_tested():
assert not _has_real_content("not tested")
assert not _has_real_content("untested")
@staticmethod
def test_has_real_content_rejects_separator():
assert not _has_real_content("---")
assert not _has_real_content("***")
@staticmethod
def test_has_real_content_accepts_real_text():
assert _has_real_content("pytest passed: 4 files, 67 cases")
assert _has_real_content("![screenshot](url)")
@staticmethod
def test_mask_html_comments():
text = "Before <!-- comment --> After"
result = _mask_html_comments(text)
assert "comment" not in result
assert "Before" in result
assert "After" in result