Repository navigation
refactor(source-control): read the commit and PR convention keys from docs conventions source-control.yaml #9860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
melodic-automation-lanes
merged 7 commits into
main
from
work-resolve-issue/issue-9725-40127063899-1
Oct 25, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
916878a
Resolve issue #9725
melodic-automation-lanes[bot] 9ac86b9
test(source-control): anchor the personal-overlay explain match to .c…
kyle-sexton f729be6
Address review feedback on work-resolve-issue/issue-9725-40127063899-1
melodic-automation-lanes[bot] 93195c2
Merge remote-tracking branch 'origin/main' into pr-9860
kyle-sexton 4b18ac8
fix(source-control): read team convention files only when git tracks …
kyle-sexton 12a75f2
Address review feedback on work-resolve-issue/issue-9725-40127063899-1
melodic-automation-lanes[bot] ac7b005
Fix failing CI checks on work-resolve-issue/issue-9725-40127063899-1
melodic-automation-lanes[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
.changes/source-control/refactor-9725-convention-yaml-5e1c7a94.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| bump: minor | ||
| --- | ||
|
|
||
| ### Changed | ||
|
|
||
| - The commit and PR convention keys (`subject_pattern`, `type_list`, `pr_title_pattern`, `trailer_policy`, `pr_body_attribution`, `pr_body_required_sections`, `branch_issue_pattern`) now take their team value from `docs/conventions/source-control.yaml`, validated by `schemas/source-control.schema.json`. `.claude/source-control.md` is read only for a key the YAML lacks, for one release, and a YAML the shared reader rejects stops the lookup instead of falling back. `/source-control:setup apply layer=team` writes the YAML and moves the convention keys out of the legacy file. | ||
| - `parse-branch-issue.sh` reads `branch_issue_pattern` from the team YAML before the legacy markdown, and `--explain` prints the layer that supplied the pattern on stderr. Like `/source-control:commit`, it reads either team file only when git tracks it and notes an untracked one it skipped. The deprecation note for the `branch_issue_pattern` userConfig now points at the YAML. | ||
|
|
||
| ### Added | ||
|
|
||
| - `lib/convention-key.sh`, the team-layer reader for the convention keys: `layer ROOT KEY` prints `yaml`, `legacy-md` or `none`, and `value` and `list` print the YAML value. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,20 @@ | ||
| # yaml-language-server: $schema=../../plugins/source-control/schemas/source-control.schema.json | ||
| # Team layer for the source-control plugin's YAML settings. | ||
| # Resolution: plugins/source-control/reference/config-resolution.md. | ||
| # | ||
| # pr_body_required_sections is the section list this repository's pull-request contract asks for, | ||
| # each non-empty, alongside a native closing keyword. The contract runs in the `ci-status` job of | ||
| # .github/workflows/pr-require-checks.yml, in the `check-contract` composite step pinned to | ||
| # melodic-software/ci-workflows/.github/actions/pr-require-checks/check-contract, which exempts | ||
| # `dependabot[bot]` from the linkage check and no other author. The linkage half is advisory: a body | ||
| # that misses a closing keyword or a required section gets a warning, an upserted comment and the | ||
| # `needs-issue-linkage` label, and `ci-status` still passes on that account. The composite is the | ||
| # authority; this key restates it so /source-control:pull-request drafts a body that conforms. Read | ||
| # the composite at the SHA pr-require-checks.yml pins, not at its default branch, since that pin is | ||
| # what actually runs. Re-read it before changing either. | ||
| pr_open_state: ready | ||
| pr_body_required_sections: | ||
| - Summary | ||
| - Fix | ||
| - Verification | ||
| - Related |
2 changes: 1 addition & 1 deletion
2
...e-control/evals/setup-writes-only-confirmed-change/graders/team-file-written.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| --- | ||
| type: file_exists | ||
| path: .claude/source-control.md | ||
| path: docs/conventions/source-control.yaml | ||
| arm: both | ||
| --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
kyle-sexton marked this conversation as resolved.
Resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
kyle-sexton marked this conversation as resolved.
Resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| #!/usr/bin/env bash | ||
| # shellcheck shell=bash | ||
| # Team-layer reader for the commit and PR convention keys of the source-control | ||
| # plugin: subject_pattern, type_list, pr_title_pattern, trailer_policy, | ||
| # pr_body_attribution, pr_body_required_sections and branch_issue_pattern. | ||
| # | ||
| # The team value lives in docs/conventions/source-control.yaml (ADR 0064), | ||
| # validated by schemas/source-control.schema.json. For one release a key the YAML | ||
| # lacks is still read from the legacy `## <key>` section of | ||
| # .claude/source-control.md; the YAML wins whenever it carries the key. The YAML | ||
| # is parsed by yaml-subset.awk, the shared parser, and the value is printed | ||
| # as written: parse-concern-value.sh is not used because it strips a trailing | ||
| # slash, which belongs to a directory value and would change a regex. | ||
| # | ||
| # Sourced by scripts; run directly for the model-run skills: | ||
| # | ||
| # bash convention-key.sh layer ROOT KEY print the team layer that supplies KEY: | ||
| # yaml | legacy-md | none | ||
| # bash convention-key.sh value ROOT KEY print KEY's scalar from the YAML | ||
| # bash convention-key.sh list ROOT KEY print KEY's list items from the YAML | ||
| # | ||
| # `layer` names the file in the form callers report: `yaml` is | ||
| # docs/conventions/source-control.yaml, `legacy-md` is .claude/source-control.md | ||
| # (read only because the YAML lacks the key), `none` means neither carries it. | ||
| # ROOT is the repo root from config-root.sh; the caller has already classified it | ||
| # `repo`. `value` and `list` print nothing for a key the YAML lacks and exit 3 | ||
| # for a YAML the parser rejects, so a caller can stop instead of reading the | ||
| # legacy file past a broken team file. | ||
|
|
||
| CONVENTION_KEY_YAML_REL="docs/conventions/source-control.yaml" | ||
| CONVENTION_KEY_MD_REL=".claude/source-control.md" | ||
| CONVENTION_KEY_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| # True when git tracks the repo-relative file REL under ROOT. An untracked or | ||
| # gitignored team file is not a config layer (skills/commit/SKILL.md). | ||
| convention_key_tracked() { | ||
| git -C "$1" ls-files --error-unmatch -- "$2" >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Print the parser's key<TAB>value records for the team YAML under ROOT, nothing | ||
| # when the file is absent. Returns 3 when the parser rejects the file; a key | ||
| # repeated in one mapping is a rejection too. | ||
| convention_key_records() { | ||
| local file="$1/$CONVENTION_KEY_YAML_REL" text | ||
| [[ -f "$file" ]] || return 0 | ||
| text="$(<"$file")" | ||
| LC_ALL=C awk -v STRICT=1 -f "$CONVENTION_KEY_DIR/yaml-subset.awk" <<<"$text" 2>/dev/null || return 3 | ||
| } | ||
|
|
||
| # Print the value of KEY from the team YAML under ROOT, or nothing. | ||
| convention_key_yaml_value() { | ||
| local records | ||
| records="$(convention_key_records "$1")" || return 3 | ||
| PCV_KEY="$2" LC_ALL=C awk -F '\t' '$1 == ENVIRON["PCV_KEY"] && !seen++ { print substr($0, length($1) + 2) }' <<<"$records" | ||
| } | ||
|
|
||
| # Print the scalar items of the sequence KEY in the team YAML, one per line. | ||
| convention_key_yaml_list() { | ||
| local records | ||
| records="$(convention_key_records "$1")" || return 3 | ||
| PCV_KEY="$2" LC_ALL=C awk -F '\t' 'index($1, ENVIRON["PCV_KEY"] ".") == 1 && substr($1, length(ENVIRON["PCV_KEY"]) + 2) ~ /^[0-9]+$/ { print substr($0, length($1) + 2) }' <<<"$records" | ||
| } | ||
|
|
||
| # True when the team YAML carries KEY, as a scalar or as a non-empty list. | ||
| convention_key_yaml_has() { | ||
| local root="$1" key="$2" scalar items | ||
| scalar="$(convention_key_yaml_value "$root" "$key")" || return 3 | ||
| [[ -z "$scalar" ]] || return 0 | ||
| items="$(convention_key_yaml_list "$root" "$key")" || return 3 | ||
| [[ -n "$items" ]] | ||
| } | ||
|
|
||
| # True when the legacy markdown file under ROOT has a `## KEY` heading outside a | ||
| # code fence, as the resolvers' markdown readers see it. | ||
| convention_key_md_has() { | ||
| local root="$1" key="$2" file="$1/$CONVENTION_KEY_MD_REL" | ||
| [[ -f "$file" ]] || return 1 | ||
| PCV_KEY="$key" LC_ALL=C awk ' | ||
| NR == 1 { sub(/^\357\273\277/, "") } | ||
| { sub(/\r$/, ""); sub(/[ \t]+$/, "") } | ||
| /^(```|~~~)/ { fenced = !fenced; next } | ||
| !fenced && $0 ~ "^##[ \t]+" ENVIRON["PCV_KEY"] "([ \t]+#+)?$" { found = 1; exit } | ||
| END { exit !found } | ||
| ' "$file" | ||
| } | ||
|
|
||
| # Print yaml | legacy-md | none. Returns 3 for an unparsable YAML. | ||
| convention_key_layer() { | ||
| local root="$1" key="$2" rc | ||
| convention_key_yaml_has "$root" "$key" | ||
| rc=$? | ||
| if ((rc == 0)); then | ||
| echo yaml | ||
| elif ((rc == 3)); then | ||
| return 3 | ||
| elif convention_key_md_has "$root" "$key"; then | ||
| echo legacy-md | ||
| else | ||
| echo none | ||
| fi | ||
| } | ||
|
|
||
| if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then | ||
| case "${1:-}" in | ||
| layer) convention_key_layer "${2:?root}" "${3:?key}" ;; | ||
| value) convention_key_yaml_value "${2:?root}" "${3:?key}" ;; | ||
| list) convention_key_yaml_list "${2:?root}" "${3:?key}" ;; | ||
| *) | ||
| echo "usage: bash convention-key.sh layer|value|list ROOT KEY" >&2 | ||
| exit 2 | ||
| ;; | ||
| esac | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.