clone

an offline map explorer where each world, from a game map to a city's open data, ships as one .atlas file

feat: let a newer policy supersede builds of the same capture

Dami committed 58fe998
Two builds of one capture share a creation time, and the registry broke
the tie by stamp -- an arbitrary winner, so a rebuild under a changed
rule could lose to the build it was meant to replace, and superseded
builds had to be pruned by hand. The version now carries a policy
revision: bumped when generate's rules change in a way that should
reach every library, decisive between builds of one capture, and
still outweighed by any newer capture. Bundles from before the field
read as revision zero and lose to any revised build, which retires the
hand-pruning.
commit
58fe99834d99b705e93c911f4064477aab1250d5
parent
e9ecf815892a1580fe272aebb0ebdc7360ef8a69
author
Dami <dami.etoile@gmail.com>
5 files changed, +52 -3
Minternal/bundle/bundle.go5+++++
Minternal/bundle/bundle_test.go26++++++++++++++++++++++++++
Minternal/bundle/bundletest/bundletest.go3++-
Minternal/bundle/stamp.go8++++++--
Mtools/generate/bundles.go13+++++++++++++
M internal/bundle/bundle.go +5 -0
M internal/bundle/bundle_test.go +26 -0
M internal/bundle/bundletest/bundletest.go +2 -1
M internal/bundle/stamp.go +6 -2
M tools/generate/bundles.go +13 -0
@@ -13,6 +13,13 @@ import (
1313 "github.com/FelineStateMachine/atlas/internal/bundle"1414 )1515 16+// policyRevision orders builds of the same capture. The data has not moved17+// between them, but what this tool makes of a capture has -- a merge rule, a18+// kept field, a dropped category -- and among equal captures the registry19+// serves the highest revision. Bump it when a policy change should supersede20+// the builds already in every library.21+const policyRevision = 122+1623 // writeBundles packs each game into its own .atlas file, named by game,1724 // capture day, and stamp. The directory is a registry, not a mirror: a new1825 // capture lands beside the builds before it rather than over them, nothing
@@ -54,6 +61,7 @@ func writeGameBundle(
5461 Format: bundle.Format,5562 FormatVersion: bundle.FormatVersion,5663 Game: bundle.Game{Slug: game.Slug, Title: game.Title},64+ Version: bundle.Version{Revision: policyRevision},5765 TileGrid: bundle.TileGrid{5866 SourceZoom: grid.SourceZoom,5967 FirstTile: grid.FirstTile,
@@ -208,6 +216,7 @@ type registryVersion struct {
208216 File string `json:"file"`209217 Stamp string `json:"stamp"`210218 CreatedAt string `json:"createdAt"`219+ Revision int `json:"revision,omitempty"`211220 Size int64 `json:"size"`212221 Maps int `json:"maps"`213222 }
@@ -256,6 +265,7 @@ func writeRegistryIndex(bundleDir string) error {
256265 File: filepath.Base(path),257266 Stamp: manifest.Version.Stamp,258267 CreatedAt: manifest.Version.CreatedAt,268+ Revision: manifest.Version.Revision,259269 Size: size,260270 Maps: len(manifest.Maps),261271 })
@@ -267,6 +277,9 @@ func writeRegistryIndex(bundleDir string) error {
267277 if entry.Versions[i].CreatedAt != entry.Versions[j].CreatedAt {268278 return entry.Versions[i].CreatedAt > entry.Versions[j].CreatedAt269279 }280+ if entry.Versions[i].Revision != entry.Versions[j].Revision {281+ return entry.Versions[i].Revision > entry.Versions[j].Revision282+ }270283 return entry.Versions[i].Stamp > entry.Versions[j].Stamp271284 })272285 listed = append(listed, *entry)