Repository navigation
docs backend evidence maps MAP 15
AlexandreZanata edited this page Oct 26, 2026
·
1 revision
Current assessment: 2026-10-25 remediation supersedes earlier integration/acceptance claims. Historical evidence below is retained.
Status: LOCAL_DONE / INTEGRATION_PENDING Validation: PASS (Go + JVM + real-phone Room/native-layout/migration/worker instrumentation) Integration: INTEGRATION_PENDING
Tested tree: codex/map-ev-implementation plus the MAP-15 closure changes
below. Date: 2026-10-25. No map UI behavior was changed by the rework except
the downloads screen wiring; no ENGINE_GATE claim.
- Room schema 27 keeps only public map metadata:
map_generation(now withdata_version, the numeric native version directory) andmap_packagewith a composite(generation, package_id)key. Package binaries live outside Room.MIGRATION_26_27is append-only (ADD COLUMNwith an empty default); pre-existing rows count as unpublished until re-activated. -
MapManifestVerifierverifies the MAP-12 Ed25519 envelope, manifest SHA-256 and trustedkey_idbefore any row is written. The production path takes raw 32-byte pinned keys: platform-first via an X.509 wrapper, falling back to the owned Monocypher/BSD-2-Clause bridge on API 26. Unknown key ids, wrong key sizes and absent providers fail closed. No digest-only fallback. -
MonocypherEd25519is a small owned JNI bridge over vendored auditedmonocypher.c/monocypher-ed25519.c(Monocypher 4.0.2, BSD-2-Clause OR CC0-1.0, byte-identical to the pinned MAP-14 source). No cryptographic algorithm is reimplemented in Kotlin. - Distribution is configured, never invented:
MapDistributionConfig(base URL + region + pinned raw keys from build-time operational config) drivesMapDistribution.fetchEnvelope(1 MiB cap, HTTPS-only). Empty configuration shows the specific pendency (missingUrl/missingRegion/missingKeys, invalid keys flagged); no fake download button exists. -
MapPackageRepositorydownloads with HTTPRange/If-Range, keeps a.partfile for resume, enforces the signed size cap during the transfer, validatesContent-Rangeon resume (missing/mismatched range with a non-empty part fails closed), re-checks disk space when the server ignoresRangeand resends the whole file, and verifies exact size + SHA-256 before atomically publishing (publish-part+ rename; a crash can never expose a partial file). Oversize/digest/range failures delete the staged bytes; networkIOExceptionstays retryable and never becomes success. - Activation verifies every staged final file, requires every package
READYand a numericdata_version, publishes the verified bytes to the native<filesDir>/<dataVersion>/layout the pinned engine scans (flat files only; non-publishable paths fail closed), flips the Room generation under a mutex (re-verified inside), then reclaims: only orphan staging dirs, terminal inactive staging, other numeric version dirs and stale files. In-progress (PENDING/DOWNLOADING) staging is never deleted. A concurrent activation re-verifies under the mutex instead of corrupting state. - The prior active generation is preserved on any failure (failed B never
touches A's published files; open readers keep old bytes across an atomic
rename swap). Crash between publish and Room flip heals on the next
activate(idempotent re-publish). - A 32 MiB reserve is checked before starting a download; insufficient space fails without making a network request.
-
MapDownloadWorkeris a HiltCoroutineWorker: storage/digest/version failures are terminal, networkIOExceptionrequests WorkManager retry, and cancellation leaves the.partfile for the next run. An unsupported data version fails closed. No account-private table or route/favorite data is touched.MapDownloadSchedulerenqueues uniquemap-download-<generation>work withCONNECTED+ storage-not-low and exponential 30s backoff; inputs are generation + base URL only. - Public maps require no login. Account switch/logout never cancels or leaks private state into the download.
- Legacy (pre-layout, empty
data_version) active rows are repaired by a same-generation re-import, which keeps the active flag; any other active re-import is refused.
-
B-BR-MAP-ACTIVATE-ATOMIC-01: Activating a generation must be atomic across all package files in<nativeRoot>/<dataVersion>/and the Roommap_generationactive flip. All candidate.publish-partfiles are staged and SHA-256-verified before any live.mwmis touched; existing live files are backed up in<nativeRoot>/<dataVersion>/.rollback/prior to rename. If any file rename orstore.activatefails, or if the process terminates before Room commits the new generation, the rollback journal restores the previous active generation's exact native bytes without marking the previous generation corrupt or requiring re-download. -
B-BR-MAP-IO-BOUND-01: AllMapPackageRepositoryfile reads, copies, and SHA-256 computations execute onioDispatcher(Dispatchers.IO) with cooperative coroutine cancellation. UI availability polling (publishedState) reuses verified file stamps(length, lastModified, sampleSha256, fullSha256)after full verification at activation/first-read boundaries so multi-megabyte.mwmfiles are not re-hashed on the main thread or on every UI poll.MapDistribution.fetchEnvelopeenforces the 1 MiB ceiling while reading the response stream (even whenContent-Lengthis omitted) and cancels the underlying HTTP call on coroutine cancellation. -
BUC-MAP-15-02: Activate a multi-package generation and preserve/recover the previously active native generation across mid-set swap failure, Room commit failure, process crash/restart, concurrent activations, and active reader leases.
-
data/local/map/MapPackageEntities.kt,dao/MapPackageDao.kt,AnpFuelDatabasev27,MIGRATION_25_26,MIGRATION_26_27. -
data/map/MapManifestVerifier.kt(raw-keyverifyoverload + platform/X.509-first helper),Ed25519Verifier.kt,MonocypherEd25519.kt,MapDistributionKeys.kt(strictkeyid:b64parsing),MapDistribution.kt(bounded envelope fetch),MapPackageStore.kt,MapPackageRepository.kt(native layout publish, mutex-guarded activate + retention, hardened transfer). -
data/src/main/jni/: vendoredmonocypher/(byte-identical to/data/dev/src/comaps-4587b8ad/3party/monocypher, hashes inprovenance.json), owneded25519_bridge.c,CMakeLists.txtwith 16 KBmax-page-size=16384;data/build.gradle.ktsexternalNativeBuild plusMAP_DIST_BASE_URL/MAP_DIST_REGION/MAP_DIST_KEYSbuild config (empty by default = unconfigured). -
data/worker/MapDownloadWorker.ktandMapDownloadScheduler.kt,data/di/MapModule.kt(native root =filesDir, distribution config + distribution bindings). -
data/schemas/.../26.json,27.json. -
app/.../MapDownloadsViewModel.kt+MapDownloadsScreen.kt+MapAppModule.kt(WorkManager seam): check → envelope → verify → catalog/dependencies/size → explicit unique-work download with progress/cancel/retry → verified activation → observable published state. -
app/.../MapScreenViewModel.kt: no-package banner follows the real Room active generation.
Backend (Go, real stack):
-
go test ./internal/modules/mapdist/ -run 'TestCommittedKotlinFixture|TestDistribution'PASS: committedcontracts/testdata/map/dist-kotlin-v1loads (Loadverifies the real Go signature + package digests), unknown key ids are refused withErrUntrustedKey, wrong key bytes withErrBadSignature; pre-existingTestDistributionHandlerManifestAndRangeandTestDistributionRejectsTamperingAndUnsafePackagesstill PASS. - Local real HTTP server (
mapdist.Handlerover the committed fixture, temporary, removed after use): manifest 200, package 200 (4096 bytes, sha256 matches manifest),Range: bytes=4-→ 206 with exactContent-Range: bytes 4-2047/2047+ ETag = package sha256, unknown region/package → 404. The committed envelope'smanifest_sha256and the served package bytes were independently re-verified (curl + sha256).
JVM tests (:data:testDebugUnitTest, all green):
-
MapManifestVerifierTest: previous platform-path cases unchanged. -
MapManifestGoFixtureTest(new): the committed Go envelope verifies through the raw-key path; cloned key id, wrong key bytes, truncated signature and tampered manifest all fail closed; the Monocypher bridge is exercised with the same Go bytes where JNI is present and asserts fail-closed absence otherwise;parseMapKeysaccepts the pinned entry and refuses empty/duplicate/malformed/wrong-size configs. -
MapPackageRepositoryTest(7 cases, kept): legacy platform-key paths still green; 206 mocks now carry spec-compliantContent-Range. -
MapPublishTest(new, 13 cases): Go-signed fixture publishes exact bytes tonative/<version>/; failed B preserves published A; concurrent activations converge on one coherent generation; open readers keep old bytes across a same-path swap; partial publish heals on re-activation; oversize body fails closed without activation;Content-Rangemissing/mismatched fails closed and full resend recovers; wrong start fails; ignored-Range re-checks full-size space; unsupported version fails without touching native state; terminal staging recycled while in-progress/pending kept; legacy blank-version rows repair on same-generation re-import;checkResumeRangeunit cases. -
MapPackageRecoveryTest(5 cases, kept): resume after process death, corrupt final, concurrent readers, cancellation, no private state. -
Migration25To26UnitTest: untouched, green.
Real phone instrumentation through adb (2311DRK48G, Android 16 / API 36):
./gradlew :data:connectedDebugAndroidTest \
-Pandroid.testInstrumentationRunnerArguments.class=com.anpfuel.data.map.MonocypherEd25519InstrumentedTest
# 1/1 PASS (Go seed 00..1f vectors, mutations, sizes, platform agreement)
./gradlew :data:connectedDebugAndroidTest \
-Pandroid.testInstrumentationRunnerArguments.class=com.anpfuel.data.local.map.V25ToV26DatabaseMigrationTest
# 2/2 PASS (18→26 preserves rows, rollback recovers)
./gradlew :data:connectedDebugAndroidTest \
-Pandroid.testInstrumentationRunnerArguments.class=com.anpfuel.data.local.map.V26ToV27DatabaseMigrationTest
# 1/1 PASS (26→27 preserves rows, data_version defaults to "")
./gradlew :data:connectedDebugAndroidTest \
-Pandroid.testInstrumentationRunnerArguments.class=com.anpfuel.data.worker.MapDownloadWorkerTest
# 7/7 PASS (terminal storage/digest/version failures, retry on IOException,
# success activates, missing inputs fail, scheduler constraints)
./gradlew :data:connectedDebugAndroidTest \
-Pandroid.testInstrumentationRunnerArguments.class=com.anpfuel.data.map.MapNativeLayoutInstrumentedTest
# 1/1 PASS (device-signed envelope verifies via raw-key path, exact bytes
# land in files/2601/, restart keeps Room+filesystem coherent, open reader
# survives the atomic same-path swap, no .part leftovers)
./gradlew :data:connectedDebugAndroidTest \
-Pandroid.testInstrumentationRunnerArguments.class=com.anpfuel.data.map.MapPersistenceInstrumentedTest
# 1/1 PASS (Room + platform Ed25519 device proof retained)- Staging probe 2026-10-25:
GET /v1/map/regions/{world,brazil,brazil-parana-east,test-rect}/manifestand/v1/map/assertions?limit=1all return 404 onhttps://teste.abastevo.com.br→ operational distribution is not configured there, so the app shows the pending state. No host/key was invented to work around this. - App JVM:
MapScreenViewModelTest(active/no-package, source switch, retry) andMapDownloadsViewModelTest(unconfigured pendency, offline retryable, catalog check, enqueue/cancel, failure retry, activateActive, same-generation check) green.
- Keys/base URL/region default to empty (unconfigured) in this worktree: no
download can start until operational values are supplied via
-PmapDistBaseUrl/-PmapDistRegion/-PmapDistKeys. Publishing those values is an operational step, not part of this change. - Two full-suite observations on 2311DRK48G are environmental and outside
MAP-15:
RealImageOcrDeviceTestrequires a manually pushed private corpus (run-asstep named in its own assertion), andDatabasePocGateTest.databaseFileSizeUnderFifteenMegabytesAfterOneWeekStationImportreports exactly 15 MB on this device while an empty-table schema delta cannot move megabytes (physical reasoning recorded; typical budget is device/storage-sensitive). The two migration-chain tests that surfaced as missing-path (CatalogMigration17To18Test,CommunityCacheMigration16To17Test) were repaired in this batch with the full chain to 27. - No map UI behavior change beyond the downloads screen wiring; no ENGINE_GATE re-claim (the native side is proven by MAP-14 over the identical layout).
- Home
- Roadmap
- docs-README
- docs-android-build
- docs-android-design-system
- docs-android-forum
- docs-android-games
- docs-android-map-engine
- docs-android-navigation
- docs-android-ocr-image
- docs-android-ocr-live-framing
- docs-android-premium-area
- docs-android-premium-integration
- docs-android-release
- docs-android-ui-containers
- docs-architecture-android-stack
- docs-architecture-android
- docs-architecture-backend
- docs-architecture-data-sources
- docs-architecture-overview
- docs-architecture-sources-ev-research
- docs-architecture-sources-national-limits
- docs-architecture-sources-national-stations
- docs-architecture-sources-register
- docs-assets-app-tutorial-CAPTURE_CONTRACT
- docs-assets-app-tutorial-FABLE_LANDING_POLISH_PROMPT
- docs-assets-app-tutorial-README
- docs-assets-attribution
- docs-assets-brand-README
- docs-assets-flags-ATTRIBUTION
- docs-assets-fuel-icons-README
- docs-assets-games-fuel-v1-README
- docs-assets-home-icons-README
- docs-assets-landing-fleet-android-20261012-BRIEF
- docs-assets-landing-hero-20261011-BRIEF
- docs-assets-landing-illustrated-20261012-BRIEF
- docs-assets-landing-illustrated-20261012-README
- docs-assets-landing-minimal-20261012-BRIEF
- docs-assets-landing-open-data-20261026-BRIEF
- docs-assets-landing-redesign-20261011-PREPARATION_EVIDENCE
- docs-assets-landing-redesign-20261011-README
- docs-assets-landing-redesign-20261011-REFERENCE_BRIEF
- docs-assets-landing-sync-20261012-BRIEF
- docs-assets-map-icons-README
- docs-backend-anp-ingestion
- docs-backend-api
- docs-backend-community-pricing
- docs-backend-data-model
- docs-backend-domain-model
- docs-backend-driver-private-data
- docs-backend-forum-architecture
- docs-backend-forum-bulletins
- docs-backend-forum-sources
- docs-backend-payments-provider-admission
- docs-backend-payments-provider-register
- docs-backend-photos-capture
- docs-backend-photos-subset-submission
- docs-backend-premium-api
- docs-backend-premium-cloud-protocol
- docs-backend-testing
- docs-backend-toolchain
- docs-brand-app-icons
- docs-brand-identity
- docs-decisions-001-kotlin-compose-stack
- docs-decisions-002-price-import-immutability
- docs-decisions-003-nominatim-reverse-geocode
- docs-decisions-005-modular-monolith-and-postgresql
- docs-decisions-006-official-catalog-and-exact-contracts
- docs-decisions-007-anonymous-proof-of-possession
- docs-decisions-008-privacy-and-retention
- docs-decisions-009-community-consensus-and-projections
- docs-decisions-010-private-object-evidence
- docs-decisions-012-licensing-and-hosted-business
- docs-decisions-015-kotlin-multiplatform-shared-domain
- docs-decisions-016-android-commercial-community-ios-deferred
- docs-decisions-017-station-profile-and-verified-representation
- docs-decisions-021-community-first-contribution
- docs-decisions-022-comaps-derived-native-map-engine
- docs-decisions-023-admin-suite-granted-tiers-contributors
- docs-decisions-025-private-abastevo-empresas-organization-boundary
- docs-decisions-026-multilingual-public-site
- docs-decisions-027-ai-reviewed-landing-translations
- docs-decisions-028-ai-reviewed-portal-translations
- docs-decisions-README
- docs-enterprise-README
- docs-enterprise-architecture
- docs-enterprise-backlog-INDEX
- docs-enterprise-backlog-ep00-governance
- docs-enterprise-backlog-ep01-platform
- docs-enterprise-backlog-ep02-organizations
- docs-enterprise-backlog-ep03-identity-access
- docs-enterprise-backlog-ep04-sync
- docs-enterprise-backlog-ep05-fleet-meters
- docs-enterprise-backlog-ep06-trips
- docs-enterprise-backlog-ep07-gps-navigation
- docs-enterprise-backlog-ep08-fuelings
- docs-enterprise-backlog-ep09-documents
- docs-enterprise-backlog-ep10-expenses-finance
- docs-enterprise-backlog-ep11-maintenance
- docs-enterprise-backlog-ep12-fuel-stock
- docs-enterprise-backlog-ep13-intelligence
- docs-enterprise-backlog-ep14-station-claims
- docs-enterprise-backlog-ep15-station-commerce
- docs-enterprise-backlog-ep16-subscriptions
- docs-enterprise-backlog-ep17-data
- docs-enterprise-backlog-ep18-imports-notifications-integrations
- docs-enterprise-backlog-ep19-back-office
- docs-enterprise-backlog-ep20-release
- docs-enterprise-business-rules
- docs-enterprise-contract
- docs-enterprise-conventions
- docs-enterprise-data-offering
- docs-enterprise-decisions
- docs-enterprise-domain-model
- docs-enterprise-glossary
- docs-enterprise-journeys
- docs-enterprise-modules-back-office
- docs-enterprise-modules-data
- docs-enterprise-modules-documents
- docs-enterprise-modules-expenses-finance
- docs-enterprise-modules-fleet
- docs-enterprise-modules-fuel-stock
- docs-enterprise-modules-fuelings
- docs-enterprise-modules-gps-navigation
- docs-enterprise-modules-identity
- docs-enterprise-modules-imports-notifications-integrations
- docs-enterprise-modules-intelligence
- docs-enterprise-modules-maintenance
- docs-enterprise-modules-organizations
- docs-enterprise-modules-station-claims
- docs-enterprise-modules-station-commerce
- docs-enterprise-modules-subscriptions
- docs-enterprise-modules-trips
- docs-enterprise-offline-sync
- docs-enterprise-permissions
- docs-enterprise-portal-routes
- docs-enterprise-privacy-security
- docs-enterprise-product-vision
- docs-enterprise-source-admission
- docs-enterprise-state-model
- docs-enterprise-testing
- docs-enterprise-ux-app
- docs-enterprise-ux-web
- docs-operations-README
- docs-operations-backup
- docs-operations-deploy-agent
- docs-operations-dou-editions
- docs-operations-edge-cache
- docs-operations-enterprise-activation
- docs-operations-map-static-overlay
- docs-operations-moderation-feedback
- docs-operations-moderation-profiles
- docs-operations-monitoring
- docs-operations-operator-access
- docs-operations-payment-providers-guide
- docs-operations-payments
- docs-operations-premium-billing
- docs-operations-recovery
- docs-operations-registry-daily-sync
- docs-operations-registry-runs
- docs-product-README
- docs-product-admin-tiers
- docs-product-community-community-first
- docs-product-community-experience
- docs-product-community-metrics
- docs-product-community-moderation
- docs-product-community-safety
- docs-product-community-terms-pt-br
- docs-product-driver-suite-README
- docs-product-driver-suite-android-state
- docs-product-driver-suite-cloud-sync
- docs-product-driver-suite-cost-profiles-and-maintenance
- docs-product-driver-suite-driver-model-and-earnings
- docs-product-driver-suite-foundation-decisions
- docs-product-driver-suite-gps-lifecycle
- docs-product-driver-suite-mobile-hub
- docs-product-driver-suite-odometer-review
- docs-product-driver-suite-outbox-wire
- docs-product-driver-suite-quick-refuel
- docs-product-driver-suite-reports
- docs-product-driver-suite-shifts-and-distance
- docs-product-driver-suite-signed-commands
- docs-product-ev-README
- docs-product-ev-charging-stop-planner
- docs-product-ev-energy-model
- docs-product-ev-financial-method
- docs-product-ev-journey-ui
- docs-product-ev-preparation
- docs-product-ev-typed-data
- docs-product-exploration
- docs-product-forum-contract
- docs-product-forum-policies
- docs-product-glossary
- docs-product-landing-content
- docs-product-landing-guides
- docs-product-landing-organic-growth-i18n-plan
- docs-product-landing-organic-traffic-expansion-plan
- docs-product-licensing
- docs-product-map-discovery
- docs-product-map-favorites-and-trips
- docs-product-map-reports-routing-guidance
- docs-product-notification-content
- docs-product-official-prices
- docs-product-open-source-business
- docs-product-overview
- docs-product-payments-README
- docs-product-payments-offer-policy
- docs-product-premium-README
- docs-product-premium-financial-method
- docs-product-premium-source-policy
- docs-product-stations-catalog
- docs-product-stations-fuel-feedback
- docs-product-stations-fuel-quality
- docs-product-stations-identity-and-ev-catalog
- docs-product-stations-profile-contract
- docs-product-stations-profile-representation
- docs-product-stations-registry-sources
- docs-product-vehicle-registration
- docs-product-vehicles-and-occurrences
- docs-security-android-terms-acceptance
- docs-security-free-account-access
- docs-security-identity-profile
- docs-security-media-location-policy
- docs-security-privacy-notice
- docs-security-privacy-policy
- docs-security-retention
- docs-security-risks
- docs-security-security-privacy
- docs-store-README
- docs-store-play-readiness
- docs-store-play-store-listing
- docs-store-ugc-safety
Source: AlexandreZanata/brazil-fuel-prices @ 9c7752ddd09ff1241fda4007f0e281d1a1dbab43