Version 8.8.0

All pages

Guest mode

Guest mode lets someone try Solid Memo before logging in, in a pod kept in their browser. After logging in with a real WebID, the guest can move that study into their own Pod. Everything else works the same for a guest: the deck library, studying, statistics, preferences and the data check. A guest's instance is made as any new one is, so it studies by FSRS-6 (srs.md).

A pod in the browser

localPod.ts serves each guest a small Solid pod as a fetch, which the app's Solid adapters use as they do a server. A router (routedFetch.ts) sends each request to the guest's pod or to the network, by URL, after the pod fence and the write fence (boundaries.md).

Routing a guest's requests
Requests pass the pod fence and the write fence; those to the guest pod's address go to the local pod in IndexedDB, and every other URL goes through the authenticated fetch.
The diagram's source
graph LR
  accTitle: Routing a guest's requests
  accDescr: Requests pass the pod fence and the write fence; those to the guest pod's address go to the local pod in IndexedDB, and every other URL goes through the authenticated fetch.
  UI --> UseCases --> Adapters["Solid adapters"]
  Adapters --> PodFence[podFence] --> Fence[writeFence] --> Router[routedFetch]
  Router -- "guest.solid-memo.invalid" --> LocalPod[localPod] --> Store[(IndexedDB)]
  Router -- every other URL --> authFetch --> Pod[(the user's pod)]

restoreSession prefers a real session. Without one, it returns a guest's session ({ webId: GUEST_WEBID, guest: true }) whenever a guest pod exists in this browser.

A link to a library deck, #/try?deck=…, is for anyone and doesn't wait for "Try it without logging in": without a session, the app starts a guest's study as that button does and opens the deck there (routing.md). So does a link to a release published outside the library, #/try?url=…, which opens it to add (routing.md). A browser with a guest pod goes on with it (restoreSession returns the guest's session), and the deck opens in the guest's instance. A logged-in user's opens it in their own. A guest's study that can't start leaves the landing page, with the reason.

What comes from outside

When the study is kept, every address that names the guest's pod must be one of the study's own, which the move gives a new place (Keeping the study). So data from outside never brings one in, for a guest and a logged-in user alike:

Text the reader reads, such as card text and notes or what changed in a release, may name any address. So may the fragment id of a card or a wrong option, and a review state's reference to it. Such an id is no address but the part after the # of the deck's own document, so it's copied as it is, and keeping the study doesn't refuse it.

The address of a release, and of a chapter in it, is the address of the release a deck was taken from. It's read as one whole address, and only one at the guest's pod counts: its path, query or fragment may spell anything, and a deck taken from it can be kept, as in a move into a new instance.

Keeping the study

Keeping a guest's study
A guest logs in and is offered to move the study into their Pod, where it is added or moved, and a failure leaves the study untouched.
The diagram's source
stateDiagram-v2
    accTitle: Keeping a guest's study
    accDescr: A guest logs in and is offered to move the study into their Pod, where it is added or moved, and a failure leaves the study untouched.
    [*] --> Guest: Try it without logging in
    Guest --> Login: Keep my study — log in
    Login --> Guest: Back to my study
    Login --> Offer: logged in (guest pod still here)
    Offer --> Adding: Move it into my Pod (the user has an instance)
    Offer --> Moving: Move it into my Pod (the user has none)
    Offer --> [*]: Discard it / Not now
    Adding --> Added: every deck in, the guest's study unchanged meanwhile
    Adding --> Offer: failed — the decks added stay, whole — study untouched
    Moving --> Moved: registered in the user's type index
    Moving --> Offer: failed — copy removed, study untouched
    Guest --> [*]: Discard

The guest pod's presence marks a study to keep, so nothing has to survive the redirect. After any login or restored session, GuestStudyOffer asks findGuestStudy and makes the offer while a guest pod exists. Move it into my Pod first lists the user's instances. With at least one, the study is added to the one the user chooses (Adding to an instance). With none, or when they can't be listed, it moves into a new instance (As a new instance). Logging in keeps the guest pod for later.

Adding to an instance

mergeGuestStudy adds the guest's decks, deck by deck, to the instance the user chose (the first listed, unless they pick another). The form lists the guest's decks (planGuestMerge), each checked; an unchecked deck stays with the guest's study. At least one deck must stay checked, unless the study has none.

A guest's deck from the same library release as one of the instance's (the same prov:wasDerivedFrom) says so. It's added beside that deck with its own progress, never merged card by card, and the user may uncheck it. The form says the instance keeps its own preferences: the guest's aren't carried over. Nor is the guest's digest, which is this browser's. Drafts the guest wrote in the Studio are copied too. When there are any, the form says how many and the names they're copied under (step drafts).

It runs these steps:

  1. read: list the guest's instance, noting each document's version before any is read. A study that holds more than 20,000 resources, folders more than 8 levels deep, or an answer log of MAX_LOG_MONTHS months is refused (guestStudyTooLarge). Answers waiting to be logged go to the guest's log first, and the write fence keeps the guest's instance read-only meanwhile. The whole instance, answer log included, is checked against the shapes. Nothing is added from a study that doesn't fully conform (guestStudyInvalid), or that a newer app version wrote (guestStudyTooNew). Such a study has a subject in a newer format, or a document that uses a term of the vocabulary this version doesn't know (namesLaterTerm) where only a term goes. That's a property, a subject's class, or the value of a property whose values are concepts (rdfs:range skos:Concept, such as sm:scheduler). An IRI of the vocabulary as the value of any other property, such as a card's dcterms:subject, is a resource like any other and doesn't count. Adding writes what this version reads of each deck, so what a later one said beside it would be left behind, and go with the guest's study. A draft's documents aren't asked: a draft is copied with what this version reads of it, which keeps statements in terms it doesn't know, as a draft made from a release keeps what the release states. Nor from a study with deck groups when a newer version wrote the instance's arrangement (deckTreeTooNew), refused before any deck is written. Nor when the kept decks, but any an earlier run added, would give the instance more decks than its catalog is read with (guestMergeTooManyDecks, data-model.md). Nor when the guest's groups would give its arrangement more groups than it's read with (catalogFull). Nor when a draft's copy, under the longest name it may take in the instance, would hold an IRI longer than a term may be (draftCopyTooLong, which names the draft). A draft's IRIs grow with the instance's address, which is longer than the guest's. Nor when a draft names an IRI its copy couldn't be written with as it is (draftCopyUnwritable, which names the draft too). Nor when the drafts would give the instance's drafts more documents than are read together (draftTooManyDocuments). A draft an earlier run copied, unchanged since, isn't asked again; with no draft left to copy, the instance's drafts aren't read.

  2. decks: each kept deck becomes a new deck of the instance, in the guest's order (data-model.md):

    • a new id (deck-<uuid>), with its cards and reviews documents named after it in the instance's decks/ and reviews/. The rest of its entry is the guest's: title, description, authors, license, topics, keywords, direction, pace, card language (sm:deckCardLanguage), picture hosts (sm:deckPictureHost) and creation time. So are the release it came from (prov:wasDerivedFrom) and, for a course's deck, its schema:Course type and completed chapters (sm:completedChapter). An author's name comes from a release, and its agent node fit under the guest's short catalog address. An author whose node in the instance's catalog could be longer than a term may be, with the hash and count a node may take after its name, is left out, as a card that doesn't fit is (authorFitsDeck);
    • its cards keep their fragment ids, distractors and creation times, written in this app's format, the document saying it's part of the deck. Its review states keep their SM-2 fields and snapshots, each naming its card, direction and scheduler; its FSRS-6 states come as they are;
    • a card's id, or a distractor's, comes from a release and may fit under the guest's short address but not under the new deck's. A card whose IRI there would be longer than a term may be is left out, with its review states and its answers: it could be neither written nor studied there (cardFitsDeck). A review state whose name after its card (#<id>@back-to-front@fsrs6 the longest) would be too long is written at a short subject of its own, which names its card, and the card is kept. Such a distractor is left out, not the card (movedCard). A course still asks the card with its release's options, which it reads from the release;
    • the cards document, then the reviews document, is created with one PUT only where nothing is, then the deck's catalog entry, with If-Match, read and added again on 412 a few times at most. Until the entry is written, nothing names the documents. A failure before the entry deletes the documents it wrote, and any whose write's answer was lost, never one the pod refused to create. If one can't be deleted, the failure says where it is. If the catalog can't be read to tell whether the entry was written, they stay and the failure says to look for the deck first. If only the entry's answer was lost, the deck is whole. A deck with no cards, or no review states, has no such document yet;
    • then its answers: each of the deck's answers in the guest's log is added to the instance's log for its month, insert-only, unread (appendAll, one PATCH per month, more where one would pass 64 KiB). Its deck, card and chosen wrong option are named in the new deck's documents, by the same fragment ids. A chosen wrong option whose IRI would be too long there, or whose id is longer than 256 characters, is left out, not the answer. Its grade, intervals and response times stay as given. Its id is the guest's followed by the new deck's (answer-<time>-<random>-deck-<uuid>). Answers of a deck the guest removed, or left out, aren't added, nor those of a card left out.

    No address in a deck's entry, cards or review states may name the guest's pod, in any spelling of its origin (guestDeckUrlsLeft, which names the deck, so it can be left out). Text the reader reads, such as titles, card text and notes, may name any address and is copied as it is, as is a fragment id, which is no address. The address of a release or a chapter (a deck's source, a card's release and the chapters completed) counts only as a whole, whatever it spells inside. Nothing is registered: the instance's catalog and folders hold the added decks.

  3. arrange: each of the guest's deck groups becomes a new group (#group-<uuid>) with its name, holding the added decks and new groups it held, an empty one empty. They go, in the guest's order, after the instance's own decks and groups, at the top level. It's one graft edit: one PATCH with If-Match, applied again on 412, which numbers the top level anew. With no group, nothing is written, and the added decks are listed after the instance's.

  4. drafts: each draft the guest's catalog links is copied to the instance (copyReleaseDraft): read whole, every subject moved to drafts/<name>/v<N>/ in the instance, at its version, under its name. When the instance has a draft of that name and version, it takes the next free name (<name>-2, …). It's written as a new draft is (data-model.md). A draft whose link can't be written is taken back, and none of the instance's is written over. A copy that would still link to the guest's pod by an IRI isn't written (guestUrlsLeft); its text may name any address.

  5. verify: the guest's instance must still list the same resources, each at the version noted in read (guestStudyChanged).

  6. tidy: delete the guest's instance as any instance is deleted (data-model.md), and the whole guest pod once no instance is left. A failed delete only means tidied: false.

A failure leaves the instance valid and the guest's study as it was. Every deck reported added (added) is whole: documents, entry and, unless the failure was in adding them, answers. The only other writes are the groups, after arrange, the drafts reported copied (copied), each whole, and any unnamed deck document whose deletion failed. The user is told which decks and drafts (under their names there) are in the instance. A text or address too long that stops the merge once part of the study is added names the deck (guestDeckTooLong) or the draft (draftCopyTooLong, draftCopyUnwritable), so it can be left out or deleted.

Trying again adds what isn't there yet. As each deck is added, and before each group is, this browser's update journal notes (GuestMergeNote) the new deck or group and a SHA-256 digest of what it was made from:

On the next run:

A digest keeps a note small, however much a deck's entry holds. A note an earlier version kept, holding what the deck or group was made from whole, is rewritten as its digest as the app starts, before anyone signs in, so a run it noted is still found.

A merge that deletes the guest's study forgets the notes. So does discarding the guest's study, and looking for one when the guest's pod is gone. Looking for a guest's study also forgets the notes of a guest's instance no longer in the pod, and a merge first forgets those of a deck, group or draft the study no longer holds. A move's entry is left as it is.

The journal keeps no entry, key and value together, longer than 65,536 characters. One longer isn't written, and the source's earlier entry goes. An entry that long that an earlier version kept, and that isn't a note it can rewrite short, is dropped as the app starts.

As a new instance

transferGuestStudy copies the guest's instance into a container the user chooses (by default <storage>solid-memo/main/, where a first instance goes). It runs these steps:

  1. stage: refuse (typeIndexNoStorage) when the study couldn't be registered: no type index of the chosen kind, and no storage the user's WebID leads to where one could be made (data-model.md). List the guest's instance, without the digest (this browser's), refused past the same bounds as above (guestStudyTooLarge). Check the target is free, then create it. Answers waiting to be logged go to the guest's log first. Refuse, before anything is written, a deck with an author whose agent node would be longer than a term may be under the target (guestDeckTooLong), or a draft whose copy would hold such an IRI (draftCopyTooLong). Each names the deck or draft. Deleting a copy that failed half-way walks it within the same bounds.
  2. copy: copy each resource with every IRI under the guest's instance moved under the target, and the guest's WebID renamed to the user's (ContainerMove.renames). A copy of a card whose IRI would be longer than a term may be under the target fails, as below. Added to an instance instead, such a card is left out.
  3. adopt: name the catalog's publisher as the user's profile names them. No Turtle document of the copy may still name an IRI at the origin of GUEST_ORIGIN, in any spelling. The failure names the guest's deck the document is of (guestDeckCopyUrlsLeft), so it can be removed from the guest's study: the deck's cards or reviews document, or the catalog whose entry of it links there. Else it names the document (guestUrlsLeft). Literals aren't looked at, their text or their datatypes: the copy moves only the IRIs of subjects, predicates, objects and graphs, and text such as a card's may name any address.
  4. validate: the copy must fully conform to the shapes (movedCopyInvalid).
  5. verify: the guest's instance must be unchanged since it was copied. The write fence keeps it read-only meanwhile, in the site's other open tabs too.
  6. register: attachInstance in the type index the user chose. From here on the study is theirs.
  7. tidy: delete as the merge's tidy does. Nothing more is registered: the instance's sm:Instance registration leads to the rest of its data (data-model.md).

A failure before register deletes the copy, whole, and leaves the guest's study as it was. The target's container, created where nothing was and named by nothing before register, holds only Solid Memo's copies. This browser's update journal notes the run:

The copy inherits the user's pod's default access control, like a new instance; a guest's instance has none.

While a move runs, the site's other open tabs (the web app's and the Studio's, which share one origin) hold the guest's instance and its copy: a write there fails with the moving tab's message. The moving tab holds a Web Lock named after its journal entry until the move ends, failed or not, or the tab closes or crashes. Other tabs read the entries on opening, then follow storage events, holding what an entry names only while its lock is held. An entry a failed move keeps, one a closed tab left, or one noting a deck added to an instance fences nothing. A browser without Web Locks fences no other tab; verify catches what it misses.