← 输入框|github.com|刷新
Skip to content

feat: add a rule that AI commits link their session (CC018) - #698

Closed
shenxianpeng wants to merge 1 commit into
feat/ai-prohibited-patternsfrom
claude/ai-session-link
Closed

shenxianpeng wants to merge 1 commit into
feat/ai-prohibited-patternsfrom
claude/ai-session-link

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Stacked on #697: it reuses _ai_tool_behind, so it targets that branch. Once #697 merges, retarget this to main.

Before:

The AI rules say whether a tool was used and how that is said (CC013–CC017). They never ask where the record of what the tool did is kept. Agents already write that link (Copilot's Agent-Logs-Url:, the Claude Code session URL, Devin and Codex task links), and the Entire CLI writes Entire-Checkpoint:. A project that wants every AI commit traceable to its session had no way to require the link.

$ printf 'fix: typo\n\nAssisted-by: Claude Code\n' | commit-check --message --ai-attribution disclose; echo $?
0

After:

[commit]
ai_attribution = "disclose"
require_ai_session = true
$ printf 'fix: typo\n\nAssisted-by: Claude Code\n' | commit-check --message; echo $?
✖ Commit rejected by Commit Check · 1 check failed

✖ CC018 ai-session failed: Claude Code, no session link
  A commit attributed to Claude Code does not link the session that produced it
  Suggest: Add the link the tool records for its session, such as an Agent-Logs-Url: or Entire-Checkpoint: trailer
  Docs:    https://commit-check.com/rules/#cc018
1

The same message with Entire-Checkpoint: 01M4X1NYD0BAHNW448QYK3CBC7 or Agent-Logs-Url: https://... passes, and so does a commit with no AI tool behind it.

How:

  • New rule CC018 (ai_session), run by --message. It is off until commit.require_ai_session = true, also settable with --require-ai-session and CCHK_REQUIRE_AI_SESSION. warn = ["CC018"] turns the failure into a warning. Under forbid it is not built, because an AI commit already fails CC013 there.
  • A commit is attributed to a tool the way CC305 reads it: by its author, a co-author or sign-off line, a vendor's stamp, or a disclosure under one of ai_disclosure_trailers.
  • A session link is a catalog pattern marked session=True (Agent-Logs-Url:, Claude-Session:, the Claude Code session URL line, the Devin session link, the Codex task link, Entire-Checkpoint:), or a trailer from the new commit.ai_session_trailers (--ai-session-trailers, CCHK_AI_SESSION_TRAILERS) with a value. That list is for in-house agent platforms and is empty by default. The trailer names are checked like ai_disclosure_trailers.
  • detect_session_links() returns the subset of detect_ai_signatures() that links a session. detect_ai_signatures() keeps the same output, and ALL_PATTERNS keeps its 5-tuple shape.
  • Entire joins the catalog. Its trailer is a stamp, and it has no free-text name, because "entire" is an ordinary word (Assisted-by: the entire team stays Generic AI).
  • README table rows, the "What it checks" row, and a line in the agent skill.

To review before a release:

  • The names are hard to change later: require_ai_session, ai_session_trailers, --require-ai-session, --ai-session-trailers, CCHK_REQUIRE_AI_SESSION, CCHK_AI_SESSION_TRAILERS, CC018.
  • Adding Entire changes existing verdicts. Under forbid and disclose, a commit whose only AI mark is Entire-Checkpoint: is now detected. Under disclose, the fix proposes Assisted-by: Entire, the same way Agent-Logs-Url: alone proposes Assisted-by: GitHub Copilot. But Entire records sessions, it is not the assistant, so you may prefer a different suggestion there.
  • The trailer name comes from real commits (for example Entire-Checkpoint: 01M4X1NYD0BAHNW448QYK3CBC7). Entire's blog says only that the checkpoint ID is "stored in a commit trailer", without naming it.
  • CC018 is not in --ai-attribution-only, because, like CC017, it reads the commit author.
  • The rule only checks that a link is present. It does not fetch the link or check that it resolves.
  • The #cc018 docs link works once the rules page on the site lists the rule. The SchemaStore schema needs the two new keys.

Tests: 1758 passed and coverage stays at 100%. One test, test_load_config_file_permission_error, fails only because this machine runs as root, and it fails on the base branch too.

A new [commit] setting, require_ai_session, asks a commit attributed to
an AI tool to link the session that produced it. The disclosure says a
tool was used; the link says where the record of what it did is kept.
It is off by default and is not built under ai_attribution = "forbid".

A link is a line a known tool writes for the purpose (Agent-Logs-Url:,
Entire-Checkpoint:, Claude-Session:, a Claude Code or Devin session
URL, a Codex task link) or one of the project's own ai_session_trailers
with a value. The tool is read as CC305 reads it.

Entire joins the catalog: its Entire-Checkpoint: trailer is a stamp, so
forbid and disclose now see commits that carry only that trailer.
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added the enhancement New feature or request label Nov 14, 2026
@sonarqubecloud

Copy link
Copy Markdown

@shenxianpeng shenxianpeng self-assigned this Nov 14, 2026
@codecov

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b3dd703) to head (df6d9d5).

Additional details and impacted files
@@                      Coverage Diff                      @@
##           feat/ai-prohibited-patterns      #698   +/-   ##
=============================================================
  Coverage                       100.00%   100.00%           
=============================================================
  Files                               15        15           
  Lines                             2712      2774   +62     
  Branches                           536       549   +13     
=============================================================
+ Hits                              2712      2774   +62     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant