Skip to content

fix(channels): make contract checks portable and complete - #7267

Open
kaiwangleo wants to merge 4 commits into
agentscope-ai:mainfrom
kaiwangleo:fix-channel-contract-checks
Open

fix(channels): make contract checks portable and complete#7267
kaiwangleo wants to merge 4 commits into
agentscope-ai:mainfrom
kaiwangleo:fix-channel-contract-checks

Conversation

@kaiwangleo

@kaiwangleo kaiwangleo commented Aug 25, 2026

Copy link
Copy Markdown

Closes #7264

What Problem This Solves

The existing channel contract gate can report success without proving that every registered built-in channel has a runnable contract test. On a Windows checkout using a non-UTF-8 default code page, the previous checker read UTF-8 Python sources with the platform default encoding and could raise UnicodeDecodeError. Its filename/regular-expression scan also missed SIPChannel, which is exported from sip/__init__.py, and did not reliably cover OneBot, WeChat, WeCom, XiaoYi, or Yuanbao.

The local channel runner had corresponding portability and discovery gaps: it used legacy package checks and extras, could misclassify changed files, and did not consistently include untracked files or preserve required failure status. This made a green local result insufficient evidence of complete built-in channel coverage.

Evidence

The baseline behavior was reproduced by inspecting the checker and registry: the checker used implicit Path.read_text() encoding, scanned only channel.py, and reported incomplete coverage for the registered channels. The runner also contained the legacy package name and derived changed channels from filenames rather than registry keys.

The implementation in this PR is verified by these concrete results:

  • python -X utf8=0 scripts/check_channel_contracts.py reports 18 total, 18 tested, and 0 missing channels.
  • WSL Python 3.12 checker, runner, and channel-contract regression tests: 448 passed, 1 skipped.
  • pytest tests/contract -q: 406 passed, 1 skipped.
  • pytest tests/unit -q: 8065 passed, 19 skipped.
  • The SIP runner executed 19 contract tests and 5 supplemental unit tests successfully.
  • bash -n scripts/check-channels.sh, repository pre-commit hooks, Mypy, Black, Flake8, Pylint, actionlint, and targeted git diff --check passed.

Summary

  • Replace filename and regular-expression discovery with an explicit UTF-8 AST checker driven by the built-in registry.
  • Recognize package-level exports such as SIPChannel, validate canonical BaseChannel inheritance and contract paths, and fail closed on ambiguous or disabled contract factories.
  • Add isolated contract coverage for OneBot, SIP, WeChat, WeCom, XiaoYi, and Yuanbao, and remove the Console meta-test that could pass by skipping.
  • Harden scripts/check-channels.sh for QwenPaw package/test extras, linked worktrees, tracked and untracked changes, registry-based mapping, and required-check exit codes.
  • Add checker/runner regression tests, LF normalization, documentation, and CI coverage checks. The workflow's code-change filter includes the checker, runner, and .gitattributes paths.

Scope and compatibility

This PR covers built-in channel contract coverage and its local/CI gates. Plugin-provided channels remain responsible for coverage in their own test scope. Optional channel unit tests remain supplemental and non-blocking in the local runner.

The implementation is organized into three focused commits so the coverage fixtures, static gate, and local runner can be reviewed independently. The branch is synchronized with the current upstream main; maintainers can split the commits into separate PRs if preferred.

No optional channel dependency is imported by the static checker.

@github-project-automation github-project-automation Bot moved this to Todo in QwenPaw Aug 25, 2026
@github-actions github-actions Bot added the first-time-contributor PR created by a first time contributor label Aug 25, 2026
@github-actions

Copy link
Copy Markdown

Welcome to QwenPaw! 🐾

Hi @kaiwangleo, thank you for your first Pull Request! 🎉

📋 About PR Template

To help maintainers review your PR faster, please make sure to include:

  • Description - What this PR does and why
  • Type of Change - Bug fix / Feature / Breaking change / Documentation / Refactoring
  • Component(s) Affected - Core / Console / Channels / Skills / CLI / Documentation / Tests / CI/CD / Scripts
  • Checklist:
    • Run and pass pre-commit run --all-files
    • Run and pass relevant tests (pytest or as applicable)
    • Update documentation if needed
  • Testing - How to test these changes
  • Local Verification Evidence:
    pre-commit run --all-files
    # paste summary result
    
    pytest
    # paste summary result

Complete PR information helps speed up the review process. You can edit the PR description to add these details.

🙌 Join Developer Community

Thanks so much for your contribution! We'd love to invite you to join the official QwenPaw developer group! You can find the Discord and DingTalk group links under the "Developer Community" section on our docs page:
https://qwenpaw.agentscope.io/docs/community

We truly appreciate your enthusiasm—and look forward to your future contributions! 😊

We'll review your PR soon.


Tip

⭐ If you find QwenPaw useful, please give us a Star!

Star QwenPaw

Staying ahead

Star QwenPaw on GitHub and be instantly notified of new releases.

Your star helps more developers discover this project! 🐾

@lalaliat
lalaliat requested a review from hongxicheng August 25, 2026 06:09
@hongxicheng
hongxicheng requested review from yutai78786 and removed request for hongxicheng August 25, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time-contributor PR created by a first time contributor

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

fix(channels): make contract checks portable and complete

2 participants