Skip to content

Negative cost metric silently dropped instead of rejected (§9.6) #86

@nficano

Description

@nficano

Category: spec-conformance Severity: major
Location: src/Arcp.Runtime/JobContext.fs:74-90
Spec: ARCP v1.1 §9.6

What

Spec §9.6: 'Negative values are rejected and produce no decrement.' The code silently drops the entire metric event (any name, not just cost.*) on value<0m, returning a completed task. 'Rejected' implies an observable error to the caller, not silent suppression. Equally, non-cost metrics with negative values should still flow through.

Evidence

member _.EmitMetricAsync (name, value, unit, dimensions, _ct) : Task =
    if value < 0m then
        Task.CompletedTask
    else
        if name.StartsWith("cost.") then
            match unit with
            | Some u -> onCostMetric (u, value)
            | None -> ()
        emit (JobEventBody.Metric(name, value, unit, dimensions))

Proposed fix

For names starting with cost. and value<0m, raise ArcpException InvalidRequest (or return Error). For other metric names, emit unmodified — negative non-cost metrics are not addressed by §9.6.

Acceptance criteria

  • Calling EmitMetricAsync('cost.inference', -0.01m, Some 'USD', ...) raises an INVALID_REQUEST; calling EmitMetricAsync('latency.ms', -5m, ...) still emits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    audit/spec-conformanceAudit finding — ARCP v1.1 spec conformancesev/majorSeverity — major

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions