Skip to content

Commit 0f14ff8

Browse files
committed
fix(scheduler): accept safe Unicode pull-request refs
Replay the unique Git ref allowlist onto current main so GitHub-valid emoji and Hangul branches dispatch while shell and control characters stay rejected.
1 parent c47afc2 commit 0f14ff8

6 files changed

Lines changed: 81 additions & 4 deletions

File tree

‎.github/workflows/strix-changed-path-quality-ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ on:
1313
- "tests/test_strix_changed_path_policy.py"
1414
- "tests/test_strix_workflow_dependency_hashes.py"
1515
- "tests/test_strix_quality_timeout_fixture_budget.py"
16+
- ".github/workflows/pr-review-merge-scheduler.yml"
17+
- "scripts/ci/pr_review_merge_scheduler.py"
18+
- "tests/test_pr_review_merge_scheduler.py"
1619

1720
permissions:
1821
contents: read

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Semantic Versioning where the repository publishes a release.
2626

2727
### Fixed
2828

29+
- Accepted GitHub-valid Unicode pull-request refs (for example emoji and Hangul branch names) while still rejecting shell metacharacters, Unicode control/format/separator characters, and Git-unsafe path forms; scheduler source changes now trigger the exact-head full-suite quality gate.
2930
- Materialized base Python locks only when every package line is an exact SHA-256 pin or a bounded relative `-r`/`--requirement` include. A lone `--require-hashes` directive, a dotted include such as `./lock.txt`, or `-r other-hashes.txt` no longer enters the trusted build context.
3031
- Refused a conflict-scope repository root whose immediate parent is a symbolic link, so a swapped parent cannot redirect the canonical worktree after the last-component check (CWE-367).
3132
- Bounded the Strix quality self-test's deterministic timeout fixtures to 3-second process and 5-second fake-sleep budgets so exact-head policy evidence completes inside the existing job limit without changing production Strix scanner timeouts, providers, credentials, or review semantics.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Scheduler Unicode Git refs
2+
3+
## Incident and buyer impact
4+
5+
The merge scheduler rejected GitHub-valid branch names such as
6+
`🎨-palette-ux-improvement-13325911538352561627` because `validate_git_ref`
7+
used an ASCII-only regular expression. International product branches never
8+
reached dispatch.
9+
10+
## Decision
11+
12+
Permit non-ASCII graphic and letter characters. Continue to reject ASCII
13+
shell metacharacters and whitespace; Unicode control, format, and separator
14+
categories; leading dashes; reserved `HEAD`; `@{`; traversal and hidden
15+
components; trailing dots or slashes; and component `.lock` suffixes. All
16+
Git and GitHub calls stay structured argv/API fields.
17+
18+
## References
19+
20+
Chacon, S., & Straub, B. (2014). *Pro Git* (2nd ed.). Apress.
21+
https://git-scm.com/docs/git-check-ref-format
22+
23+
The Unicode Consortium. (2024). *The Unicode Standard* (Version 16.0.0).
24+
https://www.unicode.org/versions/Unicode16.0.0/

‎scripts/ci/pr_review_merge_scheduler.py‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import subprocess
1313
import sys
1414
import time
15+
import unicodedata
1516
from collections.abc import Sequence
1617
from dataclasses import dataclass
1718
from datetime import datetime, timezone
@@ -126,7 +127,7 @@
126127
RUNNING_CHECK_STATES = {"PENDING", "EXPECTED", "QUEUED", "IN_PROGRESS", "WAITING", "REQUESTED"}
127128
FAILED_CHECK_CONCLUSIONS = {"FAILURE", "ERROR", "CANCELLED", "TIMED_OUT", "STARTUP_FAILURE"}
128129
ACTION_REQUIRED_CONCLUSIONS = {"ACTION_REQUIRED"}
129-
GIT_REF_RE = re.compile(r"^(?!-)[A-Za-z0-9._/-]+$")
130+
GIT_REF_ASCII_SAFE_CHARS = frozenset("._/-")
130131
GIT_SHA_RE = re.compile(r"^[0-9a-fA-F]{40}$")
131132
GITHUB_REPOSITORY_RE = re.compile(r"^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$")
132133
REVIEW_BODY_HEAD_SHA_RE = re.compile(r"Head SHA:\s*`([0-9a-fA-F]{40})`")
@@ -530,10 +531,20 @@ def split_repo(repo: str) -> tuple[str, str]:
530531

