Billing: Emit resource manager values - #2428
Draft
DylanTinianov wants to merge 1 commit into
Draft
DylanTinianov wants to merge 1 commit into
DylanTinianov wants to merge 1 commit into
Conversation
…L_CAPABILITY_USAGE_ENABLED Groundwork for capability-centric workflow billing (CRE-6778): - ResourceManager.EmitUsageValue emits a METER_ACTION_USAGE record from a *big.Int so chain-write capabilities can report gas fees in wei without truncation. - resourcemanager/workflow_usage.go pins the producer side of the billing contract: record type cre:workflow, resource types cre:workflow:compute and cre:workflow:gas:<chain_selector>, ResourceId "<workflow_id>:<execution_id>", emitting service names and resource pool. Matches the consumer in billing-platform-service (ConstructCapabilityUsageEventID). - loop.EnvConfig.CapabilityUsageEnabled (CL_CAPABILITY_USAGE_ENABLED) carries the new [Metering].CapabilityUsageEnabled node setting to LOOP capability plugins, independent of MeterRecordsEnabled. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
✅ API Diff Results -
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Capability usage remains blocked by MeterRecordsEnabled, contradicting the new setting’s documented independence.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds workflow capability billing primitives and propagates capability usage configuration to LOOP plugins.
Changes:
- Adds arbitrary-precision usage emission.
- Defines workflow compute/gas billing identifiers.
- Adds
CL_CAPABILITY_USAGE_ENABLEDconfiguration transport.
| File | Description |
|---|---|
pkg/resourcemanager/workflow_usage.go |
Defines workflow billing identifiers and helpers. |
pkg/resourcemanager/workflow_usage_test.go |
Tests workflow billing helpers. |
pkg/resourcemanager/resourcemanager.go |
Adds arbitrary-precision usage emission. |
pkg/resourcemanager/resourcemanager_test.go |
Tests large and nil usage values. |
pkg/loop/config.go |
Adds capability usage configuration. |
pkg/loop/config_test.go |
Tests configuration parsing and propagation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+211
to
+214
| // CapabilityUsageEnabled enables per-capability workflow usage MeterRecords | ||
| // (compute, gas) for eventually consistent billing. Independent of | ||
| // MeterRecordsEnabled, which gates durable resource metering. | ||
| CapabilityUsageEnabled bool |
This branch has not been deployed
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.

Groundwork for capability-centric workflow billing (CRE-6778). No behaviour change for existing producers.
What
ResourceManager.EmitUsageValue(ctx, identity, eventID, *big.Int, fields):METER_ACTION_USAGEfrom an arbitrary-precision value, so chain-write capabilities can report gas fees in wei/lamports without int64 truncation. Same event-id contract and fail-open semantics asEmitUsage.resourcemanager/workflow_usage.go: the producer side of the billing contract, shared by the engine (compute) and the chain-write plugins (gas):cre:workflow; resource typescre:workflow:compute(ms) andcre:workflow:gas:<chain_selector>(WorkflowGasResourceType)Utilization.ResourceId = "<workflow_id>:<execution_id>"(WorkflowUsageResourceID, rejects:in either part)chain-write/workflow-engine, resource poolworkflow_usageMatches the consumer in billing-platform-service (#963,
ConstructCapabilityUsageEventID:cre:workflow:<wf>:<exec>:<EventId>).loop.EnvConfig.CapabilityUsageEnabled(CL_CAPABILITY_USAGE_ENABLED): carries the new node setting[Metering].CapabilityUsageEnabledto LOOP capability plugins. Independent ofMeterRecordsEnabled, which gates durable resource metering.