Repository navigation
feat(ci): require batch tuning numbers and state exits (retro P6) - #24943
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1825ca4680
ℹ️ 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".
| for match in LITERAL.finditer(line): | ||
| before, after = prefix + line[: match.start()], line[match.end() :] |
There was a problem hiding this comment.
Exclude inline comments from state-literal detection
When a changed code line contains an inline comment near a state field, quoted words in that comment are treated as new lifecycle values. For example, changing status = current_status to status = current_status # explain "retry_window" makes detect() report retry_window as a new state when that text is absent at base, and an ordinary comment-clarification PR then fails the mandatory disclosure check. Unlike numeric detection, this path does not exclude comment spans. Strip or tokenize inline comments before extracting state literals so documentation-only edits do not require invented exit declarations or waivers.
Useful? React with 👍 / 👎.
| candidates.update(state_literals(line, prefix)) | ||
| # #24738 only added client/source-metadata arguments beside max_count=4096. | ||
| # The same knob/value on both sides is not tuning (including moved lines). | ||
| knobs = {key[1] for key, signs in numeric.items() if len(signs) == 1} |
There was a problem hiding this comment.
Keep independently scoped numeric assignments from cancelling
When two settings in the same file share a knob name and exchange values, aggregating signs by (path, knob, value) makes both changes disappear. For example, backend/charts/batch-pipeline-worker/values.yaml contains borrowedNodePools.maxReplicas: 3 and autoscaling.maxReplicas: 6; changing them to 6 and 3 respectively returns no detected knobs and passes validation with an empty PR body. These are direct capacity changes to separate worker pools, not unchanged or moved assignments. Preserve assignment scope or pair corresponding assignments before suppressing unchanged values so independent retunes cannot cancel each other.
Useful? React with 👍 / 👎.
| field = FIELD_VALUE.search(before) | ||
| if after.lstrip().startswith(":") or FIELD_LOOKUP.search(before): | ||
| continue | ||
| if field and not STATE_CONTEXT.fullmatch(field["field"]): | ||
| continue |
There was a problem hiding this comment.
Recognize annotated state fields before filtering their values
For an annotated assignment such as status: str = "awaiting_new_repair", FIELD_VALUE captures str as the field name, so this filter discards the new state even though STATE_CONTEXT correctly recognizes status. I verified that this assignment passes validation with an empty body, whereas the identical unannotated assignment requires an exit declaration. Annotated lifecycle defaults are already used in the monitored source, for example WorkResult.outcome in backend/utils/batch_pipeline/contracts.py. Account for the optional type annotation when identifying the assigned field so adding a type does not bypass the state-exit requirement.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
3 issues found across 3 files
Confidence score: 3/5
check_batch_tuning_disclosure.pymisses capacity knobs such asBATCH_PIPELINE_MAX_OWNER_DRAINS, so changes to those knobs can avoid the disclosure check. Match the configured knob vocabulary, not justCONCURRENCY.check_batch_tuning_disclosure.pypasses when only one changed knob has before/after numbers, leaving other changed knobs undocumented. Require numbers for every detected knob.check_batch_tuning_disclosure.pycan treat multiline comments and docstrings as code after their opening delimiter, causing false matches. Track multiline non-code spans or tokenize the source.
You’re at about 99% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".github/scripts/check_batch_tuning_disclosure.py">
<violation number="1" location=".github/scripts/check_batch_tuning_disclosure.py:31">
P2: The getenv detector misses direct capacity knobs whose environment name does not contain `CONCURRENCY`, including `BATCH_PIPELINE_MAX_OWNER_DRAINS`; broaden it to recognize the configured knob vocabulary in the full environment name.</violation>
<violation number="2" location=".github/scripts/check_batch_tuning_disclosure.py:73">
P2: Multiline docstring and comment contents are classified as code after their opening delimiter. Track multiline non-code spans or tokenize the changed source before applying tuning regexes.</violation>
<violation number="3" location=".github/scripts/check_batch_tuning_disclosure.py:149">
P2: The check passes after documenting only one of several changed knobs. Require before/after numbers for every detected knob, not `any` one knob.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| NUMBER = r"-?(?:\d[\d_]*(?:\.[\d_]*)?|\.\d[\d_]*)(?:[eE][+-]?\d+)?" | ||
| ASSIGNMENT = re.compile(rf"(?<![`'\"])\b(?P<knob>{KNOB})\s*[:=]\s*(?P<value>{NUMBER})", re.I) | ||
| GETENV = re.compile( | ||
| rf"(?<![`'\"])\bos\.getenv\(\s*['\"](?P<knob>\w*CONCURRENCY\w*)['\"]\s*,\s*['\"]?(?P<value>{NUMBER})", re.I |
There was a problem hiding this comment.
P2: The getenv detector misses direct capacity knobs whose environment name does not contain CONCURRENCY, including BATCH_PIPELINE_MAX_OWNER_DRAINS; broaden it to recognize the configured knob vocabulary in the full environment name.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/scripts/check_batch_tuning_disclosure.py, line 31:
<comment>The getenv detector misses direct capacity knobs whose environment name does not contain `CONCURRENCY`, including `BATCH_PIPELINE_MAX_OWNER_DRAINS`; broaden it to recognize the configured knob vocabulary in the full environment name.</comment>
<file context>
@@ -0,0 +1,223 @@
+NUMBER = r"-?(?:\d[\d_]*(?:\.[\d_]*)?|\.\d[\d_]*)(?:[eE][+-]?\d+)?"
+ASSIGNMENT = re.compile(rf"(?<![`'\"])\b(?P<knob>{KNOB})\s*[:=]\s*(?P<value>{NUMBER})", re.I)
+GETENV = re.compile(
+ rf"(?<![`'\"])\bos\.getenv\(\s*['\"](?P<knob>\w*CONCURRENCY\w*)['\"]\s*,\s*['\"]?(?P<value>{NUMBER})", re.I
+)
+EXCLUDED = re.compile(r"_(?:ENABLED|PERCENT|UIDS|ALLOWLIST|URL)$", re.I)
</file context>
|
|
||
|
|
||
| def code(line: str) -> bool: | ||
| return bool(line.strip()) and not line.lstrip().startswith(("#", "//", "/*", "* ", '"""', "'''")) |
There was a problem hiding this comment.
P2: Multiline docstring and comment contents are classified as code after their opening delimiter. Track multiline non-code spans or tokenize the changed source before applying tuning regexes.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/scripts/check_batch_tuning_disclosure.py, line 73:
<comment>Multiline docstring and comment contents are classified as code after their opening delimiter. Track multiline non-code spans or tokenize the changed source before applying tuning regexes.</comment>
<file context>
@@ -0,0 +1,223 @@
+
+
+def code(line: str) -> bool:
+ return bool(line.strip()) and not line.lstrip().startswith(("#", "//", "/*", "* ", '"""', "'''"))
+
+
</file context>
| if knobs and not any( | ||
| re.search(r"\bbefore\b.{0,120}\d", part, re.I | re.S) | ||
| and re.search(r"\bafter\b.{0,120}\d", part, re.I | re.S) | ||
| and any(token(knob, part) for knob in knobs) |
There was a problem hiding this comment.
P2: The check passes after documenting only one of several changed knobs. Require before/after numbers for every detected knob, not any one knob.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/scripts/check_batch_tuning_disclosure.py, line 149:
<comment>The check passes after documenting only one of several changed knobs. Require before/after numbers for every detected knob, not `any` one knob.</comment>
<file context>
@@ -0,0 +1,223 @@
+ if knobs and not any(
+ re.search(r"\bbefore\b.{0,120}\d", part, re.I | re.S)
+ and re.search(r"\bafter\b.{0,120}\d", part, re.I | re.S)
+ and any(token(knob, part) for knob in knobs)
+ for part in parts
+ ):
</file context>
| and any(token(knob, part) for knob in knobs) | |
| + and all(token(knob, part) for knob in knobs) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e844a5cffc
ℹ️ 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".
| ) | ||
| KNOB = r"(?:max|min|limit|cap|concurrenc\w*|workers?|pool\w*|page_size|batch_size|drains?\w*|per_second|qps|throttle\w*|maxReplicas|minReplicas|targetBacklogPerWorker)\w*" | ||
| NUMBER = r"-?(?:\d[\d_]*(?:\.[\d_]*)?|\.\d[\d_]*)(?:[eE][+-]?\d+)?" | ||
| ASSIGNMENT = re.compile(rf"(?<![`'\"])\b(?P<knob>{KNOB})\s*[:=]\s*(?P<value>{NUMBER})", re.I) |
There was a problem hiding this comment.
Detect numeric defaults with Python type annotations
When a capacity default has a type annotation, this pattern cannot reach its numeric value because it expects a number immediately after : or =. For example, changing the existing batch_size: int = 8 parameter in backend/utils/batch_pipeline/pump.py to batch_size: int = 16 produces no detected knobs and passes validation with an empty PR body. This lets direct numeric capacity retunes bypass the disclosure gate, not just the documented indirect/formula changes. Allow an optional Python type annotation before the assignment operator.
Useful? React with 👍 / 👎.
| re.search(r"\bbefore\b.{0,120}\d", part, re.I | re.S) | ||
| and re.search(r"\bafter\b.{0,120}\d", part, re.I | re.S) |
There was a problem hiding this comment.
Require separate numeric evidence for before and after
When a PR body supplies only one numeric value, both searches can consume that same number because the wildcard crosses the other disclosure label. For example, MAX_DRAINS before: unknown; after: 8 passes validation, as does MAX_DRAINS after: unknown; before: 4, despite explicitly omitting one required value and providing no waiver. Bound each search to its own before/after clause so the check actually requires both numbers.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1788dd1031
ℹ️ 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".
| rf"(?:(?<!['\"])\b{STATE_NAME}\b\s*(?::|{STATE_OPERATOR})" | ||
| rf"|['\"]{STATE_NAME}['\"]\s*(?::|\]\s*{STATE_OPERATOR}))\s*\(*\s*$", re.I |
There was a problem hiding this comment.
Recognize state comparisons through mapping getters
When a new lifecycle value is introduced through a comparison such as if job.get("state") == "awaiting_new_repair":, detection returns no states and validation passes with an empty PR body. The pattern only accepts an operator immediately after the state identifier or a subscript, so the getter's closing syntax prevents recognition. Getter-based lifecycle comparisons are already used in the monitored code, including backend/utils/batch_pipeline/intake.py:175 and :183. Recognize this direct comparison form so introducing a state through the existing access convention still requires an exit declaration.
Useful? React with 👍 / 👎.
| "or Numbers-waived: <reason>." | ||
| ) | ||
| for state in sorted(states): | ||
| if not (token(state, cleaned) and EXIT.search(cleaned)): |
There was a problem hiding this comment.
Exclude empty waiver labels from exit-path evidence
When the PR body names a detected state and includes an empty State-exit-waived: field, validation succeeds without either an exit declaration or a reasoned waiver. For example, New state: awaiting_new_repair\nState-exit-waived: returns no errors or notices: the waiver parser correctly rejects the empty reason, but EXIT.search(cleaned) then treats the exit in the waiver label itself as recovery evidence. Remove waiver-field labels from the exit-evidence search so an unfilled waiver cannot silently bypass the state-exit requirement.
Useful? React with 👍 / 👎.
Indented Markdown code blocks (after a blank line) and an unclosed <!-- no longer supply disclosures or waivers; list continuations stay prose. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f349067e70
ℹ️ 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".
| if sign in ("+", "-") and code(line): | ||
| non_code = [match.span() for match in NON_CODE.finditer(line)] |
There was a problem hiding this comment.
Exclude multiline string contents from tuning detection
When a documentation-only edit changes an assignment example inside a multiline Python docstring, this loop treats the example as executable tuning. For example, changing MAX_DRAINS = 4 to MAX_DRAINS = 8 inside a triple-quoted docstring produces a detected knob and fails validation with an empty PR body. code() excludes delimiter lines, but neither it nor the per-line NON_CODE scan tracks whether subsequent lines remain inside the string. Track multiline string boundaries so edits to documentation do not require numeric disclosures or waivers for nonexistent runtime changes.
Useful? React with 👍 / 👎.
| "backend/charts/pusher/**", | ||
| "backend/utils/pusher_*.py", | ||
| ) | ||
| KNOB = r"(?:max|min|limit|cap|concurrenc\w*|workers?|pool\w*|page_size|batch_size|drains?\w*|per_second|qps|throttle\w*|maxReplicas|minReplicas|targetBacklogPerWorker)\w*" |
There was a problem hiding this comment.
Include the worker HPA demand target in knob detection
Changing targetQueuedUnitsPerWorker: 41 to targetQueuedUnitsPerWorker: 42 in the monitored worker values file detects no knobs and passes validation with an empty PR body because this field does not match KNOB. This is a direct numeric capacity retune, not an indirect/formula change: backend/charts/batch-pipeline-worker/templates/_instances.tpl:7 reads it into capacityTarget, which templates/hpa.yaml:47 uses as the HPA's average-value target. The existing values-file comments even identify 41 versus 42 as the passing/failing sustained-step boundary. Include this deployed scaling target so these retunes require the intended disclosure.
Useful? React with 👍 / 👎.
…osure evidence Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 52363df53b
ℹ️ 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".
| ) | ||
| KNOB = r"(?:max|min|limit|cap|concurrenc\w*|workers?|pool\w*|page_size|batch_size|drains?\w*|per_second|qps|throttle\w*|maxReplicas|minReplicas|targetBacklogPerWorker)\w*" | ||
| NUMBER = r"-?(?:\d[\d_]*(?:\.[\d_]*)?|\.\d[\d_]*)(?:[eE][+-]?\d+)?" | ||
| ASSIGNMENT = re.compile(rf"(?<![`'\"])\b(?P<knob>{KNOB})\s*[:=]\s*(?P<value>{NUMBER})", re.I) |
There was a problem hiding this comment.
Match concurrency knobs after identifier prefixes
Changing the existing DEFAULT_PUBLISH_CONCURRENCY = 4 to 8 in backend/config/batch_pipeline.py produces no detected knobs and passes validation with an empty PR body because the assignment matcher requires the identifier to start with a KNOB alternative. This directly changes runtime concurrency: publish_concurrency() uses that constant as its environment default, and BatchPump uses the result to bound publication with semaphores. Recognize concurrency terms within prefixed identifiers so this direct numeric retune requires disclosure rather than bypassing the gate.
Useful? React with 👍 / 👎.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ackets Co-Authored-By: Claude Opus 5.5 <[email protected]>
Requested by David
What changes
Retro P6 adds
batch-pipeline-tuning-disclosureto the shared manifest in both local and CI lanes. Numeric capacity assignments and concurrency environment defaults in the batch config, pipeline source, worker/pusher charts, andbackend/utils/pusher_*.pyrequire numeric disclosures in one PR-body section naming a matched knob: before/after, from/to, or a nearby numeric arrow (6 -> 4or6 → 4). A knob with no removed numeric assignment may instead usenew: <num>orinitial <num>. Newly added literals directly assigned or compared to state-like names, or passed as state/status/phase/disposition/outcome/reason kwargs, must name an exit, terminal, dead-letter, re-entry, clear, or recovery path; literals already anywhere in the merge-base tree are exempt.Numbers-waived: <reason>andState-exit-waived: <reason>waive their respective requirement and echo the reason.HTML comments, fenced code blocks and inline code are stripped before validating disclosures, state exits or waivers. Logging arguments and literals merely near state-related words do not count as new states.
The same single manifest entry runs hermetic regression tests before checking the body. Only changed lines trigger detection; flags, comment-only lines, and unchanged context do not count. The detector deliberately misses indirect/formula tuning: this is a disclosure ratchet.
David approved this exact manifest and script/test change on 2026-11-08 at 16:13Z. No workflow file changed. The change is limited to
.github/checks-manifest.yamland the two P6 files under.github/scripts/.Why this check
The retro's #24481 HPA retune is the design precedent; the sweep below exercises HPA bounds changes such as #24742. Its from/to wording is supported, but its knob names are only in inline code, which the requested prose-only rule excludes. Existing product-invariant and failure-class checks validate different author declarations; neither detects capacity knobs or new lifecycle literals. This check reuses the manifest's existing diff/metadata plumbing without changing workflow wiring or inventing another PR orchestration layer.
Product invariants affected
none
Failure-Class: none
Merged-PR false-positive sweep (2026-11-08T20:01:42.025036+00:00)
200 merged PRs screened; 69 trigger-touching diffs checked; 16 would fail and 53 would pass. 14 failing PRs require numeric disclosures; 2 require state declarations (3 state literals total). The prior sweep reported 18 failures; the refreshed capped corpus also advances its merge cutoff.
Method:
gh pr list --repo BasedHardware/omi --state merged --search 'merged:>=2026-10-09' --limit 200 --json number,title,body,mergeCommit,mergedAt,files, followed bygh pr diff <number> --repo BasedHardware/omifor matching paths. Full paginated file lists were checked whenever the initial listing reached 100 files. Each diff was checked against its PR body and reconstructed PR merge-base: merge-parent merge-base for normal merges; PR-head/merge-parent merge-base cross-checked with the recorded PR base for one-parent merges. State candidates use a whole-tree lookup at that merge-base.The capped corpus spans 2026-11-04T12:58:21Z through 2026-11-08T19:20:24Z: a sample within the requested 30-day window, not full-month coverage. No production reads or GCP tier were used.
The stricter state association passes #24743 (the prior proximity-only candidate). #24733 and #24729 now pass the expanded numeric wording. The required inline-code stripping means #24742 still fails: its from/to numbers are supported, but its matched knob names appear only in inline code. #24884 and #24725 also fail when their state names are excluded as inline code. These are explicit effects of the requested prose-only policy, not claims that those historical PRs omitted all semantic explanation.
Sample of would-fail PRs:
max_countrecord_barrier_agedMIN_STORAGE_PCM_BUDGET_MBmaxReplicas,minReplicasPAGE_SIZEmarker_retry_overflow,marker_write_failedlimitMAX_OWNER_DRAINSMAX_DELAYED_OWNERSMAX_HEAD_REQUEUESAll would-fail PRs: #24889, #24884, #24799, #24742, #24736, #24725, #24716, #24712, #24710, #24707, #24703, #24697, #24689, #24680, #24643, #24601.
Validation
1788dd10315e7a709dcaf6150838907638386ad0, covering fenced/inline examples, direct state association (including the logging regression), from/to and arrows, and first-time versus changed numeric values.make preflightpassed all 14 selected local checks, including 26 P6 tests and 78 manifest-contract tests, withOMI_PR_BODY_FILEandBACKEND_UNIT_FILE_BUDGET_SECONDS=900. The normal bounded pre-push gate also passed all 14 checks using the final body and the same budget, withGOOGLE_APPLICATION_CREDENTIALSand everyCLOUDSDK_*variable removed.scripts/pr-preflight --suggestrequired no invariant citations;Failure-Class: noneis declared above.🤖 Generated with Claude Code