Skip to content

fix(usage): enforce safe-integer token bounds in Python and reject empty/boolean cost amounts in TypeScript (#103) - #110

Open
drk-ram wants to merge 2 commits into
agentrust-io:mainfrom
drk-ram:drk-ram-fix-usage-104
Open

drk-ram wants to merge 2 commits into
agentrust-io:mainfrom
drk-ram:drk-ram-fix-usage-104

Conversation

@drk-ram

@drk-ram drk-ram commented Oct 23, 2026 •

Copy link
Copy Markdown

Summary

  • Enforce 0 <= value <= 9007199254740991 (2**53 - 1) on token counts and rollup totals in src/agentrust_telemetry/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 (packages/typescript/src/usage.ts).

Closes #103

Validation

  • python -m pytest tests/test_usage.py -q
  • python -m ruff check src/agentrust_telemetry/usage.py tests/test_usage.py

…pty/boolean cost amounts in TypeScript (agentrust-io#104)

- Enforce 0 <= value <= 2**53 - 1 on token fields and rollup sums in Python usage.py, and validate currency/pricing_version string types in CostObservation.
- Reject non-number/non-string or empty/whitespace amount values in TypeScript CostObservation.asEventValue.

Closes agentrust-io#104

Signed-off-by: Raghuvar Durga <177662415+drk-ram@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@drk-ram
drk-ram requested review from a team and imran-siddique as code owners October 23, 2026 22:59
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🟡 Contributor Check: MEDIUM

Check Result
Profile MEDIUM
Credential LOW
Overall MEDIUM

Automated check by AgenTrust Contributor Check.

@github-actions github-actions Bot added the needs-review:MEDIUM Contributor check flagged MEDIUM risk label Oct 23, 2026
…#110

Signed-off-by: Srinivasa Dinakar Jainti <dinakarjs@gmail.com>

@dinakarjs dinakarjs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed source at e8eedb8. Python unittest discovery passed with inherited OTEL_* variables removed; the initial three OTel failures were environment configuration. TypeScript build and all 44 existing tests passed using node --import tsx --test test/*.test.ts; the npm check launcher itself encountered an IPC-listen EPERM here, so I do not claim that wrapper passed. Local results only, not hosted CI. Python: 158 tests pass.

The TypeScript change needs a committed behavioral regression. I prepared a test-only adoption companion at dinakarjs#2, based exactly on this head. Its two tests pass on this branch; restoring the previous TypeScript implementation makes the refusal assertion fail. Please adopt the signed commit and retain attribution, then obtain independent review of the combined change. This is a COMMENT because I am contributing those tests.

Metadata correction: the description currently closes #104, but this cost validation work belongs to #103; please correct that closing reference.

Prepared with OpenAI Codex.

@drk-ram drk-ram changed the title fix(usage): enforce safe-integer token bounds in Python and reject empty/boolean cost amounts in TypeScript (#104) fix(usage): enforce safe-integer token bounds in Python and reject empty/boolean cost amounts in TypeScript (#103) Oct 24, 2026
@drk-ram

drk-ram commented Oct 24, 2026

Copy link
Copy Markdown
Author

Thanks @dinakarjs! Fast-forward merged your signed TypeScript boundary test commit (f958f56, packages/typescript/test/cost-boundaries.test.ts) with full authorship and sign-off preserved, and updated the PR title/description to reference Closes #103.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review:MEDIUM Contributor check flagged MEDIUM risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(usage): enforce safe-integer token bounds in Python and reject empty/boolean cost amounts in TypeScript

2 participants