feat(sdk-ts): forward target_type and target_id on evaluation requests (6/6)#184
Closed
abhinav-galileo wants to merge 4 commits intoabhi/rfc-1-1-pr5-python-sdk-targetfrom
Closed
feat(sdk-ts): forward target_type and target_id on evaluation requests (6/6)#184abhinav-galileo wants to merge 4 commits intoabhi/rfc-1-1-pr5-python-sdk-targetfrom
abhinav-galileo wants to merge 4 commits intoabhi/rfc-1-1-pr5-python-sdk-targetfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
d6c4da5 to
8652936
Compare
8c29414 to
96b15bd
Compare
EvaluationRequest now accepts optional target_type + target_id. When both are set, the server resolves the target row via (tenant_id, target_type, external_id) and merges target_controls into the effective set. Direct agent controls and policy-derived controls mask any target-level setting; target_controls with enabled=true contribute otherwise. Missing target returns 404. No-target requests remain unchanged.
Agent, control, and policy creation now read the effective tenant via a get_tenant_id dependency backed by a pluggable TenantResolver. Default resolver reads X-Tenant-Id header and falls back to DEFAULT_TENANT_ID so callers that omit the header continue to work. Association inserts into agent_policies and agent_controls record the owning agent's tenant_id. Deployments with their own tenant identity source can swap the resolver at startup via set_tenant_resolver. Read paths remain unscoped.
Threads optional target_type / target_id through check_evaluation, check_evaluation_with_local, and evaluate_controls so callers can opt into target-bearing evaluation when the server supports it. Fields default to None so existing call sites are unchanged.
- Regenerated method-name overlay picks up the new /api/v1/targets endpoints so Speakeasy produces ergonomic method names for them. - Manually updates the generated EvaluationRequest model to expose the new optional targetType / targetId fields and to remap them to the target_type / target_id wire format. This matches what Speakeasy would produce from the updated openapi.json; full regeneration requires an authenticated Speakeasy session locally. - Adds Vitest coverage asserting the serialized payload omits target fields when unset, serializes them as snake_case when set, and handles explicit nulls.
8652936 to
42fa1fb
Compare
96b15bd to
5bb953b
Compare
42fa1fb to
aa5acb0
Compare
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on top of #183. Kept in draft until the full stack is validated end-to-end.
Summary
Regeneration note for reviewers
The `src/generated/evaluation-request.ts` change was made by hand because running `make generate` locally requires an authenticated Speakeasy session (the CLI opens a browser for OAuth). The edit mirrors the pattern Speakeasy uses for other optional + nullable string fields in the same directory (see `step.ts` for reference) and matches the `EvaluationRequest` shape in `server/.generated/openapi.json` after PR1-PR3.
Once `make sdk-ts-generate-check` is run with a live Speakeasy session, any residual cosmetic diff can be dropped in cleanly. The overlay change, on the other hand, is produced by the local Python overlay-generator script and does not require Speakeasy.
Test plan