Repository navigation
examples: send-first, sign and submit a thread's first message - #15
Merged
Merged
Conversation
go/examples/send-first signs one direct msg (SPEC.md §7.2, no re) with a key read from a file (one line, base64url of a 32-byte seed; never argv or env), runs the signed token through the §4 pipeline, submits it to <hub>/v1/submit and prints the m_ id. Client-side checks: to is one c_ id or 1-32 unique k_ ids, body 1-32768 bytes (lowerable with --max-body), subject 1-200 bytes when present, valid UTF-8. Exit 0 only on a 2xx that carries this message's id; 1 on any refusal, redirect or network error; 2 on input errors, which send nothing. Tests: unit tests in the root module (payload fields, signature verifies, limits at and past each boundary, refusals) and an end-to-end test in go/hub that builds the program and runs it against an in-process hub (accepted into the recipient's requests queue; E_STALE from a skewed hub exits 1). A 17-mutant battery (sign with the wrong key, no domain separator with the program's own Verify gate off, status check off, limits off by one, bytes vs runes, ts truncated) was killed 17/17. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ZacxDev
added a commit
to ZacxDev/muster
that referenced
this pull request
Nov 3, 2026
Replace the embedded hand-signed Go program in section 3 step 5 with a link to the tested go/examples/send-first program in the ClankMail repo (ZacxDev/clankmail#15) and its go run command. The side that starts the conversation sends the first message with it; the other side replies through its plugin. --max-body 16384 covers muster's 16 KiB chief-body limit, so the separate limit sentence is dropped. Drop the stale "v0.134.0 and earlier do not contain it" release sentence and keep only the `version` probe. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner
Author
|
Audit round 0 (requirements & deletion pass) at Ledger: round 0 · requirements: 11 (unattributed: 0, UNATTRIBUTED-UNKNOWN: 8) · deletion candidates: 2 |
The program copied the msg rules from go/clankmail/schema.go (recipient shape and count, body and subject lengths, ts sign). The post-sign clankmail.Verify already enforces them, exits 2 and sends nothing, so the copies go. Kept: the UTF-8 check (Go's json encoder would silently replace invalid UTF-8) and --max-body, now a caller-chosen stricter limit (0, the default, applies only the spec's). Tests: schema-invalid input (33 keys, duplicate key, channel plus key, a handle, empty, 32769-byte and 32770-byte bodies, 201-byte subject) is refused with exit 2, Verify's error on stderr, and zero requests to the fake hub. The hub test is trimmed to the seam: the message is accepted and the printed id names the stored signed message. The doc comment says @main, as the README does; @latest is v0.3.0. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner
Author
Owner
Author
|
Audit round 1 (full checklist) at |
…y file - The redirect case now redirects (307, 308, 302) with a Location naming a second hub that would accept the message, and asserts exit 1 and zero submissions at the target. Without CheckRedirect the 307 and 308 cases deliver the message and exit 0, so the test now fails. - A stray positional argument is no longer echoed: only its length is reported, since a key pasted on the command line most likely ends up there. The argv test asserts the value is absent from stderr. - A test pins the 64 KiB response cap: a 200 whose id comes after the cap exits 1. - The key file read is bounded to 128 bytes; a longer file is refused (exit 2) without repeating its contents. README: keep it mode 0600. - Package doc: exit 0 only when the hub answers 2xx with that message's id. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The flag package quotes the offending argument ("flag provided but not
defined: -<arg>", "invalid value \"<arg>\" for flag ..."), and a base64url
key pasted on the command line can start with '-'. Its output is now
discarded and only the kind of error is printed; -h still prints usage.
Tests cover a key pasted as an unknown flag and as a flag value; restoring
the echo fails both with the leaked value in stderr.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
v0.3.1 will be cut from this PR's merge commit, the first tag that includes the example, so the README and the doc comment pin it instead of following @main for a program that reads a private key. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ZacxDev
marked this pull request as ready for review
November 3, 2026 18:16
ZacxDev
added a commit
to ZacxDev/muster
that referenced
this pull request
Nov 3, 2026
ZacxDev/clankmail#15 merged and v0.3.1 is the first tag carrying the example: the link now points at tree/v0.3.1 and the go run is pinned to @v0.3.1 (verified to resolve through the module proxy and to parse the documented flags). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ZacxDev
added a commit
to ZacxDev/muster
that referenced
this pull request
Nov 3, 2026
* docs: onboarding a ClankMail peer (docs/clankmail.md) A step-by-step guide for pairing two operators' muster chiefs over ClankMail with the muster-clankmail plugin: the trust model, keys and the handle ceremony, the plugin token, running it beside muster (container, compose, Kubernetes notes), pinning peers, the first message, day-to-day approvals and key changes, and the error strings the plugin emits. There is no outbound-first path yet (the plugin only replies; compose drafts are not shipped), so the guide gives a small program that signs a first message with the chief key using the public ClankMail library. docs/plugins.md said a thread is bound by muster-clankmail's `send --bind <session>`; that command does not exist. It now says the plugin has no send command and the first sender binds the thread by hand. Verified locally against a throwaway hub (clankmail main 85b8d43) and the image built from this branch: keygen, identity claim/grant, show, /health, peer verify, requests, a stranger listed and not delivered, the hand-signed first message delivered as sender_verified on its own root, an approved reply reaching the other side on the same root, and the config/disabled-peer/E_AUTH strings in the troubleshooting table (muster was a stub answering the plugin routes, not a real server). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(clankmail): first message via ClankMail's send-first example Replace the embedded hand-signed Go program in section 3 step 5 with a link to the tested go/examples/send-first program in the ClankMail repo (ZacxDev/clankmail#15) and its go run command. The side that starts the conversation sends the first message with it; the other side replies through its plugin. --max-body 16384 covers muster's 16 KiB chief-body limit, so the separate limit sentence is dropped. Drop the stale "v0.134.0 and earlier do not contain it" release sentence and keep only the `version` probe. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(clankmail): placeholder hub, build-from-main, re-create on env change, RBAC caveat Round-1 audit fixes for docs/clankmail.md: - R1: replace the private hub domain (9 sites) with the placeholder hub.example in HUB_URL and HUB_NAME; say the real hub comes from the inviter and both chiefs must use the same hub. leakscan with the denied-identifier key active: 9 findings at b0f5e3b, 0 here. - Y2: no release (latest v0.135.0) carries the plugin or #409's thread routing; build server and plugin from main, and name what breaks on an older server. Compose: MUSTER_IMAGE/MUSTER_VERSION for the local image, and a full plugin service with image and healthcheck override. - Y3: after editing CLANKMAIL_PEERS, re-create the container (docker rm + run, compose up -d, or the Deployment env); docker restart keeps old env. - Y4: namespace isolation holds only with the least-privilege provisioner layout; the default ClusterRoleBinding also grants secrets get in every namespace, so the chief-key Secret is readable without exec. - Nit: "unmarked (verified)" -> "marked sender_verified: true". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(clankmail): round-2 audit fixes — RBAC isolation, verified mark, compose exec - R-A: a namespace of its own does not keep the chief key from muster in either provisioner layout. Default: muster's SA holds secrets and pods/exec everywhere. Least-privilege: it keeps cluster-wide rolebindings create + bind on muster-agent-namespace (and namespaces delete), so it can grant itself the plugin's Secret. Name what isolates it (another cluster, or the provisioner.md admission policy with the plugin outside the agent prefix and muster's namespace) and the consequence (a compromised muster-server can sign as @<owner>/chief). Same correction in configuration.md's admin-socket note. - Y-B: only UNVERIFIED senders are marked in a turn; sender_verified is a field on the stored message and the tools' JSON. - Y-C: compose exec form for the admin commands; publish 127.0.0.1:8080 on the compose service; kubectl exec form in pairing step 4. - Nits: MUSTER_VERSION=local also tags stt-cohere's image; a k8s rollout follows only for env in the pod template, not envFrom ConfigMaps. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs: round-3 audit nits — muster's own namespace, ConfigMap valueFrom configuration.md: the admin-socket remedy now also requires the plugin's namespace to be separate from muster's own, where deploy-key pools have muster read Secrets even under the least-privilege layout. clankmail.md: a rollout follows only for a literal env value; a ConfigMap read through envFrom or env[].valueFrom.configMapKeyRef needs a manual rollout restart. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(clankmail): point send-first at ClankMail v0.3.1 ZacxDev/clankmail#15 merged and v0.3.1 is the first tag carrying the example: the link now points at tree/v0.3.1 and the go run is pinned to @v0.3.1 (verified to resolve through the module proxy and to parse the documented flags). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
go/examples/send-first, a small tested program that signs one directmsgand submits it, so a client that only sends replies can have its first message sent from the other side. Spec sections touched: none (it uses §3, §4, §7.2 and §8POST /v1/submitas written).What it does
--key FILE: one line, base64url (no padding) of a 32-byte Ed25519 seed, decoded canonically, at most 128 bytes read (a longer file is refused without repeating its contents). Never from argv or the environment; a stray positional argument is refused, and only its length is reported, never its value.msgwithv,t,from,ts(Unix ms),to,body, optionalsubject, and nore. An empty subject is omitted. Before signing it checks only that subject and body are valid UTF-8, because Go's json encoder would silently replace invalid bytes.--max-body Nis an optional stricter body limit, in bytes, for a recipient whose client accepts less (for example 16384).clankmail.Signand runsclankmail.Verifyon the result. That gate is where the §7.2 field rules are enforced (recipient shape, count and uniqueness; body 1-32768 bytes; subject 1-200 bytes) along with the §4 98304-byte token limit. The program does not keep its own copy of these rules. A message Verify refuses exits 2 with Verify's error, and nothing is sent. Otherwise the token is posted astext/plain.m_id on stdout only when the hub answers 2xx with this message's id. Exit 1 on any non-2xx (error code and detail printed quoted to stderr), a redirect (not followed), a 2xx without the right id, or a network error. Exit 2 on input errors, which send nothing.README: a "Send a first message" section and a Layout row. The section is outside "Try it in 30 seconds", so
make readme-snippetsextracts the same blocks as before. The README and the package doc tell people to use@mainbecause thev0.3.0tag does not contain the example. They will pin a tagged release once one that includes it is cut.Tests
go/examples/send-first/main_test.go(root module, runs undermake conformance-go):the key file is longer than 128 bytes, nothing sent and nothing of the file on stderrE_SCHEMAerror and makes zero requests to the fake hub: 33 keys, a duplicate key, a channel plus a key, a handle, an empty body, 32769-byte and 32770-byte (multibyte) bodies, a 201-byte subject--max-bodyis counted in bytesLocationnaming a second fake hub that would accept the message exit 1, and that hub receives zero submissions200 OK without an m_ id); the same answer with the id under the cap exits 0SECRETSEED) is absent from stderrgo/hub/example_send_first_test.go(runs undermake hub-test): builds the program from this checkout and runs it against an in-process hub. It checks only the seam: the message is accepted, and the printed id fetches the stored signed message (same id, sender, body and subject). Queue placement and refusal paths are covered elsewhere.Mutation battery, last commit (one at a time, restored from a copy; the
main.gochecksum matched afterwards): 4/4 killed, each by its own assertion.CheckRedirectdeleted:307 to an accepting hub: exit 0 stdout "m_…\n" stderr ""; want exit 1, empty stdout, stderr containing "307 Temporary Redirect"andorigin received 1 submissions, target 1; want 1 and 0(the same for 308; the 302 case fails only on its stderr, since a followed 302 becomes a GET)key as argv: stderr "send-first: unexpected argument \"SECRETSEED\" (…)"; want "unexpected positional argument (10 bytes); the key is read from --key FILE, never from argv" and no trace of the argumentLimitReaderreplaced by the raw body:200 with 65536 bytes of padding before the id: exit 0 … want 1129-byte key file: exit 2 … stderr "send-first: not a ClankMail key file (…)"; want … stderr containing "the key file is longer than 128 bytes"(and the same for 1 MiB)Mutation battery, earlier commits (not re-run at this head): 8/8 killed.
hub received 1 requests, want 0andexit 1 ... want exit 2 ... stderr containing "the signed message does not verify: E_SCHEMA: ...". Thetoken too largeusage case fails too.invalid UTF-8 body: want error containing "valid UTF-8", got <nil>, and at the program levelinvalid UTF-8 body: exit 0 .../usage errors sent 1 submissionsinvalid UTF-8 subject: want error containing "valid UTF-8", got <nil>--max-bodyignored:body over a 16384 limit: exit 0 stderr "", want 2 and "body is 16386 bytes; --max-body is 16384"--max-bodycounted in characters: the same assertionGET the printed id "m_aaaa…": status 404status 404Gates run locally (Go 1.26.8)
make conformance-go: clankmail 166 and send-first 14 tests passed, 0 failedmake hub-test(-race): 83 passed, 0 failedmake hub-consumer-check: okmake readme-snippets: go, python, ts, read, read-sig and read-swap all okgo vetandgofmt -longo/examples/send-first: cleanmake conformance-python: 165/165make conformance-ts: 165 passedmake smoke-local: 10/10genvectorsoutput is byte-identical tovectors/vectors.json🤖 Generated with Claude Code