From 8cf472636d84c15458d3addff431efc82468d048 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Mon, 12 Oct 2026 16:54:34 -0500 Subject: [PATCH] pola: split a party's self facet from its puppet facet From a review of vattr97 #33: a public `pay` method is as good as handing out the purse. Generated-by: Claude Opus 5.5 --- pola/SKILL.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pola/SKILL.md b/pola/SKILL.md index ab2db09..04579ce 100644 --- a/pola/SKILL.md +++ b/pola/SKILL.md @@ -27,6 +27,7 @@ So at each level, code has two roles: - **Attenuate at API boundaries.** Hand out the narrowest facet that works: a deposit facet rather than the purse; a seat rather than the escrow's admin; a read-only view rather than the DB. When designing an API, decide which facets it has and who should get each. - **Separate parties get separate scopes.** If two parties' authority shares a scope, a bug or a careless line lets one act as the other. A scope holding both Alice's and Bob's purses is a design error. - **Tests too.** Tests are where the code's intended authority flow is first written down. Write each party as a `makeFoo`-style actor holding its own authority privately; the test's top level is the wiring layer that creates the parties and introduces them ([sequence-diagram-actor-sim](https://github.com/Agoric/agoric-sdk/blob/master/.agents/skills/sequence-diagram-actor-sim/SKILL.md)). +- **Split what a party shows from what makes it act.** A maker returns `{ self, puppet }`. `self` is what the party would hand anyone: a deposit facet, a shop, perhaps a balance. `puppet` holds the methods that exercise the party's own authority, such as `pay` or `offer`; a `pay` method on the public face is as good as handing out the purse. Only the driver (the test, or the party's own UI) gets the puppet. A party that acts only when called needs no puppet. - **Modules decide what authority enters through imports and leaves through exports.** Export makers, not instances that close over power ([no-ambient-authority](../no-ambient-authority/SKILL.md)). ```ts @@ -35,12 +36,16 @@ const alice = { usdc: await E(usdc.issuer).makeEmptyPurse(), ... }; const bob = { usdc: await E(usdc.issuer).makeEmptyPurse(), ... }; await E(seatB).offer(await E(bob.stock).withdraw(shares(3n)), ...); -// right: each party holds its own; the test only wires and observes -const makeBob = ({ stockIssuer, usdcIssuer, stockPayment }) => { - const stock = E(stockIssuer).makeEmptyPurse(); // Bob's alone +// right: each party holds its own; the test wires, drives, and observes +const makeAlice = async ({ usdcIssuer, stockIssuer, dollars }) => { + const usdc = await E(usdcIssuer).makeEmptyPurse(); // Alice's alone ... - return { sell: seat => ..., getBalances: () => ... }; + return harden({ + self: { getBalances }, // what she'd show anyone + puppet: { buy: (shop, price) => ... }, // the test makes her act + }); }; +await alice.puppet.buy(bob.self.shop, dollars(300n)); ``` ## Review checklist @@ -49,5 +54,5 @@ Before committing, for each new maker, scope, and export: 1. Draw (in your head or as a [wiring-diagram](../wiring-diagram/SKILL.md)) who holds what after this change. 2. Does any non-wiring scope hold two parties' authority, or more than its task needs? -3. Could a narrower facet replace what's passed? +3. Could a narrower facet replace what's passed? Does any public facet have a method that spends or acts for its owner? 4. Name the wiring layer at this level. Is it small?