Repository navigation
intent_bridge: normalize integer-by-value timestamps to int and bound now by JCS_SAFE_INTEGER - #573
Conversation
… now Normalize authorized_at, expires_at, and observed_at to Python int in verify_bridge, sign_successor_artifact, and verify_successor_artifact without mutating caller inputs in place, and bound verify_bridge's now parameter by JCS_SAFE_INTEGER (2**53 - 1). Closes agentrust-io#568 Signed-off-by: Raghuvar Durga <177662415+drk-ram@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
dinakarjs
left a comment
There was a problem hiding this comment.
Reviewed exact head 3b3651a. Integer-by-value timestamp outputs are normalized on copied containers, signed JCS equivalence is preserved, and the caller's float-valued inputs remain unchanged. now is explicitly bounded to the safe-integer domain without changing the expiry equality refusal.
Independent Linux/Python 3.12.14, matching hash-locked dependencies and exact-checkout imports: 510 selected bridge/successor/integer/public-error tests pass. Additional control verifies normalized int output against unchanged float-valued caller input; bool, negative, fractional, NaN, Inf and above-safe-range now values all refuse. Source diff and DCO checked; returned technical CI succeeds, Dependabot skipped. No blocking finding in this normalization/range change; no live authority, dispatch or hardware claim. Reviewed with OpenAI Codex assistance.
What this changes
Contributor: Raghuvar Durga (@drk-ram)
Closes #568
In
src/agentrust_trace/intent_bridge.py:_bind_successor_observationvalidatedafter["observed_at"]with_integer_value(...)intoobserved_at(int), then returned the caller'safterdictionary unchanged. Whenafter["observed_at"]was a whole-valuedfloat(such as150.0),sign_successor_artifactemitted"observed_at": 150.0(float) in the returned artifact dictionary andverify_successor_artifactreturned a bound envelope whose"observed_at"remained150.0(float)._bind_successor_observationnow returns{**after, "observed_at": observed_at}without mutatingafterin place.verify_bridgevalidatedauthorization["authorized_at"]andauthorization["expires_at"]with_integer_value(...)intotimestamp(int), then discardedtimestampand returnedauthorizationwithfloatvalues when100.0or200.0was supplied.verify_bridgenow stores the normalizedintvalues in a shallow copynormalized_auth = dict(authorization)and returnsnormalized_authwithout mutating the caller'sbridge["authorization"]in place.verify_bridgenow boundsnowbyJCS_SAFE_INTEGER(2**53 - 1), raisingIntentBridgeError("now must be a non-negative integer Unix timestamp within the JCS safe-integer range")whennow > JCS_SAFE_INTEGER.Type of change
Spec section
Section 3.2.2 (integer-by-value and JCS safe-integer domain in the reference library's
intent_bridgemodule).Tests for a fix
tests/test_intent_bridge_integer_normalization.py:test_verify_bridge_normalizes_whole_float_timestamps_to_int_without_mutating_input(fails onmainwithAssertionError: assert <class 'float'> is int)test_sign_successor_artifact_normalizes_whole_float_observed_at_to_int(fails onmainwithAssertionError: assert <class 'float'> is int)test_verify_successor_artifact_normalizes_whole_float_observed_at_to_int(fails onmainwithAssertionError: assert <class 'float'> is int)test_verify_bridge_bounds_now_by_jcs_safe_integer(fails onmainwithAssertionError: Regex pattern did not matchbecausenow=JCS_SAFE_INTEGER + 1andnow=10**20were not rejected by thenowrange check)Validation commands run:
pytest tests/test_intent_bridge.py tests/test_intent_bridge_integer_normalization.py tests/test_successor_observation.py tests/test_integer_by_value.py tests/test_public_functions_raise_what_they_document.py: passed (510 passed)python tools/sweep_public_surface.py --strict: passed (89 parameters swept, 141 accepted junk values, 0 unfiled leak(s))python tools/review_bar.py --base origin/main --head HEAD: passed (7 fail on behaviour, 0 fail on a missing name or file, 0 pass or skip)python tools/check_dashes.py: passed (no dashes outside examples/, spec/trace-v0.1.md)ruff check src/agentrust_trace/intent_bridge.py tests/test_intent_bridge_integer_normalization.py: passed (All checks passed!)mypy --strict src/agentrust_trace/intent_bridge.py tests/test_intent_bridge_integer_normalization.py: passed (Success: no issues found in 2 source files)Checklist
git commit -s)CHANGELOG.mdupdated (for any normative change)<!-- CHANGED: #NNN: description -->in spec text