feat(probeverdict): pure verdict logic for geolocation probe submissions - #415
Open
Ryanmello07 wants to merge 1 commit into
Open
feat(probeverdict): pure verdict logic for geolocation probe submissions#415Ryanmello07 wants to merge 1 commit into
Ryanmello07 wants to merge 1 commit into
Conversation
Turns a probe submission into verified / unverified / suspect from the
only two corroboration rules that need no external reference point:
absence of country consensus, and country instability inside a 24h
window.
Two omissions from Input are load-bearing and structural, not
oversights:
- There is no mmdb-derived country field. A probed country differing
from what the free mmdb would have said is the entire point of this
project, so with no field for it a caller cannot get the rule wrong.
- There are no RTT or coordinate fields. An RTT-distance floor was
designed and dropped before implementation: it needs a fixed
reference point for where the RTT was measured from, and
network_client_connection.connection_block exists precisely because
more than one such point can exist. A wrong reference point does not
fail safe -- it can flag an honest, correctly-placed provider as
suspect. suspect("rtt_impossible") therefore does not exist.
Both omissions are pinned by a reflection test over Input's field set,
since neither can be asserted behaviourally.
No I/O, no dependencies beyond time, so the package is testable
independent of the transport that produced the submission.
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.
New standalone
probeverdictpackage: pure decision logic, no I/O, no DB, no dependencies beyondtime. Turns a geolocation probe submission intoverified/unverified/suspect, decoupled entirely from the transport that produced the submission.Entirely new files — this applies to
mainwith zero conflicts. The branch is a clean cherry-pick ontoupstream/main(69ae7789); it addsprobeverdict/probeverdict.goandprobeverdict/probeverdict_test.goand touches no existing file, so nothing else in the repo can regress.Rules
Only the two corroboration rules that need no external reference point:
unverified/no_consensussuspect/unstable. Outside that window a changed country is a legitimate correction, not a flip-flop.Everything else verifies.
suspectverdicts are advisory — this package decides nothing about provider selection.Two omissions from
Inputthat are load-bearingNo mmdb-derived country field. A provider's egress country legitimately differs from where its control connection originates — that divergence is the entire point of egress geolocation, and treating it as suspicious would flag honest providers wholesale. Keeping the field off
Inputmakes the rule structural: a caller cannot get it wrong because there is nothing to pass.No RTT or coordinate fields, and no great-circle helper. An RTT-distance floor (light-speed minimum RTT for a claimed distance) was designed for this package and deliberately dropped before implementation. It needs a fixed reference point for where the RTT was measured from, and
network_client_connection.connection_blockexists precisely because more than one such point can exist. A single hardcoded origin is wrong for any provider measured against a different instance, and the error is not one-sided: a misplaced origin can flag an honest, correctly-placed provider assuspectrather than only loosening the check. Weighed against a check already defeatable by a provider willing to add artificial delay to its own latency, it was not worth carrying the reference-point problem.Verdict.Reasonnever takes the value"rtt_impossible".The package doc comment records both decisions inline so a future reader does not reintroduce them by accident.
Tests
5 tests, written before the implementation, all passing:
TestEvaluateNoConsensusIsUnverifiedTestEvaluateCountryFlipFlopIsSuspectTestEvaluateCountryChangeOutsideWindowIsVerifiedTestEvaluateMmdbDivergenceAloneIsNotSuspect— a clean first-time probe verifies regardless of what mmdb would have saidTestInputHasNoMmdbRttOrCoordinateFields— reflection overInput's field set, pinning both omissions aboveThe last is the guard with teeth: neither omission can be asserted behaviourally, since both are the absence of an input. Confirmed it fails as intended by temporarily adding an
ObservedRTTfield:Verification on this branch
go test ./probeverdict/ -v— 5/5 PASSgo build ./...— cleango vet ./...— cleangofmt -l probeverdict/— cleanThe package is pure Go with no DB, so the tests run standalone without a local stack.