531532
def validate_git_ref(ref: str) -> str:
532533
"""Return a conservative Git ref name for gh workflow dispatch fields."""
534+
has_unsafe_character = not isinstance(ref, str) or any(
535+
(
536+
ord(character) < 128
537+
and not character.isalnum()
538+
and character not in GIT_REF_ASCII_SAFE_CHARS
539+
)
540+
or (ord(character) >= 128 and unicodedata.category(character)[0] in {"C", "Z"})
541+
for character in ref
542+
)
533543
if (
534544
not isinstance(ref, str)
535545
or not ref
536-
or not GIT_REF_RE.fullmatch(ref)
546+
or has_unsafe_character
547+
or ref.startswith("-")
537548
or ref == "HEAD"
538549
or ref.startswith("/")
539550
or ref.endswith(("/", "."))
@@ -542,7 +553,10 @@ def validate_git_ref(ref: str) -> str:
542553
or "//" in ref
543554
):
544555
raise ValueError(f"invalid git ref: {ref!r}")
545-
if any(part == "." or part.startswith(".") for part in ref.split("/")):
556+
if any(
557+
part == "." or part.startswith(".") or part.endswith(".lock")
558+
for part in ref.split("/")
559+
):
546560
raise ValueError(f"invalid git ref: {ref!r}")
547561
return ref
548562

‎tests/test_pr_review_merge_scheduler.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ def test_run_split_repo_and_graphql(monkeypatch):
162162
with pytest.raises(ValueError):
163163
sched.split_repo("/repo")
164164

165-
assert sched.validate_git_ref("feature/safe.branch-1") == "feature/safe.branch-1"
165+
for safe_ref in (
166+
"feature/safe.branch-1",
167+
"🎨-palette-ux-improvement-13325911538352561627",
168+
"기능/안전한-브랜치",
169+
):
170+
assert sched.validate_git_ref(safe_ref) == safe_ref
166171
for bad_ref in (
167172
"",
168173
"-bad",
@@ -174,6 +179,10 @@ def test_run_split_repo_and_graphql(monkeypatch):
174179
"feature/main.",
175180
"feature/@{upstream}",
176181
"feat;echo pwned",
182+
"feature/main.lock",
183+
"feature/non\u00a0breaking-space",
184+
"feature/zero\u200bwidth-space",
185+
"feature/control\ncharacter",
177186
):
178187
with pytest.raises(ValueError):
179188
sched.validate_git_ref(bad_ref)

‎tests/test_strix_changed_path_policy.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
REPOSITORY_ROOT = Path(__file__).resolve().parents[1]
1313
GATE_SCRIPT = REPOSITORY_ROOT / "scripts" / "ci" / "strix_quick_gate.sh"
14+
QUALITY_WORKFLOW = (
15+
REPOSITORY_ROOT / ".github" / "workflows" / "strix-changed-path-quality-ci.yml"
16+
)
1417
START_MARKER = 'python3 - "$REPO_ROOT" "$changed_file" <<\'PY\'\n'
1518
END_MARKER = "\nPY\n}\n\nnormalize_changed_files_cache()"
1619
LEGAL_PACKRAT_PATH = (
@@ -90,5 +93,28 @@ def test_rejects_traversal_absolute_controls_and_shell_punctuation(self) -> None
9093
self.assertEqual(result.stdout, "")
9194

9295

96+
class MergeSchedulerQualityTriggerTests(unittest.TestCase):
97+
"""Keep scheduler control-plane changes inside an exact-head full-suite gate."""
98+
99+
def test_scheduler_source_workflow_and_tests_trigger_quality_ci(self) -> None:
100+
"""Every central merge-scheduler surface must trigger the permanent gate."""
101+
102+
workflow = QUALITY_WORKFLOW.read_text(encoding="utf-8")
103+
for path in (
104+
".github/workflows/pr-review-merge-scheduler.yml",
105+
"scripts/ci/pr_review_merge_scheduler.py",
106+
"tests/test_pr_review_merge_scheduler.py",
107+
"tests/test_strix_changed_path_policy.py",
108+
):
109+
self.assertEqual(workflow.count(f' - "{path}"'), 1)
110+
111+
self.assertIn(
112+
"ref: ${{ github.event.pull_request.head.sha || github.sha }}",
113+
workflow,
114+
)
115+
self.assertIn("python -m coverage run -m pytest tests -q", workflow)
116+
self.assertIn("git diff --exit-code", workflow)
117+
118+
93119
if __name__ == "__main__":
94120
unittest.main()

0 commit comments

Comments
 (0)