refactor(shell): use [[ ]] for conditional tests in scripts/canary-rollout.sh and its tests (S7688, part of #1462)
User description
What
Split A of 5 of #1463, split by directory at the Maintainer's direction: scripts/canary-rollout.sh and its tests (2 files). It is part of #1462, SonarCloud shell:S7688: use [[ instead of [.
The files are taken unchanged from #1463 head 3c6d334, which was level with main. That PR's review rounds (CodeRabbit, Codex, pr-review) are already folded in. #1463 is closed in favour of these five smaller PRs, because a 68-file mechanical change kept drawing review rounds and never converged.
| Split | Scope |
|---|---|
| A | scripts/canary-rollout.sh + tests/canary_rollout.bats |
| B | scripts/compliance-audit.sh |
| C | other top-level scripts/*.sh + their tests |
| D | scripts/lib/*.sh + their tests |
| E | .github/scripts/** |
#1462 stays open until all five merge.
Review focus
Inside [[ ]], -eq/-ne/-lt/-le/-gt/-ge evaluate both operands as arithmetic, which [ ] does not:
- an empty or non-numeric operand now compares as
0instead of failing the test; - a leading-zero value is read as octal (
08is an error,010is 8). #1463 added$((10#…))normalisation and tests where it found config values; - a value from outside (API JSON, issue text, env input) that reaches such a comparison unvalidated is evaluated, and a string like
a[$(cmd)]would runcmd.
Please check each numeric comparison in this diff whose operand is not a local counter or exit status.
Checks
- Every changed file passes
bash -n(bash 5) and is not a#!/bin/shscript. shellcheck -x -S warningreports no new findings compared withmain.- Related bats suites, run locally on this branch (GNU
date, bash 5), with any failure re-run onmain:tests/canary_rollout.bats— 534 ok, 2 failed; the same 2 (orchestrator cross-repo promote #1054, failed promote tag-write #1023) fail identically onmainlocally, a macOS environment difference. CI on Linux is authoritative.
🤖 Generated with Claude Code
Problem
See the linked issue.
Risk
Low — changes automation shell logic under scripts/, covered by shellcheck (--severity=warning) and the bats suite.
Test plan
Tests added/updated: tests/canary_rollout.bats. Verification: bash scripts/dev-lead-lint.sh (shellcheck --severity=warning) ran pre-commit; the bats suite runs in CI.
Rollback
Revert this PR. No non-revertible side effects (no tags, migrations, or external state).
Monitoring
This PR's Lint (shellcheck) and bats checks show pass/fail; watch subsequent dev-lead / pr-review runs for behavioral regressions.
CodeAnt-AI Description
Handle zero-padded and oversized canary settings safely
What Changed
- Canary thresholds and retry settings with leading zeros are now treated as decimal values, not octal.
- Invalid or oversized ingress run limits fall back to 5000, preventing incorrect cap checks.
- When the candidate and prior release cannot be compared, the gate reports an indeterminate result instead of claiming the reusable is unchanged.
Impact
✅ Decimal-safe canary thresholds
✅ Reliable ingress run limits
✅ Accurate indeterminate gate results
💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
@codeant-ai ask: Your question here
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
@codeant-ai ask: Can you suggest a safer alternative to storing this secret?
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
@codeant-ai: Your feedback here
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
@codeant-ai: Do not flag unused imports.
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
@codeant-ai: review
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.