Repository navigation
Description
Problem
#66963 established the trust rule for model-routing attribution: the routed model is attributed only from the runner-written aw_info.json. Files the agent job's sandbox can write, such as agent/awf-routing-outcome.json and agent/awf-reflect.json, never establish attribution on their own. parse_token_usage.cjs accepts a harness outcome only after checking it against the proxy's model-routing records.
#67114 (fixes #67113) added the workflow.info and model_routing.outcome events to usage/aw_session.jsonl and made audit and logs read routing from them. In both layers, the harness outcome overrides the trusted data:
actions/setup/js/unified_session.cjs,collectUnifiedSession(L546-L552): forstatus,wireModel,effectiveEndpoint,selectedEndpoint,effort,appliedEffortandfailureCode, any value in themodel_routing.outcomeevent (provenanceagent/awf-routing-outcome.json) overwritesworkflow.info.modelRouting(provenanceaw_info.json).pkg/cli/model_routing_session.go,sessionModelRoutingAttribution.modelRouting(L161-L190): after routing is built fromworkflow.info, every non-empty outcome field (Status,WireModel,EffectiveEndpoint,SelectedEndpoint,Effort,AppliedEffort,FailureCode) replaces the matching value. An outcome with noworkflow.infoalso marks routing as found.
A compromised or buggy harness can therefore make audit, logs and anything built on the unified session report a routing status, model or endpoint that the runner never corroborated. This affects reporting, not enforcement. It is the same forgery that #66963's model_attribution_security tests guard against for aw_info.json.
Proposed fix
- Keep each unified event faithful to its source. Populate
workflow.info.modelRoutingonly fromaw_info.json, and populatemodel_routing.outcomeonly from the harness file.collectUnifiedSessionshould not copy fields between them. Optionally, record a disagreement marker when they differ. - Take attribution only from
workflow.infoinmodel_routing_session.go. This covers status, model, wire model, endpoints, efforts and failure code. Treat the outcome as advisory evidence: expose it separately (for example asharness_outcome) and add an audit finding or warning when it disagrees withworkflow.info. An outcome-only session must never count as attributed routing. - Tests:
- Forged outcome values must not change the audit's routing or the unified
workflow.info. For example, test an outcome with statusselectedand a different wire model or endpoint. - A disagreement between the outcome and
workflow.infoproduces the warning. - Outcome-only sessions don't count as routed.
- Mirror the cases in
model_attribution_security.test.cjs.
- Forged outcome values must not change the audit's routing or the unified
Reference
PR #67254 briefly changed the collectUnifiedSession precedence in the opposite direction by copying values derived from aw_info.json into the outcome event. A code-scanning review flagged that change as well. It is being reverted from #67254 so that this fix lands on its own.
Activity