agents: add mirror, ifttt-lint, and Bazel 5xx flake rules (#4465)

Plain `# Keep in sync` comments drift without automated checks,
single-URL tool downloads fail during upstream outages, and CI triage
misclassified transient Bazel HTTP 5xx and I/O download errors as code
bugs.

Require `LINT.IfChange` / `LINT.ThenChange` directives for paired
sections and verified mirror URLs for tool downloads in agent style and
review rules. Detect transient Bazel download failures in CI log triage
and suggest checking `mirror.bazel.build`, with unit tests.
diff --git a/.agents/rules/code-style.md b/.agents/rules/code-style.md
index eb4ebf4..90cd037 100644
--- a/.agents/rules/code-style.md
+++ b/.agents/rules/code-style.md
@@ -62,6 +62,10 @@
 * Add `keep-sorted` `start` and `end` markers on list and dict config or
   registry tables, even when they have a single entry.
 
+## Synchronized Sections (`ifttt-lint`)
+* Use `LINT.IfChange(<name>)` and `LINT.ThenChange(<target>)` directives instead
+  of plain `# Keep in sync` comments for paired code or config sections.
+
 ## Bulk Logging
 * In bulk operations, log a single summary line on success; on failure, list
   each failing item sorted, one per line, with its location and reason.
diff --git a/.agents/rules/github_actions_workflows.md b/.agents/rules/github_actions_workflows.md
index f009b19..4d6469e 100644
--- a/.agents/rules/github_actions_workflows.md
+++ b/.agents/rules/github_actions_workflows.md
@@ -27,7 +27,9 @@
 * **Verified Tool Downloads (`./.github/actions/download-tool`)**: Use
   `./.github/actions/download-tool` (or `dev/verified_download.py`) to fetch,
   SHA-256-verify, and cache tool binaries; key caches by `<name>-<sha256>`
-  without OS or version prefixes.
+  without OS or version prefixes. Check for verified mirrors serving the exact
+  SHA-256 payload (e.g., `mirror.bazel.build`) and list all valid mirrors in
+  `urls`.
 * Preserve `suppress-no-jobs-ran-error` fallback jobs in conditional workflows.
 * Pass inputs (e.g. `${{ inputs.issue }}`) directly to commands without
   redundant shell stripping.
diff --git a/.agents/skills/analyze-ci-failure/scripts/analyze_ci_failure.py b/.agents/skills/analyze-ci-failure/scripts/analyze_ci_failure.py
index 7906ae6..e11334a 100755
--- a/.agents/skills/analyze-ci-failure/scripts/analyze_ci_failure.py
+++ b/.agents/skills/analyze-ci-failure/scripts/analyze_ci_failure.py
@@ -9,6 +9,7 @@
 import urllib.request
 
 _ANSI_ESCAPE = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])")
+_HTTP_5XX_DOWNLOAD_ERROR = re.compile(r"get returned 5\d\d\b", re.IGNORECASE)
 
 _HTTP_GATEWAY_ERRORS = (
     # keep-sorted start
@@ -25,6 +26,7 @@
     "critical path",
     "curl: (",
     "errno 5",
+    "error downloading [",
     "error during connect:",
     "error waiting for container",
     "error:",
@@ -36,6 +38,7 @@
     "fatal",
     "fatal:",
     "filenotfounderror",
+    "get returned 5",
     "input/output error",
     "no such package",
     "no such target",
@@ -162,6 +165,31 @@
     return False
 
 
+def _is_repo_download_flake(errors):
+    """Returns whether error lines indicate a transient Bazel download failure.
+
+    Args:
+        errors: Sequence of extracted error log lines.
+
+    Returns:
+        True if any line shows an HTTP 5xx or transient download failure.
+    """
+    for err in errors:
+        if _HTTP_5XX_DOWNLOAD_ERROR.search(err):
+            return True
+        lower_err = err.lower()
+        if "error downloading [" in lower_err and any(
+            reason in lower_err
+            for reason in (
+                "timed out",
+                "connection reset",
+                "unexpected end of file",
+            )
+        ):
+            return True
+    return False
+
+
 def parse_log(log_path):
     if not os.path.exists(log_path):
         return [f"Log file not found at {log_path}"]
@@ -212,6 +240,12 @@
     ):
         is_flake = True
         flake_reason = "Buildkite agent / Docker runner infrastructure failure (dockerd disconnection / grpc context canceled / exit status 125). This is an infrastructure flake, not a codebase bug."
