Date: 2026-02-22
Checklist Item: MIG-004
Ticket: ISIS-0173
Goal#
Backfill missing historical cost metadata for terminal jobs using provider log reconciliation plus deterministic runtime estimation fallbacks.
Scope#
Eligible records are terminal jobs in jobs:
completedfailedcancelled
A record is considered missing cost data when no non-negative canonical cost is
present in existing job/output metadata aliases (for example
metadata.estimatedCostUsd or output.metadata.estimatedCostUsd).
Backfill Strategy#
For each eligible job, the backfill pipeline performs:
- Provider log reconciliation:
- Match by
jobIdfirst, thenqueueJobId. - Prefer explicit
estimatedCostUsdfrom provider logs when available. - Otherwise derive cost from log
executionTimeMsand provider pricing configuration.
- Match by
- Metadata reconciliation:
- Accept existing cost aliases when present.
- Runtime estimation fallback:
- Use runtime metadata fields (
executionTimeMs, worker metrics duration, terminal timestamps) plus configured provider rates.
- Use runtime metadata fields (
When a value is resolved, backfill writes:
metadata.estimatedCostUsdmetadata.costBackfillaudit block (source,backfilledAt, optional provider/runtime/endpoint details)output.metadata.estimatedCostUsd(and missing runtime/provider fields when available)
Source Resolution Rules#
Deterministic precedence:
provider_logs.estimated_cost_usdprovider_logs.execution_time_ms- Explicit metadata aliases (
output.metadata.*,job.metadata.*) - Runtime-driven estimation from metadata and timestamps
Operational Interfaces#
API (admin)#
POST /api/v1/jobs/admin/costs/backfill
Request body:
json
{
"limit": 2000,
"dryRun": false,
"providerLogs": []
}
Access requirements:
- Bearer auth role:
admin,ops, orsre - API key permission:
jobs:queue:admin
CLI#
isis jobs backfill-costs --dry-run --provider-log-file ./runpod-logs.json
Result Contract#
Backfill response includes:
scannedmissingCostDatabackfilledunresolvedfailedproviderLogsProcessedproviderLogsMatchedbackfilledJobIdsunresolvedJobIdsfailedJobIdssourceCountsproviderCountscheckedAt
Safety Controls#
- Dry-run mode for impact estimation without writes.
- Bounded scan with hard max limit (
50000) and page batching. - Provider logs are optional and validated for identifier + cost/runtime signal.
- Ambiguous or insufficient data remains unresolved for operator review.