refactor(billing): extract gkg-billing crate

What does this MR do and why?

Extracts all billing logic into a new dedicated crates/gkg-billing/ crate, leaving a single auditable file outside this crate (crates/gkg-server/src/billing_adapter.rs) where auth meets billing. Pure refactor — no behavior changes. This helps keep the billing logic in the new crate for ease of auditing for SOX compliance.

SOX boundary after this MR

The complete billing surface in this repo is two paths:

  1. crates/gkg-billing/ — all billing logic, types, constants, the Snowplow tracker, the pipeline observer.
  2. crates/gkg-server/src/billing_adapter.rs — the only file outside that crate that touches billing types. It contains exactly one impl From<&Claims> for BillingInputs and nothing else.

BillingConfig (the 12-line enabled / collector_url struct) intentionally stays in crates/gkg-server-config/ because moving it would force gkg-server-config to depend on gkg-billingquery-engine/labkit-events, which would defeat the explicit "lightweight config crate" design that indexer, cli, and other crates rely on. BillingConfig is a pure descriptor with no behavior; trivial to audit in place.

What BillingInputs is, and why

BillingObserver previously took an entire auth::Claims struct, reaching into 11 specific fields. After this MR, the observer takes a BillingInputs value struct that exposes exactly those 11 fields and nothing else. The conversion Claims → BillingInputs happens at one site, in billing_adapter.rs.

End to end testing

Should be similar to original MR - !937 (merged) - no behavioural changes.

Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/593192

Related to https://gitlab.com/gitlab-org/orbit/knowledge-graph/-/work_items/507

Edited by Sharmad Nachnolkar

Merge request reports

Loading