Revenue leakage auditor

Audit one account-period for revenue leakage by comparing usage against billing, emitting only bounded adjustment ceilings as data for eligible under-billed accounts.

You’re reading version sha-d6fc4f0bcf9f. Go to the current version

Overview

revenue-leakage-auditor is a finance review skill. It reads one account's usage record, billing history, discount policy, threshold, and parent adjustment bounds, then decides whether an under-billing gap is real enough to recover. It does not charge a customer, refund money, mint authority, or settle an adjustment.

The output is a typed review decision plus zero or more bounded AttenuationRequest ceilings carried as data. A downstream driver may hand a ceiling to the core spend/refund accepting runner, which alone owns child grant minting, reservation, settlement, and receipt sealing. This skill only records the review and the bounded data a later governed runner may consume.

SKILL.md

Revenue Leakage Auditor

revenue-leakage-auditor is a finance review skill. It reads one account's usage record, billing history, discount policy, threshold, and parent adjustment bounds, then decides whether an under-billing gap is real enough to recover. It does not charge a customer, refund money, mint authority, or settle an adjustment.

The output is a typed review decision plus zero or more bounded AttenuationRequest ceilings carried as data. A downstream driver may hand a ceiling to the core spend/refund accepting runner, which alone owns child grant minting, reservation, settlement, and receipt sealing. This skill only records the review and the bounded data a later governed runner may consume.

What This Skill Does

  1. Reads durable per-account reconciliation state through registry:runx/data-store@0.1.2.
  2. Matches usage_records.account_id to billing_history.account_id for the same billing period.
  3. Computes the billed-vs-usage gap only from supplied records.
  4. Applies charge_threshold_pct before treating a gap as leakage.
  5. Drops accounts excluded by discount_policy.excluded_accounts.
  6. Drops gaps covered by discount_policy.known_discounts.
  7. Emits one bounded ceiling per eligible under-billed account, clamped to parent_adjustment_bounds.
  8. Appends a reconciliation event with a CAS append_event using a stable idempotency key keyed by account and period.

Inputs

yaml
usage_records:
  account_id: string
  usage_amount: number
  period: string
billing_history:
  account_id: string
  billed_amount: number
  period: string
discount_policy:
  excluded_accounts: [string]
  known_discounts: array
charge_threshold_pct: number
parent_adjustment_bounds: object

The usage and billing records may include currency and evidence_ref. When an evidence ref is absent, the reviewer derives a stable reference from account_id and period rather than inventing an external source.

Output

yaml
decision:
  leakage_found: boolean
  reason: string
ceilings:
  - schema: runx.attenuation_request.v1
    form: data
    account_id: string
    amount:
      amount: number
      currency: string
    currency: string
    scopes: [spend.reserve, spend.settle, receipt.seal]
    usage_evidence_ref: string
    billing_evidence_ref: string
    idempotency_key: string
    downstream_runner: registry:runx/spend@0.1.1
escalation:
  required: boolean
  lane: human_approval
  reason: string
data_store:
  package_ref: registry:runx/data-store@0.1.2
  read_projection: object
  append_event: object
observations: object

ceilings is empty when no leakage is found, the account is excluded, a known discount covers the gap, records are incomplete, or the gap stays inside the threshold. A ceiling is a review artifact only; it is not a reservation, subset proof, mint, settlement, or proposal envelope.

Decision Rules

  • Leakage found only when account and period match, usage and billing amounts are complete, currency is compatible, the account is not excluded, no known discount covers the gap, and the under-billed percentage exceeds charge_threshold_pct.
  • No change when billing is at or above usage, the gap is within threshold, or a known discount covers the difference.
  • Needs agent when account, period, usage amount, billed amount, currency, threshold, or parent bounds are missing or contradictory.
  • Human approval lane is named whenever a downstream runner would consume a ceiling. The approval happens outside this review skill.

Data-Store Handoff

This skill carries the registry:runx/data-store@0.1.2 handoff contract in the review packet and executes the same governed data operation envelope through data.source graph steps.

  • read_projection reads resource: account_reconciliations for the account aggregate.
  • append_event writes either revenue_leakage.detected or revenue_leakage.no_change.
  • idempotency_key is keyed by account id, period, and review outcome.
  • expected_version is supplied by the review packet so CAS failures are visible instead of overwritten.

