Skip to content

Week 4: rigorous testing - fuzz, integration, gap coverage, python coverage gate - #4

Merged
shreyanshjain7174 merged 1 commit into
mainfrom
feat/week4-test-rigor
May 2, 2026
Merged

shreyanshjain7174 merged 1 commit into
mainfrom
feat/week4-test-rigor

Conversation

@shreyanshjain7174

Copy link
Copy Markdown
Contributor

Summary

Pure test-rigor work, no product surface changes. Lifts:

  • Go coverage 88.6% -> 95.0% on internal+pkg.
  • Python coverage 0% -> 96.8% with a hard `--cov-fail-under=85` CI gate.
  • Test count: Go +10 tests, Python 35 -> 61 tests.
  • Fuzzers: 3 new (CompactSchema, InferCapabilities, DependsOnFor) — all clean across ~1.4M executions.
  • Live integration test that proves "ACP on top of MCP" with measurable byte reduction.

What landed

Go fuzzers

Fuzzer Package Asserts
FuzzCompactSchema sources/mcp every emitted compact form uses only legal mini-language tokens
FuzzInferCapabilities sources/mcp sorted, deduped, lowercase, no single-char tokens
FuzzDependsOnFor builder no self-cycles, sorted unique IDs, every returned id present in available map

Live integration

`tests/integration/mcp_source_to_acp_test.go` boots a fake MCP server with verbose JSON-Schema descriptors, imports it via `internal/sources/mcp.Importer`, builds a manifest through the real ACP server, and asserts the manifest is strictly smaller than the upstream MCP `tools/list` body. Local run: 622-byte manifest vs 1017-byte tools/list (39% reduction on a 2-tool fixture; production S4 hits 97.4%).

Gap-coverage

  • `internal/server/server_extra_test.go`: handleFeedback (bad JSON, GET, sink-error 500), CryptoIDSource (1000 unique IDs no collisions), ListenAndServe (graceful context cancel + bad-addr error), unauth response shape.
  • `internal/proxy/gates_test.go`: AlwaysApprove + AlwaysDeny (was 0% before).
  • `pkg/acp/api_error_test.go`: APIError.Error() format + IsAPIError (was 0% before).

Python tests

  • `adapters/python/tests/test_acp_common_properties.py`: random schema atoms, random graph permutations, k-fold diamonds, cycle injection.
  • `adapters/python/tests/test_acp_langgraph_build.py`: stubs `langgraph.graph` so build_graph runs the full StateGraph path without the framework dep.
  • `benchmark/tests/test_harness_determinism.py`: count_tokens purity, zero-MCP-tokens edge case, p95 monotonicity.
  • `benchmark/tests/test_harness_main.py`: request_acp_manifest, measure_run, main() with stubbed urlopen.
  • `benchmark/tests/test_report.py`: render() over real S1+S4 sample numbers; main() with tmp_path.

CI

  • pytest now runs with `--cov` on adapters + benchmark trees.
  • `--cov-fail-under=85` hard gate.
  • pytest-cov added to the python install step.

Validation

```
go vet ./... # clean
go test -race -count=1 -timeout 60s ./... # 9 packages green
go coverage on internal+pkg # 95.0% (was 88.6%)
staticcheck ./... # clean
govulncheck ./... # zero vulnerabilities
pytest --cov-fail-under=85 # 61 passed, 96.84% coverage
```

Verifier

Independent verifier subagent ran before commit: PASS. Cosmetic suggestion to use stdlib helpers in the integration test was applied in the same branch.

…erage gate

Pure test-rigor work. No product surface changes. Lifts Go coverage
88.6% -> 95.0%, Python coverage 0% -> 96.8%, adds three new fuzzers
and a live MCP-source-to-ACP integration test.

Go fuzzers (1.4M+ executions across 4 fuzzers, zero crashes locally):

- internal/sources/mcp/FuzzCompactSchema: random JSON-Schema shapes,
  asserts every emitted compact form uses only legal mini-language
  tokens (string/int/float/bool/json/bytes plus '?' and '[]' suffixes,
  enum:..., ref:...).
- internal/sources/mcp/FuzzInferCapabilities: arbitrary tool names +
  extras, asserts capabilities are sorted, deduped, lowercase, no
  single-char tokens.
- internal/builder/FuzzDependsOnFor: random dependency graphs,
  asserts no self-cycles in the output, sorted unique IDs, every
  returned id present in the available map.

Live integration test:

- tests/integration/mcp_source_to_acp_test.go boots a fake MCP server
  with verbose JSON-Schema descriptors, imports it via
  internal/sources/mcp.Importer, builds a manifest through the real
  ACP server stack, and asserts the manifest payload is strictly
  smaller than the upstream MCP tools/list body. This is the
  'ACP on top of MCP' positioning made executable.
- Local run: 622-byte manifest vs 1017-byte tools/list (39% reduction
  on a 2-tool fixture; production S4 hits 97.4%).

Gap coverage:

- internal/server/server_extra_test.go covers
  handleFeedback (bad JSON, GET method, sink error -> 500),
  CryptoIDSource (1000 unique IDs, no collisions),
  ListenAndServe (graceful context-cancel + bad-addr error path),
  unauth response shape (JSON envelope, never plain text).
- internal/proxy/gates_test.go covers AlwaysApprove + AlwaysDeny
  (was 0% before).
- pkg/acp/api_error_test.go covers APIError.Error() formatting and
  IsAPIError() (was 0% before).

Python tests (35 -> 61):

- adapters/python/tests/test_acp_common_properties.py: random schema
  atoms, random graph permutations, k-fold diamonds, cycle-injection
  must always raise CycleError.
- adapters/python/tests/test_acp_langgraph_build.py: stubs the
  langgraph.graph module via sys.modules so build_graph runs the full
  StateGraph construction path without the framework dep.
- benchmark/tests/test_harness_determinism.py: count_tokens purity,
  zero-MCP-tokens edge case, p95 monotonicity, RunResult JSON wire
  shape stability.
- benchmark/tests/test_harness_main.py: request_acp_manifest +
  measure_run + main() against a stubbed urlopen, including the
  HTTPError -> exit 2 path.
- benchmark/tests/test_report.py: render() against the real S1+S4
  sample numbers, including main() with tmp_path.

CI:

- pytest now runs with --cov on adapters and benchmark trees.
- --cov-fail-under=85 hard gate.
- pytest-cov added to the python install step.

Validation:

- go vet ./...: clean
- go test -race -count=1 -timeout 60s ./...: 9 packages green
- go coverage on internal+pkg: 95.0% (was 88.6%)
- staticcheck ./...: clean (after S1017 cleanup in fuzz test)
- govulncheck ./...: zero vulnerabilities
- pytest -q --cov-fail-under=85: 61 passed, 96.84% coverage

Signed-off-by: Shreyansh Sancheti <43677304+shreyanshjain7174@users.noreply.github.com>
@shreyanshjain7174
shreyanshjain7174 merged commit c432afc into main May 2, 2026
6 checks passed
@shreyanshjain7174
shreyanshjain7174 deleted the feat/week4-test-rigor branch May 2, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant