Repository navigation
Make Foundry sync hold up: reconnects, journals, kits, maps and player requests - #314
Merged
Merged
Conversation
Fixes found by reading the whole module and running the two-sided bench:
- A socket replaced by Save settings no longer clears or reconnects the
new one when its close arrives late (stale handlers now check they are
still the current socket).
- Players no longer get the status dot: it always read disconnected and
clicking it opened a keyless socket that retried every 30 seconds.
- Mentions of pages a player can't open show "a hidden page", not the name.
- Text before the first heading goes back to Chronicle without a sync-made
"Overview"/"Content" heading; page names in added headings are escaped.
- An identity item (kit, ancestry) the GM swapped in Foundry is left alone
until Chronicle's pick changes; the picks last applied are kept on the
actor.
- A map's own picture is copied into the world through PictureStore, since
Chronicle's signed links expire after 15 minutes.
- The GM layer row is kept out of player flags; tokens read hit points from
bar1_value/bar1_max.
- Chronicle's real-time refusal ("tracks real-world time") is recognised.
- Stash, crafting and shop requests from players are limited per player,
like quest requests.
- Test connection names a key for another campaign, and a page that isn't
Chronicle; the unreachable message covers mixed content.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CZefPfJdwbn2k1DtGMYyod
Security fix. A map's picture copied into the world's files stayed at the same address after the GM shadowed part of the map, and was copied even for a map journal no player could open. Now: - The picture is copied only once a player can open the map's journal; sharing the journal copies it then. Other maps keep the short-lived link. - When a map gains a shadow, the copy is overwritten with a one-pixel blank picture of the same name and format (Foundry can't delete files), and the store forgets it. The page records the id, so if the shadow is removed in a later session the real picture is written back. - The GM's own view of a newly shadowed map takes a fresh link instead of the blanked file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CZefPfJdwbn2k1DtGMYyod
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.
Requested by Key Maker · project thread
Fixes: none
Security implication: security fix. Players no longer see the names of pages they can't open in mention links, a map's GM layer row is no longer written where players can read it, players can no longer flood the GM's client (and its API key) with stash, crafting or shop requests, and a map picture copied into the world's files follows who may see it.
Consumer-verified: Chronicle
internal/plugins/maps/drawing.goToken(bar1_value,bar1_max) andLayer.LayerType;internal/plugins/media/signed_url.goSignedURLTTL = 15 * time.Minute;internal/plugins/calendar/service.goreal-time refusal text "tracks real-world time";internal/plugins/syncapi/middleware.goRequireCampaignMatch403 "api key not authorized for this campaign".Foundry compatibility: not run in a live Foundry world; checked with the unit tests and the two-sided bench (fake Foundry, real Chronicle). Live click-paths below.
Mockup: n/a (no new UI; players lose a status dot that was always red)
What this changes
A full check of the Foundry functionality: four reviews read the module and Chronicle's sync side by area, each finding was confirmed in the code, and the bench ran against Chronicle
mainand against #2134 (keyxmakerx/Chronicle). These are the fixes that were small and safe; the larger gaps are filed.api-client.mjs).applyConnectioncloses the old socket and opens a new one at once; the old socket'sonclosearrived later and set_ws = nullanddisconnectedon the live connection, which could show "Connection lost", leave the dot red, and after a click on the dot open a second socket that delivered every event twice. Each handler now acts only while its socket is stillthis._ws.module.mjs). Only the GM connects, so a player's dot always read disconnected, and clicking it calledconnect()with no key, retrying every 30 s._addStatusIndicatornow returns for non-GMs._mention-links.mjs). The module reads with an owner key, so mention text is the real name. A player now sees "a hidden page" (CHRONICLE.Mentions.Hidden) for a page they can't open here, as Chronicle shows it.journal-sync.mjs). Text before the first heading becomes a page named "Overview" (or "Content" with no headings);_joinTextPageswrapped it in<h2>Overview</h2>on push, adding a section to the Chronicle page on every Foundry edit. The first page with one of those names now goes back as lead text. Page names in added headings are escaped.actor-sync.mjs,_identity-item-plan.mjs). Every Chronicle apply compared the actor's kit/ancestry item with Chronicle's pick and replaced it, so a kit the GM swapped in Foundry was deleted by the next unrelated Chronicle change. The picks last applied are kept in the actor flagidentityApplied, and a field is swapped only when Chronicle's pick changed since. A failed swap keeps the older pick so it is retried.map-sync.mjs,picture-store.mjs,_blank-picture.mjs). Pages kept Chronicle's signed link (15 minutes), refreshed only when the GM opened a viewer. A map's own picture is now copied into the world with the existingPictureStore(cookieless, Chronicle host only, 25 MB cap). Over the cap or on a failed copy the link is kept and retried on the next sync or GM viewer open. World files are served to anyone with the address, so:_playersCanSee, LIMITED or better); sharing the journal copies it then, and a map no player can open keeps the link;PictureStore.retire), since Foundry can't delete files, and the store forgets it. The page flagretiredPicturesmakes a later session, which finds the blank file, write the real picture back if the shadow is removed;_map-flag-filter.mjs).isLayerSafeForPlayerFlagsdropslayer_type: 'gm'(and rows with no type), matching what Add a player-eyes crawl; fix two viewer-visibility gaps Chronicle#2140 does for player listings.map-viewer.mjs). The viewer readmax_hp/current_hp, which Chronicle never sends; it now readsbar1_max/bar1_value._date-push-rejection.mjs)./real.?time/did not match Chronicle's "tracks real-world time", so the backstop paused date push with the months-and-leap-days notice.stash-sync.mjs,crafting-relay.mjs,shop-room-window.mjs). Each now uses the quest board'smakeAskLimiter(30 per 10 s per player) before calling Chronicle with the GM's key._connection-test.mjs). A 403 for a key made for another campaign says so (WrongCampaign) instead of "missing a permission"; a 200 that isn't JSON (a sign-in page in front of Chronicle) isNotChronicle, not "Campaign found"; the unreachable message now covers Chronicle being down and https-to-http.Honest deviations
bench/actors.bench.mjs"two Chronicle changes applied at once" now also clearsidentityAppliedin its reset, since the reset simulates Chronicle's kit being new.Not fixed here, filed: #308 (duplicated journal or actor keeps its link), #309 (request timeouts, catch-up retry, revoked key), #310 (smaller gaps). The biggest remaining risk is the existing #292: "Pull only" and "Push only" are saved but ignored.
Why
Key Maker asked for a deep check that all the Foundry functionality works and is solid.
Test plan
node --test tools/test-*.mjs: 1688 pass, 0 fail, 4 skipped (was 1669 onmain)tools/check-comment-clutter.sh: OKCHRONICLE_DIR=../Chronicle bench/run.shonmainbefore the change: 42/42CHRONICLE_DIR=<Chronicle #2134> bench/run.shwith the change: 41/42; the one failure was the reset described above. After that fix and the new scenario,bench/run.sh actors: 11/11CHRONICLE_DIR=../Chronicle bench/run.sh mapson Chroniclemain: 3/3 (the bench's maps carry no pictures, so the copy itself is covered by the unit tests)retirerefusing paths outside its folder, real-time refusal text, wrong-campaign and sign-in-page connection tests, relay limits; bench scenario "a kit the GM swaps in Foundry survives a later Chronicle edit to another field"chronicle-media/<id>.<ext>). Add a shadow to that map in Chronicle. Open the address in a private browser window → blank, not the map. Broken: the full map still shows./media/…?sig=…).Tenet self-check
.ai.md(maps, picture store, mentions) andTESTING.md(map picture checks) updatedGenerated by Claude Code