Skip to content

test(gateway): cover normalized OAuth tool contracts - #508

Open
elibosley wants to merge 3 commits into
mainfrom
fix/oauth-tool-contract-normalization
Open

test(gateway): cover normalized OAuth tool contracts#508
elibosley wants to merge 3 commits into
mainfrom
fix/oauth-tool-contract-normalization

Conversation

@elibosley

@elibosley elibosley commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Protect OAuth tool dispatch from false contract mismatches caused by documentation normalization.

Why This Exists

An unchanged OAuth tool could be rejected as changed before dispatch when discovery normalized its descriptor but the final peer check used raw metadata.

Resolution

Extend the existing subject-scoped execution test to include documentation that requires normalization, plus an exact schema value that must remain unchanged. The production correction is already upstream; this PR adds regression coverage.

Reviewer Considerations

  • This is test-only and does not change authorization, exposure checks, or OAuth subject isolation.
  • Current main (925bd00c) has unrelated missing runtime and gateway exports. Local validation uses the repair revision from fix: repair merged runtime and gateway regressions #507 (63f627b6) with this test patch applied. Those repairs are not duplicated here.

Behavior Changes

No production behavior changes. The test now detects inconsistent normalization between discovery and dispatch.

Implementation Summary

  • Add Markdown and bidirectional controls to tool and schema documentation.
  • Assert that documentation is normalized while an enum literal remains exact.
  • Execute the advertised tool through its authenticated subject peer.

Verification

  • Focused OAuth regression: passed on fix: repair merged runtime and gateway regressions #507 (63f627b6) with this patch applied.
  • Negative control: replacing the final normalized input schema with the raw peer schema makes the test fail with contract_changed; restoring the upstream implementation passes.
  • rustfmt --edition 2024 --check crates/labby-gateway/src/gateway/manager/tests/code_mode.rs: passed.
  • git diff --check: passed.
  • On main (925bd00c), Cargo tests are blocked by existing missing runtime exports; workspace formatting is blocked by existing syntax errors in api/router.rs. fix: repair merged runtime and gateway regressions #507 repairs this baseline.
  • On fix: repair merged runtime and gateway regressions #507 with this patch, cargo test -p labby-gateway --all-features: 1,101 passed, 5 ignored.
  • On that same revision, cargo clippy -p labby-gateway --all-features --all-targets -- -D warnings and cargo fmt --all -- --check: passed.
  • Default-feature gateway suite: 1,085 passed, 5 ignored, 1 existing failure. gateway_skills_list_is_restricted_to_route_visible_upstreams expects unknown_upstream while the feature-disabled build correctly returns feature_not_compiled. The all-feature run passes that test.

Risk

Low; one existing test is extended. Main must receive its separate build repairs before its test suite can run.

@jmagar
jmagar force-pushed the fix/oauth-tool-contract-normalization branch from b6c1746 to a476849 Compare September 1, 2026 19:08
@jmagar
jmagar marked this pull request as ready for review September 1, 2026 21:21
@jmagar jmagar closed this Sep 2, 2026
@jmagar jmagar reopened this Sep 2, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file labels Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants