Repository navigation
Commit 0d5473c
fix: compare in-memory task timestamps numerically (a2aproject#1233)
# Description
Fix timestamp filtering and descending ordering in
`InMemoryTaskStore.list()`. Comparing `ToJsonString()` values
lexicographically reverses chronological order when fractional-second
precision differs. For example, `2025-01-01T00:00:00.123Z` incorrectly
passes a filter whose threshold is `2025-01-01T00:00:00.123000001Z`,
despite being one nanosecond earlier. The same comparison also produces
incorrectly ordered pages.
Compare integer nanoseconds using `ToNanoseconds()` for both filtering
and sorting. Preserve the inclusive filter boundary, descending ID
tie-breaker, and placement of tasks without timestamps after timestamped
tasks.
[A2A specification §5.6.1,
Timestamps](https://a2a-protocol.org/latest/specification/#561-timestamps)
states: “Millisecond precision SHOULD be used where available”. It also
specifies `google.protobuf.Timestamp`, whose representation contains
seconds and nanoseconds, and permits omitted fractional seconds. Numeric
comparison handles these precisions without discarding sub-millisecond
information.
Add 15 regression cases covering seconds, milliseconds, microseconds,
nanoseconds, equal timestamps, second boundaries, pagination, ID
tie-breaking, absent timestamps/status, and timestamps before/at the
Unix epoch. Before the fix, 11 cases fail and four pass; after the fix,
all 35 in-memory task store tests pass.
Validation on Python 3.10 with PostgreSQL 15 and MySQL 8:
- `./scripts/lint.sh`: Ruff check/format and ty passed (three existing
unused-ignore warnings outside this change).
- `uv run pytest`: 2,092 passed, 3 xfailed, 1 xpassed. The xfail/xpass
cases are already marked for a2aproject#869.
- `uv run pytest --cov=src --cov-report=term-missing
--cov-fail-under=88`: same test results, 93.17% coverage.
- JSCPD: 2.61% duplication, below the 3% threshold.
- Built the wheel and ran `tests.install_smoke` in six clean
environments: base, http-server, fastapi, grpc, telemetry, and sql all
passed.
Local transport checks used proxy exclusions for loopback addresses.
Cross-version `uv --with` environments were prepared before the full
runs to keep dependency downloads outside server-startup timeouts.
- [x] Follow the CONTRIBUTING guide: feature branch based on current
upstream main.
- [x] Conventional Commit title: `fix: compare in-memory task timestamps
numerically`.
- [x] Tests and linters pass.
- [x] Protocol reference included above; no public API changes.
Co-authored-by: Gatsuk Andrey <GatsukAS@zdrav.mos.ru>
Co-authored-by: mykytanetipa <mykytanetipa@google.com>1 parent f3ac824 commit 0d5473c
2 files changed
Lines changed: 91 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
| 96 | + | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | | - | |
| 105 | + | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
260 | 345 | | |
261 | 346 | | |
262 | 347 | | |
| |||
0 commit comments