Repository navigation
feat: targeting rule authoring, for agents that write flags - #8
Merged
Merged
Conversation
Wraps the three operations coverage.yaml excluded as console-only tooling: get-targeting-context, lint-targeting-rule and test-targeting-rule, as feature_flags.targeting_context, lint_rule and test_rule. They have an SDK audience now. An agent writing a flag through the SDK (the Kaiten MCP server is one) has no editor to tell it that a rule names a fact or an entitlement that does not exist, and such a rule never fails: it never matches. These are how it finds out before it saves. TargetingContextNode is the first recursive model, so the test payload generator learned to stop a recursion with an empty array or an absent property, rather than a null the schema does not allow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: tomflenner <flennertom@gmail.com>
Alex (Alexkuva)
approved these changes
Oct 16, 2026
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.
What does this PR change?
Adds
feature_flags.targeting_context(),feature_flags.lint_rule(rule)andfeature_flags.test_rule(rule, *, targeting_key=None, context=None), sync and async. They wrapget-targeting-context,lint-targeting-ruleandtest-targeting-rule, with the models generated from the vendored contract (TargetingContext,TargetingContextNode,TargetingRuleVerdict,TargetingRuleIssue,TargetingRuleRehearsal, and theTargetingFactTypeenum).This reverses a documented decision.
coverage.yamlexcluded these three operations as "rule-editor tooling for the Kaiten console, with no SDK audience". This PR maps them instead.Why?
They have an SDK audience now: anything that writes flags without the console's editor. The Kaiten MCP server is one (kaitencloud/mcp#1). An agent writing a flag has nothing to tell it that a rule names a fact or an entitlement that doesn't exist, and such a rule never errors: it silently never matches. The MCP lints every rule before saving it, and lets an agent dry-run one against a real customer or instance.
Today it reaches these endpoints around the SDK, through its private transport, because there are no methods for them. With this PR it can drop that.
OFREP evaluation stays excluded, as before: it belongs to OpenFeature and the OFREP provider.
Testing
task check: generate:check, ruff, mypy --strict, 761 passed. The three operations are intest_contract.py, so each request is validated against the contract and each response is parsed into its model.TargetingContextNodeis the first recursive model. The contract test's payload generator now ends a recursion with an empty array or an absent property, notnull, so the model round-trip tests cover it.targeting_context()returns__kaitenwithlicense,entitlements,instance,customeranddeploymentZone;lint_ruleaccepts a valid rule, and reports a truncated one with its message and line;test_rulewithtargeting_keyandkaiten.instanceSlugmatches and returns the facts it read.Checklist
CONTRIBUTING.md.Signed-off-byline.🤖 Generated with Claude Code