Crew Cards: The Public Door

Design problem and decision

  • Design problem The school and the registry now have owners and operations. Nothing yet says who may ask for what.
  • Architect's decision For each public method: who is the caller, what may they ask for, and what do they get back? Where is "who" decided, and where is "whether"?
  • Outcome The viewer can write a door table for an actor, keep caller authorization at the door and business validity with the owner, choose update or query, and treat the route between two canisters as a door with its own caller rule.
  • Starting point Lesson 2 left the school at 08:40 with chain tip 117 and 344·12 Passed{91}.
  • Handoff Lesson 4 decides which accepted changes are written to a chain.
  • Pacing Four minutes.

Worked design

Crew Cards is illustrative.

Doors of school

Method Kind Caller Allowed when Reply
enroll(course) update a registered student course exists, not already on it Enrolled or Refused(reason)
record_score(student, course, score) update the instructor of that course enrolled, not yet scored, 0 to 100 Scored{passed} or Refused(reason)
request_card(course) update a registered student, for themself status Passed, no award open, workflow can admit it Ticket n or Refused(reason)
award_status(ticket) query the ticket's student, or the dean — Pending, Carded{card}, Completed or Refused(reason)
transcript() query a registered student, for themself — that student's rows
set_pass_mark(mark), add_course, add_student update controller — Ok
transport entry update added peers only — transport bytes

Doors of registry

Method Kind Caller Allowed when Reply
verify(card) query anyone — Valid{holder, course, school}, Revoked or NoSuchCard
chain reads query anyone — blocks, certified tip
accredit(school, course), suspend(school), reinstate(school), revoke(card) update controller — Ok
route card.issue peer route an added peer school that school is accredited for the course and in good standing Issued{card, block} or Rejected(reason)

The student is always derived from the caller. No method takes "which student am I" as an argument. On card.issue the school is the authenticated sender. It is never a field of the request.

The calls of this film, at 08:45, starting from chain tip 117:

Caller and call Stops at Reply Changed
mira · record_score(344, 12, 100) the door Refused(NotInstructor) nothing
tov · record_score(344, 12, 60) the owner Refused(AlreadyScored) nothing
mira · transcript() — [12: Passed 82] nothing
ode · award_status(7), previewed for after 09:00 when ticket 7 is Mira's the door Refused(NotYours) nothing
mira · suspend(harbour) on the registry the door rejected: not the controller nothing

The story in one pass

Draw doors on the school's rim and ask three questions at each. Send a student to the instructor's door and watch her stop at the rim. Send the instructor with a request the roll will not accept and watch him pass the door and be refused inside. Open the query doors. Cross to the registry: a locked row for the board, an open door for the public, and one dashed door that only a peer canister can use.

Views and visual objects

Use the shared visual language. This film introduces Door and DoorTable.

View Framing and anchor
school As in lesson 2. Doors sit on the left rim, in a fixed order from top: enroll, record_score, request_card, then the two hollow query doors, then one locked controller door. The transport entry is a narrow dashed door on the right rim, facing the channel.
registry The registry canister. A locked row of board doors on the top rim. The hollow verify door on the bottom rim. The dashed card.issue door on the left rim, facing the channel. Inside, the canonical Rechain machine with two reducers, standing and cards.
sheet The DoorTable over the left third.

Scene doors — A door is a contract

Already on screen The school view from lesson 2. Callers mira, tov, dean wait outside the left rim.

Beat three_questions — Who, what, and what comes back

View and focus school. Focus on the left rim.

Narration

Everything outside reaches the school through a public method. Think of each one as a door, and write three things on it. Who may come through. What they may ask for. What they get back. That is a contract, and it is yours to design.

Cue and animation On “a door”, three solid Doors draw on the left rim, labeled enroll, record_score, request_card. On “Who may come through”, a small caller tag writes above each door: student, instructor of the course, student. On “What they get back”, a faint OutcomeCard outline shows behind each door and fades.

Leaves with Three labeled update doors with caller tags.

Beat door_table — Write the table

View and focus sheet.

Narration

Write it as a table: method, caller, allowed when, reply. Notice what is missing. No method asks the caller which student they are. The school works that out from who is calling.

