Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
384a88899c | ||
|
|
e62f6ac285 | ||
|
|
b5411466e3 | ||
|
|
f720e3d341 | ||
|
|
427a8f4642 | ||
|
|
5e468ef525 | ||
|
|
abde27c130 | ||
|
|
e887996105 | ||
|
|
4221f2d176 | ||
|
|
fd47da3a98 | ||
|
|
65761a1da5 | ||
|
|
b1cdb74e75 | ||
|
|
d25d46557e | ||
|
|
8cf472636d | ||
|
|
b64b80efd5 | ||
|
|
237b470be8 | ||
|
|
9538b4ea0a | ||
|
|
581e8af605 | ||
|
|
f115f6eda3 | ||
|
|
a4308a5722 | ||
|
|
6d150c4450 | ||
|
|
2a0815f004 |
No files matched your search
@@ -14,6 +14,12 @@ Code](https://code.claude.com/docs/en/skills) and
|
|||||||
|
|
||||||
## writing code
|
## writing code
|
||||||
|
|
||||||
|
- [pola](pola/SKILL.md) — organize all code, tests included, by
|
||||||
|
the flow of authority: each part gets only what its task needs.
|
||||||
|
- [facet](facet/SKILL.md) — hand other code a fresh, frozen object; what its functions return crosses the boundary too.
|
||||||
|
- [capability-based-design](capability-based-design/SKILL.md) — one object per authority distinction; narrowing only intersects.
|
||||||
|
- [caretaker](caretaker/SKILL.md) — revocable access as a forwarder plus a separate revoker.
|
||||||
|
- [acls-dont](acls-dont/SKILL.md) — don't check who's asking; hand out narrowed capabilities. An anti-pattern, in pattern form.
|
||||||
- [no-ambient-authority](no-ambient-authority/SKILL.md) — clocks,
|
- [no-ambient-authority](no-ambient-authority/SKILL.md) — clocks,
|
||||||
RNGs, `fetch`, and the filesystem come in as parameters.
|
RNGs, `fetch`, and the filesystem come in as parameters.
|
||||||
- [io-between-turns](io-between-turns/SKILL.md) — sync I/O is a pointy
|
- [io-between-turns](io-between-turns/SKILL.md) — sync I/O is a pointy
|
||||||
@@ -43,14 +49,25 @@ Code](https://code.claude.com/docs/en/skills) and
|
|||||||
the link goes; no bare URLs, no "click here".
|
the link goes; no bare URLs, no "click here".
|
||||||
- [citation-needed](citation-needed/SKILL.md) — back a challenged claim
|
- [citation-needed](citation-needed/SKILL.md) — back a challenged claim
|
||||||
with live links, quoted and dated.
|
with live links, quoted and dated.
|
||||||
|
- [hackmd-deck](hackmd-deck/SKILL.md) — a light talk as a flashback:
|
||||||
|
TADA, then how, then the challenges, tagged for an emoji retro.
|
||||||
- [ibis-design](ibis-design/SKILL.md) — search a design space:
|
- [ibis-design](ibis-design/SKILL.md) — search a design space:
|
||||||
issues, positions, and arguments.
|
issues, positions, and arguments.
|
||||||
|
- [wiring-diagram](wiring-diagram/SKILL.md) — who holds what, drawn
|
||||||
|
like MarkM's ERTP slides: every arrow cites the code, and Mallory
|
||||||
|
shows what a leak doesn't reach.
|
||||||
|
TODO: consider copying or adapting its companion for message order,
|
||||||
|
sequence-diagram-actor-sim (agoric-sdk `.agents/skills/` on branch
|
||||||
|
`connolly/ago-1299-agentic-planning-tdd`).
|
||||||
- [obsidian-markdown](obsidian-markdown/SKILL.md) — the workspace is
|
- [obsidian-markdown](obsidian-markdown/SKILL.md) — the workspace is
|
||||||
an Obsidian vault: one line per paragraph, relative links, no file
|
an Obsidian vault: one line per paragraph, relative links, no file
|
||||||
symlinks you expect Obsidian to show.
|
symlinks you expect Obsidian to show.
|
||||||
|
|
||||||
## at the terminal
|
## at the terminal
|
||||||
|
|
||||||
|
- [discord-agent-workspace](discord-agent-workspace/SKILL.md) — set
|
||||||
|
someone up like this: Claude Code in a workspace folder, messaged
|
||||||
|
from Discord.
|
||||||
- [watchme](watchme/SKILL.md) — I record the session with `script -f`;
|
- [watchme](watchme/SKILL.md) — I record the session with `script -f`;
|
||||||
read the typescript instead of asking me what happened.
|
read the typescript instead of asking me what happened.
|
||||||
- [run-confined](run-confined/SKILL.md) — run an untrusted installer in
|
- [run-confined](run-confined/SKILL.md) — run an untrusted installer in
|
||||||
@@ -62,7 +79,18 @@ Code](https://code.claude.com/docs/en/skills) and
|
|||||||
|
|
||||||
## adding one
|
## adding one
|
||||||
|
|
||||||
Name the directory for the trigger, not the topic. Write the
|
Name the directory for the trigger, not the topic. Write the `description` for the matcher: what I'd say, what I'd be doing, and what it's *not* for.
|
||||||
`description` for the matcher: what I'd say, what I'd be doing, and
|
|
||||||
what it's *not* for. Cite the source; quote the key line; explain the
|
Write the body for an agent in the middle of a task. It reads the skill's text, not the pages the skill links to, and it acts on rules, examples, and reasons:
|
||||||
rest.
|
|
||||||
|
- **Body:** the rule, an example, and a line of why; the why carries the rule to cases it doesn't spell out. Use terms of art by name ("confused deputy", "POLA"): a known name is a key into what the agent already knows. Quote a source only where its words *are* the rule.
|
||||||
|
- **Sources:** a footer with one line per source: title, link, and a clause saying what's there. It's for people, and for backing a claim when it's challenged ([citation-needed](citation-needed/SKILL.md)).
|
||||||
|
- **History**, such as who said what, when, or how the rule came about, goes in the commit message.
|
||||||
|
|
||||||
|
For each line, ask: would deleting it change what an agent does? If not, it belongs in the footer or the commit message.
|
||||||
|
|
||||||
|
When a skill resolves a tension, with forces pulling different ways, write it as a pattern after the Portland Pattern Repository (and Alexander before it): **Context**, **Problem**, **Forces**, **Therefore**, **Resulting context**. The forces give an agent reasons to handle cases the rules don't cover, and the resulting context says what the resolution costs. An anti-pattern takes the same form, with the tempting answer among the forces. See [notify-me](notify-me/SKILL.md) and [acls-dont](acls-dont/SKILL.md). A recipe with no tension, like [yarn-lock-separate-commit](yarn-lock-separate-commit/SKILL.md), stays plain.
|
||||||
|
|
||||||
|
TODO: revise every skill with this in mind.
|
||||||
|
|
||||||
|
TODO: revise every skill for flow. Edits tend to be local: a new point gets added where it was needed, without asking how it changes the whole. Read each skill end to end, and rework it so it reads as one document.
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
---
|
||||||
|
name: acls-dont
|
||||||
|
description: >-
|
||||||
|
ACLs don't: allowlists and access lists are an anti-pattern; hand out a narrowed capability instead of checking who's asking. Use when about to write or review an allowlist, whitelist, ACL, permission table, role check, `isAllowed(user)`, `allowed.includes(sender)`, or an `access.json`; when deciding who may use a bot, service, endpoint, device, or store; when someone says "allowlist", "ACL", "ACLs don't", or "confused deputy". Not for choosing which narrowing to hand out, or how to shape the API that narrows (that's pola).
|
||||||
|
---
|
||||||
|
|
||||||
|
# ACLs don't
|
||||||
|
|
||||||
|
```js
|
||||||
|
// anti-pattern: the bot hears everyone, then checks a list
|
||||||
|
E(gateway).subscribe(msg => {
|
||||||
|
if (allowed.includes(msg.author.id)) respond(msg);
|
||||||
|
});
|
||||||
|
|
||||||
|
// therefore: whoever holds "hear everyone" narrows it, and the bot gets only that
|
||||||
|
const fromDan = M.splitRecord({ author: M.splitRecord({ id: danId }) });
|
||||||
|
const bot = makeBot({ messages: E(all).narrow(fromDan) });
|
||||||
|
```
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
A component can do things for several parties, and not every party should get all of it: a bot in a shared channel, an HTTP endpoint, a device, a store.
|
||||||
|
|
||||||
|
## Problem
|
||||||
|
|
||||||
|
**How does the component keep each party to what it may do?**
|
||||||
|
|
||||||
|
## Forces
|
||||||
|
|
||||||
|
- An allowlist looks simple and auditable: one list, one check.
|
||||||
|
- Frameworks offer one by default, so it's the first thing to hand. The Discord plugin keeps one in `access.json`.
|
||||||
|
- To check the list, the component must hold the authority for every party and choose, on each request, whose to use. That is the setup for a **confused deputy**: it uses one party's authority on behalf of another. The check asks "who is asking?" when the question that matters is "with what authority?", and once a request has passed through a third party, the answer is gone.
|
||||||
|
- The list puts policy inside the mechanism. Changing who may do what means editing the component's state or config, and a party can't pass a slice of its access on to someone else without asking whoever keeps the list.
|
||||||
|
- Some identity has to come in from outside: a Discord user id, a login.
|
||||||
|
|
||||||
|
## Therefore
|
||||||
|
|
||||||
|
**Don't check who's asking. Hand each party a capability narrowed to what it may do, and let the component serve whoever holds one.**
|
||||||
|
|
||||||
|
- The component offers its wide capability, and ways to narrow it: `narrow(pattern)`, `pathjoin`, `withinHost` (see [pola](../pola/SKILL.md)).
|
||||||
|
- The party that creates it narrows and hands out. "Who may do X" is now "who was handed X".
|
||||||
|
- An outside identity becomes a capability once, at the edge, by a narrowing done by the party that holds the wide capability: `all.narrow(from(userId))`. Components inside never see the list.
|
||||||
|
- To take access back, hand out a revocable forwarder (a caretaker) and revoke it, rather than deleting a list entry.
|
||||||
|
|
||||||
|
## Resulting context
|
||||||
|
|
||||||
|
There's no check to forget or get wrong, and a party can't use authority it wasn't handed. "Who can do X?" is answered by who holds a reference to X, which a [wiring-diagram](../wiring-diagram/SKILL.md) shows. A holder can share its access, or a narrower slice of it, without asking anyone.
|
||||||
|
|
||||||
|
Revocation has to be designed in, as caretakers, rather than coming free with a list. Auditing means tracing references, not reading one table.
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- [ACLs don't](https://papers.agoric.com/papers/acls-dont/full-text/): Tyler Close, HP Labs, 2009 (HPL-2009-20). The ACL model can't make correct access decisions for interactions among more than two principals, because the information they need isn't kept across message sends; CSRF and clickjacking are instances of this.
|
||||||
|
- [The Confused Deputy](http://cap-lore.com/CapTheory/ConfusedDeputy.html): Norm Hardy, 1988. A compiler with authority to write its billing file is tricked into overwriting it by a user who names that file as the output.
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
name: capability-based-design
|
||||||
|
description: >-
|
||||||
|
Capability-based design (Tribble): every distinction in authority is a different object, and narrowing never widens. Use when designing an API, SDK, service, device, or object model that others will hold pieces of; when writing attenuation or builder methods (readOnly, subdir, narrow, restrict, scoped, forUser); when splitting read from write, or use from administration; when a scoped handle checks paths, URLs, or names. Not for what one callback receives (that's facet).
|
||||||
|
---
|
||||||
|
|
||||||
|
# Capability-based design
|
||||||
|
|
||||||
|
Give each distinct authority its own object; holding the object is the permission.
|
||||||
|
|
||||||
|
1. **One object per authority distinction.** Reading and writing are different objects; so are using a resource and administering it.
|
||||||
|
```js
|
||||||
|
// bad: one object, a mode flag, and a check
|
||||||
|
file.write(data, { as: user });
|
||||||
|
// good
|
||||||
|
const { reader, writer } = openFile(path);
|
||||||
|
```
|
||||||
|
2. **Narrowing returns a new object and only intersects.** A narrowed handle's narrowing methods can't escape its own limits: "widening is a security hole".
|
||||||
|
```js
|
||||||
|
// bad: the second call replaces the first
|
||||||
|
onlyTypes: types => make({ ...opts, types }),
|
||||||
|
// good: keep every constraint; all must hold
|
||||||
|
onlyTypes: types => make({ ...opts, filters: [...opts.filters, t => types.includes(t)] }),
|
||||||
|
```
|
||||||
|
3. **Keep limits and secrets in closures,** never on properties the holder can read or overwrite (`this.root`, `this.token`). Freeze every object you return.
|
||||||
|
4. **Check the parsed form,** the one the far side will act on, not string prefixes of the raw input.
|
||||||
|
```js
|
||||||
|
// bad: 'docs/../../etc/passwd' starts with 'docs/'
|
||||||
|
if (!rel.startsWith(dir)) throw Error('outside');
|
||||||
|
// good
|
||||||
|
const abs = path.resolve(root, rel);
|
||||||
|
if (!abs.startsWith(root + path.sep)) throw Error('outside');
|
||||||
|
```
|
||||||
|
5. **Separate access control from use.** The code that decides who gets which handle is not the code that uses it; the handle's methods take no identity.
|
||||||
|
6. **Identify the authoritative source.** A file's name belongs to the directory, not the file; give each fact to the object that owns it.
|
||||||
|
|
||||||
|
Before finishing, write a test that plays the holder of the narrowest handle: call every method with hostile arguments and narrow it again, and check that nothing reaches outside its limits.
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- Dean Tribble, *Capability-based Design: Applying Security Techniques to Object-Oriented Design* (slides, Agoric): "All distinctions in authority are represented by different objects"; "'Widening' is a security hole"; "Capability-based design also drives clear abstraction boundaries".
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
name: caretaker
|
||||||
|
description: >-
|
||||||
|
Caretaker: revocable access as a forwarder plus a separate revoker. Use when access must end later: when a contract, session, share, conversation, or trial ends; when someone asks for "revoke", "expire", "cancel access", or "undo sharing".
|
||||||
|
---
|
||||||
|
|
||||||
|
# Caretaker: revoke by cutting the forwarder
|
||||||
|
|
||||||
|
**Bad:** a flag on the object you hand out; the holder can read and flip it.
|
||||||
|
```js
|
||||||
|
const share = { file, revoked: false, read() { if (!this.revoked) return this.file.read(); } };
|
||||||
|
```
|
||||||
|
**Good:** the holder gets the forwarder; only the owner gets the revoker.
|
||||||
|
```js
|
||||||
|
const makeCaretaker = target => {
|
||||||
|
let t = target;
|
||||||
|
const forwarder = Object.freeze({ read: () => { if (!t) throw Error('revoked'); return t.read(); } });
|
||||||
|
const revoker = Object.freeze({ revoke: () => { t = null; } });
|
||||||
|
return { forwarder, revoker };
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Rules: the forwarder exposes no way to reach the target, the revoker, or the revoked state; every method checks; revocation can't be undone by the holder.
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- [E in a Walnut: Capability Patterns](https://www.skyhunter.com/marcs/ewalnut.html#SEC45): the caretaker as revocable forwarder.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: citation-needed
|
name: citation-needed
|
||||||
description: Provide live, verifiable links when a factual claim is challenged with "citation needed", or when asserting a fact likely to be challenged. Formats citations as blockquote markup with the page title as the link and a date. Not for code references or repo-local docs.
|
description: Provide live, verifiable links when a factual claim is challenged with "citation needed", or when asserting a fact likely to be challenged; when writing an outline or article that may be published, with a References or sources section, a CSL-JSON sidecar, or a Zotero collection. Formats citations as blockquote markup with the page title as the link and a date. Not for code references or repo-local docs.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Citation Needed
|
# Citation Needed
|
||||||
@@ -34,6 +34,54 @@ raw in-your-face URLs.
|
|||||||
> — [Source Page Title](https://example.com/path), Site Name, Sep 23, 2026
|
> — [Source Page Title](https://example.com/path), Site Name, Sep 23, 2026
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In madmode.com posts, the dash is `--`:
|
||||||
|
`> -- [Page Title](https://example.com/path), Author or Site, Mon YYYY`.
|
||||||
|
|
||||||
|
## Writing for publication
|
||||||
|
|
||||||
|
Anything that may be shared publicly cites public sources only: never
|
||||||
|
unpublished notes, private LLM chats, or local-only links such as
|
||||||
|
`zotero://select`. A claim that rests on one of those either becomes the
|
||||||
|
author's own words or gets flagged ⚠️ until a real source turns up.
|
||||||
|
|
||||||
|
- **Primary sources first.** Cite the W3C workshop paper, not a post about
|
||||||
|
it. The author's own blog post on the topic goes in parentheses after
|
||||||
|
it, as an inline link.
|
||||||
|
- **Every reference gets a date**, so none pile up undated at the end of
|
||||||
|
a newest-first list: software by a release from around when it became
|
||||||
|
well known, web pages "as of" the month you read them, statutes by
|
||||||
|
enactment.
|
||||||
|
- **Outlines:** use Markdown footnotes (`[^key]`) collected in one
|
||||||
|
`## References` section at the end, newest first, with no subheadings
|
||||||
|
(Obsidian moves footnote definitions to the bottom, leaving
|
||||||
|
subheadings empty).
|
||||||
|
- **CSL-JSON sidecar:** keep `<name> - references.json` next to the
|
||||||
|
outline, in the same order, with `id` equal to the footnote key. It's
|
||||||
|
the data behind everything else.
|
||||||
|
- **Published posts:** don't hand-write the sources list. Put
|
||||||
|
`bib: <name> - references.json` in the post's front matter, and the
|
||||||
|
madmode site renders it with the xhlt91 bibliography conventions
|
||||||
|
(`templates/_bib.html`, `tools/csl_bib.py`). Notes starting "TODO" or
|
||||||
|
"placeholder" stay out of the published list.
|
||||||
|
- **Zotero:** `tools/zotero_import_csl.py` in madmode-blog imports the
|
||||||
|
sidecar into a collection named for the post (precedent: fs86,
|
||||||
|
ai-scrape26). The public library syncs, so importing is publishing.
|
||||||
|
Follow the library's existing conventions for each item type; RFCs, for
|
||||||
|
example, are reports with type "Request for Comments" and institution
|
||||||
|
"Internet Engineering Task Force", so the IETF RFCs saved search
|
||||||
|
finds them.
|
||||||
|
- **Links the fetcher can't read** (403, bot wall, JS-only): mark them 🙋
|
||||||
|
in the draft with the link; the author fetches the page by hand and
|
||||||
|
saves a Zotero snapshot, which can then be read from `~/Zotero/storage`.
|
||||||
|
- **Keep a copy of anything you quote, starting with the first fetch.**
|
||||||
|
Checking exact wording later means fetching again, and fetches fail:
|
||||||
|
PDFs come back as undecodable bytes, sites return 202 or 403. Save the
|
||||||
|
fetched file (e.g. under `.tmp/snapshots/`) and queue it for the author
|
||||||
|
in a 🙋 checklist (`<name> - snapshots.md`) with each source's link and
|
||||||
|
the words quoted from it. The author, acting as a human HTTP proxy,
|
||||||
|
attaches it in Zotero or saves a snapshot. Agents can't attach files to
|
||||||
|
existing Zotero items without a local API key.
|
||||||
|
|
||||||
## Search hygiene
|
## Search hygiene
|
||||||
|
|
||||||
If you are the one asserting a fact, do a quick search before stating it as
|
If you are the one asserting a fact, do a quick search before stating it as
|
||||||
|
|||||||
@@ -34,6 +34,20 @@ Generated-by: Claude Opus 5.5
|
|||||||
trailer only on those commits. Don't add it to every commit.
|
trailer only on those commits. Don't add it to every commit.
|
||||||
- **PR descriptions:** say which parts were AI-generated. The commit
|
- **PR descriptions:** say which parts were AI-generated. The commit
|
||||||
trailers stay the record that counts.
|
trailers stay the record that counts.
|
||||||
|
- **Unreviewed PRs are drafts.** When an agent opens a PR under the
|
||||||
|
human's GitHub account and the human hasn't read it yet, open it as
|
||||||
|
a draft (`gh pr create --draft`) and start the description with:
|
||||||
|
|
||||||
|
```
|
||||||
|
> [!WARNING]
|
||||||
|
> **Unreviewed LLM output.** Generated by <Tool> <Version>; no human
|
||||||
|
> has reviewed this code yet.
|
||||||
|
```
|
||||||
|
|
||||||
|
The human removes the caveat and marks it ready after reviewing.
|
||||||
|
The caveat exists because the PR appears to come from the human.
|
||||||
|
A PR opened from a bot account already shows who wrote it, so it
|
||||||
|
doesn't need the caveat.
|
||||||
- **The human stays responsible.** The commit author vouches for the
|
- **The human stays responsible.** The commit author vouches for the
|
||||||
contribution. That includes disclosing material that is not their
|
contribution. That includes disclosing material that is not their
|
||||||
original creation, and making sure the tool's terms grant enough
|
original creation, and making sure the tool's terms grant enough
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
---
|
||||||
|
name: discord-agent-workspace
|
||||||
|
description: Set up a Claude Code agent you can message from Discord, working in a workspace folder of your projects — when someone says "set me up like Dan's bot", "I want to text my Claude from my phone", "Claude Code on Discord", or "make a workspace for my agent". Walks a non-developer through the Discord bot, the workspace folder (AGENTS.md, skills, repos), access control, and keeping it running. Not for chat-only Claude apps with no computer behind them.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Discord agent workspace
|
||||||
|
|
||||||
|
Dan's arrangement, reproduced for someone else:
|
||||||
|
|
||||||
|
- **Claude Code** runs in a terminal on a computer that stays on.
|
||||||
|
- **The Discord channel plugin** turns a Discord bot into a pipe: allowed people's messages arrive in that session, and Claude answers with a `reply` tool ([plugin README](https://github.com/anthropics/claude-plugins-official/tree/main/external_plugins/discord)).
|
||||||
|
- **A workspace folder** holds the projects plus written-down conventions, so each fresh session knows where it is and how the owner likes things done.
|
||||||
|
|
||||||
|
Your user may not be a developer. Do each step with them, one at a time; say what a command does before running it, and stop at anything that needs their account, their browser, or a secret. Never paste a token into chat; have them put it in the file or command themselves.
|
||||||
|
|
||||||
|
## 0. Is it worth it for them?
|
||||||
|
|
||||||
|
Ask what they'd send it. Good fits: tasks over files (code, documents, notes, data) that take a sentence to ask, minutes to do, and a glance to check. Poor fits: work that lives only in web apps with no files or API, or results they can't review. If it's a poor fit, say so and stop.
|
||||||
|
|
||||||
|
They need: Claude Code with a Claude subscription or API account, a Discord account and a server they can add a bot to, and a computer that stays on (a desktop, or a small cloud VM).
|
||||||
|
|
||||||
|
## 1. The workspace
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mkdir -p ~/agent-workspace && cd ~/agent-workspace
|
||||||
|
git clone <each project they want the agent to work on>
|
||||||
|
```
|
||||||
|
|
||||||
|
Write `AGENTS.md` at the top, and link `CLAUDE.md` to it (`ln -s AGENTS.md CLAUDE.md`) so every agent tool finds it. Keep it under a page, in their words:
|
||||||
|
|
||||||
|
- who they are and what the projects are for, one line each with a link;
|
||||||
|
- house rules, e.g. "PRs are drafts", "ask before pushing", "keep Discord replies short";
|
||||||
|
- what is off limits.
|
||||||
|
|
||||||
|
Skills are conventions that load when relevant. Put them in `.agents/skills/<name>/SKILL.md` and link Claude Code's location to it:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mkdir -p .agents/skills .claude && ln -s ../.agents/skills .claude/skills
|
||||||
|
```
|
||||||
|
|
||||||
|
Start with none or one. Add a skill when they catch themselves repeating an instruction; Dan's [mad-skills](https://git.inference.coop/dckc/mad-skills) show the shape. Claude Code also keeps its own memory per workspace, so corrections stick across sessions.
|
||||||
|
|
||||||
|
## 2. The Discord bot
|
||||||
|
|
||||||
|
Follow the plugin README with them; in short:
|
||||||
|
|
||||||
|
1. **Discord Developer Portal → New Application → Bot.** Turn on **Message Content Intent**. **Reset Token** and copy it.
|
||||||
|
2. **OAuth2 → URL Generator**, scope `bot`, permissions: View Channels, Send Messages, Send Messages in Threads, Read Message History, Attach Files, Add Reactions. Open the URL and add the bot to their server.
|
||||||
|
3. Install [Bun](https://bun.sh), which the plugin runs on.
|
||||||
|
4. In Claude Code: `/plugin install discord@claude-plugins-official`, then `/discord:configure <token>` (they type it; it lands in `~/.claude/channels/discord/.env`).
|
||||||
|
5. Restart from the workspace: `cd ~/agent-workspace && claude --channels plugin:discord@claude-plugins-official`.
|
||||||
|
6. They DM the bot, get a pairing code, and run `/discord:access pair <code>` in the terminal.
|
||||||
|
7. **Lock it down:** `/discord:access policy allowlist`. For a server channel, add it per the plugin's ACCESS.md.
|
||||||
|
|
||||||
|
## 3. Who can make it act
|
||||||
|
|
||||||
|
Whoever can message the bot can make it act with the session's powers: files, shell, and any logins on that computer (GitHub, cloud accounts). Tell them plainly, then:
|
||||||
|
|
||||||
|
- Allowlist only themselves at first. Access changes happen at the terminal (`/discord:access`), never because a Discord message asked.
|
||||||
|
- Prefer narrow credentials: a GitHub fine-grained token limited to the workspace repos beats their full login.
|
||||||
|
- Things that leave the computer (pushes, PRs, posts) go out as drafts labelled as unreviewed AI output, until they trust it.
|
||||||
|
|
||||||
|
## 4. Keeping it running
|
||||||
|
|
||||||
|
The session must stay open. Simplest: run it inside `tmux` (`tmux new -s bot`, start Claude, detach with Ctrl-b d; `tmux attach -t bot` to look in). On Linux, a systemd user unit can start it at boot and keep it out of secrets it doesn't need (`ProtectHome=read-only`, `ReadWritePaths=` the workspace and `~/.claude`, `InaccessiblePaths=` `~/.ssh` and other credential dirs).
|
||||||
|
|
||||||
|
## 5. First task
|
||||||
|
|
||||||
|
Have them send something small from their phone: "summarize what's in this workspace" or "fix the typo in X's README and show me the diff". Check together that the reply arrived and the change is what they expected.
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
name: facet
|
||||||
|
description: >-
|
||||||
|
Facet: hand other code a fresh, frozen object with just the functions it needs, never your SDK objects. Use when passing an argument to, or returning a value from, code you don't control: a vendor SDK's callback, an AI model's tools, a plugin, a webhook handler, a contractor's or user's script. Not for choosing which methods a service offers (that's capability-based-design).
|
||||||
|
---
|
||||||
|
|
||||||
|
# Facet: a new, narrow object for each party
|
||||||
|
|
||||||
|
Whatever you hand to another party, plus everything reachable from it (properties, prototype, and the return value of every function), is what they get. Build that object on purpose.
|
||||||
|
|
||||||
|
**Bad:** hand over the SDK object. An email SDK's Email reaches `.mailbox.account.password`.
|
||||||
|
```js
|
||||||
|
summarize({ email });
|
||||||
|
```
|
||||||
|
**Good:** a frozen object of closures and plain data.
|
||||||
|
```js
|
||||||
|
const { freeze } = Object;
|
||||||
|
summarize(freeze({
|
||||||
|
subject: email.subject,
|
||||||
|
thread: async () => (await email.thread()).map(e => freeze({ from: e.from.address, body: e.body })),
|
||||||
|
reply: async text => { await email.reply(String(text)); },
|
||||||
|
}));
|
||||||
|
```
|
||||||
|
|
||||||
|
Rules:
|
||||||
|
|
||||||
|
1. **Return data, not what the underlying call returned.** `text => email.reply(text)` hands out the Email that `reply` returns. Chaining APIs (`db.set()` returning the db, any method returning `this`) leak the same way.
|
||||||
|
2. **Copy records** into frozen plain objects; SDK records carry back-references.
|
||||||
|
3. **Keep authority in closures,** not properties: a `this.client` or `this.headers` field is readable and writable by the holder. Freeze what you hand out.
|
||||||
|
4. **Bind scope when you make the facet.** Don't take a folder name, path, or user from the holder and act on it with your own authority.
|
||||||
|
|
||||||
|
Before finishing, walk everything reachable from each facet and add a test that does it: no client, token, raw store, or other party's data.
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- [E in a Walnut: Capability Patterns](https://www.skyhunter.com/marcs/ewalnut.html#SEC45): facets.
|
||||||
|
- [awesome-ocap wiki](https://github.com/dckc/awesome-ocap/wiki): a pattern language for ocaps.
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
---
|
||||||
|
name: hackmd-deck
|
||||||
|
description: HackMD slide deck for a light talk — use when asked to draft slides, a deck, or a talk for show & tell, office hours, or a demo; when someone says "hackmd deck", "whip up some slides", or names a talk title and points at work to present (repos, git history, session transcripts). Covers the flashback story arc, emoji markers for wins and friction, and real artifacts as eye candy. Not for .pptx files or polished conference talks.
|
||||||
|
---
|
||||||
|
|
||||||
|
# HackMD deck
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
---
|
||||||
|
title: Good Fences Make Good Agents
|
||||||
|
type: slide
|
||||||
|
---
|
||||||
|
|
||||||
|
# Good Fences Make Good Agents
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎉 Monday's issue drafts itself
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## How: who holds what
|
||||||
|
|
||||||
|

|
||||||
|
```
|
||||||
|
|
||||||
|
Example: [Good Fences Make Good Agents](../../../capsite/docs/good-fences-slides.md); an early, overboard one: [Jun 25 slides](https://hackmd.io/T9-oFWEPSb2zzqWAGFv60Q#/).
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
A talk at something like Agoric's engineering show & tell: "Presentations should take little to no preparation", by engineers for engineers. The work already exists in repos, commits, test output, and session transcripts.
|
||||||
|
|
||||||
|
## Problem
|
||||||
|
|
||||||
|
**I have done a bunch of stuff I think is interesting, but I can't justify the time to make a polished presentation.**
|
||||||
|
|
||||||
|
## Therefore
|
||||||
|
|
||||||
|
**Let an agent do a quick-n-dirty one: a flashback, built from the record.**
|
||||||
|
|
||||||
|
The arc:
|
||||||
|
|
||||||
|
1. 🎉 TADA! Look what I did. It must be on the thread the talk follows.
|
||||||
|
2. Now that you're hooked, how I did that.
|
||||||
|
3. Eye candy along the way: diagrams, verbatim code, test output.
|
||||||
|
4. Conclusions and/or challenges that lead to discussion.
|
||||||
|
|
||||||
|
Ground every slide in the record: quote code and test output verbatim (trim with `...`), check claims against the code and git history, and mark what's only designed or not deployed with ⏳.
|
||||||
|
|
||||||
|
Mark wins, losses, challenges, and friction with emojis: visually appealing, intuitive at a glance.
|
||||||
|
|
||||||
|
- wins: 🎉 the TADA · ✅ shipped · ✨ sparkle, delight · 💡 aha: now I see how to address the issue · 🙌 help, or a gift from someone else's work
|
||||||
|
- friction and follow-ups: ⏳ delays, not yet · 🧰 fragile tooling, ceremony · 💤 silent failures · 📘 docs · 🔔 alerts · 📈 observability · 🪄 a wish, often one a problem brings to mind · 🔧 fixes owed · 🧱 walls
|
||||||
|
|
||||||
|
Write the deck in the repo the talk is about (e.g. `docs/<title>-slides.md`), images beside it, and commit it.
|
||||||
|
|
||||||
|
## Resulting context
|
||||||
|
|
||||||
|
The deck takes 15 minutes: the agent spends 5, the presenter polishes for 10. The user pastes it into HackMD and uploads the images.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: hypertext-links
|
name: hypertext-links
|
||||||
description: Writing style for links in markdown docs — use when writing or reviewing any doc with URLs to external pages, repo files, or intra-repo documents; enforces descriptive link text over bare/generic links.
|
description: Writing style for links in markdown docs and chat (Discord supports `[text](<url>)`) — use when writing or reviewing any doc or Discord message with URLs to external pages, repo files, or intra-repo documents; enforces descriptive link text over bare/generic links.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Hypertext Links
|
# Hypertext Links
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: no-ambient-authority
|
name: no-ambient-authority
|
||||||
description: >-
|
description: >-
|
||||||
Use when writing or reviewing code whose functions touch I/O, clocks, random number generators, process.env, fetch, or filesystem; when someone says "ambient authority", "wash your mouth out", or "that function shouldn't reach for that"; when debating dependency injection or default-arg seams; when asked what OCap discipline is. Source: the Agoric wiki's OCap Discipline page.
|
Use when writing or reviewing code whose functions touch I/O, clocks, random number generators, process.env, fetch, or filesystem; before writing or refactoring any Python script (DisciplinedPython style guide and checker); when someone says "ambient authority", "wash your mouth out", or "that function shouldn't reach for that"; when debating dependency injection or default-arg seams; when asked what OCap discipline is. Source: the Agoric wiki's OCap Discipline page.
|
||||||
---
|
---
|
||||||
|
|
||||||
# OCap Discipline
|
# OCap Discipline
|
||||||
@@ -42,6 +42,30 @@ capability-based languages, systems, papers, and talks.
|
|||||||
authority they need, then *delegate* it downward.
|
authority they need, then *delegate* it downward.
|
||||||
3. **Test scripts** are named `test-*.js`; tests export nothing.
|
3. **Test scripts** are named `test-*.js`; tests export nothing.
|
||||||
|
|
||||||
|
## Python: DisciplinedPython
|
||||||
|
|
||||||
|
For Python, the rules above are spelled out in the DisciplinedPython style
|
||||||
|
guide in awesome-ocap (local checkout `~/projects/awesome-ocap`). Read it
|
||||||
|
before writing or refactoring a Python script; don't invent conventions.
|
||||||
|
|
||||||
|
- [ocap-py-style-guide.md](https://codeberg.org/dckc/awesome-ocap/src/branch/master/style-guide/ocap-py-style-guide.md):
|
||||||
|
the script recipe (`main(...)` plus `_script_io()` under the `__main__`
|
||||||
|
guard, authorities passed by name), standard authority names (`argv`,
|
||||||
|
`cwd`, `stdout`, `connect`, `run`, `urlopen`, `now`), prompt attenuation
|
||||||
|
in `main`, and **status goes through `logging.info(...)` directly**: not
|
||||||
|
`print`, not `stderr` writes, not an injected logger.
|
||||||
|
- [disciplined-python-attenuation.md](https://codeberg.org/dckc/awesome-ocap/src/branch/master/style-guide/disciplined-python-attenuation.md):
|
||||||
|
narrowing authority function by function.
|
||||||
|
- Checker: run `~/projects/awesome-ocap/tools/disciplined_python_check.py path/to/script.py`
|
||||||
|
and treat each finding as a bug. It points at matching before/after
|
||||||
|
examples in `tests/fixtures/disciplined_python/{errors,fixed}/`.
|
||||||
|
- Calibration: Python can't enforce a capability boundary (name mangling
|
||||||
|
and introspection get around any wrapper), so for a small script,
|
||||||
|
attenuation that lives mostly in names is fine. An example: a read-only
|
||||||
|
library view whose path object could still POST. GET-only is ideal;
|
||||||
|
note the gap honestly and move on. Robustness against adversaries
|
||||||
|
means leaving Python (e.g. for Hardened JavaScript).
|
||||||
|
|
||||||
## how this shows up in review
|
## how this shows up in review
|
||||||
|
|
||||||
- `crypto.getRandomValues()` called inside an exported function →
|
- `crypto.getRandomValues()` called inside an exported function →
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
---
|
||||||
|
name: pola
|
||||||
|
description: >-
|
||||||
|
Principle of Least Authority as the way to organize all code: trace the flow of authority, give each component only what its task needs, design APIs around attenuation. Everything reachable from what you hand out is handed out too, including what its functions return: wrappers return plain data, never the SDK's objects. Use when writing or reviewing any code, tests included: makers and their parameters, module imports and exports, which objects share a scope, what a facet exposes; when designing a service's API (attenuation methods, flower-shaped narrow-then-fire handles, mechanism vs policy, secrets in payloads); when tempted to write an allowlist; when someone says "POLA", "least authority", "who can reach that?", "Bob shouldn't see Alice's purse", or "makeFoo-style actors". The table stakes (no clocks, fetch, or env reached for inside logic) are no-ambient-authority; this is the organizing principle on top.
|
||||||
|
---
|
||||||
|
|
||||||
|
# POLA: organize code by the flow of authority
|
||||||
|
|
||||||
|
Mark Miller, [SOSP 50th anniversary panel](https://www.youtube.com/watch?v=br9DwtjqmVI) (3 min):
|
||||||
|
|
||||||
|
> we design abstraction boundaries so that a component's interface only requires arguments that are somehow relevant to its task. If such argument passing were the only source of authority, we would have taken a huge step towards least authority.
|
||||||
|
|
||||||
|
Every reference to anything but immutable data is authority: a purse is the right to spend some assets; a mint, the right to create them; a seat, the right to take part in one deal; a DB handle, every row. Ask of every reference: who holds it, who gave it to them, and does their task need all of it?
|
||||||
|
|
||||||
|
## Recursively, at every level
|
||||||
|
|
||||||
|
[Navigating the Attack Surface](https://www.youtube.com/watch?v=wW9-KuezPp8) (15 min): the same move repeats at each level of composition (OS accounts, apps, modules, objects), and the benefit multiplies, like a Menger sponge. CapMail's main module "receives all of that authority … wiring them together, subdividing the authority … and handing it out piecemeal … written knowing that the address book does not need access to the PGP keyring, so the main module simply doesn't give it that access."
|
||||||
|
|
||||||
|
So at each level, code has two roles:
|
||||||
|
|
||||||
|
- **A wiring layer** (entry point, `main`, test setup, a maker) holds a lot of authority, and its job is to split it and hand out pieces. Keep it small and obvious: it is the TCB at its level.
|
||||||
|
- **Everything else** gets only the pieces its task needs, as arguments, and can't reach more.
|
||||||
|
|
||||||
|
## In practice
|
||||||
|
|
||||||
|
- **Makers take only what their task needs.** `makeAlice({ usdcPurse, stockDepositFacet })`, not `makeAlice({ ledger })`.
|
||||||
|
- **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.
|
||||||
|
- **What you hand out includes everything reachable from it: properties, prototypes, and what its functions return.** A wrapper like `text => email.reply(text)` hands out whatever `reply` returns, often an SDK object that leads back to the client and its token. Return plain data or nothing, and copy SDK records into frozen plain objects.
|
||||||
|
- **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)).
|
||||||
|
- **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
|
||||||
|
// wrong: one scope holds everyone's purses; Bob's code could spend Alice's
|
||||||
|
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 wires, drives, and observes
|
||||||
|
const makeAlice = async ({ usdcIssuer, stockIssuer, dollars }) => {
|
||||||
|
const usdc = await E(usdcIssuer).makeEmptyPurse(); // Alice's alone
|
||||||
|
...
|
||||||
|
return harden({
|
||||||
|
// 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.tradeWith(bob); // the one spontaneous step
|
||||||
|
```
|
||||||
|
|
||||||
|
## Shaping an API: hand out authority, then narrow it
|
||||||
|
|
||||||
|
Security is extreme modularity. MarkM's slide puts it as two parallel principles:
|
||||||
|
|
||||||
|
> Modularity: Avoid needless dependencies
|
||||||
|
> Security: Avoid needless vulnerabilities
|
||||||
|
> Vulnerability is a form of dependency
|
||||||
|
> Mod: Principle of info hiding - need to know.
|
||||||
|
> Sec: Principle of least authority - need to do.
|
||||||
|
|
||||||
|
So the moves that make a module well-factored also make it hold less authority:
|
||||||
|
|
||||||
|
- **A service is mechanism; its creator sets policy.** Keeping policy out of a mechanism is modularity. In ocap code it is least authority too, because policy is which references get handed out. A service that only hands out and narrows access needs no authority to decide who gets what, so it holds none. Its creator decides by what it hands out, and new kinds of authority come out of that composition: a governor that fences a mower by pushes, or a seller that sells "talk to user X" at $1 and refuses after N sales. Neither the mower nor the Discord vat knows about fences or prices.
|
||||||
|
- **Don't check who's asking; hand out narrowed capabilities.** An allowlist inside the service is policy inside the mechanism ([acls-dont](../acls-dont/SKILL.md)).
|
||||||
|
- **Make it flower-shaped: narrow, then fire.** A handle to something wide offers narrowings that each return a narrower handle, and the act comes last: `socket.pathjoin(p).withHeaders(h).connect(listener)`, not `connect(url, headers, listener)`. One wide call needs its caller to hold every argument's authority at once; a chain lets each holder narrow it and pass it on. Each step returns a new, immutable handle that can only be narrower: patterns intersect, and a header that contradicts an earlier grant throws. A mutable builder that gets passed along lets whoever holds it widen what you handed out. The raw device can keep the wide call, and a vat over it hands out the flower, as WebApp does over the fetch device.
|
||||||
|
- **Narrow along the lines the protocol needs.** Check where the authority actually has to go. Discord sends a resuming client to another host, which a handle narrowed by path can't reach. A narrowing by host pattern (`withinHost('*.discord.gg')`) covers exactly that, so there's no need to widen the handle back to "anywhere".
|
||||||
|
- **A narrowing is data, not a callback.** Pass a pattern (an Endo `M` pattern; it's passable, so it can cross vats) for the service to apply. A predicate object called on every item sees everything it filters, so it already holds the authority it was meant to narrow.
|
||||||
|
- **Hand out a reference to a secret, not the secret.** When the secret has to go inside a payload, such as a token in a WebSocket frame, a splicer holds the secret and gives out a ref exo it alone can redeem. Accept the ref only in the fields that carry it to its proper recipient. If a field Discord broadcasts would also accept it, anyone with the ref can publish the secret.
|
||||||
|
- **One primitive, with libraries on top.** A timer device offers `wakeAt(t, handler)`; repeaters and cron schedules are a library over it, and each schedule is its own object whose holder can cancel only that one. Reading something is authority too: `wake(now)` reveals the clock, so a vat that may wait but not read the time gets a delay-only facet.
|
||||||
|
|
||||||
|
## Review checklist
|
||||||
|
|
||||||
|
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 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?
|
||||||
|
5. Does any component check an allowlist, or take a policy decision that its creator could make by narrowing what it hands out?
|
||||||
|
6. Walk everything reachable from each object you hand out, including the return value of each of its functions. Does it reach an SDK client, a token, or another party's data?
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- [From E to EcmaScript and Back Again](https://qconsf.com/sf2010/dl/qcon-sanfran-2010/slides/MarkS.Miller_FromEToECMAScriptAndBackAgain.pdf): Mark S. Miller, QCon SF 2010; slide 3 is "Security as Extreme Modularity".
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
---
|
||||||
|
name: wiring-diagram
|
||||||
|
description: >-
|
||||||
|
Capability wiring diagram: who holds a reference to what, and so who can do what — use when asked for a wiring diagram, a capability diagram, or a picture of who holds what; when reviewing a design for POLA and wanting to see the reference graph; when stepping through how that graph changes across create, checkpoint, crash and revive (an "algorithm animation"). In the style of MarkM's ERTP slides. Sequence diagrams of messages between parties are a separate skill (sequence-diagram-actor-sim).
|
||||||
|
---
|
||||||
|
|
||||||
|
# Capability wiring diagram
|
||||||
|
|
||||||
|
POLA says each party should hold only the authority its job needs. A wiring diagram lets you check that at a glance: one picture of **who holds a reference to what, and therefore who can do what**. The arrows that are absent are the security argument. To show what happens over time, step the diagram through frames, one message each (an algorithm animation, below), draw a sequence diagram (see sequence-diagram-actor-sim), or both.
|
||||||
|
|
||||||
|
Exemplars:
|
||||||
|
- `capsite-cookie-rotation/docs/cookie-rotation-wiring.html` (+ `.png`) in this workspace: the original.
|
||||||
|
- `~/qtrx/packages/umb-download/docs/wiring.html` (+ `.png`): three makers, two outside parties, and an adversary holding a webkey.
|
||||||
|
- `capsite-toybox-kernel/docs/sugarmint-sturdyrefs.html` in this workspace: a step-through of E's sugarMint making sturdyrefs, crashing, and reviving, with nested panes, facets on shared state, weak tables, and cross-vat proxies.
|
||||||
|
|
||||||
|
Start from [`template.html`](template.html), next to this file: it has the drawing helpers and a small scene to replace. For a step-through, start from the sugarMint page. The deliverable is a local HTML file in the repo's `docs/`, not a claude.ai artifact, unless asked.
|
||||||
|
|
||||||
|
## Read the graph from the code, not the story
|
||||||
|
|
||||||
|
Every arrow must correspond to something real: a constructor argument, a stored id, a binding, a held token, or a file someone keeps. Before drawing, list the references as `holder → target: where in the code`. Read the factories (`make…`, `newX`, `configure`) and anything that stores an id. An id is a reference when its holder can redeem it: a DO id string reaches the object through code that holds the namespace binding, or through a route that redeems ids for anyone (cookie-rotation's `/at/<id>`, which makes the id a bearer capability). Draw the arrow from the id's holder, and say what redeems it. If you can't cite where a reference comes from, it doesn't get an arrow.
|
||||||
|
|
||||||
|
Read each object's fields before you say what it is. E's SturdyRef looks like plain data (vatID, swiss number) but also holds a LocatorUnum presence, which is its authority to look the number up. A table keyed by data can't be weak-keyed: say which side is weak (E's swissTable is a WeakValueMap), and draw the weak arrow dashed.
|
||||||
|
|
||||||
|
Watch for references dropped on purpose, such as a setup route that mints an instance, hands its id to one holder and forgets it. That's often the point of the design: say so in a caption, or leave the arrow out.
|
||||||
|
|
||||||
|
When a caption claims something a reader may doubt, cite the line that shows it, and keep what the code shows apart from what you infer. If the code is lost, say so and draw no arrows into it.
|
||||||
|
|
||||||
|
## One pane per maker call
|
||||||
|
|
||||||
|
In MarkM's [makeMint slide](https://docs.agoric.com/guides/js-programming/hardened-js.html#from-ocaps-to-electronic-rights-mint-and-purse), each stacked pane is one call to `makeMint`. Inside a pane is what that one call made: one issuer, mint, brand and ledger, and a stack of purses, because `makePurse` runs many times per mint. For each box, ask: *a new one per what call?*
|
||||||
|
|
||||||
|
- Stack a box only when its scope makes many. `store.readOnly()` returns the same object every time, so readOnly is 1:1 with its store and not stacked.
|
||||||
|
- Put state where the code keeps it. If one Durable Object holds many stores in one kv, the kv is one table in the DO's pane, like makeMint's ledger, not one per store.
|
||||||
|
- Name a pane after the real maker (the class or function in the code), not an invented `makeFoo`.
|
||||||
|
- Nested scopes nest panes: issuer ⊃ account ⊃ hold.
|
||||||
|
- Facets that close over shared state go in one pane, each facet a box, with arrows to the shared state table: an ERTP mint, issuer and brand; an account and its revoker. Drawing facets apart is how the picture shows attenuation.
|
||||||
|
- A stack can be over time: one vat pane per incarnation.
|
||||||
|
|
||||||
|
## Between vats
|
||||||
|
|
||||||
|
A reference to an object in another vat is a proxy in the holder's vat that forwards over CapTP or Cap'n Web. Draw the holder's vat as a small pane with the proxy in it, and the arrow from the proxy onward. That proxy is where a crash shows up as a broken reference.
|
||||||
|
|
||||||
|
## Include an adversary
|
||||||
|
|
||||||
|
Add a Mallory who holds whatever is most likely to leak (an instance id, a webkey, a URL), with an arrow to exactly what it reaches. Her caption says what she *can't* reach. Mallory makes the absent arrows visible.
|
||||||
|
|
||||||
|
## Vocabulary
|
||||||
|
|
||||||
|
| element | helper | means |
|
||||||
|
|---|---|---|
|
||||||
|
| blue ball | `actor(cx, cy, label)` | a person or a program with its own agency |
|
||||||
|
| grey ball | `actor(cx, cy, label, "url(#ext)")` | outside the system: a browser extension, a third-party service |
|
||||||
|
| pale region | `maker(x, y, w, h, "makeFoo")` | a maker (factory, DO class) and the instances it made; stacked panes say "there are many" |
|
||||||
|
| rounded square | `obj(x, y, w, h, label, stacked)` | an object or facet; `stacked` when its scope makes many |
|
||||||
|
| ledger table | `table(x, y, title, rows, [colW0, colW1])` | an object's state; rows are key/value; `rowY(i)` and `colX` give arrow anchors |
|
||||||
|
| dot → arrowhead | `ref(x1, y1, x2, y2, bend)` | holder references target; `bend` (±0.05–0.3) curves around things |
|
||||||
|
| speech bubble | the `path` + `code` block | the one call the picture is about, in `E(target).method(args)` form |
|
||||||
|
| caption | `cap(x, y, text, attrs)` | what an actor holds, and what it can't reach |
|
||||||
|
|
||||||
|
## Layout
|
||||||
|
|
||||||
|
- Actors in a row along the top (y≈200), makers below (y≈320 onward), captions along the bottom (y≈ height − 14).
|
||||||
|
- Put each maker under the actors that mostly use it, so arrows run short and downward.
|
||||||
|
- Speech bubble at the top, its tail pointing at the speaker. Move the bubble's path (`M x,y`) and the tail segment (`h… l-38,48 l6,-48`) together.
|
||||||
|
- Captions: two or three short lines, never on an arrow or a ball. Use `"text-anchor": "start"` to set one beside a ball.
|
||||||
|
- Long arrows that cross a maker: increase `|bend|` until the curve clears tables and objects. The control point is the midpoint offset by `bend × (−dy, dx)`. Where one bend can't clear everything, give explicit control points (the sugarMint page's `via` and `via2`).
|
||||||
|
|
||||||
|
## Step-through (algorithm animation)
|
||||||
|
|
||||||
|
When the story is a sequence of state changes (create, checkpoint, crash, revive), keep one layout and step through frames, like slides:
|
||||||
|
|
||||||
|
- Each frame is one message. The bubble shows it, with its tail at the sender; a step inside some object gets a dashed bubble with no tail.
|
||||||
|
- Orange marks what that message changed: a halo on new objects and tables, a fill on new rows, orange for new references.
|
||||||
|
- Below the picture: a short heading, a sentence saying what the message did and why, and a cite line (`file:line`).
|
||||||
|
- Dead things fade (opacity 0.25); broken references are red, dashed, with a ✕.
|
||||||
|
- Controls: Prev/Next, arrow keys, a slider, and `#sN` deep links.
|
||||||
|
- In code, name frames (`F.save`, `F.revive`) and derive visibility from them (`on(F.sturdy, F.rebuild)`, `fresh(F.save)`), so inserting a frame doesn't shift every index.
|
||||||
|
|
||||||
|
## Accessibility
|
||||||
|
|
||||||
|
Keep `<title>` short. Write `<desc>` as prose that names every actor and maker, every reference, the bubble's call, and what the adversary can't reach. Someone who can't see the picture should get the same argument from it. A step-through sets `<desc>` per frame.
|
||||||
|
|
||||||
|
## Render and check
|
||||||
|
|
||||||
|
Render with headless Chromium. The viewport comes out shorter than `--window-size`, so render taller and crop to the SVG size; `--force-prefers-reduced-motion` keeps highlights from being caught mid-fade:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
chromium --headless=new --disable-gpu --no-sandbox --hide-scrollbars --force-prefers-reduced-motion \
|
||||||
|
--window-size=W,$((H+100)) --screenshot=full.png "file://$PWD/NAME.html"
|
||||||
|
python3 -c "from PIL import Image; Image.open('full.png').crop((0,0,W,H)).save('NAME.png')" && rm full.png
|
||||||
|
```
|
||||||
|
|
||||||
|
**Look at each screenshot** (Read it) and fix overlaps: captions on arrows, arrows through tables, text clipped at the bottom. Expect two or three rounds. If arrowheads vanish, look for an id collision: SVG marker ids share the page's id namespace, and an `<h2 id="head">` once hijacked `url(#head)`. The template's marker is `arrow`.
|
||||||
|
|
||||||
|
QA screenshots in a scratch directory are fine at any point. Don't commit a PNG until the user confirms the diagram is right; a step-through gets none unless asked. Commit the HTML and the PNG separately, so the source diff stays readable.
|
||||||
|
|
||||||
|
## Review checklist
|
||||||
|
|
||||||
|
- Does every arrow cite something in the code? Is any real reference missing?
|
||||||
|
- Does each actor hold only what its job needs? If the picture shows an actor holding more, that's a finding about the design, not a drawing problem.
|
||||||
|
- For each stacked box: is a new one really made per instance? For each unstacked box: is there really only one?
|
||||||
|
- Are facets drawn apart where they differ in authority, and pointed at shared state where they share it?
|
||||||
|
- Do references into another vat go through a proxy in the holder's vat?
|
||||||
|
- Does the adversary's caption match what the arrows show?
|
||||||
|
- Does `<desc>` tell the same story in prose?
|
||||||
|
- Is any secret value drawn? Elide values (`session=…`, `{…}`): the picture shows *that* a row exists, not its contents.
|
||||||
|
|
||||||
|
## TODO
|
||||||
|
|
||||||
|
Migrate or copy sequence-diagram-actor-sim here. It lives at `~/projects/ymax-workspace/agoric-sdk/.agents/skills/sequence-diagram-actor-sim/SKILL.md`, on agoric-sdk branches `connolly/ago-1264-agentic-planning` and `connolly/ago-1299-agentic-planning-tdd`, not yet on master.
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html><head><meta charset="utf-8">
|
||||||
|
<title>TITLE: who holds what</title>
|
||||||
|
<!-- drawn after the style of MarkM's ERTP slides; NAME.png is a headless-Chromium screenshot of this page -->
|
||||||
|
<style>
|
||||||
|
html, body { margin: 0; background: #fff; }
|
||||||
|
.sans { font-family: "Helvetica Neue", "DejaVu Sans", sans-serif; }
|
||||||
|
.obj { font-family: "DejaVu Serif", serif; font-style: italic; }
|
||||||
|
.mono { font-family: "DejaVu Sans Mono", monospace; }
|
||||||
|
</style></head>
|
||||||
|
<body>
|
||||||
|
<svg id="c" xmlns="http://www.w3.org/2000/svg" width="1120" height="820" viewBox="0 0 1120 820"
|
||||||
|
role="img" aria-labelledby="title desc">
|
||||||
|
<title id="title">TITLE: who holds what</title>
|
||||||
|
<desc id="desc">Prose for screen readers: name every actor and maker, every
|
||||||
|
reference (who holds what), the speech bubble's call, and what the
|
||||||
|
adversary can and cannot reach.</desc>
|
||||||
|
<defs>
|
||||||
|
<radialGradient id="ball" cx="40%" cy="35%" r="70%">
|
||||||
|
<stop offset="0%" stop-color="#7cc8f8"/>
|
||||||
|
<stop offset="100%" stop-color="#3aa6ee"/>
|
||||||
|
</radialGradient>
|
||||||
|
<radialGradient id="ext" cx="40%" cy="35%" r="70%">
|
||||||
|
<stop offset="0%" stop-color="#e3e3e3"/>
|
||||||
|
<stop offset="100%" stop-color="#b9b9b9"/>
|
||||||
|
</radialGradient>
|
||||||
|
<linearGradient id="objfill" x1="0" y1="0" x2="0" y2="1">
|
||||||
|
<stop offset="0%" stop-color="#6cbcf4"/>
|
||||||
|
<stop offset="100%" stop-color="#4aa8ec"/>
|
||||||
|
</linearGradient>
|
||||||
|
<marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="9" markerHeight="9" orient="auto-start-reverse">
|
||||||
|
<path d="M0,0 L10,5 L0,10 z" fill="#1d4f7a"/>
|
||||||
|
</marker>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
<script>
|
||||||
|
const svg = document.getElementById("c");
|
||||||
|
const NS = "http://www.w3.org/2000/svg";
|
||||||
|
const el = (name, attrs, parent = svg) => {
|
||||||
|
const e = document.createElementNS(NS, name);
|
||||||
|
for (const [k, v] of Object.entries(attrs)) e.setAttribute(k, v);
|
||||||
|
parent.appendChild(e);
|
||||||
|
return e;
|
||||||
|
};
|
||||||
|
const text = (x, y, s, cls, attrs = {}) => {
|
||||||
|
const t = el("text", { x, y, class: cls, "text-anchor": "middle", fill: "#1d3550", ...attrs });
|
||||||
|
t.textContent = s;
|
||||||
|
return t;
|
||||||
|
};
|
||||||
|
|
||||||
|
const INK = "#1d4f7a";
|
||||||
|
const dot = (x, y) => el("circle", { cx: x, cy: y, r: 4.5, fill: INK });
|
||||||
|
/** a reference: dot at the holder, arrowhead at the target */
|
||||||
|
const ref = (x1, y1, x2, y2, bend = 0, extra = {}) => {
|
||||||
|
dot(x1, y1);
|
||||||
|
const mx = (x1 + x2) / 2 - (y2 - y1) * bend, my = (y1 + y2) / 2 + (x2 - x1) * bend;
|
||||||
|
el("path", { d: `M${x1},${y1} Q${mx},${my} ${x2},${y2}`, fill: "none", stroke: INK, "stroke-width": 2, "marker-end": "url(#arrow)", ...extra });
|
||||||
|
};
|
||||||
|
|
||||||
|
// maker box: a pale rounded region, with stacked instances inside
|
||||||
|
function maker(x, y, w, h, label) {
|
||||||
|
el("rect", { x, y, width: w, height: h, rx: 26, fill: "#d6ecfb", stroke: "#b5dbf5", "stroke-width": 1.5 });
|
||||||
|
text(x + 18, y + 30, label, "obj", { "text-anchor": "start", "font-size": 20 });
|
||||||
|
for (let i = 2; i >= 0; i -= 1) {
|
||||||
|
el("rect", {
|
||||||
|
x: x + 18 + i * 9, y: y + 48 + i * 9, width: w - 52, height: h - 82, rx: 22,
|
||||||
|
fill: "#c8e5fa", stroke: "#8ec9f2", "stroke-width": 1.5, "fill-opacity": 0.9,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// an object: rounded square, optionally stacked (several made)
|
||||||
|
function obj(x, y, w, h, label, stacked = false) {
|
||||||
|
const n = stacked ? 3 : 1;
|
||||||
|
for (let i = n - 1; i >= 0; i -= 1) {
|
||||||
|
el("rect", { x: x + i * 7, y: y - i * 7, width: w, height: h, rx: 12, fill: "url(#objfill)", stroke: "#2f8fd6", "stroke-width": 1.5 });
|
||||||
|
}
|
||||||
|
text(x + w / 2, y + h / 2 + 7, label, "obj", { "font-size": 19 });
|
||||||
|
}
|
||||||
|
function actor(cx, cy, label, fill = "url(#ball)") {
|
||||||
|
el("circle", { cx, cy, r: 52, fill, stroke: "#2f8fd6", "stroke-width": 1.5 });
|
||||||
|
text(cx, cy + 6, label, "sans", { "font-size": label.length > 8 ? 15 : 17 });
|
||||||
|
}
|
||||||
|
// a table like the ERTP ledger
|
||||||
|
function table(x, y, title, rows, colW) {
|
||||||
|
const rowH = 28, w = colW[0] + colW[1];
|
||||||
|
el("rect", { x, y, width: w, height: 36 + rowH * rows.length, fill: "#5fb5f2", stroke: "#2f8fd6", "stroke-width": 1.5 });
|
||||||
|
text(x + w / 2, y + 25, title, "obj", { "font-size": 18 });
|
||||||
|
rows.forEach(([k, v], i) => {
|
||||||
|
const ry = y + 36 + i * rowH;
|
||||||
|
el("line", { x1: x, y1: ry, x2: x + w, y2: ry, stroke: "#2f8fd6", "stroke-width": 1.2 });
|
||||||
|
text(x + 10, ry + 19, k, "mono", { "text-anchor": "start", "font-size": 14 });
|
||||||
|
if (v) text(x + colW[0] + 10, ry + 19, v, "mono", { "text-anchor": "start", "font-size": 14 });
|
||||||
|
});
|
||||||
|
el("line", { x1: x + colW[0], y1: y + 36, x2: x + colW[0], y2: y + 36 + rowH * rows.length, stroke: "#1d4f7a", "stroke-width": 1.5 });
|
||||||
|
return { rowY: (i) => y + 36 + i * rowH + rowH / 2, x, w, colX: x + colW[0] };
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- scene: replace from here down ----
|
||||||
|
|
||||||
|
// speech bubble: the one invocation the picture is about; tail toward the speaker
|
||||||
|
el("path", {
|
||||||
|
d: "M30,22 h470 a16,16 0 0 1 16,16 v34 a16,16 0 0 1 -16,16 h-330 l-38,48 l6,-48 h-102 a16,16 0 0 1 -16,-16 v-34 a16,16 0 0 1 16,-16 z",
|
||||||
|
fill: "#d9d9d9", stroke: "#555", "stroke-width": 2,
|
||||||
|
});
|
||||||
|
const code = el("text", { x: 46, y: 62, class: "mono", "font-size": 17, fill: "#222" });
|
||||||
|
code.innerHTML = '<tspan fill="#b0177b">await</tspan> E(store).set(<tspan fill="#1a7f37">"cookie"</tspan>, freshCookie);';
|
||||||
|
|
||||||
|
// actors: people, programs, outside services (grey: "url(#ext)")
|
||||||
|
actor(150, 200, "Alice");
|
||||||
|
actor(560, 200, "client");
|
||||||
|
actor(930, 200, "Mallory");
|
||||||
|
|
||||||
|
// makers, with what they made inside
|
||||||
|
maker(30, 320, 470, 470, "makeMapStore");
|
||||||
|
maker(560, 320, 530, 470, "makeWebApp");
|
||||||
|
obj(80, 420, 120, 80, "store");
|
||||||
|
obj(80, 600, 120, 80, "readOnly", true);
|
||||||
|
const kv = table(260, 430, "kv", [["cookie", "session=…"], ["", ""], ["", ""]], [90, 110]);
|
||||||
|
obj(620, 560, 140, 90, "access", true);
|
||||||
|
const init = table(830, 420, "init", [["url", "…"], ["headerStore", ""]], [130, 85]);
|
||||||
|
|
||||||
|
// references: holder first; one comment per arrow, in the form "holder → target"
|
||||||
|
ref(140, 228, 125, 418, 0.05); // Alice → store
|
||||||
|
ref(172, 224, 508, 210, 0.04); // Alice → client (she wired it)
|
||||||
|
ref(554, 218, 660, 553, 0.12); // client → access
|
||||||
|
ref(916, 220, 720, 553, -0.08); // Mallory → access
|
||||||
|
ref(160, 470, kv.x - 2, kv.rowY(0), 0.05); // store → kv
|
||||||
|
ref(150, 666, kv.x - 2, kv.rowY(0) + 6, -0.25); // readOnly → kv
|
||||||
|
ref(760, 600, init.x - 2, init.rowY(1), -0.1); // access → init
|
||||||
|
ref(init.colX + 40, init.rowY(1), 208, 640, -0.28); // init.headerStore → readOnly
|
||||||
|
|
||||||
|
// captions: what each actor holds, what the adversary can't reach
|
||||||
|
const cap = (x, y, s, attrs = {}) => text(x, y, s, "sans", { "font-size": 14, fill: "#33536f", ...attrs });
|
||||||
|
cap(930, 118, "holds the instance id:");
|
||||||
|
cap(930, 136, "uses the cookie, can't reach store");
|
||||||
|
cap(265, 806, "shapes: keyShape \"cookie\", valueShape M.string()");
|
||||||
|
</script>
|
||||||
|
</body></html>
|
||||||
Reference in new issue
Block a user