Compare commits
21
Commits
6adb4bce33
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fd5ad9457 | ||
|
|
7728a1d908 | ||
|
|
035bf497c8 | ||
|
|
cde1632421 | ||
|
|
5294138a48 | ||
|
|
c2a6fcdd63 | ||
|
|
bb9265c90f | ||
|
|
a83a5e62db | ||
|
|
391d9383d1 | ||
|
|
a633aa44da | ||
|
|
e16e856eca | ||
|
|
cf83169064 | ||
|
|
53dd9b3b2d | ||
|
|
9c75e44fef | ||
|
|
8eaff2bf7a | ||
|
|
5118c5c9b0 | ||
|
|
2851fe872a | ||
|
|
2b8704bdd0 | ||
|
|
e13420cd6d | ||
|
|
ff600b84f6 | ||
|
|
5c477151cc |
No files matched your search
@@ -26,8 +26,12 @@ Code](https://code.claude.com/docs/en/skills) and
|
|||||||
instrument.
|
instrument.
|
||||||
- [silent-failures-are-evil](silent-failures-are-evil/SKILL.md) — every
|
- [silent-failures-are-evil](silent-failures-are-evil/SKILL.md) — every
|
||||||
failure path leaves a trace in the logs.
|
failure path leaves a trace in the logs.
|
||||||
|
- [typed-remotes](typed-remotes/SKILL.md) — `Remote<X>`, never a bare
|
||||||
|
`Remote`; `@satisfies`, not `@type`; and a lint rule so it stays fixed.
|
||||||
- [lazy-tdd](lazy-tdd/SKILL.md) — works the first time? fine. Goofed?
|
- [lazy-tdd](lazy-tdd/SKILL.md) — works the first time? fine. Goofed?
|
||||||
You owe a test.
|
You owe a test.
|
||||||
|
- [py-doctest](py-doctest/SKILL.md) — Python tests are doctests on the
|
||||||
|
API they test, setup in private helpers, no `test_*.py`.
|
||||||
- [refactor-mercilessly](refactor-mercilessly/SKILL.md) — at each
|
- [refactor-mercilessly](refactor-mercilessly/SKILL.md) — at each
|
||||||
green, move logic out of the modules that hold authority into small,
|
green, move logic out of the modules that hold authority into small,
|
||||||
fast-tested ones; keep refactors in commits of their own.
|
fast-tested ones; keep refactors in commits of their own.
|
||||||
@@ -48,12 +52,18 @@ Code](https://code.claude.com/docs/en/skills) and
|
|||||||
|
|
||||||
- [grice-maxims](grice-maxims/SKILL.md) — say what's needed and no
|
- [grice-maxims](grice-maxims/SKILL.md) — say what's needed and no
|
||||||
more, only what you can back up, in an order easy to follow.
|
more, only what you can back up, in an order easy to follow.
|
||||||
|
- [journalism-101](journalism-101/SKILL.md) — lead with the news;
|
||||||
|
don't bury the lede, don't write about the document ("This
|
||||||
|
page..."), and write for readers who weren't in the conversation.
|
||||||
- [hypertext-links](hypertext-links/SKILL.md) — link text says where
|
- [hypertext-links](hypertext-links/SKILL.md) — link text says where
|
||||||
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:
|
- [hackmd-deck](hackmd-deck/SKILL.md) — a light talk as a flashback:
|
||||||
TADA, then how, then the challenges, tagged for an emoji retro.
|
TADA, then how, then the challenges, tagged for an emoji retro.
|
||||||
|
- [gh-progress-report](gh-progress-report/SKILL.md) — a milestone comment
|
||||||
|
on an issue: `## heading`, no date, real commands and their output,
|
||||||
|
`git log10` back to the last checkpoint.
|
||||||
- [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
|
- [wiring-diagram](wiring-diagram/SKILL.md) — who holds what, drawn
|
||||||
@@ -62,12 +72,22 @@ Code](https://code.claude.com/docs/en/skills) and
|
|||||||
TODO: consider copying or adapting its companion for message order,
|
TODO: consider copying or adapting its companion for message order,
|
||||||
sequence-diagram-actor-sim (agoric-sdk `.agents/skills/` on branch
|
sequence-diagram-actor-sim (agoric-sdk `.agents/skills/` on branch
|
||||||
`connolly/ago-1299-agentic-planning-tdd`).
|
`connolly/ago-1299-agentic-planning-tdd`).
|
||||||
|
- [delegation-diagram](delegation-diagram/SKILL.md) — where authority
|
||||||
|
came from, after Keyhive's certflow diagrams: solid lines for who
|
||||||
|
delegated, dashed for provenance; reach computed, traced on hover,
|
||||||
|
and faded on revoke.
|
||||||
|
- [tab-dump-topics](tab-dump-topics/SKILL.md) — an office hours tab
|
||||||
|
dump, regrouped by topic in meeting order under timestamped
|
||||||
|
headings, from the transcript.
|
||||||
- [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
|
||||||
|
|
||||||
|
- [makefile-style](makefile-style/SKILL.md) — make for named
|
||||||
|
checkpoints: short targets, logic in scripts, `make help` from `##`
|
||||||
|
comments, file targets, `CONFIRM=` on destructive ones.
|
||||||
- [discord-agent-workspace](discord-agent-workspace/SKILL.md) — set
|
- [discord-agent-workspace](discord-agent-workspace/SKILL.md) — set
|
||||||
someone up like this: Claude Code in a workspace folder, messaged
|
someone up like this: Claude Code in a workspace folder, messaged
|
||||||
from Discord.
|
from Discord.
|
||||||
@@ -77,6 +97,9 @@ Code](https://code.claude.com/docs/en/skills) and
|
|||||||
a throwaway systemd user unit that can't see `~/.ssh` and friends.
|
a throwaway systemd user unit that can't see `~/.ssh` and friends.
|
||||||
- [what-was-i-doing](what-was-i-doing/SKILL.md) — where did this file
|
- [what-was-i-doing](what-was-i-doing/SKILL.md) — where did this file
|
||||||
come from? Correlate mtimes with git history across every repo.
|
come from? Correlate mtimes with git history across every repo.
|
||||||
|
- [rholo-node-cloudflare](rholo-node-cloudflare/SKILL.md) — a rholo
|
||||||
|
testnet node on Cloudflare: an observer as an experiment, not a
|
||||||
|
validator; ask for each right narrowly, by `define` or by hand.
|
||||||
- [notify-me](notify-me/SKILL.md) — desktop notification at the end
|
- [notify-me](notify-me/SKILL.md) — desktop notification at the end
|
||||||
of a long turn, sticky if I'm stepping away; not every reply.
|
of a long turn, sticky if I'm stepping away; not every reply.
|
||||||
|
|
||||||
@@ -92,7 +115,7 @@ Write the body for an agent in the middle of a task. It reads the skill's text,
|
|||||||
|
|
||||||
For each line, ask: would deleting it change what an agent does? If not, it belongs in the footer or 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.
|
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. Mark the parts in the text, as Alexander did, not with generic headings: the context in the opening paragraph, the problem as a bold sentence, the forces as a list, the resolution after a bold **Therefore:**, and its cost to close. Headings, where the body needs them, name the point ([docs-files-api](docs-files-api/SKILL.md)): "Confidential details stay private", not "Therefore". 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. TODO: rework the patterns ([notify-me](notify-me/SKILL.md), [acls-dont](acls-dont/SKILL.md), [refactor-mercilessly](refactor-mercilessly/SKILL.md), [hackmd-deck](hackmd-deck/SKILL.md)), which still use the parts as headings. 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 with this in mind.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
---
|
||||||
|
name: delegation-diagram
|
||||||
|
description: >-
|
||||||
|
Delegation diagram, after Keyhive's certflow diagrams: where each party's authority came from, what it reaches, and what a revocation takes with it — use when asked for a certflow or delegation diagram; when a design delegates or attenuates authority through chains (facets of facets, caretakers, invitations, certificate capabilities, UCANs); when someone asks "who can reach what?", "where did Bob get that?", or "what breaks if we revoke this?"; when an interactive page should trace reach on hover or revoke on click. Not for a snapshot of who holds what (that's wiring-diagram), nor for the order of messages (sequence-diagram-actor-sim).
|
||||||
|
---
|
||||||
|
|
||||||
|
# Delegation diagram
|
||||||
|
|
||||||
|
A wiring diagram shows who holds what now. It doesn't say how they got it, so it can't answer the questions a review of delegation asks: **where did this authority come from, what does it reach, and what goes when it's revoked?** Keyhive's certflow diagrams answer them by drawing the grant itself as a thing, with two kinds of line.
|
||||||
|
|
||||||
|
Exemplar: [`example-ertp-endowment.html`](example-ertp-endowment.html), next to this file: a toybox host endowing a guest's ERTP definition with a narrowed WebApp and a rholo signer. Start from it: the scene is data (`parties`, `subjects`, `grants`), and drawing, reach, revocation, the step-through, and the deep links all derive from that data.
|
||||||
|
|
||||||
|
## Two kinds of line
|
||||||
|
|
||||||
|
- Parties are balls. Each grant is a box labelled with the access it gives over its subject: `read: doc`, `relay: inbox`, `deposit: purse`.
|
||||||
|
- **Solid lines say who delegated to whom:** granter → grant → grantee.
|
||||||
|
- **Dashed lines say where the authority comes from:** subject → grant → grant, down the chain, skipping the parties in between. A grant made from another grant has a dashed line from it; follow the dashes up and you reach the subject.
|
||||||
|
|
||||||
|
Keeping the two apart is the point: a party can pass along a grant it holds, but the dashes show it can't widen it. A grant whose dashed line doesn't lead to its subject is either a bug in the design or a bug in the drawing.
|
||||||
|
|
||||||
|
Dashed means provenance here. In a wiring diagram it means a weak reference, so don't mix the two notations in one picture.
|
||||||
|
|
||||||
|
## Live references, not only certificates
|
||||||
|
|
||||||
|
Certflow is for certificate capabilities: signed delegations that hold up while the issuer is offline. In an ocap system, the same picture works for live references:
|
||||||
|
|
||||||
|
- A grant is an attenuating object: a facet, a caretaker's forwarder, a store's `readOnly()`, a definition's endowment.
|
||||||
|
- To delegate is to send that object in a message, and the solid line cites the call that sent it.
|
||||||
|
- The dashed line is what the object forwards to or closes over, and it cites the maker that built it.
|
||||||
|
|
||||||
|
As in wiring-diagram, every line cites the code (`file:line`). If you can't cite where a grant came from, it gets no line.
|
||||||
|
|
||||||
|
## Reach is computed, not drawn
|
||||||
|
|
||||||
|
Keep the scene as data (parties, subjects, and grants with who made each, who holds it, and its access) and draw it from that data. Compute reach; never mark it by hand. Then the page can't claim a reach the data doesn't support. Give each grant three kinds of source, all drawn dashed, which reach treats differently:
|
||||||
|
|
||||||
|
- `over`: what it acts on, narrowed. Reach follows it: holding `testnet` reaches the node, through its `/api/v1/`.
|
||||||
|
- `from`: the wider grant it was narrowed from. Reach doesn't follow it: holding `testnet` doesn't reach `webApps`. Following it would erase the attenuation the diagram exists to show.
|
||||||
|
- `uses`: what it holds and never hands out, such as a signer's read-only facet of the key store. Reach doesn't follow it, but revoking it disables the grant that uses it.
|
||||||
|
|
||||||
|
Reach is still an upper bound: it assumes each object passes on all it's `over`. Say so where it matters.
|
||||||
|
|
||||||
|
- **Hover a party to trace its reach:** highlight what it reaches and fade the rest. Hover Mallory, who holds whatever is most likely to leak, and her caption should match what lights up.
|
||||||
|
- **Revoke on click:** a revocation is a diamond held by the revoker, with a solid red line that ends in ✕ instead of an arrowhead, and red dashes back to where the revoker's authority comes from. Recompute reach. What depended on the revoked grant fades, unless another route still backs it. Fading, rather than deleting, keeps the change visible.
|
||||||
|
- **Build in sequence:** a snapshot can't show order, so step through the grants one at a time, as wiring-diagram's step-through does: Prev/Next, arrow keys, and `#sN` deep links.
|
||||||
|
- Also take `#reach=bob` and `#revoke=g3` in the URL, so a link, or a headless screenshot, shows a highlighted state without a mouse.
|
||||||
|
|
||||||
|
## Works in one colour
|
||||||
|
|
||||||
|
Every distinction is carried by shape and line style: ball versus box, solid versus dashed, arrowhead versus ✕, diamond. Colour may reinforce them but never carry them alone. The page should still read printed in black, and to someone who can't tell red from green.
|
||||||
|
|
||||||
|
## Render and check
|
||||||
|
|
||||||
|
Render with headless Chromium, as in wiring-diagram, once plain, then once per interesting `#reach=` and `#revoke=` state. Look at each screenshot. Check that:
|
||||||
|
|
||||||
|
- each solid line cites a call, and each dashed line cites a maker;
|
||||||
|
- the dashes from every grant lead to its subject;
|
||||||
|
- each party's computed reach is what its job needs, and Mallory's caption matches hers;
|
||||||
|
- revoking each grant fades exactly what the design says it should;
|
||||||
|
- `<desc>` tells the same story in prose: who delegated what to whom, and from what.
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- [07 · Certflow Diagrams](https://www.inkandswitch.com/keyhive/notebook/07/) (Ink & Switch, Keyhive lab notebook, 2026-10-31): the notation, and hover, click-to-revoke, and drag-to-delegate on live diagrams.
|
||||||
|
- [Keyhive notebook 01](https://www.inkandswitch.com/keyhive/notebook/01/): the Granovetter diagram that certflow adapts.
|
||||||
|
- [wiring-diagram](../wiring-diagram/SKILL.md): the snapshot companion, with the drawing helpers and the headless render recipe.
|
||||||
|
- [caretaker](../caretaker/SKILL.md): revocable access as a forwarder plus a revoker, the usual live-reference grant.
|
||||||
@@ -0,0 +1,261 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>ERTP endowment delegation</title>
|
||||||
|
<style>
|
||||||
|
:root { --ink: #1d2430; --faint: #6b7280; --bg: #ffffff; --box: #f3f4f6; --ball: #dbeafe; --ext: #e5e7eb; --hot: #c2410c; --red: #b91c1c; }
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root:not([data-theme="light"]) { --ink: #e5e7eb; --faint: #9ca3af; --bg: #111827; --box: #1f2937; --ball: #1e3a5f; --ext: #374151; --hot: #fb923c; --red: #f87171; }
|
||||||
|
}
|
||||||
|
body { margin: 0; padding: 16px; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, sans-serif; }
|
||||||
|
main { max-width: 1040px; margin: 0 auto; }
|
||||||
|
h1 { font-size: 1.25em; margin: 0 0 .3em; }
|
||||||
|
p { margin: .4em 0; max-width: 70em; }
|
||||||
|
svg { width: 100%; height: auto; display: block; }
|
||||||
|
svg text { fill: var(--ink); font: 13px system-ui, sans-serif; }
|
||||||
|
svg .small { font-size: 11px; fill: var(--faint); }
|
||||||
|
.node, .edge { transition: opacity .2s; }
|
||||||
|
.dim { opacity: .15; }
|
||||||
|
.gone { opacity: .25; }
|
||||||
|
.hot rect, .hot circle { stroke: var(--hot); stroke-width: 3; }
|
||||||
|
.grant { cursor: pointer; }
|
||||||
|
.party { cursor: default; }
|
||||||
|
#controls { display: flex; gap: .5em; align-items: center; flex-wrap: wrap; margin: .5em 0; }
|
||||||
|
#step { min-width: 12em; }
|
||||||
|
code { font-size: .92em; }
|
||||||
|
@media (prefers-reduced-motion: reduce) { .node, .edge { transition: none; } }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
<h1>Where the ERTP vat's authority comes from</h1>
|
||||||
|
<p>A guest (Claude) proposes a definition; the host (Dan) endows it with a <code>testnet</code> WebApp and a rholo deploy <code>signer</code>, then hands the vat's root to the guest. <b>Solid</b> lines: who delegated to whom. <b>Dashed</b>: what each grant acts on, or was narrowed from. Reach follows what a grant acts on, never the wider grant it was narrowed from. <b>Hover</b> a party to trace its reach; <b>click</b> a grant to see what revoking it takes with it; click again to restore.</p>
|
||||||
|
<div id="controls">
|
||||||
|
<button id="prev" type="button">◀ Prev</button>
|
||||||
|
<button id="next" type="button">Next ▶</button>
|
||||||
|
<input id="slider" type="range" min="0" value="0" aria-label="step">
|
||||||
|
<span id="step"></span>
|
||||||
|
</div>
|
||||||
|
<svg id="pic" viewBox="0 0 1030 600" role="img" aria-labelledby="t d">
|
||||||
|
<title id="t">ERTP endowment delegation</title>
|
||||||
|
<desc id="d"></desc>
|
||||||
|
<defs>
|
||||||
|
<marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="context-stroke"/></marker>
|
||||||
|
</defs>
|
||||||
|
<g id="edges"></g>
|
||||||
|
<g id="nodes"></g>
|
||||||
|
</svg>
|
||||||
|
<p id="caption"></p>
|
||||||
|
<p class="small" id="cite"></p>
|
||||||
|
<p style="color: var(--faint)">Lines cite <code>packages/toybox</code> on vattr97 branch <code>toybox-rholo</code>, and the definition's own <code>main.js</code>. Only removing the key from the store is a revocation the code has today; clicking the other grants asks "what if?". Notation after Ink & Switch's <a href="https://www.inkandswitch.com/keyhive/notebook/07/">Certflow Diagrams</a>.</p>
|
||||||
|
</main>
|
||||||
|
<script>
|
||||||
|
'use strict';
|
||||||
|
// The scene, as data: draw it and compute reach from it, never by hand.
|
||||||
|
const parties = {
|
||||||
|
kernel: { x: 120, y: 70, label: 'kernel', note: 'boot vat' },
|
||||||
|
dan: { x: 540, y: 70, label: 'Dan', note: 'owner host' },
|
||||||
|
claude: { x: 790, y: 70, label: 'Claude', note: 'guest' },
|
||||||
|
mallory: { x: 950, y: 70, label: 'Mallory', note: 'has a leaked link' },
|
||||||
|
vat: { x: 520, y: 290, label: 'ERTP vat', note: 'the endowed definition' },
|
||||||
|
};
|
||||||
|
// subjects: what the grants finally act on
|
||||||
|
const subjects = {
|
||||||
|
fetch: { x: 80, y: 540, label: 'fetch: any URL' },
|
||||||
|
node: { x: 240, y: 540, label: 'rholo testnet node', ext: true },
|
||||||
|
device: { x: 420, y: 540, label: 'secp256k1 signing' },
|
||||||
|
keystore: { x: 630, y: 540, label: 'Dan\'s key store' },
|
||||||
|
};
|
||||||
|
// `over`: what a grant acts on, narrowed; reach follows it.
|
||||||
|
// `from`: the grant it was narrowed from; reach doesn't follow that.
|
||||||
|
// `uses`: what it holds and never hands out; reach doesn't follow that either.
|
||||||
|
const grants = {
|
||||||
|
webApps: { x: 80, y: 190, access: 'make WebApps', by: 'kernel', to: 'dan', over: ['fetch'], from: [], cite: 'examples/wallet/boot.js:112 (owner starters)' },
|
||||||
|
rholoSigners: { x: 290, y: 190, access: 'make rholo signers', by: 'kernel', to: 'dan', over: ['device'], from: [], cite: 'examples/wallet/boot.js:112; src/devices/rholo.js:216' },
|
||||||
|
testnet: { x: 200, y: 370, access: 'HTTP: testnet /api/v1/ only', by: 'dan', to: 'vat', over: ['node'], from: ['webApps'], cite: 'examples/webapp.js:93 (makeWebApp); examples/wallet/gateway/agents.exo.js:368 (endow)' },
|
||||||
|
readOnly: { x: 780, y: 430, access: 'read: key store', by: 'dan', to: null, over: ['keystore'], from: [], cite: 'examples/store-maker.js (readOnly facet)' },
|
||||||
|
signer: { x: 420, y: 430, access: 'sign: /testnet, phlo ≤ 2M', by: 'dan', to: 'vat', over: ['device'], uses: ['readOnly'], from: ['rholoSigners'], cite: 'src/devices/rholo.js:216 (make), :263 (sign)' },
|
||||||
|
root: { x: 800, y: 300, access: 'call: alicePaysBob, faucet', by: 'dan', to: 'guestLink', over: ['vat'], from: [], cite: 'rho-ertp main.js:61 (the root closes over testnet and signer)' },
|
||||||
|
guestLink: { x: 870, y: 190, access: 'act as guest "claude"', by: 'dan', to: 'claude', over: [], from: [], cite: 'examples/wallet/gateway/page.js (invite link, a webkey)' },
|
||||||
|
};
|
||||||
|
// who holds what outright, besides grants delegated to them
|
||||||
|
const keeps = [['dan', 'keystore'], ['mallory', 'guestLink']];
|
||||||
|
// a revocation the code supports: the keeper deletes privateKey
|
||||||
|
const revocable = { readOnly: 'Dan deletes privateKey from the store: the signer can no longer sign' };
|
||||||
|
// the build order, one delegation per step
|
||||||
|
const steps = [
|
||||||
|
['webApps', 'The kernel\'s boot vat gives the owner host a WebApp maker, over fetch.'],
|
||||||
|
['rholoSigners', 'It also gives the owner a rholo signer maker, over the signing device.'],
|
||||||
|
['testnet', 'Dan narrows the WebApp maker to the testnet node\'s /api/v1/, and endows the vat with it.'],
|
||||||
|
['readOnly', 'Dan passes a read-only facet of his key store to the signer maker. The signer reads the key with it at each signature and never hands it out; Dan keeps the store.'],
|
||||||
|
['signer', 'The signer: one shard, a phlo cap, the key read at each signature. Dan endows the vat with it.'],
|
||||||
|
['root', 'The vat\'s root closes over testnet and signer, and answers only alicePaysBob, faucet, tryNonNat; endow saves it in Dan\'s names.'],
|
||||||
|
['guestLink', 'Dan\'s guest link gives Claude the guest agent, whose names hold the root. Mallory got a copy.'],
|
||||||
|
];
|
||||||
|
|
||||||
|
const NS = 'http://www.w3.org/2000/svg';
|
||||||
|
const mk = (tag, attrs = {}, parent) => {
|
||||||
|
const e = document.createElementNS(NS, tag);
|
||||||
|
for (const [k, v] of Object.entries(attrs)) e.setAttribute(k, v);
|
||||||
|
if (parent) parent.append(e);
|
||||||
|
return e;
|
||||||
|
};
|
||||||
|
const pos = id => parties[id] || subjects[id] || grants[id];
|
||||||
|
const W = 150, H = 46;
|
||||||
|
|
||||||
|
// what `id` reaches: what it holds, and what each of those is made from
|
||||||
|
const reachOf = (id, revoked) => {
|
||||||
|
const held = new Map();
|
||||||
|
const add = (a, b) => { if (!held.has(a)) held.set(a, []); held.get(a).push(b); };
|
||||||
|
for (const [g, d] of Object.entries(grants)) {
|
||||||
|
if (revoked.has(g)) continue;
|
||||||
|
if (d.to) add(d.to, g);
|
||||||
|
for (const o of d.over) if (!revoked.has(o)) add(g, o);
|
||||||
|
}
|
||||||
|
for (const [a, b] of keeps) add(a, b);
|
||||||
|
const seen = new Set([id]);
|
||||||
|
const todo = [id];
|
||||||
|
while (todo.length) for (const n of held.get(todo.pop()) || []) if (!seen.has(n)) { seen.add(n); todo.push(n); }
|
||||||
|
return seen;
|
||||||
|
};
|
||||||
|
|
||||||
|
// an edge from a's box or ball to b's, trimmed at the shapes' edges
|
||||||
|
const anchor = (p, toward) => {
|
||||||
|
const dx = toward.x - p.x, dy = toward.y - p.y, len = Math.hypot(dx, dy) || 1;
|
||||||
|
if (parties[p.id]) return { x: p.x + dx / len * 34, y: p.y + dy / len * 34 };
|
||||||
|
const t = Math.min((W / 2 + 4) / Math.abs(dx || 1e-9), (H / 2 + 4) / Math.abs(dy || 1e-9));
|
||||||
|
return { x: p.x + dx * t, y: p.y + dy * t };
|
||||||
|
};
|
||||||
|
for (const [id, p] of Object.entries({ ...parties, ...subjects, ...grants })) p.id = id;
|
||||||
|
|
||||||
|
const edges = [];
|
||||||
|
const line = (a, b, kind) => {
|
||||||
|
const A = anchor(pos(a), pos(b)), B = anchor(pos(b), pos(a));
|
||||||
|
const g = mk('g', { class: 'edge' }, document.getElementById('edges'));
|
||||||
|
const l = mk('line', { x1: A.x, y1: A.y, x2: B.x, y2: B.y, stroke: 'currentColor', 'stroke-width': kind === 'from' ? 1.5 : 2, 'stroke-dasharray': kind === 'from' ? '6 5' : 'none', 'marker-end': 'url(#arrow)' }, g);
|
||||||
|
g.style.color = 'var(--ink)';
|
||||||
|
const x = mk('text', { x: (A.x + B.x) / 2, y: (A.y + B.y) / 2 + 5, 'text-anchor': 'middle', 'font-size': 18, visibility: 'hidden' }, g);
|
||||||
|
x.textContent = '✕';
|
||||||
|
edges.push({ a, b, kind, g, l, x });
|
||||||
|
};
|
||||||
|
for (const [g, d] of Object.entries(grants)) {
|
||||||
|
line(d.by, g, 'by');
|
||||||
|
if (d.to) line(g, d.to, 'to');
|
||||||
|
for (const o of d.over) line(o, g, 'from');
|
||||||
|
for (const f of d.from) line(f, g, 'from');
|
||||||
|
for (const u of d.uses || []) line(u, g, 'from');
|
||||||
|
}
|
||||||
|
for (const [a, b] of keeps) line(a, b, 'keep');
|
||||||
|
|
||||||
|
const nodes = {};
|
||||||
|
const nodesG = document.getElementById('nodes');
|
||||||
|
for (const [id, p] of Object.entries(parties)) {
|
||||||
|
const g = mk('g', { class: 'node party', tabindex: 0 }, nodesG);
|
||||||
|
mk('circle', { cx: p.x, cy: p.y, r: 30, fill: 'var(--ball)', stroke: 'var(--ink)', 'stroke-width': 1.5 }, g);
|
||||||
|
mk('text', { x: p.x, y: p.y + 4, 'text-anchor': 'middle', 'font-weight': 600 }, g).textContent = p.label;
|
||||||
|
mk('text', { x: p.x, y: p.y + 46, 'text-anchor': 'middle', class: 'small' }, g).textContent = p.note;
|
||||||
|
nodes[id] = g;
|
||||||
|
}
|
||||||
|
for (const [id, p] of Object.entries(subjects)) {
|
||||||
|
const g = mk('g', { class: 'node' }, nodesG);
|
||||||
|
mk('rect', { x: p.x - W / 2, y: p.y - H / 2, width: W, height: H, rx: 2, fill: p.ext ? 'var(--ext)' : 'var(--bg)', stroke: 'var(--ink)', 'stroke-width': 3 }, g);
|
||||||
|
mk('text', { x: p.x, y: p.y + 4, 'text-anchor': 'middle', 'font-weight': 600 }, g).textContent = p.label;
|
||||||
|
nodes[id] = g;
|
||||||
|
}
|
||||||
|
for (const [id, p] of Object.entries(grants)) {
|
||||||
|
const g = mk('g', { class: 'node grant', tabindex: 0, role: 'button' }, nodesG);
|
||||||
|
mk('rect', { x: p.x - W / 2, y: p.y - H / 2, width: W, height: H, rx: 10, fill: 'var(--box)', stroke: 'var(--ink)', 'stroke-width': 1.5 }, g);
|
||||||
|
mk('text', { x: p.x, y: p.y - 4, 'text-anchor': 'middle', 'font-weight': 600 }, g).textContent = id;
|
||||||
|
mk('text', { x: p.x, y: p.y + 13, 'text-anchor': 'middle', class: 'small' }, g).textContent = p.access;
|
||||||
|
nodes[id] = g;
|
||||||
|
}
|
||||||
|
// a revocation the code has: a diamond by the revoker, on the grant
|
||||||
|
const diamond = mk('g', { class: 'node' }, nodesG);
|
||||||
|
mk('path', { d: 'M780,384 l10,10 l-10,10 l-10,-10 z', fill: 'var(--bg)', stroke: 'var(--ink)', 'stroke-width': 1.5 }, diamond);
|
||||||
|
|
||||||
|
let step = steps.length, revoked = new Set(), focus = null;
|
||||||
|
const shown = () => new Set(steps.slice(0, step).map(([g]) => g));
|
||||||
|
|
||||||
|
const render = () => {
|
||||||
|
const vis = shown();
|
||||||
|
const reach = focus ? reachOf(focus, revoked) : null;
|
||||||
|
// what nothing backs any more, once something is revoked: compare with no revocation, from every party
|
||||||
|
const lost = new Set();
|
||||||
|
if (revoked.size) {
|
||||||
|
const before = new Set(), after = new Set();
|
||||||
|
for (const p of Object.keys(parties)) { reachOf(p, new Set()).forEach(n => before.add(n)); reachOf(p, revoked).forEach(n => after.add(n)); }
|
||||||
|
for (const n of before) if (!after.has(n) && grants[n]) lost.add(n);
|
||||||
|
for (const r of revoked) lost.add(r);
|
||||||
|
// a grant that uses what was lost can't do its job either
|
||||||
|
let grew = true;
|
||||||
|
while (grew) {
|
||||||
|
grew = false;
|
||||||
|
for (const [g, d] of Object.entries(grants))
|
||||||
|
if (!lost.has(g) && (d.uses || []).some(u => lost.has(u))) { lost.add(g); grew = true; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const [id, g] of Object.entries(nodes)) {
|
||||||
|
const hidden = grants[id] && !vis.has(id);
|
||||||
|
g.style.display = hidden ? 'none' : '';
|
||||||
|
g.classList.toggle('dim', !!reach && !reach.has(id));
|
||||||
|
g.classList.toggle('gone', lost.has(id) && !reach);
|
||||||
|
g.classList.toggle('hot', !!reach && id === focus);
|
||||||
|
}
|
||||||
|
for (const e of edges) {
|
||||||
|
const grant = grants[e.a] ? e.a : grants[e.b] ? e.b : null;
|
||||||
|
const hidden = (grant && !vis.has(grant)) || (grants[e.a] && !vis.has(e.a)) || (grants[e.b] && !vis.has(e.b));
|
||||||
|
e.g.style.display = hidden ? 'none' : '';
|
||||||
|
const cut = revoked.has(e.a) || revoked.has(e.b);
|
||||||
|
e.l.setAttribute('stroke', cut ? 'var(--red)' : 'currentColor');
|
||||||
|
e.l.setAttribute('marker-end', cut ? '' : 'url(#arrow)');
|
||||||
|
e.x.setAttribute('visibility', cut && (e.kind === 'to' || (e.kind === 'by' && !grants[e.b].to)) ? 'visible' : 'hidden');
|
||||||
|
e.x.setAttribute('fill', 'var(--red)');
|
||||||
|
e.g.classList.toggle('dim', !!reach && !(reach.has(e.a) && reach.has(e.b)));
|
||||||
|
e.g.classList.toggle('gone', !reach && (lost.has(e.a) || lost.has(e.b)));
|
||||||
|
}
|
||||||
|
diamond.style.display = vis.has('readOnly') ? '' : 'none';
|
||||||
|
const [, said] = steps[Math.max(0, step - 1)];
|
||||||
|
document.getElementById('step').textContent = 'step ' + step + ' of ' + steps.length;
|
||||||
|
document.getElementById('slider').value = step;
|
||||||
|
let caption = step ? said : 'Nothing delegated yet.';
|
||||||
|
if (focus) caption = parties[focus].label + ' reaches: ' + [...reachOf(focus, revoked)].filter(n => n !== focus).map(n => (pos(n).label || n)).join(', ') + '.';
|
||||||
|
if (revoked.size) caption += ' Revoked: ' + [...revoked].map(r => revocable[r] || r + ' (what if?)').join('; ') + '. Fading: ' + ([...lost].filter(n => !revoked.has(n)).join(', ') || 'nothing else; another route still backs the rest') + '.';
|
||||||
|
document.getElementById('caption').textContent = caption;
|
||||||
|
const c = steps[Math.max(0, step - 1)][0];
|
||||||
|
document.getElementById('cite').textContent = step ? c + ': ' + grants[c].cite : '';
|
||||||
|
document.getElementById('d').textContent = 'Delegations, in order: ' + steps.slice(0, step).map(([g, s]) => s).join(' ') + ' Mallory, holding a leaked copy of the guest link, reaches what Claude\'s guest agent reaches: the vat\'s root, and through it only the testnet API and a signer for one shard under a phlo cap. She can\'t read the key, sign for another shard, fetch other URLs, or make WebApps or signers.';
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const [id, g] of Object.entries(nodes)) {
|
||||||
|
if (parties[id]) {
|
||||||
|
g.addEventListener('mouseenter', () => { focus = id; render(); });
|
||||||
|
g.addEventListener('focus', () => { focus = id; render(); });
|
||||||
|
g.addEventListener('mouseleave', () => { focus = null; render(); });
|
||||||
|
g.addEventListener('blur', () => { focus = null; render(); });
|
||||||
|
}
|
||||||
|
if (grants[id]) {
|
||||||
|
const toggle = () => { revoked.has(id) ? revoked.delete(id) : revoked.add(id); render(); };
|
||||||
|
g.addEventListener('click', toggle);
|
||||||
|
g.addEventListener('keydown', ev => { if (ev.key === 'Enter' || ev.key === ' ') { ev.preventDefault(); toggle(); } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const go = n => { step = Math.max(0, Math.min(steps.length, n)); history.replaceState(null, '', '#s' + step); render(); };
|
||||||
|
document.getElementById('slider').max = steps.length;
|
||||||
|
document.getElementById('slider').addEventListener('input', ev => go(Number(ev.target.value)));
|
||||||
|
document.getElementById('prev').onclick = () => go(step - 1);
|
||||||
|
document.getElementById('next').onclick = () => go(step + 1);
|
||||||
|
document.addEventListener('keydown', ev => { if (ev.key === 'ArrowLeft') go(step - 1); if (ev.key === 'ArrowRight') go(step + 1); });
|
||||||
|
|
||||||
|
// deep links: #s3, #reach=mallory, #revoke=readOnly (combine with &)
|
||||||
|
for (const part of location.hash.slice(1).split('&')) {
|
||||||
|
const [k, v] = part.split('=');
|
||||||
|
if (/^s\d+$/.test(k)) step = Math.min(steps.length, Number(k.slice(1)));
|
||||||
|
if (k === 'reach' && parties[v]) focus = v;
|
||||||
|
if (k === 'revoke' && grants[v]) revoked.add(v);
|
||||||
|
}
|
||||||
|
render();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -21,8 +21,11 @@ Generated-by: Claude Opus 5.5
|
|||||||
## the rules
|
## the rules
|
||||||
|
|
||||||
- **When:** the content is substantially machine-generated: code,
|
- **When:** the content is substantially machine-generated: code,
|
||||||
docs, tests, or a rewrite. Not needed for a typo fix or an edit the
|
docs, tests, or a rewrite. Not needed for a typo fix, an edit the
|
||||||
human typed.
|
human typed, or a line or two the human approved word for word,
|
||||||
|
such as one entry added to a list: the tool saved a little typing,
|
||||||
|
nothing more. This holds even when the harness says to add its own
|
||||||
|
trailer to every commit.
|
||||||
- **Form:** `Generated-by: <Tool> <Version>`, as the last paragraph of
|
- **Form:** `Generated-by: <Tool> <Version>`, as the last paragraph of
|
||||||
the message, in git trailer format (`git interpret-trailers` can
|
the message, in git trailer format (`git interpret-trailers` can
|
||||||
parse it).
|
parse it).
|
||||||
|
|||||||
@@ -62,7 +62,11 @@ Whoever can message the bot can make it act with the session's powers: files, sh
|
|||||||
|
|
||||||
## 4. Keeping it running
|
## 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).
|
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). An expired login shows only in that terminal, never on Discord, so that's where `/login` happens.
|
||||||
|
|
||||||
|
On Linux, a systemd user unit can start it at boot and confine it: [claude-bot.service](claude-bot.service) runs Claude in tmux under `bwrap`, with everything read-only but the workspace, `~/.claude`, `~/.claude.json` and `~/.cache`, and credential dirs hidden. Hiding `$XDG_RUNTIME_DIR` also hides the systemd and D-Bus sockets, so `systemd-run` can't escape. Add `loginctl enable-linger` so it runs while they're logged out.
|
||||||
|
|
||||||
|
Use bwrap, not `ProtectHome=`, `ReadWritePaths=` and friends: where the user manager can't mount (Ubuntu's `kernel.apparmor_restrict_unprivileged_userns=1`), it silently runs the service unconfined. Check the live process: if `readlink /proc/<pid>/ns/mnt` matches the user's shell, it isn't confined.
|
||||||
|
|
||||||
## 5. First task
|
## 5. First task
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# claude-bot: Claude Code Discord bot, confined to one workspace folder.
|
||||||
|
# Install: ~/.config/systemd/user/claude-bot.service; systemctl --user enable --now claude-bot
|
||||||
|
# loginctl enable-linger $USER (so it runs without you logged in)
|
||||||
|
# Attach: tmux -S /run/user/$UID/claude-bot/tmux.sock attach (detach: C-b d; /login happens here)
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Claude Code Discord bot
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
WorkingDirectory=%h/workspace
|
||||||
|
Environment=PATH=%h/.local/bin:/usr/local/bin:/usr/bin:/bin
|
||||||
|
Environment=TERM=xterm-256color
|
||||||
|
RuntimeDirectory=claude-bot
|
||||||
|
|
||||||
|
# Optional: GH_TOKEN=<a fine-grained token of the bot's own, for just the repos it needs>
|
||||||
|
EnvironmentFile=-%h/.config/claude-bot/env
|
||||||
|
|
||||||
|
# The user manager has no network-online.target.
|
||||||
|
ExecStartPre=/bin/sh -c 'until getent hosts gateway.discord.gg >/dev/null; do sleep 2; done'
|
||||||
|
|
||||||
|
# bwrap, not ProtectHome= and friends: on Ubuntu (kernel.apparmor_restrict_unprivileged_userns=1)
|
||||||
|
# the user manager can't mount, and silently runs the service unconfined.
|
||||||
|
# Everything is read-only except the --bind paths; --tmpfs hides credential dirs.
|
||||||
|
# Hiding %t removes the systemd and D-Bus sockets (systemd-run would escape) and the ssh/gpg agents.
|
||||||
|
ExecStart=/usr/bin/tmux -S %t/claude-bot/tmux.sock new-session -d -s claude-bot \
|
||||||
|
/usr/bin/bwrap --die-with-parent \
|
||||||
|
--ro-bind / / --dev /dev --proc /proc --tmpfs /tmp --tmpfs %t \
|
||||||
|
--bind %h/workspace %h/workspace \
|
||||||
|
--bind %h/.claude %h/.claude \
|
||||||
|
--bind %h/.claude.json %h/.claude.json \
|
||||||
|
--bind %h/.cache %h/.cache \
|
||||||
|
--tmpfs %h/.ssh --tmpfs %h/.gnupg --tmpfs %h/.config/gh \
|
||||||
|
--ro-bind /dev/null %h/.git-credentials \
|
||||||
|
claude -n claude-bot --permission-mode auto --channels plugin:discord@claude-plugins-official
|
||||||
|
ExecStop=-/usr/bin/tmux -S %t/claude-bot/tmux.sock kill-server
|
||||||
|
|
||||||
|
# tmux exits 0 when claude exits, so on-failure would never fire.
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
@@ -56,10 +56,10 @@ JSDoc placement rules (from the
|
|||||||
no docstrings; a string literal is the honest equivalent) rather than
|
no docstrings; a string literal is the honest equivalent) rather than
|
||||||
copying it or reading the script's own source. Helpers inside still get
|
copying it or reading the script's own source. Helpers inside still get
|
||||||
their own JSDoc.
|
their own JSDoc.
|
||||||
- **Write for the reader, not the conversation:** Comments say what the
|
- **Write for the reader, not the conversation:** comments say what the
|
||||||
code is and why, in the reader's terms. No traces of how it came to be
|
code is and why; no "for now", no traces of the design discussion
|
||||||
(design discussions, who asked, "for now", analogies used while
|
(see journalism-101, "Write for readers who weren't there"), and
|
||||||
deciding), and nothing the code or its shebang already says.
|
nothing the code or its shebang already says.
|
||||||
- **External design constraints:** If a module is constrained by external
|
- **External design constraints:** If a module is constrained by external
|
||||||
contracts, standards, or off-repo design docs, add a short JSDoc note with a
|
contracts, standards, or off-repo design docs, add a short JSDoc note with a
|
||||||
`@see` link to the authoritative source at the relevant entry point(s).
|
`@see` link to the authoritative source at the relevant entry point(s).
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
name: gh-progress-report
|
||||||
|
description: >-
|
||||||
|
Progress report on a milestone, as a GitHub issue comment — use after a milestone on work that has an issue, when proposing or posting a comment that says something works and how; when someone says "report success on #N", "progress comment", or "include git log10". Not for short replies or quick notes on an issue.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Progress report
|
||||||
|
|
||||||
|
An issue comment that reports a milestone is a record its reader keeps: it reaches email, it's searchable for decades, and a public one shows up as a quick note on the author's blog. Write it as a document of its own.
|
||||||
|
|
||||||
|
- **Start with an h2**, `## <the milestone>`, such as `## Coinbase sync works, as a toybox toy`. Subsections are `###`. A short reply or a quick note gets no heading.
|
||||||
|
- **No date.** GitHub dates every comment; a date in the body only repeats it.
|
||||||
|
- **Show real commands and their output**, pasted as-is: `git log10`, `git annex list`, a test summary. They carry high-entropy facts, such as hashes, that let a later reader find exactly what was done.
|
||||||
|
- **`git log10`** is an alias: `log -n 10 --pretty=format:'%ad %h %s' --date='format:%Y-%m-%d %H:%M'`. Run the alias itself, not a format of your own. Filter by path to the code that matters, add `-n 30` or whatever reaches back to the last checkpoint reported, and trim uninteresting commits. Keep the hashes even when they're about to go bad: an unpushed branch, a retcon to come.
|
||||||
|
- **Hashes stay linked**: put `git log10` lines in a list, not a code block, where GitHub would show them as plain text. In prose GitHub links a hash of the issue's own repo; for another repo, write `owner/repo@hash`. So a line reads `- 2026-11-18 00:58 dckc/vattr97@ea49f0f fix(toybox): ...`, and the subject's own markup, such as backticks, still renders.
|
||||||
|
- **Say how it's put together**, not only that it works: who holds what, and how they came to hold it. A Mermaid `flowchart` with a subgraph per process works as a quick wiring diagram, and a `sequenceDiagram` shows the messages; GitHub renders both. Start the sequence where authority enters, not where the interesting part begins; nothing should arrive by magic ([wiring-diagram](../wiring-diagram/SKILL.md)).
|
||||||
|
- **Link, don't paste, long code**: a gist or a file at a pushed commit. A link into a commit that isn't pushed is a 404; name the path instead.
|
||||||
|
- **End with what's still to do**, briefly.
|
||||||
|
|
||||||
|
Keep confidential details out: hosts, ports, accounts, credentials, balances.
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- [The closet librarian approach to cloud services](https://www.madmode.com/2021/closet-librarian-approach-cloud-services.html), MadMode 2021: why issue comments are an archive.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: hypertext-links
|
name: hypertext-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.
|
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; when adding, moving, or deleting a doc (link it into context: from its parent, and back up); enforces descriptive link text over bare/generic links.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Hypertext Links
|
# Hypertext Links
|
||||||
@@ -41,4 +41,32 @@ Not `**Label**: [link](...)` — just bullets:
|
|||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
- [Akka Core documentation](https://doc.akka.io/libraries/akka-core/current/)
|
- [Akka Core documentation](https://doc.akka.io/libraries/akka-core/current/)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Link it into context
|
||||||
|
|
||||||
|
A page nothing links to is a bug: readers and agents won't find it, and it
|
||||||
|
rots unnoticed. When you add a document, in the same change:
|
||||||
|
|
||||||
|
- **Link to it** from its parent, the page whose subject it belongs to
|
||||||
|
(a goal tree, an index, a README).
|
||||||
|
- **Link from it** to that context, near the top: one line saying what it's
|
||||||
|
part of. Readers arrive by search or a pasted link, not from the start.
|
||||||
|
- **Make it stand alone**: no "as discussed above" or "next we consider";
|
||||||
|
link the first use of a project name or acronym to its home page.
|
||||||
|
|
||||||
|
The natural order is link first, page second. On a wiki, you add a page by
|
||||||
|
typing its WikiName where it belongs; that makes a link to a page that
|
||||||
|
doesn't exist yet, which you then follow and fill out (TODO: citation).
|
||||||
|
Tim Berners-Lee's original WorldWideWeb browser on NeXT worked the same
|
||||||
|
way: select some text, then make it a link to a new document (TODO:
|
||||||
|
citation).
|
||||||
|
|
||||||
|
Before deleting or moving a page, find what links to it (`git grep` the
|
||||||
|
file name), and fix those links in the same change. No links in? That was
|
||||||
|
the bug.
|
||||||
|
|
||||||
|
Source: Tim Berners-Lee, [Linking to context](https://www.w3.org/Provider/Style/IntoContext.html),
|
||||||
|
in W3C's _Style Guide for online hypertext_: "Watch that your text and
|
||||||
|
vocabulary stands by itself"; imagine "you yourself may wish to reuse the
|
||||||
|
document."
|
||||||
+29
-9
@@ -74,16 +74,36 @@ dependencies between issues with "(see 5)".
|
|||||||
|
|
||||||
## writing it in markdown
|
## writing it in markdown
|
||||||
|
|
||||||
A leading `-` or `.` collides with list syntax and editor
|
Prefer **emoji style** in markdown: each element is a list item led by its emoji, so nesting is the list's own and sources link on the line they support. Links don't render inside a fenced block.
|
||||||
auto-bulleting. Put each symbol after the list marker, escaping where
|
|
||||||
needed (`- \- con`, `- \+ pro`), or use a fenced block with indentation
|
|
||||||
as in the example below.
|
|
||||||
|
|
||||||
Past a screenful, give each top-level issue its own heading
|
| Symbol | Emoji |
|
||||||
(`### ? 3. What is the fence?`) with its elements in a fenced block
|
| :---: | :---: |
|
||||||
below. Headings show up in the editor outline and give each issue a
|
| `?` | ❓ |
|
||||||
link target. Links don't render inside a fence, so put sources after
|
| `?!` | ✅ |
|
||||||
the block and refer to them from the line they support.
|
| `?~` | ❓🔶 |
|
||||||
|
| `:` | 💡 |
|
||||||
|
| `:+` | 👍 |
|
||||||
|
| `:-` | 👎 |
|
||||||
|
| `:~+` | 🔶 |
|
||||||
|
| `+` | ➕ |
|
||||||
|
| `-` | ➖ |
|
||||||
|
| `!` | 📌 |
|
||||||
|
| `.` | 💬 |
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
### ❓ 1. How should we test our software?
|
||||||
|
|
||||||
|
- 🔶 1a. Use tape.
|
||||||
|
- ➕ It's what we currently use.
|
||||||
|
- ➖ It doesn't have code coverage.
|
||||||
|
- 👍 1b. Use [test262](https://github.com/tc39/test262).
|
||||||
|
```
|
||||||
|
|
||||||
|
Past a screenful, give each top-level issue its own heading (`### ❓ 3. What is the fence?`), as above: headings show up in the editor outline and give each issue a link target.
|
||||||
|
|
||||||
|
In plain text (chat, commit messages, code comments), use the symbols, in a fenced block with indentation as in the example below. A leading `-` or `.` collides with list syntax and editor auto-bulleting.
|
||||||
|
|
||||||
|
Source: the [IBIS page's emoji style](https://github.com/dckc/vattr97/wiki/IBIS#emoji-style); an example is [Reviving references on workerd](https://github.com/dckc/vattr97/wiki/reviving-references-on-workerd).
|
||||||
|
|
||||||
## example
|
## example
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
name: journalism-101
|
||||||
|
description: >-
|
||||||
|
Journalism 101: lead with the news, don't bury the lede, don't write about the document ("This page...", "This doc covers...", "In this section we..."), and write for readers who weren't in the conversation that produced it. Use when writing or revising the opening of any doc, page, README, issue, PR description, email, report, or reply; when someone says "bury the lede", "lede", "inverted pyramid", "navel-gazing", "chit-chat", "who's the audience?", or "no newspaper story starts with 'This newspaper story'". Not for link text (that's hypertext-links) or trimming words in general (that's grice-maxims).
|
||||||
|
---
|
||||||
|
|
||||||
|
# Journalism 101
|
||||||
|
|
||||||
|
## Lead with the news
|
||||||
|
|
||||||
|
The first sentence says the most important thing: what happened, what's needed, what the reader should do. Background, history, and how we got here come after, in order of importance (the inverted pyramid), so a reader who stops early still has the point.
|
||||||
|
|
||||||
|
- Buried: "After the office move, two candidates turned up, and each one just has to press a few keys, so ... the iPad works."
|
||||||
|
- Lede first: "The iPad remote works: it pressed Home on bldbox from the couch. Next: enroll it on Mom's Wi-Fi."
|
||||||
|
|
||||||
|
A status, a result, or a decision goes at the top, not at the end of a paragraph of context.
|
||||||
|
|
||||||
|
## Don't write about the document
|
||||||
|
|
||||||
|
No newspaper story starts with "This newspaper story...". The reader knows what they're reading; say the thing itself.
|
||||||
|
|
||||||
|
- Navel-gazing: "This page works toward one remote that Mom and Dad can actually use."
|
||||||
|
- The thing itself: "Mom and Dad need one remote they can actually use."
|
||||||
|
|
||||||
|
The same goes for "This document describes...", "This section covers...", "In this README, we...", and "The purpose of this issue is...". In a heading or a link, too: name the subject, not the container.
|
||||||
|
|
||||||
|
## Write for readers who weren't there
|
||||||
|
|
||||||
|
A story reports what happened, not the interviews that turned it up. Docs, comments, commit messages, and issues likewise: the reader wasn't in the conversation that produced them, so leave no trace of it. No design discussions, no who asked, no "for now", no analogies used while deciding. No answers to questions only the conversation raised, and no rebuttals of a draft the reader never saw.
|
||||||
|
|
||||||
|
- Chat leaking in: "Any Linux with systemd and Nix will do; it needn't be NixOS."
|
||||||
|
- For the reader: "Install Nix if it isn't there yet."
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- [Inverted pyramid (journalism)](https://en.wikipedia.org/wiki/Inverted_pyramid_(journalism)), Wikipedia: most important first, details in descending order.
|
||||||
|
- [Lead paragraph](https://en.wikipedia.org/wiki/Lead_paragraph), Wikipedia: the lede, and "burying the lede".
|
||||||
+3
-1
@@ -31,7 +31,9 @@ From Dan Connolly's
|
|||||||
## paying the debt (test-driven debugging)
|
## paying the debt (test-driven debugging)
|
||||||
|
|
||||||
1. Write a test that reproduces the goof, in the project's existing test
|
1. Write a test that reproduces the goof, in the project's existing test
|
||||||
framework and style, next to related tests.
|
framework and style, next to related tests. For a Python script or
|
||||||
|
tool, that's a doctest in the module, whatever files sit next to it
|
||||||
|
([py-doctest](../py-doctest/SKILL.md)).
|
||||||
2. Run it; **watch it fail** for the reason you expect. A test that
|
2. Run it; **watch it fail** for the reason you expect. A test that
|
||||||
passes before the fix proves nothing about the fix.
|
passes before the fix proves nothing about the fix.
|
||||||
3. Fix the code.
|
3. Fix the code.
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
---
|
||||||
|
name: makefile-style
|
||||||
|
description: >-
|
||||||
|
Makefile style: make for named checkpoints, short targets, scripts for logic, an accurate `make help` from `##` comments, file targets instead of phony ones, and a CONFIRM= guard on destructive targets. Use when writing or reviewing a Makefile or `.mk` file; when about to run a sequence of device or admin commands by hand ("no yolo! makefiles plz"); when a recipe grows loops, conditionals, or traps; when adding a `help` target. Not for build systems other than make.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Makefile style
|
||||||
|
|
||||||
|
## make names the checkpoints
|
||||||
|
|
||||||
|
Device and admin work (flash a card, restore an iPad, install a service) goes through make targets, not commands typed ad hoc. A target is a named step the operator can read before running, rerun, and cite later: `make flash DEV=/dev/sdd CONFIRM=erase` says what it does and what it touches.
|
||||||
|
|
||||||
|
## Short targets; logic goes in a script
|
||||||
|
|
||||||
|
A recipe is a few commands. Loops, conditionals, traps, and multi-line `test ... || { ...; }` chains go in a script beside the Makefile, which the target runs. AWK is fine for light text transforms; a non-trivial one gets its own `.awk` file.
|
||||||
|
|
||||||
|
Why: make's quoting (`$$`, one shell per line, `\` continuations) makes logic hard to read and easy to break; a script can be run, tested, and read on its own.
|
||||||
|
|
||||||
|
## `make help` from `##` comments
|
||||||
|
|
||||||
|
Put `## description` on the line before each target the operator runs; a small awk program pairs each `##` comment with the next `target:` line. Keep `help` accurate and current, and make it the first target, so plain `make` shows it.
|
||||||
|
|
||||||
|
```makefile
|
||||||
|
## Show available targets
|
||||||
|
help:
|
||||||
|
@awk 'BEGIN {d=""} /^## / {d=substr($$0,4)} \
|
||||||
|
/^[a-zA-Z0-9_.-]+:/ {if(d) {split($$0,t,":"); \
|
||||||
|
printf " %-12s %s\n", t[1], d; d=""}}' \
|
||||||
|
$(MAKEFILE_LIST)
|
||||||
|
```
|
||||||
|
|
||||||
|
Where a repo already has a shared `make-help.awk`, use it.
|
||||||
|
|
||||||
|
## Target the real file
|
||||||
|
|
||||||
|
Name the file a step produces as its target, so make skips the step when the file is there: no idempotence check, no phony alias. Factor a long path into a variable so its two uses are plainly the same. Prefer architecture-independent paths.
|
||||||
|
|
||||||
|
```makefile
|
||||||
|
AYATANA_PKG = gir1.2-ayatanaappindicator3-0.1
|
||||||
|
AYATANA_DOC = /usr/share/doc/$(AYATANA_PKG)/copyright
|
||||||
|
|
||||||
|
all: $(AYATANA_DOC) $(TARGETS)
|
||||||
|
systemctl --user daemon-reload
|
||||||
|
|
||||||
|
$(AYATANA_DOC):
|
||||||
|
sudo apt-get install -y $(AYATANA_PKG)
|
||||||
|
```
|
||||||
|
|
||||||
|
Except Nix's `result`: it links into the store, where every mtime is 1970, so as a target it always looks stale, and as a prerequisite it always forces a rebuild. Let a target check `test -e result` instead.
|
||||||
|
|
||||||
|
## Paths and installs
|
||||||
|
|
||||||
|
- `$(CURDIR)` for the working directory (`make -C dir` sets it); no `$(makeFileDir)` dance. `$(HOME)` for the target's home.
|
||||||
|
- `ln -sf` for durable installs from the source tree, so updates flow without a copy step.
|
||||||
|
|
||||||
|
## Destructive targets need CONFIRM=
|
||||||
|
|
||||||
|
A target that erases or overwrites (a disk, a device, a restore) refuses unless the operator says so on the command line, with a word that names the harm: `make restore CONFIRM=erase`. Before writing, it shows what it's about to touch (`lsblk` of the device) and checks it's the kind of thing expected (removable, on USB, a plausible size); that check is a script, per above.
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- [Makefile conventions](https://github.com/dckc/madmode-blog/blob/master/pages/2026/makefile-style.md), madmode-blog, 2026: checkpoints, short targets, the `help` awk, `$(CURDIR)`, `ln -sf`, file targets.
|
||||||
@@ -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; 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.
|
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 tempted to inject a logger or assert on log output; when a helper takes a port, a socket path, or a file path beside the fetch or fs that reaches it ("designation vs authority"); when setting up a test's I/O; when asked what OCap discipline is. Source: the Agoric wiki's OCap Discipline page.
|
||||||
---
|
---
|
||||||
|
|
||||||
# OCap Discipline
|
# OCap Discipline
|
||||||
@@ -42,6 +42,43 @@ 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.
|
||||||
|
|
||||||
|
## designation is not authority
|
||||||
|
|
||||||
|
A string that names a resource is a designator: a port, a socket path, a file path, a package directory computed from `import.meta.url`. Joined to a broad power the code holds anyway (`fetch`, `WebSocket`, `fs`), it becomes access to that resource, and to everything else the same power reaches. That's the integer-to-pointer cast again, done by the caller. Hand out the object bound to the resource, not its address:
|
||||||
|
|
||||||
|
- A test harness's `startToybox()` answered `{ server, port, appPort, sock }`, and each test joined those to its own `fetch` and `WebSocket`. Now it answers `{ http(path, init), app(path, init), admin(kernel), stop() }`, each bound to its own socket, so a helper can be handed just the app socket.
|
||||||
|
- A module-level `here` (the package's path) let any line read or write anywhere by joining onto it. Instead, hand a directory and the tree under it, as `openat(dirfd, path)` reaches it: `pkg.readText('test/boot/boot.js')`, relative paths only, no `..`. endo's `EndoMount` and `ReadableTree`, and workerd's disk service, have the same shape.
|
||||||
|
- Where something truly needs an address (workerd's `-d dir=<path>`), the bound object can answer one (`tree.path(rel)`), at the edge.
|
||||||
|
|
||||||
|
Bearer secrets (swiss numbers, webkeys) are designation and authority in one string, for crossing a boundary that can't carry a reference: a link, a page's JSON. Mint and deref them at that boundary, and let inner modules deal in references. A module that mints them holds a registry and entropy its task doesn't need.
|
||||||
|
|
||||||
|
## tests are the edge; their helpers aren't
|
||||||
|
|
||||||
|
A test may import Node's I/O, but set it up once, as a promise each test awaits, not at module level (ava's `test.before(t => { t.context = ... })` is the same idea):
|
||||||
|
|
||||||
|
```js
|
||||||
|
const worldP = (async () => {
|
||||||
|
const { startToybox } = makeToyboxes({ startWorkerd, freePort, mkdir, fetch, WebSocket });
|
||||||
|
const fs = { cp, mkdir, readFile, rm, writeFile };
|
||||||
|
return {
|
||||||
|
startToybox,
|
||||||
|
net: { createHttpServer, listenLocal },
|
||||||
|
pkg: makeTree(fs, fileURLToPath(new URL('..', import.meta.url))),
|
||||||
|
makeDir: async prefix => makeTree(fs, await mkdtemp(join(tmpdir(), prefix))),
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
test('...', async () => {
|
||||||
|
const { startToybox, pkg, makeDir } = await worldP;
|
||||||
|
// ...
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
- Each helper takes its powers as its first parameter, and only those it uses: `copyExamples({ pkg }, dir)`, not `copyExamples(world, dir)`.
|
||||||
|
- Group powers that are equivalent in authority anyway, and pass the group whole: with a server and a local listener, `net` reaches the network as `fetch` would.
|
||||||
|
- Destructure the world on one line. When a whole group fits better than its members, take the group and pick at the call: `makeClient({ fetch: net.fetch }, url)`.
|
||||||
|
- Spawning a shell script to copy a few files (`execFile('wallet-boot.sh')`) is the biggest hammer for the smallest job. If the copy is configuration, make it data, or point a read-only root at the files where they are.
|
||||||
|
|
||||||
## Python: DisciplinedPython
|
## Python: DisciplinedPython
|
||||||
|
|
||||||
For Python, the rules above are spelled out in the DisciplinedPython style
|
For Python, the rules above are spelled out in the DisciplinedPython style
|
||||||
@@ -53,12 +90,19 @@ before writing or refactoring a Python script; don't invent conventions.
|
|||||||
guard, authorities passed by name), standard authority names (`argv`,
|
guard, authorities passed by name), standard authority names (`argv`,
|
||||||
`cwd`, `stdout`, `connect`, `run`, `urlopen`, `now`), prompt attenuation
|
`cwd`, `stdout`, `connect`, `run`, `urlopen`, `now`), prompt attenuation
|
||||||
in `main`, and **status goes through `logging.info(...)` directly**: not
|
in `main`, and **status goes through `logging.info(...)` directly**: not
|
||||||
`print`, not `stderr` writes, not an injected logger.
|
`print`, not `stderr` writes, not an injected logger. Logging is an
|
||||||
|
operational side effect, not output: tests check `stdout` and return
|
||||||
|
values, never log records, since correctness doesn't depend on logging.
|
||||||
- [disciplined-python-attenuation.md](https://codeberg.org/dckc/awesome-ocap/src/branch/master/style-guide/disciplined-python-attenuation.md):
|
- [disciplined-python-attenuation.md](https://codeberg.org/dckc/awesome-ocap/src/branch/master/style-guide/disciplined-python-attenuation.md):
|
||||||
narrowing authority function by function.
|
narrowing authority function by function.
|
||||||
- Checker: run `~/projects/awesome-ocap/tools/disciplined_python_check.py path/to/script.py`
|
- 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
|
and treat each finding as a bug. It points at matching before/after
|
||||||
examples in `tests/fixtures/disciplined_python/{errors,fixed}/`.
|
examples in `tests/fixtures/disciplined_python/{errors,fixed}/`.
|
||||||
|
Known checker bug: it flags `sqlite3.connect(':memory:')` as DPY010,
|
||||||
|
but an in-memory database is private to the process, not I/O; leave
|
||||||
|
that call in place.
|
||||||
|
- Beyond the checker: passing it is the floor. A script that grows
|
||||||
|
past one job needs the shape below too; see the next section.
|
||||||
- Calibration: Python can't enforce a capability boundary (name mangling
|
- Calibration: Python can't enforce a capability boundary (name mangling
|
||||||
and introspection get around any wrapper), so for a small script,
|
and introspection get around any wrapper), so for a small script,
|
||||||
attenuation that lives mostly in names is fine. An example: a read-only
|
attenuation that lives mostly in names is fine. An example: a read-only
|
||||||
@@ -66,6 +110,45 @@ before writing or refactoring a Python script; don't invent conventions.
|
|||||||
note the gap honestly and move on. Robustness against adversaries
|
note the gap honestly and move on. Robustness against adversaries
|
||||||
means leaving Python (e.g. for Hardened JavaScript).
|
means leaving Python (e.g. for Hardened JavaScript).
|
||||||
|
|
||||||
|
## Python: each part an object, its constructor its authority list
|
||||||
|
|
||||||
|
A script that passes the checker can still hold every power in one
|
||||||
|
`main` full of nested functions. Factor it so each part's constructor
|
||||||
|
says what it can touch, and a reviewer needn't read its body:
|
||||||
|
|
||||||
|
- **`_script_io()` only snapshots.** Pass standard authorities as they
|
||||||
|
are: `gpiod.request_lines`, `socket.socket`,
|
||||||
|
`asyncio.create_subprocess_exec`, `dict(os.environ)`. No bespoke
|
||||||
|
wrappers (`socket_from_fd`, a `urlopen` that builds the request), and
|
||||||
|
nothing that can fail: `socket.socket(fileno=3)`, or deciding from
|
||||||
|
`LISTEN_FDS`, happens in `main`.
|
||||||
|
- **`main` only wires.** Nested functions closing over powers are
|
||||||
|
objects waiting to be named: give each a class, in a module of its
|
||||||
|
own, constructed with just the powers it uses:
|
||||||
|
`HatLines(request_lines, chip)`, `Brain(ask_client, button)`.
|
||||||
|
- **A class, not a function returning functions.**
|
||||||
|
`open_lines(...) -> (fd, read_edges, set_led)` is an object with its
|
||||||
|
methods scattered; make it a class with `fileno()`, `read_edges()`,
|
||||||
|
`set_led()`.
|
||||||
|
- **Powers in `__` attributes:** `self.__client`, not `self._client`.
|
||||||
|
Name mangling enforces nothing (see Calibration), but it marks which
|
||||||
|
attributes are authority, and keeps neighbors from reaching in by habit.
|
||||||
|
- **Bind designation to authority once.** A `Command(exec, program,
|
||||||
|
*leading_args)` runs one program with its URL fixed, so the part that
|
||||||
|
holds it can't point it elsewhere; `poster(open_connection, url)`
|
||||||
|
reaches one HTTP server.
|
||||||
|
- **An event loop, not threads.** asyncio: no locks, no shared state
|
||||||
|
polled from threads, and a race written as one:
|
||||||
|
`asyncio.wait({work, press}, return_when=FIRST_COMPLETED)`.
|
||||||
|
Subprocesses through `create_subprocess_exec`, sockets through
|
||||||
|
`start_unix_server` and `open_connection`, a device's fd through
|
||||||
|
`loop.add_reader`.
|
||||||
|
- **Top-level imports bring data, not powers.** `from asyncio.subprocess
|
||||||
|
import PIPE`, or a library's data types (`gpiod.LineSettings`), are
|
||||||
|
fine at the top; the powers come in through `main`. Importing a module
|
||||||
|
that holds powers isn't fatal while they go unused, but importing just
|
||||||
|
the names used is cleaner.
|
||||||
|
|
||||||
## 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 →
|
||||||
@@ -79,6 +162,9 @@ before writing or refactoring a Python script; don't invent conventions.
|
|||||||
helpers become untestable without monkey-patching; inject a
|
helpers become untestable without monkey-patching; inject a
|
||||||
narrower interface (the caller passes the one URL's worth of fetch,
|
narrower interface (the caller passes the one URL's worth of fetch,
|
||||||
not the whole world).
|
not the whole world).
|
||||||
|
- A helper taking `(port, fetch)` or `(path, fs)` → designation split
|
||||||
|
from authority: the helper can reach any port, any path. Hand it the
|
||||||
|
bound object (see above).
|
||||||
- A module's default export closing over bindings/config → a
|
- A module's default export closing over bindings/config → a
|
||||||
powerful object export. Split: pure logic (argument-only) + a thin
|
powerful object export. Split: pure logic (argument-only) + a thin
|
||||||
program-script-ish edge that wires authority in.
|
program-script-ish edge that wires authority in.
|
||||||
|
|||||||
@@ -19,12 +19,15 @@ When you rewrite a wrapped paragraph, unwrap it. Don't unwrap a whole file you a
|
|||||||
|
|
||||||
- Standard markdown links with relative paths: `[the webkeys pattern](docs/webkeys.md)`. Obsidian follows them, and GitHub renders them. `[[wikilinks]]` render only in Obsidian.
|
- Standard markdown links with relative paths: `[the webkeys pattern](docs/webkeys.md)`. Obsidian follows them, and GitHub renders them. `[[wikilinks]]` render only in Obsidian.
|
||||||
- No spaces in file names, so links need no `%20`.
|
- No spaces in file names, so links need no `%20`.
|
||||||
|
- Links to a heading, as in a TOC: Obsidian matches the fragment against the heading text, not GitHub's slug, so `#the-coffee-table-box` finds nothing. Write the heading text with spaces as `%20`: `[The coffee-table box](#The%20coffee-table%20box)`. Keep colons, `#`, `|`, `^`, and brackets out of headings you link to. GitHub won't follow these links; Obsidian is the reader that counts.
|
||||||
- Link text says where the link goes (see hypertext-links).
|
- Link text says where the link goes (see hypertext-links).
|
||||||
|
|
||||||
## File names and headings
|
## File names and headings
|
||||||
|
|
||||||
Obsidian shows file names in tabs, the file explorer, and search, so name files for what's in them.
|
Obsidian shows file names in tabs, the file explorer, and search, so name files for what's in them.
|
||||||
|
|
||||||
|
Avoid `README.md` for notes in a vault: a folder of them shows as a row of tabs all named "README". Name the file for its folder's subject (`gadget-tub/gadget-tub.md`). A repo's top-level README is the exception; GitHub needs it.
|
||||||
|
|
||||||
Headings show in Obsidian's outline pane: make them say something.
|
Headings show in Obsidian's outline pane: make them say something.
|
||||||
|
|
||||||
## Frontmatter
|
## Frontmatter
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
---
|
||||||
|
name: py-doctest
|
||||||
|
description: >-
|
||||||
|
Python doctests document the API and test it at once. Use when writing, refactoring, or fixing a Python module, script, or tool and deciding where its tests go; when about to write or add to a test_*.py, unittest, or pytest file. Not for whether a test is owed at all (that's lazy-tdd).
|
||||||
|
---
|
||||||
|
|
||||||
|
# Doctests in the module
|
||||||
|
|
||||||
|
Docs and tests both make code better, but docs go stale, and a test is often the clearest statement of what code does. A doctest is both: an example a reader sees next to the code, checked on every run. So **put Python tests in the module as doctests, on the API they test, with setup in small private helpers.**
|
||||||
|
|
||||||
|
As in [docs-files-api](../docs-files-api/SKILL.md), the API's docstrings carry the weight, and the module docstring stays brief and points to them. A script is the exception: people open it to learn how to run it, so its module docstring is the manual, and a doctest there runs `main(...)` with fakes. That's cheap when `main(...)` takes its authority as arguments ([no-ambient-authority](../no-ambient-authority/SKILL.md)). The example is a script, so it has both.
|
||||||
|
|
||||||
|
```python
|
||||||
|
"""Match bank rows to orders.
|
||||||
|
|
||||||
|
Usage, documented and tested together:
|
||||||
|
|
||||||
|
>>> usage = 'match_orders book.db'
|
||||||
|
>>> io = _MockIO()
|
||||||
|
>>> main(usage.split(), io.stdout, io.connect)
|
||||||
|
>>> print(io.stdout.getvalue(), end='')
|
||||||
|
1 matched; unmatched: ['A-17']
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def unmatched(conn):
|
||||||
|
"""Order ids with no bank row of the same amount.
|
||||||
|
|
||||||
|
>>> _shown(unmatched(_MockIO().connect('book.db')))
|
||||||
|
['A-17']
|
||||||
|
"""
|
||||||
|
return {oid for (oid,) in conn.execute(
|
||||||
|
"select id from orders where amount not in (select amount from bank)")}
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv, stdout, connect):
|
||||||
|
[_, db] = argv
|
||||||
|
conn = connect(db)
|
||||||
|
left = unmatched(conn)
|
||||||
|
[(n,)] = conn.execute("select count(*) from orders")
|
||||||
|
print(f"{n - len(left)} matched; unmatched: {_shown(left)}", file=stdout)
|
||||||
|
|
||||||
|
|
||||||
|
class _MockIO:
|
||||||
|
def __init__(self):
|
||||||
|
from io import StringIO
|
||||||
|
self.stdout = StringIO()
|
||||||
|
|
||||||
|
def connect(self, _db):
|
||||||
|
import sqlite3
|
||||||
|
conn = sqlite3.connect(':memory:') # in-process: not I/O
|
||||||
|
conn.executescript("""
|
||||||
|
create table orders (id text, amount int);
|
||||||
|
create table bank (id int, amount int);
|
||||||
|
insert into orders values ('A-16', 1200), ('A-17', 350);
|
||||||
|
insert into bank values (1, 1200);
|
||||||
|
""")
|
||||||
|
return conn
|
||||||
|
|
||||||
|
|
||||||
|
def _shown(x):
|
||||||
|
"""Sorted, so output doesn't depend on string hashing."""
|
||||||
|
return sorted(x.items()) if isinstance(x, dict) else sorted(x)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
def _script_io():
|
||||||
|
import sqlite3
|
||||||
|
import sys
|
||||||
|
main(sys.argv, sys.stdout, sqlite3.connect)
|
||||||
|
|
||||||
|
_script_io()
|
||||||
|
```
|
||||||
|
|
||||||
|
Run with `python3 -m doctest tool.py` (add `-v` to see each example). Silence means pass.
|
||||||
|
|
||||||
|
- Ignore neighboring `test_*.py` files as a style cue: one may be an accident that stuck, and each copy makes the next look more like a precedent. Don't add to them or start a new one. When refactoring a module that has one, moving its tests into doctests is fair game, in a commit of its own.
|
||||||
|
- When a test needs more than a helper can hide (a fixture tree on disk, a subprocess, minutes of runtime), say so and ask before reaching for a test file.
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- [No more undocumented, untested code](https://www.madmode.com/2006/advogato_entry0044.html): Dan Connolly, MadMode, 2006-03-18. "If the code is worth writing, it's worth testing and documenting."
|
||||||
|
- [Practical production python scripts](https://www.madmode.com/2019/python-eng.html): Dan Connolly, MadMode, 2019-07-22. Factoring logic out of `main()` with a doctest on `fizzbuzz()`, then a module doctest of usage with `StringIO` for `stdout`.
|
||||||
|
- [doctest](https://docs.python.org/3/library/doctest.html): in the stdlib since Python 2.1 (2001); option flags such as `ELLIPSIS` and `NORMALIZE_WHITESPACE`.
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
---
|
||||||
|
name: rholo-node-cloudflare
|
||||||
|
description: >-
|
||||||
|
A rholo testnet node on Cloudflare — use when asked to run, deploy, or host a rholo (RChain in Rust) node, observer, or validator on Cloudflare Workers or Containers; when an agent must ask its host for the rights to do so, by `define` or by hand. Covers what fits (an observer, as an experiment), what doesn't (a validator), and the rights to ask for. Not for running a node on a VPS: follow rholo's own setup guide.
|
||||||
|
---
|
||||||
|
|
||||||
|
# A rholo testnet node on Cloudflare
|
||||||
|
|
||||||
|
Read rholo's [Running a node](https://github.com/rhovision-org/rholo/blob/dev/docs/src/node/validator-observer-setup.md) and [the public testnet](https://github.com/rhovision-org/rholo/blob/dev/docs/src/node/testnet.md) first; they are the authority on flags, ports and genesis. This skill says how they meet Cloudflare.
|
||||||
|
|
||||||
|
## An observer fits; a validator doesn't
|
||||||
|
|
||||||
|
A node needs inbound 40400 (protocol) and 40404 (discovery) **from every peer**; one that admits inbound only from its bootstrap sits at height 0 ([setup guide §3](https://github.com/rhovision-org/rholo/blob/dev/docs/src/node/validator-observer-setup.md#3-network-and-firewall--accept-inbound-from-every-peer)). A [Container](https://developers.cloudflare.com/containers/) gets no inbound TCP from the Internet: requests reach it only through its Durable Object, by `ctx.container.getTcpPort(port).fetch()`. And a Container's disk is ephemeral and at most 20 GB, against rholo's minimum of 100–250 GB NVMe.
|
||||||
|
|
||||||
|
So:
|
||||||
|
|
||||||
|
- **Validator: no.** It must take inbound from every peer and stay up; an absent one holds finality back.
|
||||||
|
- **Observer: an experiment.** rholo's fallback for a host that can't take inbound is to seed its data directory from a synced node, minus `node.key.pem` and `node.certificate.pem`. Whether an outbound-only observer then *follows the tip* is unmeasured; measure it before calling it running.
|
||||||
|
- **Read-only watcher: yes.** A Worker that polls nodes' HTTP APIs (`/api/status`, `/api/last-finalized-block`), in the manner of [rho-observer](https://github.com/rhovision-org/rho-observer), needs no Container at all.
|
||||||
|
|
||||||
|
## The observer's shape
|
||||||
|
|
||||||
|
- A Worker with one Durable Object class that owns a Container (`scheduling_policy: "durable_object"`), its image built from rholo's `docker/rnode/Dockerfile`, with `--build-arg GIT_HEAD_COMMIT` so `/version` names the commit.
|
||||||
|
- Instance: custom, up to 4 vCPU, 12 GiB, 20 GB disk; rholo's testnet minimum is 2–4 vCPU and 8 GB RAM.
|
||||||
|
- Start the node as an observer: no `--validator-private-key-path`, `--no-upnp`, the testnet's `--bootstrap` and genesis inputs, `--host` naming nothing peers can dial (there is none).
|
||||||
|
- **Seed on every start.** Keep a seed tarball of a synced data directory in R2, or a [container snapshot](https://developers.cloudflare.com/containers/guides/snapshots/); a host restart otherwise starts from nothing.
|
||||||
|
- **Keep it awake** with a Durable Object alarm that runs more often than `setInactivityTimeout()` (at most 6 hours).
|
||||||
|
- **Expose 40403 only**, the HTTP API, through the Worker's `fetch`. Never 40402 (propose/repl) or 40405 (admin).
|
||||||
|
- Billing is per provisioned memory and disk while it runs, so 8 GiB around the clock is the bulk of the cost; check [Containers pricing](https://developers.cloudflare.com/containers/platform/pricing/) before promising a number.
|
||||||
|
|
||||||
|
## Rights: ask for each one, narrowly
|
||||||
|
|
||||||
|
An agent starts with nothing but messaging to its host. With toybox's `define`, it sends one definition whose slots name exactly what it needs, and the host decides what to bind to each:
|
||||||
|
|
||||||
|
| slot | what it's for | narrowest binding |
|
||||||
|
|---|---|---|
|
||||||
|
| `deploy` | create and update one Worker, its Container and DO | deploy of one named script, not the account |
|
||||||
|
| `seed` | write and read the seed tarball | one R2 bucket, or one prefix |
|
||||||
|
| `seedFrom` | copy a synced node's data directory | read-only, excluding the node key and certificate |
|
||||||
|
| `logs` | see why a start failed | tail of that one Worker |
|
||||||
|
|
||||||
|
Ask for no faucet key, no validator key, and no admin port: an observer needs none. If more turns out to be needed, send another definition.
|
||||||
|
|
||||||
|
Until a Cloudflare device exists to bind those slots to, do the same by hand: prepare the Worker, Dockerfile and `wrangler.jsonc` in a branch, then send the host the commands to run and what each one needs, such as `wrangler deploy` (deploy) and `wrangler r2 object put` (seed). The host runs them with their own login. Don't ask for an account-wide API token to save the host a step.
|
||||||
|
|
||||||
|
Keep the host's account id, hostnames and tokens out of anything public.
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- [Running a node: testnet now, mainnet later](https://github.com/rhovision-org/rholo/blob/dev/docs/src/node/validator-observer-setup.md) — roles, ports, the inbound rule, seeding a node that can't take inbound.
|
||||||
|
- [Running a validator: hardware requirements](https://github.com/rhovision-org/rholo/blob/dev/docs/src/node/validator-requirements.md) — 2–4 vCPU, 8 GB RAM, 100–250 GB NVMe minimal.
|
||||||
|
- [Containers limits](https://developers.cloudflare.com/containers/platform/limits/) and [FAQ](https://developers.cloudflare.com/containers/faq/) — instance sizes; disk is ephemeral.
|
||||||
|
- [Workers TCP sockets](https://developers.cloudflare.com/workers/runtime-apis/tcp-sockets/) — inbound TCP from outside Cloudflare is "coming soon".
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
name: tab-dump-topics
|
||||||
|
description: Organize an office-hours tab dump into topics, in the order the pages came up, under headings that start with a timestamp. Use when asked to refine, sort, or organize a tab dump, or the opening post of an office hours discussion on GitHub (dckc/vattr97, Agoric/agoric-sdk, rchain-community) once notes, a transcript, or a recording are posted. Not for writing the meeting summary itself.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Tab dump by topic
|
||||||
|
|
||||||
|
A tab dump is the browser tabs from a meeting, pasted as markdown links in tab order. Tab order is not meeting order: tabs opened to prepare come first but get shown late, and a page shown twice appears once. The transcript says when each page came up.
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
1. Fetch the discussion: `gh api graphql` for the body and comments. The notes, often a later comment, link the transcript and recording wherever they live. A Google Drive share link downloads with `https://drive.google.com/uc?export=download&id=<id>`.
|
||||||
|
2. Match each tab to the moment it came up. Cues: the speaker names it ("Metagov", "the picture book slides", "issue 81"), reads its text aloud, or says "let me show you" / "scroll down" near its topic. Transcription garbles names ("Ladara" for Edera, "Rolo" for rholo, "Crescendo bot" for kriscendobot), so match on sound.
|
||||||
|
3. Where the transcript is silent, use tab order: tabs opened during the meeting are in the order opened, so a tab between two placed ones goes between them.
|
||||||
|
4. Group tabs into topics, few and broad: one per thread of conversation, not per sub-point. A tangent that serves the thread stays in it (the picture book's "keys, not driver's licenses" slide went with hosting on Edera). A thread mentioned early and taken up in depth later is one topic, at the later time. A topic with no tabs gets no heading.
|
||||||
|
5. Head each topic `### m:ss Title` (or `h:mm:ss`), the time the topic starts, not when its first tab appeared. The title states the point ("Edera, not Cloudflare"), not the subject ("Cloudflare").
|
||||||
|
6. Rename the `## Tab Dump` heading to `## Topics and Tabs`. Front matter goes under it, before the first topic: pages that frame the meeting rather than belong to a topic, such as the Discussions index.
|
||||||
|
7. End with `### Misc`, untimed: small talk (a health update), tools used along the way (the bookmark library searched to find a link), and pages that were open but not discussed.
|
||||||
|
8. Keep each link as pasted: the tab title is the link text. Add a few words after a link only where it doesn't explain itself (a `localhost` URL).
|
||||||
|
9. A page shown in two topics goes under both.
|
||||||
|
10. Replace a placeholder like `_notes, recording to appear_` with a link to the notes comment: `see [notes and recording below](#discussioncomment-NNN)`.
|
||||||
|
|
||||||
|
Draft into `.tmp/` at the workspace root and report placements that rest on tab order alone; editing the discussion is Dan's call.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
From [Dec 3 office hours](https://github.com/dckc/vattr97/discussions/90):
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
### 10:15 Fiscal sponsorship: Metagov is a 501(c)(3)
|
||||||
|
|
||||||
|
[Metagov](https://metagov.org/)
|
||||||
|
|
||||||
|
[Metagov Inc - Nonprofit Explorer - ProPublica](https://projects.propublica.org/nonprofits/organizations/853442527)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Office hours, and where tab dumps come from
|
||||||
|
|
||||||
|
Dan runs office hours as a series: open questions and discussion, mostly on object capabilities as patterns of cooperation without vulnerability. Each episode is a GitHub Discussion in an Office Hours category: Agoric/agoric-sdk (Wednesdays; episodes with recordings carry the `video-recording` label), dckc/vattr97 for Oros, and rchain-community. Every episode has at least a tab dump of the links discussed, copied with the TabCopy browser extension; notes and a recording usually follow. So the tab dump is the one record every episode has, and organizing it by topic makes it the index into the notes and recording.
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- [Office Hours: Patterns of Cooperation without Vulnerability](https://www.madmode.com/2023/office-hours.html) (MadMode, 2023-11-18): the series, and tab dumps via TabCopy.
|
||||||
|
- [Oct 1 office hours](https://github.com/dckc/vattr97/discussions/30): the tab dump with topic headings, before timestamps.
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
---
|
||||||
|
name: typed-remotes
|
||||||
|
description: >-
|
||||||
|
Typed references in Endo / toybox / Agoric JSDoc — use when writing or reviewing a vat's `Params` typedef, a `buildRootObject`, a store that holds references, or any `@param`/`@property`/`@type` that names another vat's object or a device; when about to write a bare `Remote`, `Remote[]`, `{any}`, or `@type {BuildRootObject<...>}`; when someone says "Params has a bunch of any", "it won't stay fixed", or "type the remotes". Not for whether a reference should be handed over at all (that's pola).
|
||||||
|
---
|
||||||
|
|
||||||
|
# Typed remotes
|
||||||
|
|
||||||
|
A bare `Remote` is `Remote<any>`. Every call through it, and everything
|
||||||
|
it answers, goes unchecked, so a wrong method name or a misread answer
|
||||||
|
gets through `tsc --checkJs` and fails at runtime, in another vat.
|
||||||
|
|
||||||
|
## The rule
|
||||||
|
|
||||||
|
- **Name what the reference is:** `Remote<X>`, never `Remote` or
|
||||||
|
`Remote[]`. `X` is:
|
||||||
|
- for another vat's root, that vat's own type, exported beside its
|
||||||
|
code: `/** @typedef {ReturnType<typeof buildRootObject>} Cache */`
|
||||||
|
- for a facet it hands out, the method's answer:
|
||||||
|
`ReturnType<Cache['viewer']>`
|
||||||
|
- for a device or a platform vat with no exported type, a small
|
||||||
|
interface naming the calls this code makes, in one `types.ts`
|
||||||
|
- **Declare `buildRootObject` with `@satisfies`, not `@type`:**
|
||||||
|
`/** @satisfies {BuildRootObject<Params>} */`. `@type` checks the
|
||||||
|
params but answers only `object`, so `ReturnType<typeof
|
||||||
|
buildRootObject>` is useless; `@satisfies` checks the same and keeps
|
||||||
|
what it infers.
|
||||||
|
- **One cast, where the type is truly lost, and it says why.** The
|
||||||
|
kernel answers only "some vat's root" for `createVat`. Look roots up
|
||||||
|
through one accessor typed by a role table:
|
||||||
|
|
||||||
|
```js
|
||||||
|
/** @typedef {{ cache: Cache, gateway: Gateway }} Roles */
|
||||||
|
/**
|
||||||
|
* it's the vat Roles names because ensure made it from that role's code
|
||||||
|
* @template {keyof Roles} R @param {R} role @returns {Remote<Roles[R]>}
|
||||||
|
*/
|
||||||
|
const rootOf = role => /** @type {Remote<Roles[R]>} */ (vats.get(role).root);
|
||||||
|
```
|
||||||
|
|
||||||
|
- **`unknown`, not `any`,** for what isn't checked yet, such as parsed
|
||||||
|
JSON: `{{ key?: unknown, at?: unknown }}`. Then narrow with a check.
|
||||||
|
- **Type the store's values too:** `MapStore<keyof State, State[keyof
|
||||||
|
State]>` with `put`/`got` generic over the key, not
|
||||||
|
`MapStore<string, any>`.
|
||||||
|
|
||||||
|
## Make it stay fixed
|
||||||
|
|
||||||
|
A fix to the code alone drifts back: the next agent copies the nearest
|
||||||
|
example, or a doc that blesses `Remote` as the place `any` is fine.
|
||||||
|
|
||||||
|
- Fix the **guidance** that licensed it (CONTRIBUTING, AGENTS.md), not
|
||||||
|
just the instances.
|
||||||
|
- Add a **lint rule** that rejects a bare `Remote` or `any` in JSDoc
|
||||||
|
types, on the files that are clean now, and widen its `files` as more
|
||||||
|
get typed. vattr97's `eslint-typed-refs.mjs` is one, with no
|
||||||
|
dependencies: it finds each type tag's balanced `{...}` in JSDoc
|
||||||
|
comments and flags `\bany\b` and `\bRemote\b(?!\s*<)`.
|
||||||
|
- After typing, **remove the test's `any`s**: they hid the same gaps
|
||||||
|
in the code under test (one, here, hid a store typed so that
|
||||||
|
`got('user')` was always `undefined`).
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
- [@agoric/internal types.ts](https://github.com/Agoric/agoric-sdk/blob/master/packages/internal/src/types.ts) — the `Remote` that toybox's follows, `any` by default.
|
||||||
|
- [TypeScript 4.9: the satisfies operator](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html#the-satisfies-operator) — checks a type without widening what's inferred; JSDoc `@satisfies` since 5.0.
|
||||||
@@ -80,6 +80,11 @@ it survives independently of the transcript.
|
|||||||
through them, or filter before quoting.
|
through them, or filter before quoting.
|
||||||
- Captures grow fast — tens of thousands of lines for a long session. Read
|
- Captures grow fast — tens of thousands of lines for a long session. Read
|
||||||
the tail by default, not the whole file.
|
the tail by default, not the whole file.
|
||||||
|
- The recorded shell's cwd can vanish under it. A git merge or checkout
|
||||||
|
that moves every file out of a directory deletes the directory and
|
||||||
|
recreates it. A shell `cd`'d there is left in the deleted one: the prompt
|
||||||
|
shows the path, but `ls` is empty. The fix is `cd "$PWD"`. Before
|
||||||
|
running such a merge in the operator's working tree, warn them.
|
||||||
- These are local working artifacts, not deliverables. Keep them out of
|
- These are local working artifacts, not deliverables. Keep them out of
|
||||||
version control unless a session is itself the thing worth preserving.
|
version control unless a session is itself the thing worth preserving.
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user