+    elif _is_repo_download_flake(errors):
+        is_flake = True
+        flake_reason = (
+            "Transient Bazel repository download failure (HTTP 5xx or I/O error). "
+            "Check if the archive is available on mirror.bazel.build before retrying."
+        )
     elif _contains_any(errors, _HTTP_GATEWAY_ERRORS):
         is_flake = True
         flake_reason = (
diff --git a/.agents/skills/analyze-ci-failure/scripts/analyze_ci_failure_test.py b/.agents/skills/analyze-ci-failure/scripts/analyze_ci_failure_test.py
new file mode 100755
index 0000000..05a6089
--- /dev/null
+++ b/.agents/skills/analyze-ci-failure/scripts/analyze_ci_failure_test.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python3
+"""Unit tests for analyze_ci_failure.py."""
+
+import tempfile
+import unittest
+from pathlib import Path
+
+import analyze_ci_failure
+
+_FLAKE_BANNER = "Infrastructure / Flake Issue"
+_CODE_BANNER = "Code / Configuration Issue"
+
+
+class AnalyzeCiFailureTest(unittest.TestCase):
+    def _classify_log(self, log_text: str) -> tuple[list[str], str]:
+        with tempfile.TemporaryDirectory() as tmp_dir:
+            log_path = Path(tmp_dir) / "ci.log"
+            log_path.write_text(log_text, encoding="utf-8")
+            errors = analyze_ci_failure.parse_log(str(log_path))
+            plan = analyze_ci_failure.create_plan(
+                "Default: Debian, Bazel 7.x", str(log_path), errors
+            )
+        return errors, plan
+
+    def test_bazel_http_5xx_download_classified_as_flake_with_mirror_advice(
+        self,
+    ) -> None:
+        errors, plan = self._classify_log(
+            "INFO: Running Bazel...\n"
+            "WARNING: Download from https://github.com/bazelbuild/rules_rust/releases/download/0.73.0/rules_rust-0.73.0.tar.gz failed: class java.io.IOException GET returned 500 Internal Server Error\n"
+            "ERROR: Error in download_and_extract: java.io.IOException: Error downloading [https://github.com/bazelbuild/rules_rust/releases/download/0.73.0/rules_rust-0.73.0.tar.gz] to /tmp/r.tar.gz: GET returned 500 Internal Server Error\n"
+        )
+        self.assertEqual(len(errors), 2)
+        self.assertIn(_FLAKE_BANNER, plan)
+        self.assertIn("mirror.bazel.build", plan)
+
+    def test_bazel_http_504_download_gets_mirror_advice_over_gateway_branch(
+        self,
+    ) -> None:
+        _, plan = self._classify_log(
+            "ERROR: Error in download_and_extract: java.io.IOException: Error downloading [https://example.com/tool.tar.gz] to /tmp/t.tar.gz: GET returned 504 Gateway Time-out\n"
+        )
+        self.assertIn(_FLAKE_BANNER, plan)
+        self.assertIn("mirror.bazel.build", plan)
+
+    def test_bazel_download_timeout_and_reset_classified_as_flake(self) -> None:
+        for reason in (
+            "Read timed out",
+            "Connection reset",
+            "Unexpected end of file from server",
+        ):
+            with self.subTest(reason=reason):
+                _, plan = self._classify_log(
+                    f"ERROR: java.io.IOException: Error downloading [https://example.com/a.tar.gz] to /tmp/a.tar.gz: {reason}\n"
+                )
+                self.assertIn(_FLAKE_BANNER, plan)
+
+    def test_permanent_404_and_checksum_errors_not_classified_as_flake(self) -> None:
+        for log_line in (
+            "ERROR: java.io.IOException: Error downloading [https://example.com/missing.tar.gz] to /tmp/m.tar.gz: GET returned 404 Not Found\n",
+            "ERROR: java.io.IOException: Error downloading [https://example.com/bad.tar.gz] to /tmp/b.tar.gz: Checksum was deadbeef but wanted cafebabe\n",
+        ):
+            with self.subTest(log_line=log_line):
+                _, plan = self._classify_log(log_line)
+                self.assertIn(_CODE_BANNER, plan)
+                self.assertNotIn(_FLAKE_BANNER, plan)
+
+    def test_benign_download_progress_lines_not_captured_by_parse_log(self) -> None:
+        errors, _ = self._classify_log(
+            "INFO: Download from https://example.com/ok.tar.gz succeeded\n"
+            "ERROR: Analysis of target '//foo:bar' failed: build failed\n"
+        )
+        self.assertEqual(
+            errors, ["ERROR: Analysis of target '//foo:bar' failed: build failed"]
+        )
+
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/.agents/skills/review-code/SKILL.md b/.agents/skills/review-code/SKILL.md
index ce705b0..06b89f0 100644
--- a/.agents/skills/review-code/SKILL.md
+++ b/.agents/skills/review-code/SKILL.md
@@ -88,7 +88,8 @@
       definition order, guard clauses, fail-closed `else`, single input form,
       no unrequested knobs/aliases, no speculative validation or defensive
       `None` checks, no nested comprehensions, naming precision,
-      simplification, `keep-sorted` markers, and CLI safety annotations.
+      simplification, `keep-sorted` markers, `LINT.IfChange` /
+      `LINT.ThenChange` directives, and CLI safety annotations.
 
 11. Shell Script Sub-Agent (`Role: "Shell Script Auditor"`):
     - Prompt file:
diff --git a/.agents/skills/review-code/review-code-style-prompt.md b/.agents/skills/review-code/review-code-style-prompt.md
index cf52a95..5a45f55 100644
--- a/.agents/skills/review-code/review-code-style-prompt.md
+++ b/.agents/skills/review-code/review-code-style-prompt.md
@@ -19,5 +19,7 @@
    `Justification & Exception Auditor` evaluates it for human sign-off.
 6. Relative Paths: When an object, field, or return value holds relative paths,
    verify comments or docstrings document what those paths are relative to.
+7. Synchronized Sections: Flag plain `# Keep in sync` comments for paired code
+   or config blocks and require `LINT.IfChange` / `LINT.ThenChange` directives.
 
 @.agents/skills/review-code/review-report-format.md
diff --git a/.agents/skills/review-code/review-workflows-prompt.md b/.agents/skills/review-code/review-workflows-prompt.md
index dd37d70..6226eea 100644
--- a/.agents/skills/review-code/review-workflows-prompt.md
+++ b/.agents/skills/review-code/review-workflows-prompt.md
@@ -43,7 +43,8 @@
     `bazel-contrib/setup-bazel` directly, and
     `uses: ./.github/actions/download-tool` or `dev/verified_download.py` to
     fetch, SHA-256-verify, and cache tool binaries keyed by `<name>-<sha256>`
-    without OS or version prefixes).
+    without OS or version prefixes, listing verified mirrors in `urls` when
+    available).
 11. Audit for injection and security vulnerabilities:
     - Require explicit top-level `permissions:` (`{}` or minimal scopes) in all
       workflows, and explicit job-level permissions for reusable workflow calls