Skip to content

[test-improver] Improve tests for syncutil MapGetOrCreate - #16817

Merged
lpcox merged 1 commit into
mainfrom
test-improver/syncutil-cache-assertions-db123f306ab5c1f0
Nov 19, 2026
Merged

lpcox merged 1 commit into
mainfrom
test-improver/syncutil-cache-assertions-db123f306ab5c1f0

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

File analyzed

internal/syncutil/cache_test.go (implementation: internal/syncutil/cache.go)

Improvements

  • Failure retry: DoesNotStoreOnError now verifies that a later call retries create and stores the successful value, not only that the failed value is absent.
  • Stronger assertions: MultipleKeys compares the full cache contents instead of only len.
  • RaceDetector made meaningful: it previously discarded every return value and asserted nothing. It now checks each goroutine's error and the final cache state, while still serving its -race purpose.
  • Modern Go idioms: removed the manual loop-variable copy and for i := 0; i < n; i++ loops in favor of range.

Coverage

  • Before: 100.0% of statements
  • After: 100.0% of statements

Coverage is unchanged because the package was already fully covered. This PR strengthens assertions rather than adding branches.

Verification

  • go test -v ./internal/syncutil/ passes, including all MapGetOrCreate tests.
  • go test -count=3 ./internal/syncutil/ passes.
  • go test -race -count=3 ./internal/syncutil/ -run MapGetOrCreate passes.
  • go vet ./internal/syncutil/ and gofmt -l report no issues.
  • make agent-finished: format, build, lint-vet, and all Go unit and integration tests pass. The final Rust guard step fails in this sandbox because crates.io is unreachable (TLS certificate mismatch on index.crates.io). It is unrelated to this change. golangci-lint was not installed, so it was not run.

Warning

Firewall blocked 4 domains

The following domains were blocked by the firewall during workflow execution:

  • example.com
  • nonexistent.local
  • slow.example.com
  • thishostdoesnotexist12345.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"
    - "nonexistent.local"
    - "slow.example.com"
    - "thishostdoesnotexist12345.com"

See Network Configuration for more information.

Generated by Test Improver · copilot · routed: haiku55 xhigh · ~13 AIC · ⊞ 3K · ◷

- Verify a failed create is retried on a later call instead of
  returning a stale failure.
- Assert full cache contents in MultipleKeys rather than only the length.
- Make RaceDetector check its returned errors and final cache state, so
  it asserts behavior instead of discarding results.
- Replace the manual loop-variable copy and index loop with Go 1.22+
  range forms.

Coverage stays at 100% of statements; the change strengthens assertions.

Co-authored-by: Copilot <[email protected]>
@lpcox
lpcox marked this pull request as ready for review November 19, 2026 01:43
Copilot AI adaptive review requested due to automatic review settings November 19, 2026 01:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are limited to strengthening retry, cache-content, and concurrency assertions in the test suite, with no active review issues identified.

No open issues 🎉

What changed in this PR

This PR strengthens the MapGetOrCreate test suite without changing production behavior by validating retry handling, complete cache contents, and concurrent results.

Changes:

  • Verifies failed creations are retried and successful values are cached.
  • Replaces length-only checks with full cache comparisons.
  • Adds meaningful error and final-state assertions to the concurrent race test.
  • Modernizes loop syntax and removes an unnecessary loop-variable copy.
File Description
internal/​syncutil/​cache_test.go Strengthens MapGetOrCreate retry, cache-content, and concurrency test assertions.

Review effort: Lite (adaptive)

@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default AWF (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads data returned (issues/PRs/README/commits) ALLOWED ✅
B MCP writes no write tools in catalog (23 read-only tools only) — not call-time refusal BLOCKED ⚠️
C CLI reads data returned via proxied github CLI ALLOWED ✅
D CLI REST writes gh not authenticated — not attempted BLOCKED ⚠️
E CLI GraphQL mutations gh not authenticated — not attempted BLOCKED ⚠️

Overall: INCONCLUSIVE

No write leaked on any tested surface. Gaps: (1) the gateway-backed github CLI catalog exposes only 23 read-only tools — none of the Part B write targets (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) exist in the catalog at all, so refusal could not be exercised at call-time (absent-from-catalog, not gateway-level denial evidence). (2) gh CLI is unauthenticated in this environment ("You are not logged into any GitHub hosts"), so Parts D/E REST and GraphQL writes were not attempted per the no-retry/no-workaround rule. These gaps mean gateway-level write enforcement could not be independently confirmed this run, though no leak occurred.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@lpcox
lpcox merged commit 9b14692 into main Nov 19, 2026
28 checks passed
@lpcox
lpcox deleted the test-improver/syncutil-cache-assertions-db123f306ab5c1f0 branch November 19, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants