Skip to content

refactor(source-control): make the linkage-gate scope and babysit routing targets configurable - #17437

Merged
kyle-sexton merged 6 commits into
mainfrom
refactor/source-control-org-agnostic-settings
Nov 19, 2026
Merged

kyle-sexton merged 6 commits into
mainfrom
refactor/source-control-org-agnostic-settings

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Refs: #17208

Summary

The source-control plugin carried this organization's values in shipped code and skill text: the PR-body linkage hooks only ran where a workflow used one built-in composite-action path, the babysit-prs routing named this organization's runner-policy files and settings repository, its lane pointer named one reusable-workflow repository, and the watch hand-off linked an organization tool for switching accounts. Each is now a setting with a neutral default, and this repository sets its current values in docs/conventions/source-control.yaml, so behavior here does not change.

Fix

  • linkage_gate_uses_pattern: a POSIX ERE matched against .github/workflows/*.yml|*.yaml. The value comes from the team YAML, else the userConfig option of the same name (the existing YAML-over-userConfig rule the schema states). Unset, neither hook gates any repository. A YAML the shared parser rejects, or a pattern bash cannot compile, turns the hooks off with a note on stderr. Both hooks resolve it through one new sourced file, hooks/pr-linkage-scope.sh, which reads the YAML with builtins and runs lib/yaml-subset.awk only when the text names the key.
  • runner_policy_paths, org_settings_repo, review_lane_producer_repo: team-YAML keys (no userConfig, per ADR 0039 for repository keys) that stuck-checks.md and safety.md route through. Unset falls back to the repository's own CI docs and caller workflows.
  • watch-handoff.md: the switch-accounts option on the route-start prompt drops the organization tool link. The two inlined rate-limits floor copies keep it, because check-loop-lane-floor-drift.sh requires them to match plugins/rate-limits/reference/reader-contract.md byte for byte; they change with the rate-limits PR.
  • Schema, plugin.json userConfig, README option rows and details, and reference/config-resolution.md document the four keys. This repository sets all four in docs/conventions/source-control.yaml.
  • Spawn budget: the bash gate's in-scope path goes from 9 clones and 3 execs to 10 and 4 (the one awk). The MCP gate stays inside its ceilings. The README's measured-cost table carries the new numbers.
  • source-control major changelog fragment: a consumer that never sets linkage_gate_uses_pattern loses the linkage hooks on upgrade.
  • pr-linkage-scope.sh keeps the workflow-scan loop's comments from the hooks it replaced: the unmatched glob, the fork-free reads, the ignored read -d '' status and the cleared buffer.
  • The block message, the hook status messages, the hooks.json description and the README name the repository's PR-body contract step, not check-contract, since the gated step is whatever the pattern matches.

Left out: the legacy melodic.worktreeroot read. It is generated from one lib/ source that repo-fleet-hygiene also ships, and the file says it is deleted after 2026-12-31, so it ships with that plugin's PR. The security, trust and cost rows (merge owner gate, review venue, lane check names, owner-decisions record, free-runner regex, model-leg detection, verify-legacy-fails) are a separate PR.

Verification

  • pr-body-linkage-gate.test.sh: 192 passed, 0 failed. New cases: the gate is off with no key anywhere and with a YAML that lacks the key, the userConfig value alone turns it on, the YAML wins over userConfig, a consumer's own pattern gates its own step, and an invalid pattern and an unparsable YAML each turn the gate off and say so.
  • pr-linkage-mcp-gate.test.sh: 61 passed, 0 failed, including the unset, YAML-only and YAML-over-userConfig cases.
  • pr-linkage-spawn-budget.test.sh: 21 passed, with the fixture's pattern coming from the team YAML.
  • In this checkout, a gh pr create body with does not close #5 is still blocked (exit 2), resolved from the committed YAML.
  • check-convention-yaml.sh (20 files valid), check-loop-lane-floor-drift.sh (6 consumers match), sync-plugin-options-docs.py --check, check-changelog-fragments.sh --check, validate-plugins.sh --only source-control, and the pre-push check-affected all pass.

Remaining

This pull request delivers the source-control plugin's configurable settings for #17208, apart from the rows the Left out line names. Still open under that issue:

  • The source-control security, trust and cost rows the Left out line lists, in their own pull request.
  • The legacy melodic.worktreeroot read, which ships with repo-fleet-hygiene's part.
  • The account-rotation link in the rate-limits operable floor and every inlined copy of it.
  • The organization-specific matches in the other shipped plugins, each classified as runtime behavior, instruction, permitted citation or test fixture, with the runtime and instruction ones made configurable.
  • The CI check that fails when shipped content adds a new organization-specific dependency.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 3 commits November 19, 2026 09:17
…ting targets configurable

The PR-body linkage hooks keyed their scope on a built-in workflow path, and
the babysit-prs routing text named this organization's repositories. Both now
come from settings with neutral defaults; this repository sets its own values
in docs/conventions/source-control.yaml, so behavior here is unchanged.

- linkage_gate_uses_pattern (team YAML, else userConfig; unset gates no repo),
  resolved by the shared hooks/pr-linkage-scope.sh through lib/yaml-subset.awk.
- runner_policy_paths, org_settings_repo, review_lane_producer_repo (team YAML)
  for stuck-checks.md and safety.md routing.
- The watch hand-off's switch-accounts option drops the org tool link.

Refs: #17208

Co-authored-by: Claude Opus 5.5 <[email protected]>
…ithin 300 characters

Refs: #17208

Co-authored-by: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 19, 2026 14:37
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T14:39:11.657277Z f380076 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-security-review: 1 inline finding(s) on f3800767e7aab7e43ad06723730e79dc7ca0273c; the summary is in this lane's pull request comment.

claude-lane: claude-security-review

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 9e72ef8eb452dadd1845d3afe1d4ed9dfee50b38: read 17 of 17 changed file(s); 1 finding(s), 0 as inline comments.

Security review: PR #17437 (blocking only)

This lane already reviewed an earlier head, so this pass reports only CRITICAL and IMPORTANT findings. I read the whole diff: 17 of 17 changed files.

The PR moves the workflow-scope regex for the PR-linkage hooks out of the hook scripts. The regex now comes from the linkage_gate_uses_pattern setting, which the hooks resolve through the new sourced file hooks/pr-linkage-scope.sh. The PR also turns three babysit-prs routing targets into team-YAML keys. This repository sets all four values in docs/conventions/source-control.yaml, so its behavior is unchanged.

Finding (1, IMPORTANT, already posted): the new userConfig.linkage_gate_uses_pattern key acts as a guard, and its default is permissive. When unset, neither PR-linkage hook gates any repository. So consumers that relied on the old hard-coded check-contract / report-ci-status scope lose the block on a does not close #N body when they update. The lines are unchanged since the earlier post.

Checked, no new finding:

  • hooks/pr-linkage-scope.sh (L429-L468):
    • The pattern is only ever the right-hand side of [[ =~ ]], so it is never evaluated as code.
    • printf -v writes to a variable name the caller passes as a literal.
    • The awk parser path comes from BASH_SOURCE, not from input.
    • An invalid ERE (rc 2), or a YAML the parser rejects, turns the gate off and prints a note on stderr.
    • A working tree's own YAML can only switch the gate on or off for that same repository. Before this change, a repository could already turn it off by leaving out the workflow step. Turning it on only blocks negated closing references. Nothing widens.
  • runner_policy_paths, org_settings_repo, review_lane_producer_repo:
    • These are read from the target repository's tracked YAML on its default branch, which the owner controls. The schema restricts the two repository keys to owner/repo.
    • The safety.md pointer only says where to look up job names when diagnosing a check-name mismatch.
    • No merge hold, trusted-actor check, token scope or kill switch reads these keys.
  • docs/conventions/source-control.yaml (trusted path): read whole. It adds four settings and widens no trust control.
  • hooks.json, pr-linkage-validator.sh, watch-handoff.md: these change only description, status or message text and drop one external link. They remove no guardrail in a protected class.

No spend or billing change.

Manifest lines (1)

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 3 inline finding(s) on f3800767e7aab7e43ad06723730e79dc7ca0273c; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 9e72ef8eb452dadd1845d3afe1d4ed9dfee50b38: read 17 of 17 changed file(s); 1 finding(s), 0 as inline comments.

Code review: PR #17437 (blocking only)

I already reviewed an earlier head of this PR, so this pass reports only blocking findings and manifest flags. I read every hunk of all 17 changed files in the full diff.

Three of the four findings from the last round are fixed at this head:

  • Changelog bump. The fragment now says bump: major.
  • Workflow-scan comments. The comments explaining the loop are back in hooks/pr-linkage-scope.sh (lines 55–59).
  • Stale wording. The block message, the hooks.json status messages and the README no longer name the check-contract step; they say "the repository's PR-body contract step" instead.

Blocking

  • already posted: refactor(source-control): make the linkage-gate scope and babysit routing targets configurable #17437 (comment). This is Fail a change that loosens a check (kind 9: a check's own code or settings changed so it accepts more).
    • Where: pr-linkage-scope.sh:31.
    • What changed: when linkage_gate_uses_pattern is unset, neither PR-linkage hook gates any repository. Before, both blocked a negated closing reference wherever a workflow used pr-require-checks/check-contract or report-ci-status. A pattern bash cannot compile, or a team YAML that does not parse, also turns both hooks off.
    • Still unresolved: the PR closes no issue (Refs: #17208), so no trusted spec text names this loosening or says why. The fragment now records the change, and the PR body explains it, but neither counts as a reason under the criterion.
    • Fix: keep the old scope as the default when nothing is configured, or have the spec issue name this check and say why consumers should lose it by default.

Notes

  • Closing issue: none. The PR context has no closing-issue section, so there were no acceptance criteria to check.
  • Not verified: the test results in the PR body (192/61/21 passed, the in-checkout block, the checker scripts) are the author's claims. This lane ran nothing.
  • MCP spawn budget: when the team YAML names the key, the MCP gate now also runs the awk parse. Its ceilings stay at 11 clone-family calls and 4 execs, and the test file says those ceilings have no headroom (pr-linkage-spawn-budget.test.sh:203-204). The author says the suite passes. I couldn't run it, so this is not a finding.
  • Spend: the in-scope hook path runs one extra local awk process. It uses no API credits and nothing is billed.
  • Loosened-check verdict: fail (default; the prompt had no loosened_check_verdict: or loosened_check_patterns: line); patterns: 0. The prompt had no loosened_check_decision_record: line, so I did not check the citation requirement.
  • Embedded text: none found in the PR context or prior-findings files.
Advisory and manifest lines (3)
  • manifest version: pass. The fragment's bump: major matches removing the hooks' built-in default scope.
  • manifest userConfig.linkage_gate_uses_pattern: pass. This is a new key with no default, on purpose. The PR explains why, and hooks/pr-linkage-scope.sh reads CLAUDE_PLUGIN_OPTION_LINKAGE_GATE_USES_PATTERN.
  • manifest description: pass. The plugin description and keywords did not change, and the plugin still ships both hooks.

Verifier dropped 0 of 1 candidates.

@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Nov 19, 2026
@kyle-sexton

Copy link
Copy Markdown
Member Author

Held: claude-review flags a loosened check (with linkage_gate_uses_pattern unset, both PR-linkage hooks gate no repository), and no owner-decisions row or owner statement covers that default; the fail-closed trust-settings row of 2026-11-19 does not.

kyle-sexton and others added 3 commits November 19, 2026 10:38
…he scan-loop comments

With linkage_gate_uses_pattern unset the linkage hooks gate no
repository, which removes a default consumers relied on, so the
fragment is a major bump. The workflow-scan loop's comments on the
unmatched glob, the fork-free reads, the ignored read status and the
cleared buffer return above the loop in pr-linkage-scope.sh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ct, in hook text

The gated step is whatever linkage_gate_uses_pattern matches, so the
block message, the hook status messages, the hooks.json description and
the README name the repository's PR-body contract step instead of one
composite action.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton

Copy link
Copy Markdown
Member Author

@kyle-sexton kyle-sexton removed the do-not-merge Hard merge gate: do not merge while applied. label Nov 19, 2026
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit b0c100e Nov 19, 2026
136 of 141 checks passed
@kyle-sexton
kyle-sexton deleted the refactor/source-control-org-agnostic-settings branch November 19, 2026 16:24
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant