Repository navigation
workflows/v2: emit cre:workflow:compute usage MeterRecord per execution (CRE-6779) - #23858
DylanTinianov wants to merge 3 commits into
Conversation
|
✅ No conflicts with other open PRs targeting |
|
I see you updated files related to
|
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Failed emissions are logged as successful, and disabled metering leaks confidential execution marks.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Risk Rating: MEDIUM
Adds per-execution compute usage metering for workflow v2 engines, including confidential-execution exclusion and billing reconciliation logs.
Changes:
- Wires capability usage metering into workflow engines.
- Emits compute usage for successful and failed executions.
- Tracks confidential executions to avoid duplicate billing.
Scrupulous human review: ResourceManager failure reporting and confidential tracking lifecycle.
| File | Description |
|---|---|
core/services/workflows/v2/config.go |
Adds usage metering configuration. |
core/services/workflows/v2/confidential_module.go |
Tracks confidential executions. |
core/services/workflows/v2/compute_usage_test.go |
Tests compute usage emission. |
core/services/workflows/v2/base_engine.go |
Emits compute usage records. |
core/services/workflows/syncer/v2/handler.go |
Wires and manages the usage meter. |
core/services/cre/cre.go |
Creates the feature-gated ResourceManager. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if e.cfg.UsageMeter == nil { | ||
| return | ||
| } | ||
| if e.cfg.ConfidentialExecutions != nil && e.cfg.ConfidentialExecutions.TookExecution(executionID) { | ||
| return | ||
| } |
…on (CRE-6779) When [Metering].CapabilityUsageEnabled is set, the syncer builds a ResourceManager and every v2 engine emits one METER_ACTION_USAGE record per execution after computeDuration is known: - resource type cre:workflow:compute, value in milliseconds - Utilization.ResourceId "<workflow_id>:<execution_id>", EventId = execution id (identical on every node; billing derives cre:workflow:<wf>:<exec>:<exec>) - Identity.Service workflow-engine, DON id from the local node, org from the engine's resolved org id Emitted for successful and failed executions, outside the legacy metering block so a legacy metering failure cannot suppress it, and skipped when the execution was delegated to the confidential module (ConfidentialModule now tracks the executions it handled; the enclave path meters those). Each emission logs "Emitted capability usage meter record" with executionID, eventID, resourceType, value and orgID. That line is a contract for the billing reconciler and is covered by a unit test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ntract Identity.ResourcePool and ResourcePoolID are now "cre:workflow:compute", derived via resourcemanager.WithWorkflowUsagePool, matching the Billing <-> Decentralized stack contract. Bumps chainlink-common. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… CapabilityUsageEnabled chainlink-common #2428 dropped the separate CapabilityUsageEnabled flag per review: capability usage records share the existing [Metering].MeterRecordsEnabled gate with durable resource metering. The syncer now builds the compute usage ResourceManager when MeterRecordsEnabled is set, next to the spec meter. Bumps chainlink-common to 16997122620e in all modules: CRE-6781-emit-usage-value merged with develop's current pin 8fdc7816. Re-bump to main once #2428 and the develop bump #23910 land. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
6527b3a to
b11eb78
Compare
|





CRE-6779. Depends on chainlink-common #2428; pinned to that branch merged with develop's common pin until #2428 and #23910 land, then re-bump to main.
What
When
[Metering].MeterRecordsEnabledis on (the same gate as durable resource metering; no separate flag), the syncer builds aResourceManager(beholder emitter) and hands it to every v2 engine (syncerV2.WithUsageMeter,EngineConfig.UsageMeter/UsageIdentity). AftercomputeDurationis known,baseEngine.emitComputeUsageemits oneMETER_ACTION_USAGErecord:cre:workflow:compute, value in msResourceId<workflow_id>:<execution_id>EventIdcre:workflow:<wf>:<exec>:<exec>)Identity.Service/Don.DonIdworkflow-engine/ local node's workflow DONIdentity.ResourcePool/ResourcePoolIdcre:workflow:compute/cre:workflow:computeOrgIdBehaviour:
isMeteringblock, so a legacy metering failure cannot suppress itConfidentialModulenow marks executions it handled and the engine consumes the mark (EngineConfig.ConfidentialExecutions). Confidential compute is metered from the enclave-reported duration in a follow-up (CRE-6780).Every emission logs
Emitted capability usage meter recordwithexecutionID, eventID, resourceType, value, orgID. That line is a contract for the billing reconciler (it compares ran vs emitted vs billed) and is asserted in the test.🤖 Generated with Claude Code