Skip to content

fix: reflect repository maintenance findings - #834

Merged
keito4 merged 1 commit into
mainfrom
fix/repo-maintenance-reflect-checked-repos
Jun 17, 2026
Merged

fix: reflect repository maintenance findings#834
keito4 merged 1 commit into
mainfrom
fix/repo-maintenance-reflect-checked-repos

Conversation

@keito4

@keito4 keito4 commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add repo state handling for archived/private repositories in repo-maintenance
  • Validate Dependabot auto-merge and label-sync safety contracts instead of only checking file existence
  • Add dependency peer compatibility detection and .context temp-file handling
  • Fix dependency-health JSON handling for npm commands that return JSON with non-zero exits

Verification

  • npm run format:check
  • npm run lint
  • npm test
  • npm run shellcheck
  • bash -n script/dependency-health-check.sh
  • script/dependency-health-check.sh --json

Summary by CodeRabbit

Release Notes

  • New Features

    • Added repository state detection for archived repos with automatic check-only mode enforcement.
    • Introduced dependency peer compatibility checking via npm analysis.
    • Enhanced GitHub automation contract validation for Dependabot and Label Sync workflows.
  • Improvements

    • Dependency health check now includes peer-dependency issues in risk assessment and recommendations.
    • Dependency Review handling refined for private repositories.
  • Tests

    • Added contract validation tests for repository maintenance checks and template label configuration.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a repository state guard (archived/private detection) to repo-maintenance.md with forced check-only mode and PR creation early exit. Introduces a dependency peer compatibility check using npm ls --all --json. Strengthens Dependabot auto-merge and label-sync contract validation with template overwrites. Adjusts dependency-review handling for private repos. Extends dependency-health-check.sh with peer-issue tracking, scoring, JSON output, and strict-mode exit. Migrates temp artifacts to .context/. Adds contract and label validation tests.

Changes

repo-maintenance enhancements

Layer / File(s) Summary
Repository state guard and PR creation early exit
.claude/commands/repo-maintenance.md, test/claude-workflow-contract.test.js
Queries isArchived,isPrivate via gh repo view, forces MODE="check-only" and CREATE_PR=false for archived repos, adds early exit in Step 7 PR creation, and adds a Repository State summary line. Contract test validates the guard strings and CREATE_PR=false assignment.
Dependabot auto-merge and label-sync contract validation
.claude/commands/repo-maintenance.md, test/claude-workflow-contract.test.js
Expands Dependabot Auto-merge validation to check actor gating, read-only permissions, required gh label create commands, and continue-on-error for minor auto-approve; copies/overwrites from template on mismatch in full mode. Updates Label Sync to overwrite on missing or contract issues. Adds summary lines for both. Contract tests assert all validation strings.
Dependency peer compatibility check in repo-maintenance
.claude/commands/repo-maintenance.md, test/claude-workflow-contract.test.js
New section parses npm ls --all --json for peer/invalid/missing problems when node_modules exists; runs lockfile-only dry-run solvers for npm/pnpm; classifies failures; writes logs to .context; adds summary line. Contract test verifies the section strings.
Dependency Review: private-repo handling
.claude/commands/repo-maintenance.md
Dependency Review detection accepts repo-private flag; results matrix treats skipped/neutral as acceptable for private repos; summary bullet distinguishes public-missing vs private-optional/skipped.
Peer dependency tracking in dependency-health-check.sh
script/dependency-health-check.sh, test/claude-workflow-contract.test.js
Adds PEER_ISSUES, PEER_PROBLEMS, PEER_CHECK_SKIPPED state; extracts peer problems from npm list --all --json; adds output section; adjusts health score and Medium risk trigger; adds peer_issues/peer_check_skipped JSON fields; extends recommendations; broadens strict-mode exit. Contract test validates JSON field and exit condition.
Config Template Sync extensions for dependabot/label-sync files
.claude/commands/repo-maintenance.md, test/claude-workflow-contract.test.js
Adds dependabot-auto-merge.yml, label-sync.yml, labels.yml to managed templates; introduces MANAGED_TEMPLATE_FILES mapping array; replaces single-array loop with pair-iteration diff-detection loop; migrates temp-dir creation to .context/-scoped mktemp; updates narrative. Contract tests verify template mappings and .context/ usage.
AGENTS.md updater temp path and label contract tests
.claude/commands/repo-maintenance.md, test/template-workflows.test.js
Changes AGENTS.md updater fallback script temp path to .context/-scoped. Adds parameterized test asserting dependabot-minor, needs-review, and breaking-change labels exist in both template and actual labels files.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • keito4/config#833: Directly overlaps with this PR's Dependabot auto-merge/label-sync contract validation, required label creation commands, and dependabot-minor/needs-review/breaking-change label handling.
  • keito4/config#580: Introduces the Dependency Review check in repo-maintenance that this PR now modifies to handle private repos as optional/neutral.
  • keito4/config#603: Overlaps at the same dependabot-auto-merge.yml and label-sync.yml workflow-contract and template-sync points in repo-maintenance.

