fix(commit): step 17 enforces AI Reviewer Metadata + required body (#730)#965
Conversation
) Require commit workflow step 17 to consume an upstream AI-generated COMMIT_BODY instead of synthesizing a fallback body, and fail fast when the required AI Reviewer Metadata heading is missing. Keep PATTERN.md and workflow.toml in sync, lock the behavior with a commit-pattern test, and bump the workspace patch version to 0.1.450. ### AI Reviewer Metadata - **Design Intent**: Preserve the documented audit trail by making step 17 reject missing upstream commit bodies and commit bodies that omit the required metadata block. - **Key Decisions**: Removed the step-17 fallback call to `scripts/gen_commit_msg.sh --body`, added an explicit `### AI Reviewer Metadata` gate with PATTERN.md guidance in the error path, synchronized PATTERN/workflow wording, and extended the existing commit workflow test to lock the new contract. - **Reviewer Guidance**: - **Timing/Race Scenarios**: none. - **Boundary Cases**: missing `COMMIT_BODY`; non-empty body that lacks `### AI Reviewer Metadata`; valid body that still includes the existing reviewer-guidance subfields. - **Regression Tests Added**: `plan_cmd::tests_commit::commit_reviewer_guidance_schema_requires_regression_tests_for_timing_scenarios` Closes #730. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the workspace version to 0.1.450 and modifies the commit pattern and workflow to strictly require an upstream COMMIT_BODY containing an '### AI Reviewer Metadata' block, removing the previous fallback mechanism. Corresponding tests were added to verify these enforcement checks. Feedback suggests refactoring the new test assertions into a dedicated test function and aligning step numbering between the documentation and the workflow configuration to resolve inconsistencies.
| for content in [&commit_pattern, &commit_workflow] { | ||
| assert!( | ||
| content.contains( | ||
| "Step 17 requires upstream COMMIT_BODY from the AI-generated commit body step." | ||
| ), | ||
| "commit pattern/workflow step 17 must fail fast when upstream COMMIT_BODY is missing" | ||
| ); | ||
| assert!( | ||
| content | ||
| .contains("Step 17: commit body missing required '### AI Reviewer Metadata' block"), | ||
| "commit pattern/workflow step 17 must emit the explicit AI Reviewer Metadata error" | ||
| ); | ||
| assert!( | ||
| !content.contains("scripts/gen_commit_msg.sh --body"), | ||
| "commit pattern/workflow step 17 must not synthesize a fallback commit body" | ||
| ); | ||
| } |
There was a problem hiding this comment.
For better test organization and clarity, consider moving these new assertions into a separate test function. The current function commit_reviewer_guidance_schema_requires_regression_tests_for_timing_scenarios has a very specific name, but it's now testing multiple unrelated aspects of the commit pattern. Splitting this logic will make the tests easier to understand and maintain.
A new test function could be named something like commit_pattern_step17_enforces_commit_body_and_metadata.
| inspection. Require `${COMMIT_BODY}` from the upstream AI commit-body step; do | ||
| not synthesize a fallback body here. |
There was a problem hiding this comment.
There seems to be a discrepancy in step numbering between PATTERN.md and workflow.toml. This section is labeled ## Step 14 in the markdown, but the corresponding step in workflow.toml has id = 17, and the error messages in this step correctly refer to "Step 17".
To avoid confusion for developers referring to PATTERN.md, please renumber the steps in this file starting from this one to align with the ids in workflow.toml. For example, ## Step 14: Generate Commit Message Parts should be ## Step 17: Generate Commit Message Parts, and subsequent steps should be renumbered accordingly.
Also, please update the error messages in this step (and in workflow.toml) that refer to step 14/15 to point to the new, correct step numbers (e.g., step 17/18).
Audit Trail — Merge Rationale (Severity-Tiered Protocol)Local pre-PR review (session `01KPNZ59WJ4D2V0VJPC1E56E7N`): verdict=fail/HAS_ISSUES but `findings=[]` and `severity_counts={low:0, medium:0, high:0, critical:0}` — classic parser FP (documented in memory `review_meta_parsing_bug`). Ship-ready. Cloud bot review (gemini-code-assist): 2 MEDIUM findings.
Per severity-tiered merge protocol (memory `feedback_review_severity_tiered`): only HIGH/CRITICAL/P1 block merge. MEDIUMs aggregate into followup issue + merge. Followup filed: #966. Test (macos-latest) FAILURE: pre-existing baseline noise per memory `feedback_macos_ci_ignore`. Linux green. Merging. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 395e73fd5a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| echo "ERROR: Step 17 requires upstream COMMIT_BODY from the AI-generated commit body step." >&2 | ||
| echo "See patterns/commit/PATTERN.md step 14/15." >&2 | ||
| exit 1 |
There was a problem hiding this comment.
Keep a generation path when COMMIT_BODY is unset
This new hard-fail turns COMMIT_BODY from optional into mandatory, but the same workflow does not populate COMMIT_BODY before Step 17 (it is only declared as a variable, and the first CSA_VAR:COMMIT_BODY assignment happens later in this step). In runs where callers do not pass --var COMMIT_BODY=... (including standalone commit workflow usage and nested INCLUDE commit call sites), Step 17 now aborts immediately, so the commit flow can no longer complete. Please either restore an internal body-generation fallback or add an explicit upstream step that sets COMMIT_BODY before this guard.
Useful? React with 👍 / 👎.
Summary
patterns/commit/workflow.tomlstep 17 previously fell back to an empty-body generator when${COMMIT_BODY}was absent, and did not validate the mandatory### AI Reviewer Metadatablock documented inPATTERN.mdstep 14/15.${COMMIT_BODY}and validates the metadata marker, aborting with a clear message pointing at PATTERN.md.PATTERN.mdsynced in the same commit per Rule 027 (pattern-workflow-sync).Test plan
cargo test -p cli-sub-agent plan_cmd_tests_commitexit 0just pre-commitexit 0Closes #730.
🤖 Generated with Claude Code