Cue and animation On “a table”, the DoorTable slides in and its first three rows fill. On “what is missing”, the argument lists highlight: (course), (student, course, score), (course). On “from who is calling”, a thin line links mira outside the rim to 340 in Students.

Leaves with The DoorTable with three rows. The table slides away.

Scene who_and_whether — Two different refusals

Already on screen The school view. Chain tip 117. Roll shows 344·12 Passed{91}.

Beat stopped_at_door — The wrong caller

View and focus school. Focus on the record_score door.

Narration

Mira tries to record a score of one hundred for Sol. The door asks Courses one question: who teaches course twelve? Tov does. Mira is not Tov. She stops at the door and gets the reason. Nothing inside was asked to change.

Cue and animation On “Mira tries”, the mira badge carries the pill record_score(344, 12, 100) to the door. On “asks Courses”, a thin read line runs from the door to Courses and returns tov. On “Mira is not Tov”, the door stays closed with a neutral bar. On “gets the reason”, a neutral OutcomeCard Refused(NotInstructor) returns to her. On “Nothing inside”, dispatch and the roll pulse once, untouched.

Leaves with Chain tip 117. No action was built.

Beat refused_inside — The right caller, the wrong request

View and focus school. Focus moves from the door to the roll.

Narration

Now Tov tries to change Sol's score to sixty. Tov is the instructor, so the door opens. Office builds the action and dispatches it. The roll looks at its own state: Sol is already scored. It refuses. No prepared change, no block.

Cue and animation On “Tov tries”, tov carries record_score(344, 12, 60) to the door. On “the door opens”, the door opens and the pill docks at Office in a write frame. On “dispatches it”, the action pill Score(344, 12, 60, 70) enters dispatch. On “already scored”, the reducer shows a cross beside Passed{91}. On “No prepared change”, the prepared commit row stays empty and the chain row stays still. A neutral OutcomeCard Refused(AlreadyScored) returns to Tov.

Hold PauseAndExplain pointing at the door and then the reducer. The balloon reads:

The door decides WHO      NotInstructor
The owner decides WHETHER AlreadyScored
Both answer with a reason.
Neither changes anything.

Leaves with Chain tip 117. Roll unchanged.

Beat no_side_door — Memory has no door

View and focus school. Focus on the roll's state folder.

Narration

There is no third way in. No door leads to the roll's memory, to Settings, or to anyone's memory. Passing a door gives you a request. It never gives you the data.

Cue and animation On “no third way in”, a faint dotted path from dean toward the roll's state folder draws and stops at the canister rim where there is no door. On “gives you a request”, the three doors pulse. On “never gives you the data”, the vaults and the state folder pulse once, closed.

Leaves with The school with three update doors.

Scene other_doors — Queries, controllers and peers

Already on screen The school view.

Beat query_doors — Reading is also a contract

View and focus school. Focus on the lower left rim.

Narration

Reads get doors too. A query door changes nothing, and it still has a caller rule. Mira may read her own transcript. Later today Mira will hold ticket seven, and Ode will not be able to read its status. And one locked door is for the controller alone: the dean sets the pass mark.

Cue and animation On “Reads get doors”, two hollow Doors draw, labeled transcript and award_status. On “her own transcript”, mira sends transcript() and an OutcomeCard [12: Passed 82] returns. On “Ode will not”, a badge ode and the pill award_status(7) draw in a dashed preview outline at the door, with a dashed neutral Refused(NotYours) beside them. The preview fades. No ticket exists yet at 08:45. On “one locked door”, a solid door with a small lock draws, labeled set_pass_mark, with dean beside it.

Leaves with Six doors on the school's left rim.

Beat registry_doors — The board and the public

View and focus school to registry.

Narration

Cross to the registry. Its authority is different, so its doors are different. Suspend, reinstate, accredit and revoke are locked to the board. Verify is open to anyone, and it only reads. Mira cannot suspend her own school, and neither can the dean.

