Skip to content

feat(ai): credit reporting and optional provider wrappers (KTN-201) - #9

Draft
backtrack5r3 (tomflenner) wants to merge 8 commits into
mainfrom
feat/ai-credits
Draft

backtrack5r3 (tomflenner) wants to merge 8 commits into
mainfrom
feat/ai-credits

Conversation

@tomflenner

Copy link
Copy Markdown
Contributor

What does this PR change?

KTN-201 generated write-only AI union and response models, reserve/commit/run helpers, typed errors/keyed retries, model and conversion-rule management, inference/reservation reads, optional OpenAI/Anthropic drop-in/delegation wrappers with sync/async streaming settlement. Adds extras, CI compatibility checks, changelog and version 1.1.0.

Testing

Integrated full suite: 948 passed, 8 optional provider compatibility tests skipped because provider packages absent in main environment. Isolated provider-compatible focused suite previously passed with real installed SDK types and synthetic transports. Ruff, mypy (76 files), model/sync generation freshness and targeted contract tests passed.

Compatibility / migration impact

Vendored contract from companion Kaiten feature branch; source.yaml records source commit. Strict read union remains non-AI. AI handwritten response classes replaced with compatibility aliases. Providers are optional extras, no prompts sent to Kaiten.

Decisions to review

NOT_SENT requires demonstrable pre-send failures; ambiguous post-send errors remain provider errors. Usage extraction/validation failures preserve provider results and attempt settlement without usage. Agent interfaces do not establish awaited veto-capable preflight before every internal model inference; full agent wrappers were not fabricated. This is an explicit scope gap pending API/requirements decision.

Not in this PR

Provider proxy/server pricing, universal agent preflight, tags/publication.

Checklist

  • Tests/docs/extras/attribution updated; commits signed off
  • No provider keys, prompts or customer data
  • Optional compatibility tests on final main environment / CI green

Signed-off-by: tomflenner <flennertom@gmail.com>
Signed-off-by: tomflenner <flennertom@gmail.com>
Signed-off-by: tomflenner <flennertom@gmail.com>
Signed-off-by: tomflenner <flennertom@gmail.com>
Signed-off-by: tomflenner <flennertom@gmail.com>
Signed-off-by: tomflenner <flennertom@gmail.com>
@tomflenner

Copy link
Copy Markdown
Contributor Author

Naming refactor: high-level AI helpers/meters and OpenAI/Anthropic wrappers now use entitlement= instead of pool=. Low-level entitlement_slug, HTTP routes and connection-pool settings are unchanged; old high-level pool= is rejected. Updated README/changelog/examples and regenerated sync code. Local verification: 988 tests passed, 8 optional provider compatibility tests skipped; Ruff, strict mypy and generation freshness passed.

Signed-off-by: tomflenner <flennertom@gmail.com>
Signed-off-by: tomflenner <flennertom@gmail.com>
@tomflenner

Copy link
Copy Markdown
Contributor Author

Dedicated AI change and billing dependency

This PR remains dedicated to the AI credit control plane; AI fixes have been published here, not on the billing branch. It depends on billing PR #5 and should land after billing.

The AI and billing branches diverge in generated contracts and shared transaction-error definitions. A base-only retarget would be misleading. Integrate billing's merged base before merging this PR, retaining one shared error class and preserving numeric report versus AI-phase replay semantics. No force-push was performed.

Latest verification: 541 focused tests and Ruff passed, including inherited-header suppression and exact usage validation. Earlier broader verification had optional-provider skips and one missing-OpenFeature failure; final full-suite/mypy and typed contract refresh remain incomplete.

This branch has not been deployed

No deployments
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