Skip to content

feat: add reconfirm_record per RFC 6762 §10.4#1772

Draft
bluetoothbot wants to merge 1 commit into
python-zeroconf:masterfrom
bluetoothbot:koan/implement-1413
Draft

feat: add reconfirm_record per RFC 6762 §10.4#1772
bluetoothbot wants to merge 1 commit into
python-zeroconf:masterfrom
bluetoothbot:koan/implement-1413

Conversation

@bluetoothbot
Copy link
Copy Markdown
Contributor

@bluetoothbot bluetoothbot commented May 21, 2026

Summary

Add Zeroconf.reconfirm_record / async_reconfirm_record (and the
AsyncZeroconf wrapper) so callers can hint to the cache that a record
may be stale — e.g. when an application-level connect to a discovered
service fails. Implements the cache-flush-on-failure mechanism described
in RFC 6762 §10.4.

Closes #1413

Behaviour

  • async_reconfirm_record(record) schedules a background task and
    returns True if accepted, False if the record is not in the cache
    or a reconfirmation is already in flight (dedupes by cache entry).
  • The background task re-queries the record at t=0, 1s, 3s
    the §5.2 doubling-interval pattern and "two or more queries" minimum
    from §10.4.
  • If no fresh copy of the record lands in the cache by t=10s, the
    record is force-expired and listeners (e.g. ServiceBrowser) are
    notified through the same goodbye path used for TTL-zero responses.
  • reconfirm_record is the threadsafe variant for callers off the
    event loop.

Constants live in const.py (_RECONFIRM_QUERY_INTERVALS_MS,
_RECONFIRM_TIMEOUT_MS) with RFC citations next to them; please do not
tighten without an interop note.

Changes

  • Zeroconf.async_reconfirm_record / Zeroconf.reconfirm_record in _core.py
  • AsyncZeroconf.async_reconfirm_record in asyncio.py
  • Background reconfirm pipeline in RecordManager (_handlers/record_manager.py)
    plus .pxd updates for the new cdef public dict _reconfirm_tasks
    and the new cpdef entry point
  • Timing constants in const.py
  • README section explaining when callers should use it
  • tests/test_reconfirm.py (9 tests) and a quick_reconfirm_timing
    fixture in conftest.py

Test plan

  • pytest tests/test_reconfirm.py (9 passed)
  • pytest tests/ (404 passed, 2 skipped) — no regressions
  • ruff check src/ tests/ — clean
  • Cython rebuild of _handlers/record_manager.py succeeds (no
    closures inside cpdef)

Quality Report

Changes: 8 files changed, 331 insertions(+), 6 deletions(-)

Code scan: clean

Tests: passed (4 PASSED)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Add Zeroconf.reconfirm_record / async_reconfirm_record and the
AsyncZeroconf wrapper so callers can hint that a cached record may be
stale when an application-level connect fails.

Re-queries the record at t=0/1s/3s (RFC 6762 §5.2 doubling intervals)
and flushes from the cache at t=10s when no fresh response lands.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.47%. Comparing base (cb81e67) to head (56f1495).

Files with missing lines Patch % Lines
src/zeroconf/_handlers/record_manager.py 82.81% 5 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1772      +/-   ##
==========================================
- Coverage   99.77%   99.47%   -0.31%     
==========================================
  Files          33       33              
  Lines        3536     3608      +72     
  Branches      498      511      +13     
==========================================
+ Hits         3528     3589      +61     
- Misses          5       10       +5     
- Partials        3        9       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 22, 2026

Merging this PR will not alter performance

✅ 14 untouched benchmarks


Comparing bluetoothbot:koan/implement-1413 (56f1495) with master (cb81e67)

Open in CodSpeed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC 6762/10.4 Cache Flush on Failure Indication

1 participant