Cue and animation On “Cross to the registry”, the camera pans right along the channel into the registry. On “locked to the board”, four locked Doors draw on the top rim with board above them. On “open to anyone”, the hollow verify door draws on the bottom rim with anyone below. On “Mira cannot”, a mira badge arrives at suspend and stops with a neutral bar.

Leaves with The registry with five doors.

Beat peer_door — A door for a canister

View and focus registry. Focus on the left rim, where the channel arrives.

Narration

One door is left, and its caller is not a person. To issue a card, the caller must be a school canister that the board has added as a peer. The registry knows which school by who delivered the message, never by a name inside it. And that school may ask for one thing only: issue a card, for a course it is accredited to teach, while it is in good standing. It cannot revoke. It cannot speak for another school.

Cue and animation On “its caller is not a person”, a dashed Door labeled card.issue draws on the left rim at the channel's end. On “added as a peer”, a small peer mark harbour appears on the door, with a thin line up to board. On “who delivered the message”, the school end of the channel lights and the mark harbour pulses. On “issue a card”, a caller tag writes: accredited · good standing, with a thin read line to the standing reducer's selector. On “cannot revoke”, the locked revoke door on the top rim pulses once.

Hold PauseAndExplain pointing at the card.issue door. The balloon reads:

card.issue
  caller    a peer school, known by its delivery
  may ask   issue, for its own accredited course
  reply     Issued{card, block} or Rejected(reason)
The student's name travels as data, not as authority.

Leaves with The registry with six doors. The channel is still empty.

Brief to hand over

Illustrative.

Doors. Implement the two door tables above exactly. Each method checks its caller before anything else and answers a wrong caller with a typed refusal. The student is derived from the caller in every student method.

Who and whether. Caller checks live at the method and in Office's reads. Validity of a change lives in the owning reducer. A refusal of either kind changes no state and adds no block.

Peer route. card.issue accepts only added peers and takes the school from the authenticated sender. The standing reducer decides whether that school may issue for that course.

Queries. A query returns owned values built for the caller. No query returns another student's rows.

Acceptance checks, expected and not run

Given Caller and command Expect Then
08:40 state, tip 117 mira · record_score(344, 12, 100) Refused(NotInstructor) no action dispatched, tip 117
same tov · record_score(344, 12, 60) Refused(AlreadyScored) tip 117, 344·12 Passed{91}
same an unregistered principal · enroll(12) Refused(NotAStudent) tip 117
same mira · transcript() [12: Passed 82] nothing changed
ticket 7 belongs to mira ode · award_status(7) Refused(NotYours) nothing changed
same mira · set_pass_mark(10) rejected: not the controller pass mark 70
registry at tip 040 dean · suspend(harbour) rejected: not the controller harbour Good, tip 040
registry at tip 040 a canister that is not a peer sends card.issue not accepted tip 040

Production and source notes

  • Crew Cards, both door tables and every refusal name are illustrative. Caller rules are app code. The SDK supplies the method attributes, guards and the caller's identity.
  • Controller-only methods beside open ones on one canister: Shop endpoints, lines 10 to 37.
  • A method that takes the caller from the system and passes it inward, and reads that answer only to an allowed caller: Chat endpoints, send, history and workflow_status.
  • An owner-only method that adds a peer, and a route handler that receives the authenticated origin: Heavy16 endpoints, add_peer at line 116 and route at line 48. The transport entry passes the system caller to Reactor: the same file, reactor_receive.
  • A reducer can also check the acting principal carried in the action against its own state: Heavy16 ledger, the prepare of WorkView. Crew Cards uses this in the standing reducer.
  • Public values are owned and typed. Services do not expose persistent carriers, keys or guards: Conventions, lines 314 to 329.
  • Distinguish the sending canister from the original caller it forwards: Takt reference, events, last paragraph.
  • Draw Doors on the rim only. A door never extends into the canister. Solid is update, hollow is query, dashed is a peer route, a small lock is controller-only.
  • Draw the transport entry as a narrow dashed door on the right rim of the school. It is not a business door. Do not send a pill through it in this film.
  • The registry's two reducers are drawn in this film and stay idle. Lesson 4 runs them.
  • The balloon in refused_inside uses a fixed-width layout. Keep its two refusal names aligned.