Repository navigation
Give the AI router one injectable clock and move its cooldown tests by hand - #527
Merged
Merged
Conversation
…y hand Every park, availability cache window and per-minute window in the router reads one clock, the system's monotonic clock unless a test passes another through AiRouter::with_clock. The two cooldown tests advance a manual clock instead of sleeping past a 200 ms park, and the park test now checks both sides of the reset: still parked 1 ms before it, free at it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #437
Summary
hide-ai/src/router.rscooldown test 2개의 #437 allow를 없앱니다. 200ms park가 지나도록 250ms 자던 것을, 시계를 손으로 옮기는 것으로 바꿨습니다.AiRouter에 시계 하나(now)를 두고, park, availability cache 창, 분당 창, 소요 시간이 모두 그 시계를 읽습니다. 기본값은 시스템 monotonic clock(Instant::now)이고, test만with_clock(#[cfg(test)], 비공개)으로 다른 시계를 줍니다. 공개 API는 바뀌지 않습니다.docs/TESTING.md규칙 4에 "여러 곳에서 시간을 읽는 component는 시계 하나를 받는다"는 예로AiRouter::with_clock을 적었습니다.Review
now필드)로 두고 기본값은 실제 시계입니다.elapsed()호출도 같은 시계의saturating_duration_since로 바꿨습니다. 실제 시계에서는 같은 값입니다.hide-ai/src/router.rs-Instant::now()를 직접 읽는 곳이 남으면 그 창만 test 시계를 따르지 않습니다. 지금은 router 안에 남은 곳이 없습니다.Evidence
wait / 2로 줄이자 park test가 199ms 단정에서 실패. 되돌리면 통과. 옛 test(250ms 뒤 풀림만 봄)는 이 결함에서도 통과했습니다.verify-cargo.sh clippy -p hide-ai --all-targets -D warnings,fmt, router test 22개 통과(macOS).yes4개 +taskpolicy -b아래 수정 전과 후 binary를 번갈아 30번씩: 30/30 대 30/30(매 회 2개 실행). 수정 전도 흔들리지 않아 고친 위험은 읽기로 판단한 위험입니다(250ms sleep이 200ms park보다 길다는 가정, 그리고 park가 일찍 끝나는 결함을 놓치는 거짓 통과).