RSX for application architects
Eight short films teach the mental model for designing a canister app on cdk-rsx and specifying it for a developer team or an AI. The viewer does not write the code. The viewer decides which modules exist, what each one saves, who may call whom, which storage each feature needs, how the app changes over releases, and how to prove the design before and after it ships.
Each lesson.md is a storyboard design. Its narration blocks, read in order, are the voiceover. The surrounding directions say what is already on screen, where to point, which phrase starts each motion, and what state the beat leaves behind.
The architecture player has the rendered films, with chapters, captions and transcripts. Build them with npm run build:newstack-arch. No sibling code was built or run: Tool Library and its outcomes are illustrative, and the stage data in src/newstack-arch/stages/ draws the values written in each storyboard.
Audience
The viewer knows Internet Computer basics: canisters, update and query calls, controllers and upgrades. They can read a file tree and a ten-line snippet. They think in features, modules and business rules, and they hand the building to others.
Two existing series serve other audiences and stay as they are:
| Series | Audience | What it shows |
|---|---|---|
| dev_coder | A developer writing the app | Real source in editor panes, one feature request per film |
| Internal system | An engineer of the CDK | Storage machinery, layouts and the upgrade guard from inside |
| This course | An architect who specifies the app | Modules, ownership, contracts and release decisions in motion |
This course keeps the file tree and the memory/v1.rs, v2.rs files from dev_coder as landmarks. It shows a snippet only when the snippet settles a decision. It leaves macro output, storage layout and allocator behavior to the other two series.
The worked app
One app carries all eight films. Tool Library is an illustrative design made for this course. It is not in the ../newstack checkout. A neighborhood library lends tools from several branches.
| Feature | Rule |
|---|---|
| Lend a tool | A member borrows a tool from a branch for 14 days. A member holds at most 3 loans. |
| Give it back | The tool returns to its branch shelf. |
| Branches | An admin opens and closes branches. A branch can close only when every tool is home. |
| Overdue list | Staff list loans past their due day, oldest first. |
| Late fee | An overdue loan is charged through a separate payments canister. |
| Later releases | Release 2 refuses to lend to a member with an overdue loan. Release 3 records each tool's condition. |
Its file tree is the landmark the viewer follows in every film:
src/
lib.rs public canister methods
desk.rs lend and give back; saves nothing
root/
mod.rs install, restore, service wiring
memory/{mod.rs, v1.rs} what the root attaches
policy/
mod.rs
memory/{mod.rs, v1.rs} loan days, loan limit
members/
mod.rs
memory/{mod.rs, v1.rs} member -> active loans
branches/
mod.rs open and close a branch
memory/{mod.rs, v1.rs} keyed children: one Shelf per branch
shelf/
mod.rs
memory/{mod.rs, v1.rs} tool -> owned, available
loans/
mod.rs
memory/{mod.rs, v1.rs} (due day, loan) -> member, branch, tool
The same numbers recur. Branch 3 owns four of tool 17 and has two on the shelf. Member 501 holds two loans. On day 100, lend(501, 3, 17) returns loan 7, due on day 114.
Every rule the app relies on is anchored to a real example in the checkout. The mapping is in Source anchors. Shop supplies the module shapes, the probes supply the upgrade behavior, and RRT Heavy16 supplies evidence of the folder convention and of a readiness check in a large app. None of them is a lesson subject.
Course spine
The films follow one question at a time, in the order an architect meets them.
- What is a module, and what does its seal protect?
- How do modules work together without owning each other?
- When does a thing in my domain deserve its own module?
- What happens at install, and what happens at every later start?
- Which storage does each feature need?
- What does an upgrade check before it touches my data?
- How does saved data change shape?
- How do I prove the design and hand it over?
Films 1 to 4 build the app. Film 5 chooses its storage. Films 6 and 7 change it. Film 8 turns the earlier briefs into a simulation and a release rehearsal.
Mental-model review
The author's model was checked against the current source before the films were designed. It is right in its main lines. Five points changed the scripts:
- A keyed set of child modules is its own attachment type. It is not a map inside a module's data.
- The upgrade check covers layout and declared meaning for every module type under the root, plus the SDK and compiler identity. It does not cover business code, saved values or pending work.
- Nyxus and Hylix are chosen per memory declaration. Minima is an experimental collection library used inside a Nyxus memory.
- The guides make no general promise of speed. They ask for measurement.
- Changing an attached module's declared memory version also changes the parent declarations that pin it, along the path to the root.
The full review, with evidence and the exact wordings used in narration, is in mental-model-review.md.
Lessons
1. A Module Owns Its Memory
Teaches. A module is public functions, private memory, and the code between them. Outside the module the memory is a sealed handle, and only the module's own code holds the key. The viewer learns what that seal guarantees and what it does not, where the module lives in the file tree, and why a refusal must be decided before any write. The Shelf module lends one tool and refuses another.
Visualizes. One ModuleCapsule for Shelf sits beside the AppTree. A call pill enters at the public rim, passes the service band, and the key opens the vault. A second pill aimed straight at the vault from outside stops at the seal. The vault's values change in place, and a refused call leaves them still.
2. Who Owns and Who Calls
Teaches. An app has two drawings. The owning tree says where memory lives. The call graph says which service talks to which. Desk saves nothing and composes Policy, Members, Branches and Loans in one frame. The viewer learns to check every rule first and write last, and to keep borrowed state out of an awaited call.
Visualizes. Five capsules hang from the root on solid owning edges. Thin call lines then appear on top, crossing the tree. One lend pill travels the call lines inside a write frame. A check row fills with ticks before any value moves. For the late fee, the frame closes, a dashed arrow leaves the canister, and a new frame opens on return.
3. A Module for Every Branch
Teaches. Some domain things are rows, and some deserve their own module. A keyed set of child modules gives each branch a sealed Shelf with its own lifetime. The viewer compares that with a plain map of rows and learns the consequences: closing a branch removes its whole shelf, reopening starts empty, and the app must set the bound.
Visualizes. The Branches capsule grows a keyed fan. Opening branch 5 slides a new Shelf capsule onto key 5. A split screen puts the fan beside a plain table of rows and marks who can read inside each. Closing branch 3 is refused while a tool is out. Later it closes, and its capsule fades with everything inside.
4. Install Once, Bind Every Time
Teaches. Install builds the owning tree once, in one step, from the root. Every later start finds the tree again. Both paths end by binding the services, because services do not survive an upgrade and memory does. The viewer learns which file holds each path and what a same-contract release changes: code only.
Visualizes. An empty canister fills from the root down in one write frame, with one ticket per module moving into its slot. The service bands then draw over the vaults. At the upgrade the bands dissolve, the vaults stay lit with their values, a new code card slides in, and the bands redraw. Branch shelves created after install are still on their keys.
5. Choose Storage by What It Must Promise
Teaches. Storage is chosen per feature from what the feature must promise. The viewer makes five choices for Tool Library: an exact ordered map for due dates, a module per branch, a published table that is rebuilt as a whole, a filter whose yes needs an exact check, and a stable-memory engine for an archive that only grows. They learn that Nyxus and Hylix are per-memory choices, that Minima is experimental, and that every collection needs a bound.
Visualizes. Five ChoiceCards line up beside the app, each with three rows: holds, answers, costs. Each card connects to the vault it describes. The overdue list walks a sorted column and stops at a page limit. A serial number passes a filter and is then checked against the exact map. A replaced catalog swaps as one piece.
6. The Contract an Upgrade Starts From
Teaches. The canister remembers the contract of the memory it holds. A new build is admitted only if it expects that contract or names it as its predecessor. The viewer learns what the contract covers, what admission does not prove, why shipped version files are frozen, and that readiness is the app's own decision made by the old release.
Visualizes. Each vault carries a ContractSeal. The seals fold up the owning tree into one root seal. A Gate compares the root seal with the seal on each incoming build on the ReleaseRail. A code-only build passes. A build with one edited version file is turned away and the old release keeps running. A pending late fee makes the old release refuse the upgrade before the gate is reached.
7. Each Owner Converts Its Own
Teaches. Release 3 adds a condition to every tool. The viewer learns the shape of a migration: a new version file for Shelf, for Branches above it and for the root, with siblings left alone. Each owner converts only its own memory and passes its children down. All of it happens inside one upgrade. A failure leaves release 2 running. After success, the old build is refused.
Visualizes. In the AppTree, v2.rs appears in three folders and stays absent in three. In the owning tree, the root hands Branches down, Branches hands each Shelf down, and a new column appears in every shelf table. Members, Loans and Policy move across unopened. A second run fails late and the whole picture snaps back. A last attempt installs the old build and stops at the gate.
8. Rehearse the Design
Teaches. A design brief includes two ways to check it. A simulation runs commands against the modules and checks the domain rules after every step, including refusals. A rehearsal installs and populates the old release, tries the upgrade paths the app must support, and compares values before and after. The viewer learns to specify both.
Visualizes. A ScenarioSheet fills row by row, with the app's capsules reacting to each command and three invariant lights staying green. A RehearsalStrip then plays five upgrade attempts against a populated canister, with a before and after value card under each. The film ends on the complete BriefCard.
Shared visual language
Use the light paper, restrained semantic colors, small title and focused balloons from the Rechain, Reactor and Takt films. Each concept has one drawing. A close-up moves the camera into that drawing and never swaps it for a simpler one. Workspace teaching and style guide
| Concept | Drawing |
|---|---|
| Where a decision lives | AppTree. The Tool Library file tree, with fixed positions in every film. A new file slides into place. A shipped version file carries a small lock. Shared with dev_coder. |
| A module | ModuleCapsule. Three layers in one rounded outline. The top rim lists public functions. The middle band is the service, drawn with a dashed outline because it is rebuilt at every start. The bottom is the memory vault, drawn solid, with a version tab such as v1 and a small key badge that never leaves the capsule. |
| Saved values | A plain table inside the open vault. Decreases show in red with a negative delta. Increases show in green with a positive delta. |
| Ownership | OwnTree. Solid edges from a parent's vault to a child capsule. A keyed child set is a fan of edges with the key written on each. |
| Who calls whom | CallLines. Thin arrows between service bands, drawn over the tree. |
| A call | The warm rounded pill from the earlier films, carrying the full call such as lend(501, 3, 17). A solid arrow is a local call. A dashed arrow with a clock is an awaited call to another canister. |
| One call's reach | Frame. A thin outline around the capsules taking part, labeled read or write. |
| A result | OutcomeCard. The returned value, such as Lent { loan 7, due 114 }. A refusal uses the same card with a neutral outline. |
| A storage choice | ChoiceCard. Three rows: holds, answers, costs. A leader connects it to the vault it describes. |
| The memory contract | ContractSeal on each vault and one on the root. Gate compares the root seal with an incoming build's seal. An accepted check is a green tick. A refusal is a red bar across the gate. |
| Releases | ReleaseRail. Build cards r1, r2, r3 on a rail above the app. The installed build sits in a socket. |
| A simulation | ScenarioSheet. Rows of given state, command, expected outcome and the invariants that must still hold. |
| A release rehearsal | RehearsalStrip. A sequence of upgrade attempts, each with a value card before and after. |
| What to hand over | BriefCard. A short paper card with the request and its acceptance test. |
| Explanation | PauseAndExplain. All motion holds, a dashed leader points at an unchanged component, and a balloon opens above it. Motion resumes from the held frame. PauseAndExplain |
PauseAndExplain and the call pill exist in the workspace. AppTree comes from the dev_coder build. ContractSeal and Gate should reuse the fingerprint and gate geometry from the internal series, drawn at app level with no layout detail. Memory modules and Catalog The other names are proposals for the build.
Storage cells, pages, byte layouts, allocators and macro output stay off screen in this course.
Source anchors
Tool Library is illustrative. Each behavior it shows is taken from a real example, and the lesson's source notes name the lines.
| Tool Library | Anchor in ../newstack |
What the anchor establishes |
|---|---|---|
| Shelf, its seal and its bound | Shop inventory · Inventory version file | Owner-private fields, check before write, an app-set bound |
| Desk | Shop checkout | A stateless service composing others in one frame |
| Branches and its keyed shelves | Shop branches · Shop tests | Keyed child modules, removal and a fresh module on reopen |
| Install, restore and binding | Shop root wiring | One install frame, a restore path, one bind function |
| Awaited late fee | Async scope probe | Nothing borrowed crosses an await |
| Code-only release | Nested lifecycle test · SDK lifecycle test | Changed business code over the same populated memory |
| Readiness check | Heavy16 root | An app-written check that refuses an upgrade while work is pending |
| Migration through root, parent and keyed children | Nested probe root · Composition probe root V2 | Each owner converts its own memory and delegates children |
| Refusal, rollback and downgrade | Root authoring lifecycle test | Undeclared source refused, late failure rolled back, downgrade refused |
| Filter with exact confirmation | Minima benchmark tables | Each filter positive is followed by an exact lookup |
| Archive on Hylix | Hylix probe records | A hylix memory declaration in the same tree |
Primary guides: Conventions · Store architecture · Upgrades · Engines · Collections · Minima guide · Status · Compatibility · Testing
Status of examples and tests
- Tool Library, its numbers, its outcomes and every brief are illustrative. No Tool Library code exists.
- Every "acceptance test", "simulation" and "rehearsal" in the lessons is an expected test that was not run.
- Statements about SDK behavior come from the guides and linked test sources at
5af68e8a0c293b239b3f11eb0de749432f9f31f0. The review also checked the tree at merge commitf6c863661ada43a6766448fc84fc6923944dd98b, which has the same contents. Expected test outcomes come from source inspection. - The SDK is an unreleased prototype. Minima is experimental. Status
- Line numbers in source notes refer to that commit. Find the item by name if a file has moved on.
Editing the drafts
- Read the narration straight through. Each new term needs a visible object, and each sentence should move the design decision forward.
- Walk the beats with the narration muted. At each cue the named object is in frame, the cause comes before its effect, and the next beat starts from the visible result.
- If a sentence begins to explain how the SDK enforces a rule, replace it with what the architect decides and what they can observe.
- Keep scene and beat IDs stable through wording edits. Set frame boundaries after generating narration.
Continue with application design
After this series and the Rechain, Reactor and Takt primers, the whole-app design lessons use a new example to choose actor boundaries, define public methods and draw and rehearse a cross-actor workflow.