Skip to content

feat: cut over to authoritative shared pricing resolution - #11113

Merged
lpcox merged 2 commits into
mainfrom
lpcox-phase-5-pricing-parity
Nov 4, 2026
Merged

lpcox merged 2 commits into
mainfrom
lpcox-phase-5-pricing-parity

Conversation

@lpcox

@lpcox lpcox commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

User-directed cutover

This revision supersedes the initial shadow-only proposal. The user explicitly approved authoritative cutover in this same PR, preserving operator overrides and honest unpriced-model behavior, validated with deterministic regressions and provider-free smoke tests.

Authoritative path

AI-credit accounting / priceability -> source fact adapters -> shared resolvePricing -> selected tariff -> real charges / budget guards.

  • shared/model-information/pricing-resolution.js::resolvePricing, generated into host/proxy contract assets, now drives real prices, charges and priceability. The legacy selection path and shadow comparison code are removed; there is no silent legacy fallback.
  • Existing adapters supply normalized facts lazily; the shared engine owns source priority, strict long-context tiers, central freshness/effective intervals/exact provider-channel-deployment scope, and four-component provider/fallback merging. Direct operator/configured/runtime/central resolver APIs also use shared selection functions.
  • Preserve operator -> configured catalogue v1 -> complete fresh runtime -> applicable fresh scoped central -> curated/imported/selector/configured-default/sentinel policy. Higher-priority overrides do not initialize lower-priority sources. Source matching/parsing and policy-rate construction are reused, not broadly rewritten.
  • Preserve request-pinned feed/provider revisions, HTTP/WebSocket accounting, real zero/null/missing distinctions, unpriced warnings/undercount, selector ceilings, unknown/default policy, budget caps, recovery, opt-outs and BYOK boundaries. Pricing still cannot establish executability.

Intentional changes and failure behavior

  • Shared resolver output is authoritative. An injected shared tariff demonstrably changes actual charges and budget decisions; this is not comparison of legacy output to itself.
  • Resolver/source failures now log sanitized pricing_resolution_error and surface explicitly; no invented price, free usage or fallback to the removed resolver.
  • Invalid selected numeric tariffs (negative/nonfinite/malformed components) fail explicitly. Genuine zero and explicit null cache-write remain valid; genuinely unavailable pricing remains unpriced, with the existing warning/undercount policy.
  • Pre-dispatch resolver errors return structured HTTP/WebSocket 500. If usage-time accounting fails after a response is in flight, it is logged, reflection adds pricing_error, and subsequent dispatch is blocked until proxy restart/repair. Already-running responses cannot be recalled; recorded charges are not fabricated or retroactively adjusted.

The existing stale-complete-provider fallback quirk, runtime-selected fallback tier and legacy import slug/case/prefix policy are preserved, not silently corrected. Cross-provider import collisions remain explicit fixtures.

Validation and provider-free smoke results

  • Full API-proxy regression suite: 141 suites passed; 3,272 tests passed, 2 skipped. Includes existing recovery/opt-out, source-loader and HTTP/WebSocket safeguards.
  • Targeted root shared pricing/identity/contracts/eligibility: 4 suites, 163 tests passed.
  • scripts/ci/smoke-pricing-resolution.cjs runs actual distributed proxy/accounting modules from both the off-tree Docker application context and an extracted npm package. Both passed with zero network calls enforced by network tripwires.
  • Packaged smoke covers operator/configured precedence and tier boundaries, complete/partial/zero/null/missing tariffs, true budget charges/limits, feed refresh and revision pins, provider snapshot pins, BYOK exclusions, real HTTP/WebSocket usage tracking and accounting-time error blocking. Feed refresh uses deterministic fixture transport only.
  • models:generate / models:check, build, type-check, single-file bundle, ADR Markdown lint and whitespace checks passed. Canonical pricing data/catalogue revision remains unchanged.
  • Pre-commit full lint/build passed: 0 lint errors; repository warning baseline remains.

No live provider inference, label, workflow dispatch, container/VM execution or harness activation was performed.