The event is evidence of the review. It is not authority to charge, refund, or settle anything.

Adjustment Handoff

Each ceiling is a typed value, not an effect. A downstream driver must:

  • pass the ceiling to the core spend/refund accepting runner;
  • mint any attenuated child grant there, never here;
  • reserve, settle, and seal under the accepting runner's charter;
  • fail closed when a request exceeds the ceiling amount, currency, or scopes; and
  • require human approval before consuming the ceiling.

Stop Conditions

  • account_mismatch: usage and billing records name different accounts.
  • period_mismatch: usage and billing records cover different periods.
  • missing_usage_evidence: usage amount is absent or not numeric.
  • missing_billing_evidence: billed amount is absent or not numeric.
  • currency_mismatch: usage, billing, or parent bounds currencies differ.
  • excluded_account: discount policy excludes the account.
  • known_discount: discount policy covers the apparent gap.
  • below_threshold: the under-billed percentage is at or below the threshold.
  • bounds_missing: parent adjustment bounds cannot clamp the ceiling.

Verification Notes

The harness carries exactly two cases:

  • revenue-leakage-auditor-underbilling-ceiling seals a leakage review with a bounded AttenuationRequest ceiling as data and a CAS append event.
  • revenue-leakage-auditor-stop-needs-agent omits caller answers so the review blocks at needs_agent with no ceiling, no mint, no settlement, and no append event.

The dogfood run should execute the published package after install and verify the receipt from that post-publish run, not a local harness fixture receipt.

Published execution profile

The execution profile published with sha-d6fc4f0bcf9f, shown as its exact bytes.

Runner
  • audit
Profile digestsha256:0a83c47b7251e0ac30da294bd04acd2d96c613629f365b144dd7dd03de14ee73
skill: revenue-leakage-auditor
version: 0.1.0
catalog:
  kind: graph
  audience: operator
  visibility: public
  role: context
  part_of:
    - runx/spend
    - runx/refund
  category: payments
connectors:
  store:
    operations:
      - events.append
      - projection.read
runners:
  audit:
    default: true
    inputs:
      data_source_ref:
        type: string
        required: true
        description: Logical data source holding per-account revenue reconciliation state.
      store_id:
        type: string
        required: false
        description: Optional deterministic local fixture store id.
      usage_records:
        type: json
        required: true
        description: usage_records{account_id,usage_amount,period}.
      billing_history:
        type: json
        required: true
        description: billing_history{account_id,billed_amount,period}.
      discount_policy:
        type: json
        required: true
        description: discount_policy{excluded_accounts,known_discounts}.
      charge_threshold_pct:
        type: number
        required: true
        description: Minimum under-billed percentage required before emitting a ceiling.
      parent_adjustment_bounds:
        type: json
        required: true
        description: AuthorityBounds clamp for any adjustment ceiling emitted as data.
    steps:
      - id: read-account
        operation: store/projection.read
        input:
          data_source_ref: $input.data_source_ref
          resource: account_reconciliations
          aggregate_id: $input.usage_records.account_id
      - id: judge-leakage
        label: decide revenue leakage and bounded adjustment ceilings
        agent:
          role: finance
          task: revenue-leakage-auditor
        outputs:
          leakage_audit_packet:
            required: false
        inputs:
          usage_records: $input.usage_records
          billing_history: $input.billing_history
          discount_policy: $input.discount_policy
          charge_threshold_pct: $input.charge_threshold_pct
          parent_adjustment_bounds: $input.parent_adjustment_bounds
          account_projection: $steps.read-account.provider_operation.result.projection
        artifacts:
          named_emits:
            revenue_leakage_audit_packet: leakage_audit_packet
      - id: append-review
        operation: store/events.append
        idempotency_key: $steps.judge-leakage.leakage_audit_packet.data_store.append_event.idempotency_key
        input:
          data_source_ref: $input.data_source_ref
          resource: account_reconciliations
          aggregate_id: $input.usage_records.account_id
          expected_version: $steps.judge-leakage.leakage_audit_packet.data_store.append_event.expected_version
          event: $steps.judge-leakage.leakage_audit_packet.data_store.append_event.event
