Skip to content

Asks the access module before an editor resume - #282

Merged
johnnyt merged 1 commit into
mainfrom
se-4n35-resume-scope-check
Nov 28, 2026
Merged

johnnyt merged 1 commit into
mainfrom
se-4n35-resume-scope-check

Conversation

@johnnyt

@johnnyt johnnyt commented Nov 28, 2026

Copy link
Copy Markdown
Member

What changes

  • The editor asks the access module before it resumes an execution by id. StatifierExamplesWeb.EditorLive's resumed_in_reach/2 reads the scope the execution records (StatifierExamples.Charts.Durable.scope/1) and asks Riddler.Journey.Access.check/4 with StatifierExamplesWeb.JourneyAccess, the session's actor and :present before the resume. An actor outside the scope, or a scope the record holds in a shape Riddler.Journey.Scope.from_data/1 does not read, is answered :execution_not_found, the answer an id nobody stored gets. An execution that records no scope (every one the editor's own Run starts) resumes as before. The moduledoc's new section "Whose execution the page opens" says so.
  • StatifierExamplesWeb.JourneyHost.start/2 keeps its kind check alone, and its moduledoc ("The scope") now says why it need not refuse a scope its caller could not hold. The Riddler.Journey.Host start/2 callback is handed a Path and a scope and no actor, so the host cannot read who is asking; riddler's Host moduledoc ("What a renderer asks, and when") puts check/4 with :present and the start scope on the caller, before start/2. Both of this app's starts do: StatifierExamplesWeb.SettingsLive's start and StatifierExamplesWeb.SignupJourneyLive's start each take the scope from JourneyAccess.start_scope/2 and ask check/4 first. Refusing inside start/2 would need an actor the callback does not carry, which means a mechanism riddler does not name.
  • StatifierExamplesWeb.Visitor's moduledoc names the prod case. The prod configuration names no librarian_of:, so a prod build makes no session a librarian, and a start of the branch onboarding or of a setup draws the one refusal for everyone.

riddler's behaviour was read at 0.9.0, the version mix.lock resolves.

What the resume does today, by execution

Probed on the test database before the change was written:

  • a library Path's Journey (patron registration, the branch onboarding, each setup, and a setup run as a durable child of the onboarding): Durable.resume/1 answers :chart_unknown, since these charts are not ones the editor resumes. Before this change an outsider was answered :chart_unknown too, which an id nobody stored is not; now the outsider is answered :execution_not_found and a member still meets :chart_unknown.
  • the signup Path's Journey records the open scope every visitor holds, so it resumes for any visitor, as before.

Answers that change

No public function's name or arity changes. One existing answer changes on the editor page: a resume of an execution that records a scope the session's actor does not hold now shows execution refused: :execution_not_found where it showed the resume's own refusal. No existing test's expectation changes.

Tests

Two new tests in editor_live_test.exs, "picking a durable run back up":

  • "a Journey's execution is refused to an actor outside its scope": a patron registration started under one visitor's patron scope is answered :execution_not_found to another visitor and to a fresh session, and :chart_unknown to its own visitor.
  • "a Journey under the open scope resumes for any visitor": a signup Path Journey resumes on another visitor's page.

Sabotage, each run and reverted from a copy:

  • check/4's refusal turned into :ok in resumed_in_reach/2: the first test went red on its assertion.
  • every execution that records a scope refused: both tests went red on their assertions.

Gate

mix quality green (format, compile with warnings as errors, credo, dependencies, dialyzer, tests with coverage). The commit's staged tree is byte-identical to the tree that run went green on, with the repo's gate lock and one machine slot held across both, so the commit was made without a second run.

Review

Gate tier: the diff touches no released package's contract and is under the size threshold, so it took the in-turn pre-request review round: a diff review found nothing blocking. Its advisories were left as they are: the check refuses nothing the resume would accept today, since the library Paths' charts are not ones the editor resumes (the moduledoc says so); an unreadable stored scope is answered as not found with no log line; and the member's :chart_unknown assertion will move if the editor learns those charts, which its comment says.

The editor resumes a stored execution named by its execution
parameter, and a Journey's execution records the scope it runs under.
The page now reads that scope and asks the access module with the
session's actor before it resumes; an actor outside the scope is
answered what an unknown id is answered.

The host's start keeps its kind check alone, and its moduledoc says
why: the callback is handed no actor, and the caller asks the access
module before it starts. The visitor plug's moduledoc says a prod
build names no librarian.

Refs: se-4n35
@johnnyt
johnnyt merged commit 272d336 into main Nov 28, 2026
4 checks passed
@johnnyt
johnnyt deleted the se-4n35-resume-scope-check branch November 28, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant