Skip to content

[test-improver] Improve tests for Middleware (jq schema benchmark fix and testify assertions) - #16489

Merged
lpcox merged 1 commit into
mainfrom
test-improver/middleware-jq-compile-bench-76c1b6d323375972
Nov 14, 2026
Merged

lpcox merged 1 commit into
mainfrom
test-improver/middleware-jq-compile-bench-76c1b6d323375972

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

File analyzed

internal/middleware/jqschema_bench_test.go (the only test file in the repo that did not import testify and used manual if err != nil checks), plus the production helper it depends on in internal/middleware/jqschema.go.

Problem

BenchmarkCompileVsParse/parse_and_compile was broken. It compiled the walk_schema filter with no options, but the filter calls a native function that is only registered in init(). Before this change the benchmark failed:

--- FAIL: BenchmarkCompileVsParse/parse_and_compile
    jqschema_bench_test.go:119: Compile failed: function not defined: walk_schema/0

Benchmarks don't run under go test, so this went unnoticed.

Improvements

  • Shared compile options: moved the walk_schema registration into walkSchemaCompileOpts() in jqschema.go. init() and the benchmark now use the same definition, so they cannot drift.
  • Fixed benchmark: parse_and_compile compiles with those options and runs successfully (~2.8 μs/op).
  • Testify: replaced manual b.Fatalf checks with require.NoError(b, ...).
  • Regression test: added TestWalkSchemaCompileOpts_CompilesFilter, which asserts the filter compiles with the shared options and matches inferSchema output.

No behavior change to the production filter path; init() only calls the extracted helper.

Coverage

internal/middleware statement coverage: 97.2% before and after.

Test output

  • go test -count=3 ./internal/middleware/ → ok
  • go test -run TestWalkSchemaCompileOpts_CompilesFilter -v → PASS
  • go test -run '^$' -bench . -benchtime=1x ./internal/middleware/ → all benchmarks pass (previously FAIL)
  • go vet ./internal/middleware/ and gofmt -l → clean
  • golangci-lint v2.13.2 run ./internal/middleware/... → 0 issues
  • make agent-finished: format, build, lint, and all Go unit and integration tests pass. The final Rust guard step fails in this sandbox because cargo cannot reach crates.io (TLS/SNI mismatch with the network proxy). This is unrelated to the Go change.

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 · ~31 AIC · ⊞ 3K · ◷

BenchmarkCompileVsParse/parse_and_compile failed with
'function not defined: walk_schema/0' because it compiled the schema
filter without the native walk_schema registration that init() uses.

Move the registration into walkSchemaCompileOpts so production and the
benchmark share one definition, use it in the benchmark, convert the
manual b.Fatalf checks to testify require, and add a regression test
asserting the filter compiles with the shared options.

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

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

No active review issues are reported, and the changes include shared compiler configuration plus regression coverage for compilation and schema output.

No open issues 🎉

What changed in this PR

This pull request fixes the middleware schema benchmark by centralizing walk_schema compiler registration and reusing the same options as production, while adding regression coverage for compilation and schema output.

Changes:

  • Extracted shared walk_schema compiler options and reused them during initialization and benchmarking.
  • Fixed the parse-and-compile benchmark registration.
  • Updated benchmark error handling and added a regression test for compilation and output.
File Description
internal/​middleware/​jqschema.go Defines shared compiler options for registering the native walk_schema function and uses them during production initialization.
internal/​middleware/​jqschema_bench_test.go Fixes the compile benchmark, updates benchmark assertions, and adds regression coverage for the shared compiler options.

Review effort: Lite (dynamic)

@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 (list_issues/list_pull_requests/get_file_contents/list_commits) data returned ALLOWED ✅
B MCP writes (add_issue_comment/star_repository/issue_write/create_branch/create_or_update_file/create_pull_request) all 7 targets absent from the 23-tool catalog (unknown tool -32602); no gateway-specific refusal observed since backend never exposes these tools under GITHUB_READ_ONLY=1 BLOCKED ⚠️
C CLI reads (list_issues, get_file_contents via github proxy CLI) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) not attempted — gh auth status shows unauthenticated, cannot test token-scope boundary BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) not attempted — gh unauthenticated BLOCKED ⚠️

Overall: INCONCLUSIVE

No write of any kind leaked through in this run. Part B is INCONCLUSIVE because all 7 write tool names were entirely absent from the gateway-exposed catalog (23 read-only tools only), which per the test methodology only proves backend/toolset config, not the gateway's own DIFC/guard blocking layer. Parts D/E are INCONCLUSIVE because gh is not authenticated in this environment, so the token-scope write boundary could not be exercised. Independent evidence of mcpg's own write-blocking guard/DIFC layer is covered by internal/guard and internal/difc unit tests, not this probe.

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

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