Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions docs/curation/persistence-slice-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,19 @@ These are later scoped slices, each owned by its issue:
budget.
- **#194:** the page ↔ composition binding, and the ADR 0004 default/alternate wording
amendment.
- **#156 Phase 2:** mapping `Published.current/1` onto the Phase 1 view model. PR #202
is not merged, so this slice does not depend on it. Production selection stays
disabled; no page reads compositions yet.
- **#156 Phase 2 / #255:** the page reads `Published.current/1` through
`Curation.PublishedReader`, on every request and by default. A page's composition
is the active `:lexical_page` composition of the resolved global default whose
signature is the page's own lexemes (`Compositions.active/4` over
`page.headword.lexemes`, K2), so `/on/love` and `/words/:id/love` are different
scopes and no binding table is needed; while the On page's scope is active, the
exact word's overlapping `:lexical_page` scope cannot be provisioned beside it
(K3), and that page shows nothing. The reader re-checks nothing `Published`
settled: it maps the arrangement onto the opening (the lead's rule from
`LeadPolicy`, each note as a signed reason, the receipt as *Published by*) and
withholds a `work` or `exemplar` highlight as `:unsupported_item` until a later
part draws them. The development fixture still answers only behind
`:curated_opening_fixtures` and `?opening=fixture`.
- **#203 / #204:** the history projection, profile pages and the method page.
- Later stages of #201: domain defaults and personal views.

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 30 additions & 21 deletions lib/devils_dictionary/curation/opening.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ defmodule DevilsDictionary.Curation.Opening do
This struct is the **contract** between where a selection comes from and
how it is shown. `DevilsDictionaryWeb.Opening` renders it and knows nothing
else; a reader (`DevilsDictionary.Curation.OpeningReader`) produces it and
knows nothing about markup. Phase 1 has one reader, the development-only
knows nothing about markup. There are two readers:
`DevilsDictionary.Curation.PublishedReader`, every page's, which reads what
a reviewer published (#255); and the development-only
`DevilsDictionary.Curation.ManualFixture`.

What each field promises:

* `composition` — `%{id, version}` when the selection has an identity:
a fixture's key and version today. Never a URL, never a slug.
a published composition's id and version number, or a fixture's key
and version. Never a URL, never a slug.
* `origin` — `:fixture` (development, never public) or `:published`.
* `configuration` — the resolved curation configuration (#201), a
`Configuration`, or `nil`. **`nil` in Phase 1**: a fixture resolves
none and no panel ran, and the component says so.
`Configuration`, or `nil`. `nil` for a fixture, which resolves none
and no panel ran, and the component says so.
* `lead` — a `Lead` or `nil`. An honest empty lead is `nil`, not a
placeholder.
* `highlights` — zero to three `Highlight`s in position order. Never
Expand All @@ -34,14 +37,15 @@ defmodule DevilsDictionary.Curation.Opening do

## What later phases add, and where

The persisted reader will return this struct, but the contract is not
finished and the component will change with it. Deliberately absent now,
`PublishedReader` fills the composition's persisted id and version, the
configuration and version it was published under, and who selected,
reviewed and published it (#196, #201, #255). The contract is not
finished, and the component will change with it. Deliberately absent now,
because there is no real data behind them yet:

* **#196 / #201** — the composition's persisted id and version, the
configuration id and version frozen for it, the resolution reason and
policy version (the typed `configuration` field is their place), and
version provenance such as the originating run.
* **#196** — version provenance such as the originating run; and the
assessment dates (last assessed, inputs last changed, next
assessment), which are #254 P5's.
* **#203** — structured decisions and history: the configured and actual
panel, per-profile final-round ballots and counts, the human decision
and any override with its reason, and links to authorized history,
Expand All @@ -52,7 +56,7 @@ defmodule DevilsDictionary.Curation.Opening do
panel and no approval, and the opening shows those absences plainly.
"""

alias DevilsDictionary.Curation.ManualFixture
alias DevilsDictionary.Curation.{ManualFixture, PublishedReader}
alias DevilsDictionary.Curation.Opening.{Configuration, Highlight, Lead, Review}

@max_highlights 3
Expand Down Expand Up @@ -94,28 +98,33 @@ defmodule DevilsDictionary.Curation.Opening do
def empty?(%__MODULE__{}), do: false

@doc """
Which reader, if any, may compose this request's opening.
Which reader composes this request's opening.

Phase 1 has only the manual fixture, and it answers only when the
environment allows fixtures **and** the request asks with
`?opening=fixture`. `:curated_opening_fixtures` is set by `config/dev.exs`
and `config/test.exs` and by nothing that production reads, the same gate
`PublishedReader`, by default and on every public page: what a reviewer
published for the page's words, or nothing (#255). No parameter chooses a
configuration or a composition.

The manual fixture answers instead only when the environment allows
fixtures **and** the request asks with `?opening=fixture`.
`:curated_opening_fixtures` is set by `config/dev.exs` and
`config/test.exs` and by nothing that production reads, the same gate
`DevilsDictionary.Demo` uses, so a public page never renders a fixture.
`nil` — the answer everywhere else — means the page has no opening section.
"""
def reader(params) when is_map(params) do
if fixtures_enabled?() and params["opening"] == "fixture", do: ManualFixture
if fixtures_enabled?() and params["opening"] == "fixture",
do: ManualFixture,
else: PublishedReader
end

def reader(_params), do: nil
def reader(_params), do: PublishedReader

@doc "Whether this environment may render development fixtures at all."
def fixtures_enabled?,
do: Application.get_env(:devils_dictionary, :curated_opening_fixtures, false) == true

@doc """
The opening for a built `WordPage`, asked of `reader`; `nil` when there is no
reader, the page names no word, or the reader has nothing for it.
The opening for a built `WordPage`, asked of `reader`; `nil` when the page
names no word or the reader has nothing for it.

Reads the database and the committed corpus manifests, nothing else. No
provider is asked, no model is called and nothing is written.
Expand Down
17 changes: 9 additions & 8 deletions lib/devils_dictionary/curation/opening/configuration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@ defmodule DevilsDictionary.Curation.Opening.Configuration do

The typed place for #201's resolved configuration: the configuration's
stable `id` and `slug` (`global-default`), the exact `version` that was
frozen for the run or manual composition, and the resolver's answer —
frozen for the run or manual composition, the `lead_rule` that version
carries (`:bierce_first_v1`), and the resolver's answer —
`resolution_reason` (`:global_default` is the only MVP reason) and the
`resolution_policy_version` it was decided under.

**Always `nil` in Phase 1.** A development fixture resolves no
configuration and runs no panel, and the opening says exactly that; this
struct exists so #196/#201's reader has a typed field to fill rather than a
map to improvise, and so the component's rendering of both cases is tested
now. It carries no panel roster, votes or decisions: those are #203's
structured records, which join the contract when they exist.
**`nil` for a development fixture**, which resolves no configuration and
runs no panel, and the opening says exactly that.
`DevilsDictionary.Curation.PublishedReader` fills it for a published
composition (#255). It carries no panel roster, votes or decisions: those
are #203's structured records, which join the contract when they exist.
"""

@enforce_keys [:id, :slug, :version, :resolution_reason, :resolution_policy_version]
defstruct [:id, :slug, :version, :resolution_reason, :resolution_policy_version]
defstruct [:id, :slug, :version, :lead_rule, :resolution_reason, :resolution_policy_version]

@type t :: %__MODULE__{
id: pos_integer(),
slug: String.t(),
version: pos_integer(),
lead_rule: atom() | nil,
resolution_reason: atom(),
resolution_policy_version: pos_integer()
}
Expand Down
27 changes: 19 additions & 8 deletions lib/devils_dictionary/curation/opening/highlight.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@ defmodule DevilsDictionary.Curation.Opening.Highlight do

`kind` is what the component draws: `:artwork` (a picture, with the credit
its catalog committed), `:quotation` (a line, verbatim, with the citation
its source wrote) or `:exemplar` (a person, work or passage someone cited
as an example of the meaning, through an accepted `illustrates` claim,
#212). The component branches on the kind and never on which provider
supplied the item (#156, promise 9).
its source wrote), `:definition` (another sourced definition on the page,
quoted from its opening, #255) or `:exemplar` (a person, work or passage
someone cited as an example of the meaning, through an accepted
`illustrates` claim, #212). The component branches on the kind and never on
which provider supplied the item (#156, promise 9).

* `position` — 1 to 3, the order the selection gave.
* `title`, `creator`, `date` — as the source records them.
* `image` — `%{url, alt}` for an artwork, or `nil`.
* `register` — `:quotation` for a line (an exact sourced quotation; its
accuracy does not make what it says true), `nil` for a picture.
accuracy does not make what it says true), `:definition` for another
sourced definition, `nil` for a picture.
* `quotation` — `%{text, citation, provenance}` for a line, or `nil`.
`provenance` is the badge the page already derives for that line.
* `excerpt` — for a definition, the opening of its exact revision as
`DevilsDictionary.Curation.Excerpt` cuts it (`%{text, html, clipped?,
chars}`), or `nil`. `links.card_id` is then the card holding the rest.
* `links` — `source` is the source's own page for the item. The durable
page a reader inspects it on (the work's entity page, the sense
revision's evidence page) is built by the component from `reference`.
Expand Down Expand Up @@ -53,6 +58,7 @@ defmodule DevilsDictionary.Curation.Opening.Highlight do
date: nil,
image: nil,
quotation: nil,
excerpt: nil,
meaning: nil,
source: nil,
credits: [],
Expand All @@ -64,19 +70,24 @@ defmodule DevilsDictionary.Curation.Opening.Highlight do

@type t :: %__MODULE__{
position: 1..3,
kind: :artwork | :quotation | :exemplar,
register: :quotation | nil,
kind: :artwork | :quotation | :definition | :exemplar,
register: :quotation | :definition | nil,
reference: Reference.t(),
title: String.t() | nil,
creator: String.t() | nil,
date: String.t() | nil,
image: %{url: String.t(), alt: String.t()} | nil,
quotation:
%{text: String.t(), citation: String.t() | nil, provenance: String.t() | nil} | nil,
excerpt:
%{text: String.t(), html: String.t(), clipped?: boolean(), chars: integer()} | nil,
meaning: Meaning.t(),
source: map(),
credits: [Credit.t()],
links: %{source: String.t() | nil},
links: %{
optional(:card_id) => String.t() | nil,
required(:source) => String.t() | nil
},
reasons: [Reason.t()],
subject:
%{
Expand Down
20 changes: 15 additions & 5 deletions lib/devils_dictionary/curation/opening/review.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ defmodule DevilsDictionary.Curation.Opening.Review do
Who chose an opening's arrangement and whether a person has reviewed it.

* `state` — `:unreviewed` (nobody has checked it), `:reviewed` (a person
checked a development fixture; it is still not published) or
`:approved` (a human accepted this exact version for publication, #196).
checked a development fixture; it is still not published),
`:approved` (a human accepted this exact version for publication, #196)
or `:published` (a reviewer published it, and the receipt says so).
* `selected_by` / `selected_on` — who chose the arrangement, as
`%{kind, label}`: `:human`, or `:model` for anything generated.
* `reviewed_by` / `reviewed_on` — the human who reviewed it, or `nil`.
* `published_by` / `published_on` / `receipt_id` — for a published
composition, the actor and date of the publication receipt and its id
(#255). `nil` for a fixture, which nobody published.

What this deliberately does not hold: panel rosters, per-profile votes,
counts, objections and human override lineage. Those are #203's structured
Expand All @@ -21,13 +25,19 @@ defmodule DevilsDictionary.Curation.Opening.Review do
selected_by: nil,
selected_on: nil,
reviewed_by: nil,
reviewed_on: nil
reviewed_on: nil,
published_by: nil,
published_on: nil,
receipt_id: nil

@type t :: %__MODULE__{
state: :unreviewed | :reviewed | :approved,
state: :unreviewed | :reviewed | :approved | :published,
selected_by: %{kind: :human | :model | :fixture, label: String.t()} | nil,
selected_on: Date.t() | nil,
reviewed_by: String.t() | nil,
reviewed_on: Date.t() | nil
reviewed_on: Date.t() | nil,
published_by: %{kind: :human | :model, label: String.t()} | nil,
published_on: Date.t() | nil,
receipt_id: pos_integer() | nil
}
end
8 changes: 4 additions & 4 deletions lib/devils_dictionary/curation/published.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ defmodule DevilsDictionary.Curation.Published do
words. Nothing is copied into the composition, and nothing here calls a
provider or a model (C7).

Nothing in the web layer calls this yet. Production selection stays
disabled: no page reads compositions, and binding one to a page is #194's
(#205). Mapping the answer onto the #156 opening view model waits for PR
#202, which is not merged.
The word page reads it through `DevilsDictionary.Curation.PublishedReader`
(#255), which finds a page's composition by the page's words and maps this
answer onto the #156 opening view model. No page ↔ composition binding is
involved (#194, #205).
"""

import Ecto.Query
Expand Down
Loading