Skip to content

heronin: the server hands out cached map tiles - #43

Merged
fizzy-pm[bot] merged 1 commit into
mainfrom
heronin/tile-proxy
Nov 12, 2026
Merged

fizzy-pm[bot] merged 1 commit into
mainfrom
heronin/tile-proxy

Conversation

@fizzy-windows

@fizzy-windows fizzy-windows Bot commented Nov 12, 2026

Copy link
Copy Markdown

heronin: the server hands out cached map tiles

Part of fizzyedit/work#1210

In plain words

Heronin can now hand out map tiles from OpenStreetMap and keep a local copy for thirty days. Repeated requests can use that copy without contacting OpenStreetMap again.

What changes

  • Map tiles follow the existing sign-in requirement and accept GET requests.
  • Successful downloads are saved atomically; missing tiles and failed downloads are never saved.
  • Downloads and cached reads are limited to 256 KB.
        if (upstream.status == .not_found) return .missing;
        if (upstream.status != .ok) return .unavailable;
        try cwd.createDirPath(self.io, std.fs.path.dirname(path).?);
        var file = try cwd.createFileAtomic(self.io, path, .{ .replace = true });
        defer file.deinit(self.io);
        try file.file.writeStreamingAll(self.io, upstream.body);
        try file.replace(self.io);

What you will notice

Nothing visible: internal server support that makes cached map tiles available for the later Map tab work.

How we know it works

Four new tests check valid and invalid tile paths, downloading and reusing a cached tile, expiry after thirty days, failures that leave no file, and HTTP responses with the required headers. The existing sign-in test now checks that a tile request without a session is refused. All six required gates pass. A real OpenStreetMap fetch remains UNVERIFIED.

How this serves fizzy

This supports fizzy's platform goal by giving map features a reusable server capability for fetching and caching tiles.

For agents: technical summary

Goal

Serve individual OpenStreetMap tiles through Heronin with a thirty-day disk cache.

What changed and why

Added strict tile-path parsing, a recording-fetch seam, bounded upstream reads with redirects refused and an identifying User-Agent, atomic cache writes, and the authenticated GET route. Main stores tiles under HERONIN_DATA/tiles or ./tiles.

Budget: ADDED non-test lines = 70 (19 in the tracked diff plus 51 lines in the new non-test file), cap 110. Added+deleted code lines across all four allowed files, including tests = 168 (22+7 tracked plus 51+88 new), cap 260. Counts use git diff --numstat HEAD plus line counts of untracked source files; requested PR/report artifacts are separate.

How it was verified

New tests in server/tiles_tests.zig:

  • tile parse exact decimal paths and bounds
  • tile cache miss hit and thirty day expiry
  • tile missing and failed fetch are never stored
  • tile route PNG headers invalid method and unconfigured cache

Updated test in server/server_tests.zig:

  • agent routes: both, 409 without yours, saved key kept and never sent, sign-in needed checks the tile 401 response.

Gates:

  • zig fmt --check build.zig tools tests/check_public model app server: pass.
  • zig build: 55/55 steps succeeded.
  • zig build server: 3/3 steps succeeded.
  • zig build test: 54/54 steps succeeded; rerun executed 29/29 tests successfully, including all 26 server tests; other suites cached.
  • zig build web: 55/55 steps succeeded.
  • zig build check-public: 3/3 steps succeeded.

git diff --check also passes. Tests use in-process fetch fakes and HTTP readers/writers.

Not done / follow-ups

UNVERIFIED: a real fetch from tile.openstreetmap.org. After merge, Ops checks one tile on pop-os using curl against the local server with a session. App and Map tab work remains separate.

Part of fizzyedit/work#1210

Signed-off-by: fizzy foxnne-desktop-codex-2 <slot+foxnne-desktop-codex-2@fizzy.invalid>
@fizzy-pm
fizzy-pm Bot merged commit 0f63e4b into main Nov 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants