You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: granular permission mapping between Chronicle and Foundry (F-2)
Server-side:
- New GET /api/v1/campaigns/:id/entities/:eid/permissions endpoint
returns visibility mode and permission grants for an entity
- New PUT /api/v1/campaigns/:id/entities/:eid/permissions endpoint
updates entity visibility and permission grants
- Both wrap existing EntityService methods, no new DB queries
Foundry module:
- _buildOwnership(): fetches Chronicle permissions API for custom
visibility entities, maps role-based grants to Foundry ownership
(player view→OBSERVER, player edit→OWNER, no grant→NONE)
- _pushPermissions(): reverse-maps Foundry ownership changes to
Chronicle visibility/permission updates on entity create and update
- Falls back to binary is_private mapping on API failure
- User-specific grants acknowledged but not mapped (needs user ID
mapping table between Foundry and Chronicle — deferred)
Also: marked F-1 and F-2 complete in .ai/todo.md, updated TESTING.md
with multi-page sync and permission sync test items.
https://claude.ai/code/session_01XMwxFR8BCi5XvgaSVMSBZB
32.**Foundry enhancements planning session.** Analyzed gaps in journal sync, permissions, and character sheet support. Captured comprehensive plan in `.ai/todo.md` as Phase F (Sprints F-1 through F-7):
-**F-3: System detection & character field templates** — Match `game.system.id` to Chronicle systems. `CharacterFields()` on System interface. Per-system field templates for Character entity type.
17
-
-**F-4: Actor ↔ entity sync** — New `actor-sync.mjs` with system-specific adapters (dnd5e, pf2e). Bidirectional sync of character stats/attributes.
-**Planning:** Captured Phase F roadmap (F-1 through F-7) in `.ai/todo.md` and `foundry-module/.ai.md`.
15
+
-**F-1: Journal sync fidelity (DONE):** Multi-page sync — entity content with h1/h2 headings splits into separate Foundry pages via `_splitByHeadings()`. Multiple Foundry pages concatenate back into single Chronicle entry via `_collectTextPages()`. `_syncPagesToJournal()` adds/updates/removes pages incrementally. Ownership change hook now pushes `is_private` on every update.
16
+
-**F-2: Granular permission mapping (DONE):** New syncapi endpoints `GET/PUT /entities/:eid/permissions` wrapping existing `EntityService.GetEntityPermissions` / `SetEntityPermissions`. Foundry module: `_buildOwnership()` fetches Chronicle permissions and maps role grants to Foundry default ownership levels (custom visibility player view→OBSERVER, player edit→OWNER, no player grant→NONE). `_pushPermissions()` reverse-maps Foundry ownership changes to Chronicle visibility/permission updates. User-specific grants stored but not mapped (needs user ID mapping table — deferred). TESTING.md updated with multi-page and permission test items.
-[]**Sprint F-1: Journal Sync Fidelity** — Multi-page journal sync (split entity `entry_html` by headings into Foundry pages, concatenate pages back on Foundry→Chronicle). Ownership change hook (detect ownership changes in `updateJournalEntry` hook, push to Chronicle). `chronicle-sync.pageMap` flag for page tracking.
287
-
-[]**Sprint F-2: Granular Permission Mapping** — Map Chronicle `visibility: 'custom'` + `entity_permissions` to Foundry per-user ownership levels (view→OBSERVER, edit→OWNER). New syncapi endpoints: `GET /entities/:eid/permissions`, `PUT /entities/:eid/permissions`. Reverse-map Foundry ownership changes back to Chronicle.
286
+
-[x]**Sprint F-1: Journal Sync Fidelity** — Multi-page journal sync (split entity `entry_html` by headings into Foundry pages, concatenate pages back on Foundry→Chronicle). Ownership change hook (detect ownership changes in `updateJournalEntry` hook, push to Chronicle). Helpers: `_splitByHeadings`, `_collectTextPages`, `_syncPagesToJournal`.
287
+
-[x]**Sprint F-2: Granular Permission Mapping** — Map Chronicle `visibility: 'custom'` + `entity_permissions` to Foundry per-user ownership levels (view→OBSERVER, edit→OWNER). New syncapi endpoints: `GET /entities/:eid/permissions`, `PUT /entities/:eid/permissions`. Reverse-map Foundry ownership changes back to Chronicle. Helpers: `_buildOwnership`, `_pushPermissions`. User-specific grants stored in flags but not mapped to Foundry users (requires user ID mapping table — deferred).
288
288
-[ ]**Sprint F-3: System Detection & Character Field Templates** — Foundry module reads `game.system.id`, matches against Chronicle campaign systems via `GET /campaigns/:id/systems`. System ID mapping table (`dnd5e→dnd5e`, `pf2e→pathfinder2e`). `CharacterFields()` on System interface. Per-system `character_fields.json` (D&D 5e: abilities, HP, AC, level, class, skills; PF2e: equivalent). Apply field template to "Character" entity type on system enable.
289
289
-[ ]**Sprint F-4: Actor ↔ Entity Sync** — New `actor-sync.mjs` module. Foundry Actor (type: "character") ↔ Chronicle entity (type: "character"). System-specific adapters (`dnd5e-adapter.mjs`, `pf2e-adapter.mjs`) with `toChronicleFields(actor)` / `fromChronicleFields(entity)`. Hooks: `createActor`, `updateActor`, `deleteActor`. WebSocket: `entity.updated` with character type. Same `_syncing` guard pattern. Dashboard "Characters" tab.
290
290
-[ ]**Sprint F-5: NPC Viewer / Hall** — Campaign route `/campaigns/:id/npcs`. Gallery/grid of revealed NPCs (non-private character entities). Portrait, name, description, location, faction. Filters by location/organization/relation. "Reveal" = DM toggles `is_private`. Foundry integration: ownership change on NPC journal → auto-reveal on Chronicle. Long-term: NPC relationship map (filtered relation graph).
0 commit comments