From d25d46557eaa679b444665130d5256b89e17f046 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Mon, 12 Oct 2026 17:01:00 -0500 Subject: [PATCH] pola: the test takes the spontaneous step; actors decide the rest Replaces the self/puppet split: `alice.tradeWith(bob)` rather than `alice.pay(to, amount)`, per the actor-sim skill. Generated-by: Claude Opus 5.5 --- pola/SKILL.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pola/SKILL.md b/pola/SKILL.md index 04579ce..f5d89e3 100644 --- a/pola/SKILL.md +++ b/pola/SKILL.md @@ -27,7 +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. +- **The test takes the spontaneous step; actors carry out the consequences.** Give an actor what it knows at construction and let it decide how to act: `alice.run()`, or `alice.tradeWith(bob)` to introduce a counterparty. Don't drive it with arguments that decide for it, like `alice.pay(to, amount)`: that is the test acting with Alice's authority, as if it held her purse. What an actor hands others (a deposit facet, a shop) carries no authority to spend for it. - **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 @@ -41,11 +41,12 @@ const makeAlice = async ({ usdcIssuer, stockIssuer, dollars }) => { const usdc = await E(usdcIssuer).makeEmptyPurse(); // Alice's alone ... return harden({ - self: { getBalances }, // what she'd show anyone - puppet: { buy: (shop, price) => ... }, // the test makes her act + // Alice decides what to pay; Bob shows only his shop + tradeWith: async bob => E(bob.shop).sell(await E(usdc).withdraw(price), ...), + getBalances, }); }; -await alice.puppet.buy(bob.self.shop, dollars(300n)); +await alice.tradeWith(bob); // the one spontaneous step ``` ## Review checklist @@ -54,5 +55,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? Does any public facet have a method that spends or acts for its owner? +3. Could a narrower facet replace what's passed? Does any facet let a caller spend for its owner, or does the test decide what an actor does? 4. Name the wiring layer at this level. Is it small?