Skip to content

[code-simplifier] Simplify findMember matching logic in ralph-triage.js #54129

Description

@github-actions

Caution

Protected files were modified in this change.
This pull request is in request_review mode and requires explicit human scrutiny before merge.

Protected files: .squad/templates/ralph-triage.js

Summary

Simplify findMember() in .squad/templates/ralph-triage.js, one of the files flagged as a candidate in the last 24h scan (deterministic candidate list from source-files.json, generated 2026-08-20).

What changed

  • findMember(target, roster) previously ran 4 separate sequential loops over the roster array:
    1. exact name match
    2. exact role match
    3. name substring match (either direction)
    4. role substring match (either direction)
  • Replaced with a MEMBER_MATCH_STRATEGIES array of match predicates plus a single loop that tries each strategy in order via roster.find(...).
  • Behavior preserved exactly: same priority order (exact name > exact role > name substring > role substring), same normalization (normalizeName), same early-return semantics for the first strategy that yields a match.

Why

  • Removes duplicated loop boilerplate and makes the match-priority order explicit and easy to extend (adding/reordering strategies is now a one-line change instead of copy-pasting a new loop).
  • No interface or behavior changes — pure internal refactor of a private helper function.

Validation

  • node --check .squad/templates/ralph-triage.js — syntax OK.
  • make test-unit — no Go files changed, impacted-test check reported nothing to run (this file has no existing Go/JS test harness wired into make lint/make test-unit; it's a standalone template script under .squad/templates/).
  • make build — succeeded.

Process notes

This PR used the deterministic pre-computed inputs (recent-context.json, source-files.json, history-summary.json) instead of re-fetching PR/commit history via GitHub tools, per the token-efficiency guardrails for this workflow. A scope-filter sub-agent scored candidate files and flagged ralph-triage.js's findMember loops as the clearest, lowest-risk simplification opportunity among the 20 candidate files; other larger files (add_comment.cjs, add_labels.cjs, purity_scan.go) were reviewed but deferred as higher-risk for an unattended pass given the size of the changes needed.

Generated by 🔧 Code Simplifier · auto · 60.5 AIC · ⌖ 7.4 AIC · ⊞ 9.6K ·

  • expires on Aug 20, 2026, 7:36 PM UTC-08:00

Note

This was originally intended as a pull request, but the git push operation failed.

Original error: ERR_VALIDATION: pushSignedCommits: refusing unsigned push for branch 'simplify-ralph-triage-find-member-0cee6e2cdadb83b1': Signed-commit payload violates file-protection policy (request_review): .squad/templates/ralph-triage.js

Workflow Run: View run details and download bundle artifact

The bundle file is available in the agent artifact in the workflow run linked above.

To create a pull request with the changes:

# Download the artifact from the workflow run
gh run download 32328256109 -n agent -D /tmp/agent-32328256109

# Fetch the bundle into a temporary ref, then update the local branch
git fetch /tmp/agent-32328256109/aw-simplify-ralph-triage-find-member.bundle refs/heads/simplify-ralph-triage-find-member:refs/bundles/create-pr-simplify-ralph-triage-find-member-0cee6e2cdadb83b1-70e8d689
git update-ref refs/heads/simplify-ralph-triage-find-member-0cee6e2cdadb83b1 refs/bundles/create-pr-simplify-ralph-triage-find-member-0cee6e2cdadb83b1-70e8d689
git checkout simplify-ralph-triage-find-member-0cee6e2cdadb83b1
# Ensure the working tree matches the updated branch
git reset --hard
# Remove the temporary bundle ref
git update-ref -d refs/bundles/create-pr-simplify-ralph-triage-find-member-0cee6e2cdadb83b1-70e8d689

# Push the branch to origin
git push origin simplify-ralph-triage-find-member-0cee6e2cdadb83b1

# Create the pull request
gh pr create --title '[code-simplifier] Simplify findMember matching logic in ralph-triage.js' --base main --head simplify-ralph-triage-find-member-0cee6e2cdadb83b1 --repo github/gh-aw

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions