Reduce Windows CI latency without reducing native test coverage #1162
<!-- review-superseded: {"report_comment_id": 5970541508, "run_id": "37132942429", "run_attempt": "1"} -->
<details>
<summary>Superseded — see the <a href="https://github.com/ConductorOne/baton-sdk/pull/1162#issuecomment-5970541508">current review report</a> for commit <code>3eafa1ebc73f</code></summary>
General PR Review: Reduce Windows CI latency without reducing native test coverage
Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base df0612bd4fe9.
_Review mode: full_
View review run
Review Summary
The PR moves the Windows
-short test run from the go-test matrix into a new 4-shard windows-tests job in both ci.yaml and main.yaml. A new scripts/windows-test-shard.py lists every test with go test -list, assigns each top-level test name to a shard by SHA-256 hash, and runs that shard with an anchored -run pattern. Afterward it checks that every assigned package/test pair passed or skipped and that no unassigned top-level test ran. A new aggregator job is named go-test (windows-latest), so the required-check name is unchanged; it passes only when every shard passes. Windows coverage instrumentation is dropped, and TestC1ZConcurrentClose now writes grants in batches of 1,000 and entitlements in one call. The test still checks 150,000 grants and now also checks that the WAL file is non-empty before close. No production code, proto, exported API or dependency changed.I scanned the full diff for security and correctness. The listing flags match the run flags, and Go's -run handling keeps the anchored ^(A|B)$ pattern working, so subtests stay with their parent. The audit ignores subtest names (those containing /), so fuzz seed entries are not flagged. PutEntitlements splits large inserts into chunks internally (executeChunkedInsert), so the single 15,000-entitlement call is safe. windows-test-result uses if: always() and requires result == success, so cancelled or skipped shards fail the check.
How the repo criteria applied: Risk triage: Silence – no (missing or unexpected tests fail the shard). Durability – no (CI and test code only). Uncontrolled dimensions – partly: hash-based shard balance shifts as tests are added, and the selector length grows with the inventory, but the script fails loudly on both. Consumer distance – no. Consequence: rung 1 (fix CI). Verdict: LOW. The SDK API, proto, serialized-state, defaults and dependency checks don't apply because no such surfaces changed.
Not covered: I did not see a native Windows run of this script, and the PR body also defers that to this PR's CI artifacts. I did not measure how close each shard's -run selector is to the script's 30,000-character limit. The script fails with a clear error if a shard exceeds it.
Security Issues
None found.
Correctness Issues
None found.
Suggestions
.github/workflows/ci.yaml:68 (same line in .github/workflows/main.yaml): --count 4 is hard-coded separately from the shard: [0, 1, 2, 3] matrix. If --count is raised but the matrix is not, tests hashed to the new shard IDs never run and every shard still passes. Each shard only audits its own assignment, so nothing catches the gap. docs/TESTING.md documents the coupling, but --count ${{ strategy.job-total }} removes it. Confidence: high.<details>
<summary>Prompt for AI agents</summary>
Verify each finding against the current code and only fix it if needed.
## Suggestions
In `.github/workflows/ci.yaml`:
- Around line 68: Replace `--count 4` in the "Run and audit native Windows tests" step with `--count ${{ strategy.job-total }}` so the shard count always matches the matrix length. Otherwise a mismatch silently leaves tests unrun.
In `.github/workflows/main.yaml`:
- Around line 79: Make the same change (`--count ${{ strategy.job-total }}`) in the windows-tests job.
In `docs/TESTING.md`:
- In the "Native Windows CI" section: Once the count comes from the matrix, update or remove the sentence saying the matrix and `--count` must be kept in sync by hand.
</details>
</details>
🟡 Suggestion: --count 4 is hard-coded separately from the shard: [0, 1, 2, 3] matrix. If someone raises --count but leaves the matrix alone, the tests assigned to the new shard IDs never run and every shard still passes. The per-shard audit can't catch this because each shard only checks its own assignment. Taking the count from the matrix removes that drift (same change in main.yaml). Confidence: high.
run: python scripts/windows-test-shard.py --shard ${{ matrix.shard }} --count ${{ strategy.job-total }}
<!-- review-superseded: {"report_comment_id": 5970568605, "run_id": "37133194885", "run_attempt": "1"} -->
<details>
<summary>Superseded — see the <a href="https://github.com/ConductorOne/baton-sdk/pull/1162#issuecomment-5970568605">current review report</a> for commit <code>0e9500fc080d</code></summary>
General PR Review: Reduce Windows CI latency without reducing native test coverage
Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base df0612bd4fe9.
_Review mode: full_
View review run
Review Summary
The PR moves the Windows
-short test run from the go-test matrix into a new 4-shard windows-tests job in both ci.yaml and main.yaml. A new scripts/windows-test-shard.py lists every test with go test -list, assigns each top-level test name to a shard by SHA-256 hash, and runs that shard with an anchored -run pattern. Afterward it checks that every assigned package/test pair passed or skipped and that no unassigned top-level test ran. A new aggregator job is named go-test (windows-latest), so the required-check name is unchanged; it passes only when every shard passes. Windows coverage instrumentation is dropped, and TestC1ZConcurrentClose now writes grants in batches of 1,000 and entitlements in one call. The test still checks 150,000 grants and now also checks that the WAL file is non-empty before close. No production code, proto, exported API or dependency changed.I scanned the full diff for security and correctness. The listing flags match the run flags, and Go's -run handling keeps the anchored ^(A|B)$ pattern working, so subtests stay with their parent. The audit ignores subtest names (those containing /), so fuzz seed entries are not flagged. PutEntitlements splits large inserts into chunks internally (executeChunkedInsert), so the single 15,000-entitlement call is safe. windows-test-result uses if: always() and requires result == success, so cancelled or skipped shards fail the check.
How the repo criteria applied: Risk triage: Silence – no (missing or unexpected tests fail the shard). Durability – no (CI and test code only). Uncontrolled dimensions – partly: hash-based shard balance shifts as tests are added, and the selector length grows with the inventory, but the script fails loudly on both. Consumer distance – no. Consequence: rung 1 (fix CI). Verdict: LOW. The SDK API, proto, serialized-state, defaults and dependency checks don't apply because no such surfaces changed.
Not covered: I did not see a native Windows run of this script, and the PR body also defers that to this PR's CI artifacts. I did not measure how close each shard's -run selector is to the script's 30,000-character limit. The script fails with a clear error if a shard exceeds it.
Security Issues
None found.
Correctness Issues
None found.
Suggestions
.github/workflows/ci.yaml:68 (same line in .github/workflows/main.yaml): --count 4 is hard-coded separately from the shard: [0, 1, 2, 3] matrix. If --count is raised but the matrix is not, tests hashed to the new shard IDs never run and every shard still passes. Each shard only audits its own assignment, so nothing catches the gap. docs/TESTING.md documents the coupling, but --count ${{ strategy.job-total }} removes it. Confidence: high.<details>
<summary>Prompt for AI agents</summary>
Verify each finding against the current code and only fix it if needed.
## Suggestions
In `.github/workflows/ci.yaml`:
- Around line 68: Replace `--count 4` in the "Run and audit native Windows tests" step with `--count ${{ strategy.job-total }}` so the shard count always matches the matrix length. Otherwise a mismatch silently leaves tests unrun.
In `.github/workflows/main.yaml`:
- Around line 79: Make the same change (`--count ${{ strategy.job-total }}`) in the windows-tests job.
In `docs/TESTING.md`:
- In the "Native Windows CI" section: Once the count comes from the matrix, update or remove the sentence saying the matrix and `--count` must be kept in sync by hand.
</details>
---
Reviewed commit: 3eafa1ebc73f
<!-- review-state: {"last_reviewed_sha": "3eafa1ebc73fe6640bf5b38ae7febb1a977b2369", "base_sha": "df0612bd4fe92a762d7e88ce4a3b67deb6ae91a9", "workflow_ref": "ConductorOne/github-workflows/.github/workflows/general-pr-review.yaml@refs/heads/main", "run_id": "37132942429", "run_attempt": "1", "summary_marker": "### General PR Review:", "verdict_mode": "baseline", "publication": "completed", "started_at": "2026-10-03T15:21:28Z", "working_comment_id": 5970525238, "working_comment_updated_at": "2026-10-03T15:23:26Z"} -->
</details>
No blocking issues found — see the full review report
<!-- review-publication: {"run_id": "37132942429", "run_attempt": "1", "workflow_ref": "ConductorOne/github-workflows/.github/workflows/general-pr-review.yaml@refs/heads/main", "summary_marker": "### General PR Review:", "verdict_mode": "baseline", "report_comment_id": 5970541508} -->
<!-- review-superseded: {"report_comment_id": 5970568605, "run_id": "37133194885", "run_attempt": "1"} -->
<details>
<summary>Superseded — see the <a href="https://github.com/ConductorOne/baton-sdk/pull/1162#issuecomment-5970568605">current review report</a> for commit <code>0e9500fc080d</code></summary>
General PR Review: Reduce Windows CI latency without reducing native test coverage
Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base df0612bd4fe9.
_Review mode: incremental since 3eafa1eb_
View review run
Review Summary
The new commit adds
scripts/windows_test_shard_test.py, a Python unittest that builds a throwaway Go module and runs windows-test-shard.py against it. It checks two things: Example, Fuzz-seed and skipped tests count as completed, and a test binary that exits 0 without running its selected tests fails the shard. Both ci.yaml and main.yaml now run this test on shard 0 before the real shard run. I scanned the full PR diff (workflows, docs/TESTING.md, pkg/dotc1z/c1file_concurrent_test.go, and the shard script) for security and correctness issues. No new issues found.On the repo-local criteria: the change touches only CI and test code. It changes no exported API, proto, serialized state, default, or dependency, so the compatibility sections do not apply. Triage per the risk rubric:
The fixture's go 1.27.1 matches the repo's go.mod, so setup-go needs no toolchain download.
Security Issues
None found.
Correctness Issues
None found.
Suggestions
.github/workflows/ci.yaml:71 (also .github/workflows/main.yaml:82): --count 4 is still hard-coded separately from the shard: [0, 1, 2, 3] matrix. If only --count is raised, the tests hashed to the new shard IDs never run, and every shard still passes because each one audits only its own assignment. The open thread already covers this. Confidence: high.<details>
<summary>Prompt for AI agents</summary>
Verify each finding against the current code and only fix it if needed.
## Suggestions
In `.github/workflows/ci.yaml`:
- Around line 71: In the "Run and audit native Windows tests" step, replace `--count 4` with `--count ${{ strategy.job-total }}` so the shard count always matches the matrix length.
In `.github/workflows/main.yaml`:
- Around line 82: Make the same change (`--count ${{ strategy.job-total }}`) in the windows-tests job.
In `docs/TESTING.md`:
- In the "Native Windows CI" section: Once the count comes from the matrix, update or remove the sentence saying the matrix and `--count` must be kept in sync by hand.
</details>
</details>
General PR Review: Reduce Windows CI latency without reducing native test coverage
Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base df0612bd4fe9.
_Review mode: incremental since 3eafa1eb_
View review run
Review Summary
The new commit adds
scripts/windows_test_shard_test.py, a Python unittest that builds a throwaway Go module and runs windows-test-shard.py against it. It checks two things: Example, Fuzz-seed and skipped tests count as completed, and a test binary that exits 0 without running its selected tests fails the shard. Both ci.yaml and main.yaml now run this test on shard 0 before the real shard run. I scanned the full PR diff (workflows, docs/TESTING.md, pkg/dotc1z/c1file_concurrent_test.go, and the shard script) for security and correctness issues. No new issues found.On the repo-local criteria: the change touches only CI and test code. It changes no exported API, proto, serialized state, default, or dependency, so the compatibility sections do not apply. Triage per the risk rubric:
The fixture's go 1.27.1 matches the repo's go.mod, so setup-go needs no toolchain download.
Security Issues
None found.
Correctness Issues
None found.
Suggestions
.github/workflows/ci.yaml:71 (also .github/workflows/main.yaml:82): --count 4 is still hard-coded separately from the shard: [0, 1, 2, 3] matrix. If only --count is raised, the tests hashed to the new shard IDs never run, and every shard still passes because each one audits only its own assignment. The open thread already covers this. Confidence: high.<details>
<summary>Prompt for AI agents</summary>
Verify each finding against the current code and only fix it if needed.
## Suggestions
In `.github/workflows/ci.yaml`:
- Around line 71: In the "Run and audit native Windows tests" step, replace `--count 4` with `--count ${{ strategy.job-total }}` so the shard count always matches the matrix length.
In `.github/workflows/main.yaml`:
- Around line 82: Make the same change (`--count ${{ strategy.job-total }}`) in the windows-tests job.
In `docs/TESTING.md`:
- In the "Native Windows CI" section: Once the count comes from the matrix, update or remove the sentence saying the matrix and `--count` must be kept in sync by hand.
</details>
---
Reviewed commit: 0e9500fc080d
<!-- review-state: {"last_reviewed_sha": "0e9500fc080dc2836dbaa358ca422497af009f20", "base_sha": "df0612bd4fe92a762d7e88ce4a3b67deb6ae91a9", "workflow_ref": "ConductorOne/github-workflows/.github/workflows/general-pr-review.yaml@refs/heads/main", "run_id": "37133194885", "run_attempt": "1", "summary_marker": "### General PR Review:", "verdict_mode": "baseline", "publication": "completed", "started_at": "2026-10-03T15:25:48Z", "working_comment_id": 5970559100, "working_comment_updated_at": "2026-10-03T15:27:01Z"} -->
No blocking issues found — see the full review report
<!-- review-publication: {"run_id": "37133194885", "run_attempt": "1", "workflow_ref": "ConductorOne/github-workflows/.github/workflows/general-pr-review.yaml@refs/heads/main", "summary_marker": "### General PR Review:", "verdict_mode": "baseline", "report_comment_id": 5970568605} -->
Approved these changes.
pquerna
c1-squire-dev[bot]
Summary
go-test (windows-latest)required-check name; it passes only when all four shards pass.Motivation
In run https://github.com/ConductorOne/baton-sdk/actions/runs/37128377008 the Windows test step took 23.93 minutes versus 2.95 minutes on Linux. The concurrent-close fixture took 736 seconds, of which close itself took only 1.23 seconds. Its setup committed 15,000 grant batches plus 1,500 entitlement batches. Batching reduces those setup transactions to 150 grant batches and one entitlement batch without shrinking the fixture.
Package-only sharding would retain the long per-package tail. Test-name sharding divides the storage-heavy packages too. New tests enter the native platform's discovered inventory automatically; missing execution is an error rather than a green empty shard.
Verification
go test -tags=baton_lambda_support -v ./...: passed (66 packages with tests, 24 without).make lintwith the CI-pinned golangci-lint v2.13.2: zero issues.0e9500f).Measured Windows results
| Metric | Previous run | This PR |
| --- | --- | --- |
| Workflow elapsed | 25m34s | 8m14s |
| Slowest Windows job | 25m30s | 8m03s |
| Concurrent-close test (150,000 grants) | 736.03s | 49.88s |
| Native top-level inventory completed | 2,089 | 2,090 |
| Skipped tests/subtests | 101 | 101 |
Windows shard jobs completed in 6m19s, 6m53s, 7m49s, and 8m03s. Artifact audit verified identical discovery inventories across all four runners, with every native top-level package/test pair completed exactly once. No baseline test was removed; the current main revision adds one capability test. The skip inventory is identical to the baseline.
The slowest Windows job is 68% faster and concurrent-close is 93% faster. Aggregate Windows runner time is 29m04s across four runners versus 25m30s before: roughly 14% more runner work for 68% less latency. These are observed runs, not a controlled repeated benchmark.
Coverage and risk
No new test skips, reduced fixture dimensions, disabled disk sync, in-memory replacement of native storage, or production code changes. Existing
-shortbehavior andbaton_lambda_supportbuild tag remain in place. Four runners trade additional aggregate runner work and cache restores for shorter elapsed time. The unchanged Linux suite continues exercising cross-test execution in one process.