Entry sync on foundry keeps creating new journal entries #111

Closed
opened 2026-10-16 16:22:57 +00:00 by Syndria98 · 6 comments
Owner

Can you fix it? It keeps creating empty entries forever. It shouldn't do that

Can you fix it? It keeps creating empty entries forever. It shouldn't do that
Syndria98 added the ai-ready label 2026-10-16 16:22:57 +00:00
Agent added the working label 2026-10-16 16:22:58 +00:00
Collaborator

Let me look at the exact reconcile code and the test helpers once more before editing.

Let me look at the exact reconcile code and the test helpers once more before editing.
Collaborator

I've traced the notes→journal reconcile thoroughly. The reconcile only creates a page when it can find it neither by the campaign's stored page id nor by the dragonroll-foundry.noteId flag on the page. The item sync has a third fallback (adopt an unmapped document of the same name) that the notes sync lacks, which is what lets duplicates accumulate. Let me implement the parallel behaviour and cover it with tests.

I've traced the notes→journal reconcile thoroughly. The reconcile only creates a page when it can find it neither by the campaign's stored page id nor by the `dragonroll-foundry.noteId` flag on the page. The item sync has a third fallback (adopt an unmapped document of the same name) that the notes sync lacks, which is what lets duplicates accumulate. Let me implement the parallel behaviour and cover it with tests.
Collaborator

Let me also make the create path re-apply the page's flag the way the actor/item sync marks its documents, so a page that does not keep its create-time flag is still claimed.

Let me also make the create path re-apply the page's flag the way the actor/item sync marks its documents, so a page that does not keep its create-time flag is still claimed.
Collaborator

Fixed issue #111. The notes→journal reconcile in dragonroll-foundry/scripts/api.js only recognised a page through the campaign's stored foundryPageId or the page's dragonroll-foundry.noteId flag. When both were missing — a page that lost its mark, or a pairing the campaign never kept — it created a fresh page every reconcile, so the world filled with endless empty entries.

Changes

dragonroll-foundry/scripts/api.js (reconcileDragonrollNotes)

  • Claim by title: before creating, look for an existing page under the note's title that carries no Dragonroll mark and isn't already claimed this pass. Adopt it (rewrite its content, mark it, and tell the campaign its page id) instead of adding a second page of the same name. This mirrors the item sync's same-name adoption and is what stops the endless duplication.
  • Re-mark after create: run applyDragonrollNotePage on the page just created, so a world that drops the flag handed to createEmbeddedDocuments still ends up with a marked page (the same way actors/items are re-marked from the backend response).
  • Updated the section comment to describe the adoption rule.

Tests

tests/foundry-note-journal.test.js — added keepCreateFlags/failMapNote knobs to the world stub and three tests:

  • a page under the note's title with no mark is claimed, not doubled (and stays single on later reconciles);
  • two notes of one title don't share one page;
  • a page whose mark and mapping were both lost is claimed again, not doubled (the exact failure the issue describes).

Verified: with the code reverted, those three tests fail; with the fix they pass. Full suite: 389/389 pass (npm test).

Docs updated in dragonroll-foundry/README.md and frontend/app/content/docs/03-integrations/03-foundry.md to describe the title-adoption rule.

No commit or push was made; the working tree on ai/issue-111 holds only these four files.

Fixed issue #111. The notes→journal reconcile in `dragonroll-foundry/scripts/api.js` only recognised a page through the campaign's stored `foundryPageId` or the page's `dragonroll-foundry.noteId` flag. When both were missing — a page that lost its mark, or a pairing the campaign never kept — it created a fresh page every reconcile, so the world filled with endless empty entries. ## Changes `dragonroll-foundry/scripts/api.js` (`reconcileDragonrollNotes`) - **Claim by title**: before creating, look for an existing page under the note's title that carries no Dragonroll mark and isn't already claimed this pass. Adopt it (rewrite its content, mark it, and tell the campaign its page id) instead of adding a second page of the same name. This mirrors the item sync's same-name adoption and is what stops the endless duplication. - **Re-mark after create**: run `applyDragonrollNotePage` on the page just created, so a world that drops the flag handed to `createEmbeddedDocuments` still ends up with a marked page (the same way actors/items are re-marked from the backend response). - Updated the section comment to describe the adoption rule. ## Tests `tests/foundry-note-journal.test.js` — added `keepCreateFlags`/`failMapNote` knobs to the world stub and three tests: - a page under the note's title with no mark is claimed, not doubled (and stays single on later reconciles); - two notes of one title don't share one page; - a page whose mark *and* mapping were both lost is claimed again, not doubled (the exact failure the issue describes). Verified: with the code reverted, those three tests fail; with the fix they pass. Full suite: **389/389 pass** (`npm test`). Docs updated in `dragonroll-foundry/README.md` and `frontend/app/content/docs/03-integrations/03-foundry.md` to describe the title-adoption rule. No commit or push was made; the working tree on `ai/issue-111` holds only these four files.
Collaborator

Implementation is ready for review: #112

Implementation is ready for review: https://git.aranroig.com/Syndria98/dragonroll/pulls/112
Collaborator

The automated implementation stopped because of an internal error. Please check the worker logs for details.

The automated implementation stopped because of an internal error. Please check the worker logs for details.
Agent removed the working label 2026-10-16 16:57:29 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Syndria98/dragonroll#111