harness:
  cases:
    - name: revenue-leakage-auditor-underbilling-ceiling
      inputs:
        data_source_ref: tenant://revenue-leakage/account-ledger
        store_id: revenue-leakage-harness-v1
        usage_records:
          account_id: account:atlas-team
          usage_amount: 15000
          currency: USD
          period: 2026-06
          evidence_ref: usage:account:atlas-team:2026-06
        billing_history:
          account_id: account:atlas-team
          billed_amount: 10000
          currency: USD
          period: 2026-06
          evidence_ref: billing:account:atlas-team:2026-06
        discount_policy:
          excluded_accounts:
            - account:internal-sandbox
          known_discounts:
            - account_id: account:legacy-partner
              period: 2026-06
              amount:
                amount: 5000
                currency: USD
              reason: contracted launch discount
        charge_threshold_pct: 10
        parent_adjustment_bounds:
          schema: runx.authority_bounds.v1
          amount:
            max_per_account: 6000
            currency: USD
          scopes:
            - spend.reserve
            - spend.settle
            - receipt.seal
          expires_at: 2026-07-31T00:00:00Z
      env:
        RUNX_DATA_SOURCES: '{"data_sources":{"tenant://revenue-leakage/account-ledger":{"adapter":"data.local","resources":{"account_reconciliations":{"kind":"event_stream","partition_key":"aggregate_id"}}}}}'
      caller:
        answers:
          judge-leakage:
            leakage_audit_packet:
              schema: runx.revenue.leakage_audit.v1
              decision:
                leakage_found: true
                reason: account:atlas-team used USD 15000 in 2026-06, was billed USD 10000, and the 50% under-billing gap exceeds the 10% threshold with no exclusion or known discount.
              ceilings:
                - schema: runx.attenuation_request.v1
                  form: data
                  account_id: account:atlas-team
                  amount:
                    amount: 5000
                    currency: USD
                  currency: USD
                  scopes:
                    - spend.reserve
                    - spend.settle
                    - receipt.seal
                  counterparty: account:atlas-team
                  usage_evidence_ref: usage:account:atlas-team:2026-06
                  billing_evidence_ref: billing:account:atlas-team:2026-06
                  idempotency_key: revenue-leakage:account:atlas-team:2026-06:recover
                  downstream_runner: registry:runx/spend@0.1.1
                  clamp:
                    parent_bound_ref: parent_adjustment_bounds
                    max_amount:
                      amount: 6000
                      currency: USD
                    result: within_parent_bounds
              escalation:
                required: true
                lane: human_approval
                reason: Finance approval is required before a downstream C3 runner consumes the adjustment ceiling.
              data_store:
                package_ref: registry:runx/data-store@0.1.2
                data_source_ref: tenant://revenue-leakage/account-ledger
                store_id: revenue-leakage-harness-v1
                read_projection:
                  runner: read_projection
                  resource: account_reconciliations
                  aggregate_id: account:atlas-team
                append_event:
                  runner: append_event
                  resource: account_reconciliations
                  aggregate_id: account:atlas-team
                  expected_version: 0
                  idempotency_key: revenue-leakage:account:atlas-team:2026-06:detected
                  event:
                    type: revenue_leakage.detected
                    payload:
                      account_id: account:atlas-team
                      period: 2026-06
                      usage_amount:
                        amount: 15000
                        currency: USD
                      billed_amount:
                        amount: 10000
                        currency: USD
                      under_billed_amount:
                        amount: 5000
                        currency: USD
                      threshold_pct: 10
                      ceiling_idempotency_key: revenue-leakage:account:atlas-team:2026-06:recover
              observations:
                verdict: leakage_found
                account_id: account:atlas-team
                period: 2026-06
                usage_evidence_ref: usage:account:atlas-team:2026-06
                billing_evidence_ref: billing:account:atlas-team:2026-06
                usage_amount:
                  amount: 15000
                  currency: USD
                billed_amount:
                  amount: 10000
                  currency: USD
                under_billed_amount:
                  amount: 5000
                  currency: USD
                under_billed_pct: 50
                threshold_pct: 10
                bounded_ceiling_count: 1
                aggregate_id: account:atlas-team
                appended_version: 1
                refused_or_stop_reason: null
                harness_cases:
                  - revenue-leakage-auditor-underbilling-ceiling
                  - revenue-leakage-auditor-stop-needs-agent
      expect:
        status: sealed
        receipt:
          schema: runx.receipt.v1
      operator_journeys:
        - mode: standalone
          confusors:
            - settle-invoice
            - refund
          request: Audit this account period for revenue leakage.
          expected_outcome: Return usage-versus-billing findings and bounded adjustment ceilings for under-billed accounts.
        - mode: composed
          request: Continue this revenue-leakage-auditor work from evidence already gathered upstream.
          expected_outcome: Return usage-versus-billing findings and bounded adjustment ceilings for under-billed accounts.
          prior_evidence:
            - The usage and billing records already read.
          must_not_repeat:
            - Do not bill or credit the account.
    - name: revenue-leakage-auditor-stop-needs-agent
      inputs:
        data_source_ref: tenant://revenue-leakage/account-ledger
        store_id: revenue-leakage-harness-v1
        usage_records:
          account_id: account:bravo-team
          usage_amount: 10500
          currency: USD
          period: 2026-06
          evidence_ref: usage:account:bravo-team:2026-06
        billing_history:
          account_id: account:bravo-team
          billed_amount: 10000
          currency: USD
          period: 2026-06
          evidence_ref: billing:account:bravo-team:2026-06
        discount_policy:
          excluded_accounts:
            - account:internal-sandbox
          known_discounts:
            - account_id: account:legacy-partner
              period: 2026-06
              amount:
                amount: 5000
                currency: USD
              reason: contracted launch discount
        charge_threshold_pct: 10
        parent_adjustment_bounds:
          schema: runx.authority_bounds.v1
          amount:
            max_per_account: 6000
            currency: USD
          scopes:
            - spend.reserve
            - spend.settle
            - receipt.seal
          expires_at: 2026-07-31T00:00:00Z
      env:
        RUNX_DATA_SOURCES: '{"data_sources":{"tenant://revenue-leakage/account-ledger":{"adapter":"data.local","resources":{"account_reconciliations":{"kind":"event_stream","partition_key":"aggregate_id"}}}}}'
      expect:
        status: needs_agent

