Repository navigation
feat(scopes): vendored meshguide scope engine, per-position table and a neutral verdict (#1035 M1) - #1101
Conversation
…nd a neutral verdict (#1035 M1) Vendor meshguide.dk lib/scopes.js, regions.json and its Fyn/Sjælland postnumre unmodified at 9a5d7f5 (WTFPL, hashes in README.md). Generate offline the per-DAGI-postnummer table (postal scopes only where meshguide has them; street postcodes grouped) plus a conformance golden from the JS engine. internal/scopeguide: O(1) lookup, region hit test identical to scopes.js, and a pure, info-only Compare for repeaters and rooms. Relates to #1035. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first CI run measured 23 ms for 5k Recommend+Compare (3.8 ms locally) against a hard 20 ms. Log the 20 ms target and fail only at 100 ms, like the share-card renderers, and add load-independent proof: fixed allocs per call (Recommend <= 6, Compare <= 16) and an O(1) postnummer lookup ratio against a one-entry map. Compare no longer builds per-node sets. Relates to #1035. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rapport — CS-Macmini PR#1101 #1035 — head 7d71231Status: #1035 M1 is complete as a draft. All required CI jobs on Evidence tags: [T] test (red before, green after), [A] analysis or a measurement in this report, [K] CI. Requirements
Measurements [A]/[K]
Local runs [T]
Invariants [A]
CI per job [K]Run 1,
Run 2,
No reruns. Choices made without an owner answer [A]
Remaining
|
Review — CS-Minimax PR#1101 — head 7d71231Dom: APPROVE with nits Read-only review against my M0 research and the owner decisions of 2026-12-02 on #1035. I tested the head ( Evidence tags: [T] a test I ran, [A] analysis or my own measurement, [K] CI. Findings
The points I was asked to check
Tests and mutantsRuns on the merged tree:
My own mutants:
CI per job [K]Run
The earlier run What I did not verify
🤖 Generated with Claude Code |
Relates to #1035
What
#1035 M1, following the M0 plan and the owner decisions of 2026-12-02. This PR adds meshguide.dk's scope rules as a pinned, vendored engine, an offline-generated per-postnummer table, and a pure Go lookup plus a neutral verdict. It has no UI and no API route: M2 adds the node page and M3 the Scope Audit "Location" view.
internal/scopeguide/meshguide/containslib/scopes.js,regions.json,postnumre/{index,fyn,sjaelland}.jsonand the WTFPLLICENSEfromgithub.com/twinoak/meshguide.dkat9a5d7f5fd210d863067f87581e75eaf562327d71. ItsREADME.mdnames the commit and the sha256 of each file..gitattributesmarks the directory-text, so the bytes stay hash-exact. No message is sent to meshguide (decision 1).scripts/gen-scope-guide.mjsis run by hand and its output is checked in. It imports the vendoredscopes.jsand writes two files:internal/scopeguide/scopeguide-table.jsonhas one row per DAGI postnummer, 605 rows in all. The 484 Copenhagen street postcodes are grouped under 1050 K, 1550 V and 1800 Frb C, exactly likecmd/server/dagi.go(decision 3). Each row carries the postal scopes meshguide recommends there. The header carries the commit, the file hashes, the DAGI asset hash, the scope universe (428) and the firmware cap.internal/scopeguide/testdata/conformance.jsonholds meshguide's ownscopesForPoint()output for 3,918 grid and named points over Denmark.--checkfails when the checked-in files differ from a regeneration. The generator also fails if any point would need more than 31 scopes (MAX_REGION_ENTRIES32, less*).internal/scopeguide: its own module, embedded assets, parsed once.Load()andRecommend(lat, lon, postnummer) Recommendationgive the recommended default (dk) and the allow-list in meshguide's order: fixed, then regions, then postal. Each scope carries aKind.Postnummer(code)is the shared lookup for Home: "Find your area" by postnummer #1039.RegionHits,IsMeshguideScopeandParseListround out the lookup side.Compare(rec, Node) Verdictis pure.map[string]interface{}.Plan / design choices
eu,europe,dkand its region hits.scopesFor), so they are exact per row. Adding DAGI geometry would only add DAGI-derived neighbours meshguide.dk does not show. For example, Hillerød would gaindk29, which decision 4 rules out. So the generator reads no DAGI geometry: DAGI supplies only the key space (codes, names, street groups). A test pins that 3400 Hillerød has nodk29.scopes.js, operation for operation, behind a bbox prefilter. The conformance golden pins that Go matches the JS engine on all 3,918 points: region hits in order, and the full scope list.se12/oresundtherefore get no verdict.none(no scoped advert, or the firmware's*sentinel),undecoded("cannot be decoded": a scoped advert whose name this instance does not know, decision 9),recommended(dk),in_list(a scope recommended for this position),other_meshguide(a meshguide scope recommended elsewhere) andnot_meshguide.Listed,NotListed(each with its kind: fixed, region or postal),OtherMeshguide,NotMeshguideandWildcard.#and with exact case (#DK≠dk), as the firmware does.notApplicable: "role".DefaultUndecodedandConfiguredReportedas inputs.Tests
test-1035-scope-guide.js(intest-all.sh) checks:-textattribute, and meshguide's own point fixtures on the vendored engine;--checkpasses;internal/scopeguide:regions.json, the spot checks throughRecommend, outside Denmark, thePostnummerlookup and street groups, the conformance golden, the universe,ParseListandLoadrunning once;#dk, a covering local region or postal scope, a neighbour prefix layer, a neighbour postnummer, another region,#dk2100in Frederiksberg, an unknown name,#DK, none,*, undecoded;dk, without a covering region scope, with postal gaps, with other or unknown names, empty or wildcard;TestRecommendCompare5kWithinBudgettimesRecommend+Comparefor 5,000 nodes against the M0 20 ms target. The target is logged and only a 100 ms limit fails, outside-race, the same pattern as the share-card renderers.TestRecommendCompareAllocscaps allocations per call (Recommend≤ 6, measured 5;Compare≤ 16, measured 13).TestPostnummerLookupConstantTimeasserts that the postnummer lookup costs < 10x a one-entry map lookup in the same process; it measures about 3.5x, while a linear scan would be about 100x.BenchmarkRecommendruns at 275 ns/op. The lookup is one map hit plus a bbox-prefiltered hit test over 40 polygons, so it is O(1) in the node count.TestGuideMemoryBoundedmeasures the parsed guide at about 215 KB and asserts < 1 MiB. It holds 605 rows, 484 aliases, 40 regions and 428 universe names. The 845 KB of meshguide postnumre are generator-only and never embedded.deploy.ymlrunsinternal/scopeguide(go vet+go test -race) next tointernal/regions, and prints the perf, allocation, lookup, memory and conformance lines. The fork guards are unchanged.Config / customizer (rule 8)
None in M1. The roles checked are hard-coded, as M0 planned.
scopeCheck.enabled,scopeCheck.publicList, the report max age and the meshguide link come in M4.🤖 Generated with Claude Code