Remaining concrete limitations

This cutover does not wait for or claim completion of exact-decimal accounting; general compatible assembled tariffs across units/currency/token ranges/effective dates; promotion/successor/non-token handling; provider-qualified governed-import activation; broader consumer migration; or release/live-environment evidence. Source adapters retain their legacy matching policy. Staged target-price corrections, production harness constraints and runtime invocation remain unchanged.

Closes #11111.

Parent tracking only: #10295 and #10290 remain open.

Capture reached pricing facts once and compare shared tariff selection.
Preserve legacy charges, guards, source matching and request pins.

Refs #11111

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI adaptive review requested due to automatic review settings November 4, 2026 19:40
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation has been built for this PR.

Download preview artifact

To view locally:

  1. Download the docs-preview-pr-11113 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit bbde513

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 93.75% 93.75% ➡️ +0.00%
Statements 92.30% 92.30% ➡️ +0.00%
Functions 93.06% 93.06% ➡️ +0.00%
Branches 86.51% 86.51% ➡️ +0.00%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/enclave/host-executor-server.ts 91.2% → 91.2% (+0.00%) 90.1% → 89.8% (-0.29%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

Cut over real accounting and priceability to the shared resolver.
Reuse lazy source facts, preserve override policy and request pins,
and surface resolver failures without legacy fallback or free prices.
Validate distributed proxy files with provider-free accounting smokes.

Refs #11111

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox changed the title feat: add legacy-authoritative pricing shadow resolution feat: cut over to authoritative shared pricing resolution Nov 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The shadow comparison misses component-source, tier, and provenance disagreements and cannot independently validate central-pricing exclusions for BYOK or custom-target requests.

No open issues 🎉

What changed in this PR

Adds the first bounded Phase 5 pricing-shadow comparison to AWF’s shared model-information subsystem. The existing resolver remains authoritative for prices, accounting, warnings, and budgets.

Changes:

  • Adds a pure shared pricing candidate and generated host/proxy contracts.
  • Captures reached source facts and emits bounded, sanitized comparison diagnostics.
  • Adds parity and WebSocket pricing-pin coverage, and documents remaining migration gates.
File Description
src/​model-information-pricing-resolution.test.ts Tests shared selection semantics and generated asset equality.
src/​model-information-contract/​pricing-resolution.js Generated host pricing candidate.
src/​model-information-contract/​pricing-resolution.d.ts Generated host pricing declarations.
shared/​model-information/​pricing-resolution.js Implements candidate resolution and sanitized result comparison.
shared/​model-information/​pricing-resolution.d.ts Defines captures, source facts, results, and provenance contracts.
scripts/​model-information/​compile.cjs Distributes pricing contracts through canonical generation.
docs/​adr/​0004-model-information-management.md Documents shadow-only scope and remaining Phase 5 gates.
containers/​api-proxy/​runtime-model-catalog.js Observes provider tariffs and tier provenance.
containers/​api-proxy/​provider-pricing-overlays.js Observes normalized operator pricing.
containers/​api-proxy/​model-pricing-catalog.js Observes configured tariffs and catalogue metadata.
containers/​api-proxy/​guards/​pricing-shadow.test.js Covers parity, accounting preservation, and diagnostic bounds.
containers/​api-proxy/​guards/​pricing-shadow.js Runs shadow comparisons and deduplicates diagnostics.
containers/​api-proxy/​guards/​ai-credits-guard.js Integrates source capture while retaining legacy pricing authority.
containers/​api-proxy/​catalogue-proxy.test.js Adds WebSocket pinning and packaged-context diagnostic checks.
containers/​api-proxy/​catalogue-pricing.js Exposes reached central records for comparison.
containers/​api-proxy/​catalogue-contract/​pricing-resolution.js Generated proxy pricing candidate.
containers/​api-proxy/​catalogue-contract/​pricing-resolution.d.ts Generated proxy pricing declarations.

Review effort: Max (auto)

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.

Phase 5: authoritative shared pricing cutover and provider-free smoke validation

2 participants