Published package and test evidence.

This exact version passed its recorded harness run: 2 checks passed · 0 failed.

Test result

Harness resultPassed
Tested versionsha-d6fc4f0bcf9f
Recorded result2 checks passed · 0 failed
Result sourceReported by the publisher (runx_registry_publish)
Suiterunx-harness
Test recorded
Declared cases2
Test recordOpen the recorded run
Inspect receipt referencessha256:4d4457802e17954a5d258919e56883b0d470a35ddfdc39d57184d4e72db22ef1sha256:2f50a043cac4e942fdd29b3e5e73fe5fcaebfa873511ea13a8fe21315aa57fce

Package identity

Published revisionsha-d6fc4f0bcf9f
Content digestsha256:d6fc4f0bcf9f464fdfd2dc641ce5338e4b4aa062802f6674f39fbfabc59f20b9
SKILL.md digestsha256:757e40d7a10a9da2a37abd676c4e82cf958188dc77149ad2117ff78c4446b4c5
Execution profile digestsha256:0a83c47b7251e0ac30da294bd04acd2d96c613629f365b144dd7dd03de14ee73
Publisher identityUnverified publisher · dh0h
Trust tierCommunityPublished through the registry without publisher verification. This tier is not a code assessment.
Attestations
  • Publisher · Declareddh0h · 17 Oct 2026
Source provenanceNot published with this version

Version history

  1. 0.1.2Content digest sha256:81fd22d7f8152d7f045f73d1f32f5d1bae17fa1cc332eee948d28962a35dba0c
  2. sha-52347e9672dbContent digest sha256:52347e9672db2474fba5ef7fde8c836e34fc29d6edb5661917659c26e4b40f6c
  3. sha-2a51116ea85aContent digest sha256:2a51116ea85af3ebc27104ce4d15edcffc84e94130f21ab330e17d0a90caace8
  4. sha-d6fc4f0bcf9fViewingContent digest sha256:d6fc4f0bcf9f464fdfd2dc641ce5338e4b4aa062802f6674f39fbfabc59f20b9
  5. sha-de4f0a428658Content digest sha256:de4f0a4286582b202cde2b02b25b169c9a27b6ef8d577e6cb290355e263785a4