workflows: make on_pr_closed.py executable and add permissions test (#4076)

GitHub Actions workflow step scripts invoked directly as executables
require executable file mode (`100755`).
`.github/workflows/on_pr_closed.py` was checked in with `100644`
permissions, causing step execution errors when run directly.

Mark `on_pr_closed.py` as executable and introduce an automated
regression test in `tests/workflows/` that asserts any workflow script
with a shebang has executable bit permissions. In addition, update agent
rules and review skills to audit script execution permissions.
diff --git a/.agents/rules/github_actions_workflows.md b/.agents/rules/github_actions_workflows.md
index 00f2177..f417ed1 100644
--- a/.agents/rules/github_actions_workflows.md
+++ b/.agents/rules/github_actions_workflows.md
@@ -1,7 +1,7 @@
 ---
 name: github-actions-workflows
 trigger: glob
-globs: [".github/workflows/*.yml", ".github/workflows/*.yaml", ".github/*.yaml"]
+globs: [".github/workflows/**"]
 ---
 
 # GitHub Actions Workflows Rule
@@ -9,13 +9,16 @@
 * Use the latest version of referenced actions in `.github/workflows/`.
 * Preserve `suppress-no-jobs-ran-error` fallback jobs in conditional workflows.
 * Pass inputs (e.g. `${{ inputs.issue }}`) directly to commands without
-  redundant shell parameter stripping or conversions.
-* Print console messages using GitHub workflow command syntax (e.g.,
-  `::error::`, `::warning::`, `::notice::`, `::group::`).
-* **Event Payload Resolution**: Load event details directly from
-  `$GITHUB_EVENT_PATH` rather than passing fields via env vars or CLI flags.
+  redundant shell stripping.
+* Print console messages using GitHub workflow commands (e.g., `::error::`,
+  `::warning::`, `::notice::`, `::group::`).
+* **Event Payload Resolution**: For steps that are a single Python script,
+  loading event details directly from `$GITHUB_EVENT_PATH` is required (strong
+  suggestion otherwise) rather than passing fields via env vars or CLI flags.
 
 ## Workflow Python Scripts & Testing
+* **Executable Permissions**: Workflow step scripts must have `chmod +x` (mode
+  `100755`) and a shebang (e.g. `#!/usr/bin/env python3`).
 * **Test Location**: Place workflow tests under `tests/workflows/`.
 * **Imports over `sys.path`**: Never alter `sys.path`. Define a `py_library`
   with `imports = ["../../.github/workflows"]` in `tests/workflows/BUILD.bazel`.
diff --git a/.agents/skills/review-code/SKILL.md b/.agents/skills/review-code/SKILL.md
index ddc89ab..f53116c 100644
--- a/.agents/skills/review-code/SKILL.md
+++ b/.agents/skills/review-code/SKILL.md
@@ -52,6 +52,13 @@
    - Focus: Audits PR titles and descriptions against Conventional Commits
      formatting and PR update rules in `CONTRIBUTING.md`.
 
+7. **GitHub Workflows Sub-Agent** (`Role: "GitHub Workflows Auditor"`):
+   - Prompt file:
+     `.agents/skills/review-code/review-workflows-prompt.md`
+   - Focus: Audits workflow files (`.github/**`) and workflow tests against
+     `.agents/rules/github_actions_workflows.md` (e.g. `chmod +x` executable
+     permissions, shebangs, action versions, fallback jobs).
+
 ### Action Instructions
 - Immediately create a user-facing review artifact named
   `code-review-results.md` in the conversation artifact directory so progress
diff --git a/.agents/skills/review-code/review-workflows-prompt.md b/.agents/skills/review-code/review-workflows-prompt.md
new file mode 100644
index 0000000..50bc446
--- /dev/null
+++ b/.agents/skills/review-code/review-workflows-prompt.md
@@ -0,0 +1,24 @@
+You are a specialized GitHub Actions & Workflows Auditor sub-agent.
+Your sole task is to audit all workflow files (`.github/workflows/**`) and
+workflow test changes in `git diff` against the project's workflow rules and
+conventions:
+
+1. Read and strictly enforce `.agents/rules/github_actions_workflows.md`,
+   `AGENTS.md`, and `CONTRIBUTING.md`.
+2. Verify executable permissions: any script invoked directly as a workflow
+   step (e.g. `.github/workflows/*.py`, `*.sh`) must have `chmod +x` (filemode
+   `100755`) and an appropriate shebang (e.g. `#!/usr/bin/env python3`).
+3. Verify action versions: ensure workflow steps use the latest action versions.
+4. Verify fallback jobs: ensure `suppress-no-jobs-ran-error` / `noop` fallback
+   jobs exist in conditional workflows.
+5. Check event payload handling: for steps that are a single Python script,
+   verifying `$GITHUB_EVENT_PATH` is loaded directly is a requirement (strong
+   suggestion otherwise), rather than passing payload fields via CLI args or
+   environment variables.
+6. Verify workflow tests: check that tests are located in `tests/workflows/`,
+   use `imports = ["../../.github/workflows"]` in `BUILD.bazel`, and do not
+   modify `sys.path`.
+7. Verify console messaging: ensure scripts use GHA workflow command syntax
+   (e.g. `::error::`, `::warning::`, `::notice::`, `::group::`).
+
+@.agents/skills/review-code/review-report-format.md
diff --git a/.github/workflows/BUILD.bazel b/.github/workflows/BUILD.bazel
index e9bb929..09c0ea2 100644
--- a/.github/workflows/BUILD.bazel
+++ b/.github/workflows/BUILD.bazel
@@ -1,4 +1,12 @@
+package(default_visibility = ["//tests:__subpackages__"])
+
 exports_files(
     glob(["*"]),
     visibility = ["//tests:__subpackages__"],
 )
+
+filegroup(
+    name = "all_files",
+    srcs = glob(["*"]),
+    visibility = ["//tests:__subpackages__"],
+)
diff --git a/.github/workflows/on_pr_closed.py b/.github/workflows/on_pr_closed.py
old mode 100644
new mode 100755
diff --git a/tests/workflows/BUILD.bazel b/tests/workflows/BUILD.bazel
index 13d3ebb..2e3d686 100644
--- a/tests/workflows/BUILD.bazel
+++ b/tests/workflows/BUILD.bazel
@@ -37,3 +37,13 @@
         "@pypi//pytest_mock",
     ],
 )
+
+pytest_test(
+    name = "workflow_permissions_test",
+    srcs = ["workflow_permissions_test.py"],
+    data = ["//.github/workflows:all_files"],
+    target_compatible_with = NOT_WINDOWS,
+    deps = [
+        "//python/runfiles",
+    ],
+)
diff --git a/tests/workflows/workflow_permissions_test.py b/tests/workflows/workflow_permissions_test.py
new file mode 100644
index 0000000..8c98c80
--- /dev/null
+++ b/tests/workflows/workflow_permissions_test.py
@@ -0,0 +1,25 @@
+"""Tests that workflow scripts with shebangs have executable permissions."""
+
+import stat
+
+from python.runfiles import runfiles
+
+
+def test_py_files_with_shebangs_are_executable():
+    rf = runfiles.CreateOrRaise()
+    workflows_dir = rf.root() / "rules_python/.github/workflows"
+    py_files = list(workflows_dir.glob("*.py"))
+
+    assert len(py_files) > 0, f"No Python files found in {workflows_dir}"
+
+    for py_file in py_files:
+        first_line = py_file.read_text(encoding="utf-8", errors="ignore").splitlines()[
+            0
+        ]
+        if first_line.startswith("#!"):
+            mode = py_file.stat().st_mode
+            is_executable = bool(mode & stat.S_IXUSR)
+            assert is_executable, (
+                f"{py_file.name} has a shebang ('{first_line}') but does not "
+                f"have executable (+x) permissions (mode: {oct(mode)})"
+            )
diff --git a/tools/private/reviewbot/skills/review-pr/SKILL.md b/tools/private/reviewbot/skills/review-pr/SKILL.md
index 915a526..3182b14 100644
--- a/tools/private/reviewbot/skills/review-pr/SKILL.md
+++ b/tools/private/reviewbot/skills/review-pr/SKILL.md
@@ -5,29 +5,36 @@
 
 # review-pr
 