Suggested labels

released

🐇 A rabbit hops through the workflow maze,
Archiving repos gets a proper phase!
Peer deps checked, labels aligned just right,
.context/ holds temps — no /tmp in sight.
The contracts hold firm, the tests all agree,
Hoppity-hop, dependency-free! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description covers the main changes and verification steps but does not follow the provided template structure with Summary, Why, What, How to test, Checklist, and Related sections. Reformat the description to match the template: add 'Why' section explaining motivation, structure 'What' as a bulleted list, include 'How to test' with checkbox steps, complete the Checklist items, and add 'Related' section with issue numbers.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: reflect repository maintenance findings' is partially related to the changeset but lacks specificity about the main improvements (state handling, contract validation, peer compatibility detection).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/repo-maintenance-reflect-checked-repos

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

test/claude-workflow-contract.test.js

Oops! Something went wrong! :(

ESLint: 10.5.0

ReferenceError: describe is not defined
at Object. (/test/eslint-config.test.js:4:1)
at Module._compile (node:internal/modules/cjs/loader:1830:14)
at Object..js (node:internal/modules/cjs/loader:1961:10)
at Module.load (node:internal/modules/cjs/loader:1553:32)
at Module._load (node:internal/modules/cjs/loader:1355:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
at loadCJSModuleWithModuleLoad (node:internal/modules/esm/translators:326:3)
at ModuleWrap. (node:internal/modules/esm/translators:231:7)
at ModuleJob.run (node:internal/modules/esm/module_job:437:25)
at async node:internal/modules/esm/loader:639:26

test/template-workflows.test.js

Oops! Something went wrong! :(

ESLint: 10.5.0

ReferenceError: describe is not defined
at Object. (/test/eslint-config.test.js:4:1)
at Module._compile (node:internal/modules/cjs/loader:1830:14)
at Object..js (node:internal/modules/cjs/loader:1961:10)
at Module.load (node:internal/modules/cjs/loader:1553:32)
at Module._load (node:internal/modules/cjs/loader:1355:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
at loadCJSModuleWithModuleLoad (node:internal/modules/esm/translators:326:3)
at ModuleWrap. (node:internal/modules/esm/translators:231:7)
at ModuleJob.run (node:internal/modules/esm/module_job:437:25)
at async node:internal/modules/esm/loader:639:26


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude

claude Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Claude finished @keito4's task in 0s —— View job


I'll analyze this and get back to you.

@keito4 keito4 self-assigned this Jun 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7f8fe8388

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

PEER_ISSUES+=("npm lockfile solver が失敗(.context/npm-peer-compat.log を確認)")
fi
elif [ -f "pnpm-lock.yaml" ] && command -v pnpm >/dev/null 2>&1; then
if ! pnpm install --lockfile-only --ignore-scripts >.context/pnpm-peer-compat.log 2>&1; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add dry-run to the pnpm solver check

When this command runs in a pnpm repo with package.json changes or a stale lockfile, this branch mutates pnpm-lock.yaml during a health check: pnpm install --help documents --lockfile-only as "Only pnpm-lock.yaml is updated". That makes check-only maintenance dirty the worktree instead of just writing .context/pnpm-peer-compat.log; use a real dry-run/frozen validation for pnpm.

Useful? React with 👍 / 👎.

Comment on lines +2083 to +2087
if ! echo "$DEPENDABOT_WF" | grep -Fq "if: github.actor == 'dependabot[bot]'"; then
DEPENDABOT_AUTOMERGE_ISSUES+=("job-level actor gate が未設定(Dependabot 確認前に write token が発行される)")
fi
if ! echo "$DEPENDABOT_WF" | grep -q "contents: read"; then
DEPENDABOT_AUTOMERGE_ISSUES+=("workflow-level permissions が read-only ではない")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate the Dependabot contract structurally

When an older workflow has the Dependabot actor condition only on steps, or has contents: read in a comment/job while top-level permissions still grant writes, these file-wide grep checks pass even though the job still gets a write-scoped token before the Dependabot actor gate. Since full mode only rewrites when DEPENDABOT_AUTOMERGE_ISSUES is nonempty, the unsafe workflow is skipped; parse/check YAML locations such as the job if and top-level permissions instead of substring presence.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/template-workflows.test.js (1)

315-317: ⚡ Quick win

Match actual label entries instead of raw substrings.

These assertions can pass if the labels are only present in comments and can fail for valid YAML using double quotes or no quotes. Anchor the check to a - name: entry while keeping the test dependency-free.

♻️ Proposed refactor
-        expect(labels).toContain("name: 'dependabot-minor'");
-        expect(labels).toContain("name: 'needs-review'");
-        expect(labels).toContain("name: 'breaking-change'");
+        const requiredLabelNames = ['dependabot-minor', 'needs-review', 'breaking-change'];
+        for (const labelName of requiredLabelNames) {
+          expect(labels).toMatch(
+            new RegExp(`^\\s*-\\s*name:\\s*['"]?${labelName}['"]?\\s*$`, 'm'),
+          );
+        }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/template-workflows.test.js` around lines 315 - 317, The test assertions
for the labels in the expect statements (checking for 'dependabot-minor',
'needs-review', and 'breaking-change') are matching raw substrings which can
pass even if labels appear in comments and fail for valid YAML with different
quote styles. Update each of the three expect(labels).toContain() calls to match
the actual YAML list entry format by anchoring to the `- name:` prefix and using
a pattern that accommodates single quotes, double quotes, or no quotes (for
example, check for patterns like `- name:\s*['"]?dependabot-minor['"]?` using a
regular expression test rather than a simple substring match). This ensures you
are validating proper YAML label entries while remaining dependency-free.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@script/dependency-health-check.sh`:
- Around line 123-135: The issue is that the code prints a success message "No
peer dependency issues" when PEER_ISSUES is 0, even when the peer dependency
check was actually skipped due to missing node_modules. Restructure the
conditional logic by checking PEER_CHECK_SKIPPED first before printing any
status message. If PEER_CHECK_SKIPPED is true, print the skipped notice
immediately. Only if the check was not skipped should you proceed with the
existing if-else block that checks PEER_ISSUES and prints either issues or the
success message. This ensures the output accurately reflects the actual state of
the check.

---

Nitpick comments:
In `@test/template-workflows.test.js`:
- Around line 315-317: The test assertions for the labels in the expect
statements (checking for 'dependabot-minor', 'needs-review', and
'breaking-change') are matching raw substrings which can pass even if labels
appear in comments and fail for valid YAML with different quote styles. Update
each of the three expect(labels).toContain() calls to match the actual YAML list
entry format by anchoring to the `- name:` prefix and using a pattern that
accommodates single quotes, double quotes, or no quotes (for example, check for
patterns like `- name:\s*['"]?dependabot-minor['"]?` using a regular expression
test rather than a simple substring match). This ensures you are validating
proper YAML label entries while remaining dependency-free.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ee423040-d277-4bd7-a4b7-fee957e0fb05

📥 Commits

Reviewing files that changed from the base of the PR and between 060ad9a and c7f8fe8.

📒 Files selected for processing (4)
  • .claude/commands/repo-maintenance.md
  • script/dependency-health-check.sh
  • test/claude-workflow-contract.test.js
  • test/template-workflows.test.js

Comment on lines +123 to +135
if [ "$PEER_ISSUES" -gt 0 ]; then
echo -e " ${YELLOW}⚠ $PEER_ISSUES peer dependency compatibility issues${NC}"
printf '%s\n' "$PEER_PROBLEMS" | sed '/^$/d' | head -5 | sed 's/^/ - /'
if [ "$PEER_ISSUES" -gt 5 ]; then
echo " ... and $((PEER_ISSUES - 5)) more"
fi
else
echo -e " ${GREEN}✓ No peer dependency issues${NC}"
fi

if [ "$PEER_CHECK_SKIPPED" = true ]; then
echo " • Peer dependency check skipped (node_modules not installed)"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Do not report “No peer dependency issues” when the check was skipped.

When node_modules is absent, Line 74 sets PEER_CHECK_SKIPPED=true, but Lines 129-130 still print a green no-issues result before the skipped notice. Put the skipped branch first so the human output matches the actual check state.

🔧 Proposed fix
-    if [ "$PEER_ISSUES" -gt 0 ]; then
+    if [ "$PEER_CHECK_SKIPPED" = true ]; then
+      echo "  • Peer dependency check skipped (node_modules not installed)"
+    elif [ "$PEER_ISSUES" -gt 0 ]; then
       echo -e "  ${YELLOW}⚠ $PEER_ISSUES peer dependency compatibility issues${NC}"
       printf '%s\n' "$PEER_PROBLEMS" | sed '/^$/d' | head -5 | sed 's/^/    - /'
       if [ "$PEER_ISSUES" -gt 5 ]; then
         echo "    ... and $((PEER_ISSUES - 5)) more"
       fi
     else
       echo -e "  ${GREEN}✓ No peer dependency issues${NC}"
     fi
-
-    if [ "$PEER_CHECK_SKIPPED" = true ]; then
-      echo "  • Peer dependency check skipped (node_modules not installed)"
-    fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ "$PEER_ISSUES" -gt 0 ]; then
echo -e " ${YELLOW}$PEER_ISSUES peer dependency compatibility issues${NC}"
printf '%s\n' "$PEER_PROBLEMS" | sed '/^$/d' | head -5 | sed 's/^/ - /'
if [ "$PEER_ISSUES" -gt 5 ]; then
echo " ... and $((PEER_ISSUES - 5)) more"
fi
else
echo -e " ${GREEN}✓ No peer dependency issues${NC}"
fi
if [ "$PEER_CHECK_SKIPPED" = true ]; then
echo " • Peer dependency check skipped (node_modules not installed)"
fi
if [ "$PEER_CHECK_SKIPPED" = true ]; then
echo " • Peer dependency check skipped (node_modules not installed)"
elif [ "$PEER_ISSUES" -gt 0 ]; then
echo -e " ${YELLOW}$PEER_ISSUES peer dependency compatibility issues${NC}"
printf '%s\n' "$PEER_PROBLEMS" | sed '/^$/d' | head -5 | sed 's/^/ - /'
if [ "$PEER_ISSUES" -gt 5 ]; then
echo " ... and $((PEER_ISSUES - 5)) more"
fi
else
echo -e " ${GREEN}✓ No peer dependency issues${NC}"
fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@script/dependency-health-check.sh` around lines 123 - 135, The issue is that
the code prints a success message "No peer dependency issues" when PEER_ISSUES
is 0, even when the peer dependency check was actually skipped due to missing
node_modules. Restructure the conditional logic by checking PEER_CHECK_SKIPPED
first before printing any status message. If PEER_CHECK_SKIPPED is true, print
the skipped notice immediately. Only if the check was not skipped should you
proceed with the existing if-else block that checks PEER_ISSUES and prints
either issues or the success message. This ensures the output accurately
reflects the actual state of the check.

@keito4
keito4 merged commit 141cf8c into main Jun 17, 2026
23 checks passed
@keito4
keito4 deleted the fix/repo-maintenance-reflect-checked-repos branch June 17, 2026 07:11
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.116.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant