C.W.K.
Stream
Lesson 02 of 04 · published

Version Sniffing 위에 Feature Detection

~20 min · feature-detection, capabilities, sniffing

Level 0호기심 많은 독자
0 XP0/48 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

날짜 revision 있어도 맞는 mental model 은 feature detection, version sniffing 아님. Handshake 의 capabilities object 가 — 다른 쪽이 뭘 지원하는지 — source of truth. Revision 번호로 분기 ('if version >= 2025-11-25 then …') 는 fragile; 광고된 capability 로 분기 ('if 'sampling' in capabilities then …') 는 모든 revision 살아남음.

가장 자주 나오는 곳 — transitional feature. Async task 가 2025-11-25 revision 에 도착; long-running tool 호출하고 싶은 host 는 — async path 고르기 전에 — server 가 asyncTasks capability 광고하는지 확인. Async task 알지만 현재 deployment 에서 못 돌리는 server 는 — 광고 안 하면 됨; client 가 deployment 사정 모르고 적응.

같은 모양이 client capability 에도. Sampling 쓰고 싶은 server 는 — sampling request 보내기 전에 — host 가 sampling 광고했는지 MUST 확인. 없이 보내면 protocol 위반; host 가 connection drop 가능. Capability object 를 feature bitmap 처럼, version 번호를 audit trail 처럼 다뤄.

Code

Feature detection 분기·python
init = await session.initialize()
caps = init.capabilities

# 맞음 — 광고된 capability 로 분기
if caps.get("logging"):
    await session.set_logging_level("info")

# 맞음 — extension 존재로 분기 (async task 는 2025-11-25 추가지만,
# 아무도 날짜 hard-code 안 해도 feature-detection 동작)
if caps.get("experimental", {}).get("asyncTasks"):
    return await call_async(...)
else:
    return await call_sync(...)
잘못 — version sniff·python
# 피해 — server 가 backport 하거나 feature skip 하면 fragile
if init.protocolVersion >= "2025-11-25":
    return await call_async(...)

External links

Exercise

Client/server 코드에서 날짜나 version 번호 string 비교 ('2025-11-25', '>=' 등) 검색해 capability 검사로 교체. 대부분 version-sniffing 코드는 더 쉬운 길 skip 한 feature-detection 일 뿐.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.