You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(usage): enforce safe-integer token bounds in Python and reject empty/boolean cost amounts in TypeScript #103
Two cross-language parity gaps exist between src/agentrust_telemetry/usage.py and packages/typescript/src/usage.ts:
Missing RFC 8785 safe-integer and non-negative checks in Python usage.py (src/agentrust_telemetry/usage.py lines 69-72, 99-102, 134-138):
While TypeScript usageRecord, UsageAccumulator.add, and UsageAccumulator.rollup enforce Number.isSafeInteger(value) && value >= 0 (0 <= value <= 2**53 - 1) on every token field and on rollup sums, Python usage_record and UsageAccumulator.add only check isinstance(value, bool) or not isinstance(value, int) (allowing negative integers before schema validation and integers > 2**53 - 1), and UsageAccumulator.rollup does not check total <= 2**53 - 1.
Empty/whitespace strings and booleans coerced to 0/1 by Number(this.amount) in TypeScript CostObservation (packages/typescript/src/usage.ts lines 13-15):
In JavaScript, Number("") === 0, Number(" ") === 0, Number(false) === 0, and Number(true) === 1. Consequently, new CostObservation("", "USD", "provider").asEventValue() or new CostObservation(true as any, "USD", "provider").asEventValue() succeeds instead of throwing, whereas Python CostObservation rejects booleans and empty/whitespace strings.
Proposed Fix
Enforce 0 <= value <= 9007199254740991 (2**53 - 1) on token counts and rollup totals in Python usage.py, and guard non-string currency and pricing_version in CostObservation.as_event_value.
Reject non-number/non-string or empty/whitespace amount values in TypeScript CostObservation.asEventValue.
Activity
github-actions commentedon Oct 23, 2026
🟡 Contributor Check: MEDIUM
Automated check by AgenTrust Contributor Check.
fix(data_flow,propagation): validate size_bytes/token_count in Python…
fix(data_flow,propagation): validate size_bytes/token_count in Python…
fix(usage): enforce safe-integer token bounds in Python and reject em…