-IMPORTANT: The exact git diff for the pull request is pre-provided right in your prompt. Analyze this provided diff directly in a single pass without calling exploratory directory listing or file reading tools unless you specifically need surrounding lines of context from a modified file.
+IMPORTANT: The exact git diff for the pull request is pre-provided right in your
+prompt. Analyze this provided diff directly in a single pass without calling
+exploratory directory listing or file reading tools unless you specifically need
+surrounding lines of context from a modified file.
 
-You are an expert Starlark, Python, and Bazel code reviewer. Analyze the changed files for
-correctness, edge cases, and performance. Focus strictly on logical
-correctness, concurrency safety, system architecture, performance bottlenecks,
-and resource management. Do not comment on style nits or formatting issues
-that an automated formatter can handle. Be constructive and concise.
+You are an expert Starlark, Python, and Bazel code reviewer. Analyze the
+changed files for correctness, edge cases, and performance. Focus strictly on
+logical correctness, concurrency safety, system architecture, performance
+bottlenecks, and resource management. Do not comment on style nits or formatting
+issues that an automated formatter can handle. Be constructive and concise.
 
 For every issue or improvement you identify, you MUST output the finding in the
-GitHub Actions workflow command warning format. Specify the exact file path
-and line numbers that the comment applies to.
+GitHub Actions workflow command warning format. Specify the exact file path and
+line numbers that the comment applies to.
 
 Format each finding exactly as a single line to stdout matching this template:
 `::warning file={file_path},line={line_number},endLine={end_line},title={category}::{comment_body}`
 
 Where:
 *   `file_path` is the relative file path from the repository root.
-*   `line_number` is the starting line number in the file where the comment applies.
-*   `end_line` is the ending line number in the file where the comment applies (equal to line_number if the issue is on a single line).
-*   `category` is a short tag for the type of issue (e.g., "Error Handling", "Correctness", "Performance").
+*   `line_number` is the starting line number in the file where the comment
+    applies.
+*   `end_line` is the ending line number in the file where the comment applies
+    (equal to line_number if the issue is on a single line).
+*   `category` is a short tag for the type of issue (e.g., "Error Handling",
+    "Correctness", "Performance").
 *   `comment_body` is your constructive and concise feedback.
 
-Do not write any markdown commentary outside of these GHA command formatted lines.
+Do not write any markdown commentary outside of these GHA command formatted
+lines.
 
 Follow these checklists during your review:
 
@@ -35,14 +42,16 @@
 *   **PR Description Audit**: Verify the description contains the Why
     (business/technical reason), a brief high level overview of changes,
     Issue/Bug Link, and explicit Testing Evidence.
-*   **Separation of Concerns**: Suggest extracting large hardcoded data structures
-    (e.g., massive templates, complex regexes) to resource files.
-*   **Logic Correctness**: Verify calculations, negative values, division-by-zero,
-    and null safety before member access.
+*   **Separation of Concerns**: Suggest extracting large hardcoded data
+    structures (e.g., massive templates, complex regexes) to resource files.
+*   **Logic Correctness**: Verify calculations, negative values,
+    division-by-zero, and null safety before member access.
 *   **Error Handling**: Flag silent failures (e.g., empty except blocks) and
     unconditional defaults that override configs.
 *   **Deterministic Operations**: Sort collections/keys to guarantee
     reproducible/deterministic execution.
+*   **Workflow & Script Execution**: Verify workflow step scripts have
+    executable permissions (`chmod +x` / filemode `100755`) and shebangs.
 
 ### Skeptical Critic (Adversarial Specialist Review)
 *   **Dynamic Filtering**: Filter the PR diff and run only the specialist checks