Skip to content

refactor(application): edit records through ports that take the change - #998

Merged
ixuz merged 4 commits into
edit-documentfrom
edit-ports
Nov 24, 2026
Merged

ixuz merged 4 commits into
edit-documentfrom
edit-ports

Conversation

@ixuz

@ixuz ixuz commented Nov 24, 2026

Copy link
Copy Markdown
Member

What and why

Renaming an instance, describing its catalog and setting a deck's authors and license each edited a record through two ports: a read (readMeta, readCatalog, readDeck) and then a save (saveMeta, saveCatalog, saveDeck), both inside again(), which tried them again on a 412. Each save port read the document a second time and sent If-Match on that second read. What it wrote, though, was the record the use case had built from the first read. When another tab or device changed the document between the two reads, the whole record went back as the first read had it, and no 412 ever came. The retry policy was also split over two layers: editDocument (#995) in the Solid adapters, and again() with METADATA_ATTEMPTS in the use cases.

This gives those edits ports that take the change, as editDeckTree and completeChapter already do, each built on editDocument. One port per commit:

  • editMeta(instanceUrl, change) for the rename. It replaces saveMeta, which nothing else called.
  • editCatalog(instanceUrl, change) for the rename and describeCatalog. The change gets the catalog as readCatalog reads it (null, "misfit" or the catalog), so the use cases keep their rules. The rename still checks the catalog's write before it writes anything. saveCatalog stays, for the instance a session makes.
  • editDeck(deck, change) for setDeckProvenance. It takes the deck rather than its URL so it can throw deckGone with the title, as editEntry does. saveDeck stays for the edits made from the deck as shown.
  • Preferences and palette: every write is now an edit made by editDocument.
    • The choice to skip the Connected screen is made again in the adapter, on the preferences as they are then. The use cases used to retry it through again() plus a second try on createdElsewhere.
    • savePreferences, markSchedulerInvitationDismissed, upgradePreferences and savePalette are still made once, as before. They write what the screen showed, so a 412 should reach the user rather than be retried over what changed elsewhere. Adapter tests pin both behaviors down.

With that, again() and METADATA_ATTEMPTS are gone, and every write that re-applies its change does so in the Solid adapters. The use-case test fakes (fakePorts.ts) model each edit port as read, change and save on top of the existing read mocks. docs/data-model.md (write discipline) and the port docs describe the change. What the app writes to a pod stays the same.

The full check passes on each commit.

Merge order: this builds on #996 (editDocument). Until #996 is merged, this pull request also shows its six commits. Merge #996 first; this branch is then rebased onto main.

Not part of this: describeDeck, setDeckDirection and setDeckPace still save the deck as the screen shows it, and have the same gap. #997 didn't list them.

Closes: #997

ixuz added 4 commits November 24, 2026 09:48
Renaming an instance read the meta through readMeta, then saved the
renamed record through saveMeta, again() trying both again on a 412.
saveMeta read the document a second time and sent If-Match on that
read, so a change made elsewhere between the two reads was written
over with the record the first read gave, and no 412 ever came.

editMeta takes the change instead: the adapter reads the meta, has the
use case change it, and writes the record changed from that same read,
If-Match it, read and changed again on a 412 (editDocument). The use
case keeps only its rule, that a name already so is not written again.
saveMeta, which nothing else called, is gone.

Refs: #997
…n edit port

Renaming an instance and describing its catalog read the catalog
through readCatalog, then saved the changed one through saveCatalog,
again() trying both again on a 412. saveCatalog read the document a
second time and sent If-Match on that read, so a change made elsewhere
between the two reads was written over and no 412 ever came.

editCatalog takes the change instead: the adapter reads the catalog,
has the use case change it, and writes the one changed from that same
read, If-Match it, read and changed again on a 412 (editDocument). The
use cases keep only their rules: no catalog, one that does not fit its
shape, a name already so. The rename still checks the catalog's write
before it writes anything. saveCatalog stays, for the instance a
session makes.

Refs: #997
Setting a deck's authors and license read the deck through readDeck,
then saved the changed one through saveDeck, again() trying both again
on a 412. saveDeck read the catalog a second time and sent If-Match on
that read, so a change made elsewhere to the entry between the two
reads was written over and no 412 ever came.

editDeck takes the change instead: the adapter reads the entry, has
the use case change the deck, and writes the entry changed from that
same read, If-Match it, read and changed again on a 412 (editDocument).
The use case keeps only its rule, the provenance it sets. saveDeck
stays for the edits made from the deck as shown.

Refs: #997
The preferences and the palettes were the last documents a Solid
adapter read, changed, checked and saved by hand, and whether a write
was made again on a 412 was said in two layers: the choice to skip the
Connected screen was made again by the preferences use cases, through
again() and a second try of their own on createdElsewhere, while every
other preference write was made once.

Each is now an edit made by editDocument. The choice to skip the
Connected screen is made again in the adapter, on the preferences as
they are then, as the use cases made it; the other preference writes
and a palette's are made once, as before, since they write what the
screen showed. With that, nothing calls again() or METADATA_ATTEMPTS,
and both are gone: every write that re-applies its change does so in
the Solid adapters. The data model's write discipline says so.

Closes: #997
@ixuz ixuz added the enhancement New feature or request label Nov 24, 2026
@ixuz
ixuz changed the base branch from main to edit-document November 24, 2026 09:07
@ixuz
ixuz added this pull request to stack #1001 November 24, 2026 10:16
@ixuz
ixuz added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit e93d6b2 Nov 24, 2026
150 of 157 checks passed
@ixuz
ixuz deleted the edit-ports branch November 24, 2026 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

1 participant