ResourceCost common.resource-cost@1
Generated at from
openvibe-contracts v0.79.0 and
openvibe-sdk v0.25.0.
- Version
- 1.0.0
- Owner
- contracts
- Visibility
- first-party
- Status
- active
- Compatibility
- backward
- Decision
- ADR-034
- Schema
https://openvibe.network/contracts/common/resource-cost.v1.json
One charge in weighted cost units (roadmap WS-Z1): which subject used what, reserved and committed or released, with an idempotency key so a retried charge counts once.
Fields
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
subject | identity.subject-ref | yes | ||
project_id | string |
| ||
unit | enum | yes |
| |
amount | number | yes |
| |
state | enum | yes |
| |
idempotency_key | string | yes |
| |
service | string | yes | ||
at | string | yes |
|
Examples
From the contract's own test fixtures: valid ones validate, rejected ones must fail.
Valid: browser-seconds
{
"subject": {
"type": "agent",
"id": "agt_01J0000000000000000000000A"
},
"project_id": "prj_01J0000000000000000000000A",
"unit": "browser-second",
"amount": 12.5,
"state": "committed",
"idempotency_key": "run_01J-step-4",
"service": "actor",
"at": "2026-09-28T23:00:00Z"
}Rejected: short-key
{
"subject": {
"type": "user",
"id": "usr_01J0000000000000000000000A"
},
"unit": "job-run",
"amount": 1,
"state": "reserved",
"idempotency_key": "k",
"service": "x",
"at": "2026-09-28T23:00:00Z"
}Rejected: unknown-unit
{
"subject": {
"type": "user",
"id": "usr_01J0000000000000000000000A"
},
"unit": "coins",
"amount": 1,
"state": "committed",
"idempotency_key": "abcdefgh",
"service": "x",
"at": "2026-09-28T23:00:00Z"
}Validate
const contracts = require('openvibe-contracts');
contracts.validate('common.resource-cost@1', value); // { valid, errors: [{ path, message }] }