Skip to content

Examples: run quickstart on a supervisor-owned tmux server - #8

Open
tony wants to merge 5 commits into
masterfrom
tmux-arena
Open

tony wants to merge 5 commits into
masterfrom
tmux-arena

Conversation

@tony

@tony tony commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary


Added since this PR opened

Three commits. A fix first: tmux.NewServer returns an error and this branch discarded it, so a bad binary or socket path from the descriptor became a zero-value Server that failed later without naming the cause. Then the shared contract across the examples, and the documented Example functions running on a lent server — five that assert sole tenancy keep an owned server, each named with its reason. go vet clean, go test ./tmux/ ok.

Verified on the branch before pushing; gates listed in the commit messages.

@tony
tony force-pushed the tmux-arena branch 2 times, most recently from b0180a6 to 10954d3 Compare September 8, 2026 01:07
why: let the shared arena execute the quickstart without taking tmux
daemon ownership.

what:
- validate the descriptor contract before connecting.
- use the configured production endpoint and emit verified JSON evidence.
why: tmux.NewServer returns an error and this path discarded it, so a bad
binary or socket path from the arena descriptor became a zero-value Server
that failed later, somewhere else, without naming the cause.

what: propagate it, naming the step.
why: only the quickstart could run under the documentation arena, and it held
the whole contract inline. Every other example program could run against a
server it started and nothing else, so the site could prove one of them.

what:
- `examples/internal/exampletest` gains `ArenaServer`, `ResolveArenaServer`
  and `EmitEvidence`. Binding the artifact, the server and whether the arena
  is active into one value removes the risk the inline version carried, where
  the artifact id had to be written twice and could disagree with itself.
- Seven more example programs resolve their server through it, each with its
  own `go-<example>` artifact.
- `fast-path` stopped the server unconditionally. Under the arena that server
  is lent, and an example must never stop one it did not create: `run` now
  takes a server it is given and removes only the session it made, while
  standalone runs stop a server only when this process is the one that started
  it. Its session is named for the example rather than `work`, which the
  harness also uses.
- `workspace/example_test.go` is in another module and its `Example` functions
  own stdout for an exact `// Output:` match, so an evidence line cannot go
  there. A small local copy of the contract lives in `workspace/arena_test.go`
  instead, leaving the quoted examples byte-identical.
- The proof that dispatch really goes through the arena's tmux binary, and
  that evidence fails without a challenge, moves into one test in the shared
  package rather than being repeated per example.
why: the example programs can borrow the arena's server, and the library's own
documented `Example` functions could not. Each one started a server of its
own, so the site could prove the programs and nothing about the snippets a
reader actually meets in the API documentation.

what:
- `exampleServer` is the injection point: when the arena is active the
  Examples share the lent server, and when it is not they start their own
  exactly as before.
- `killExampleServer` refuses to stop a lent server, reports the refusal by
  name, and instead removes only the sessions created since the run began — so
  38 Examples can share one server without colliding on session names.
- `TestMain` prints one evidence record per documented source once the
  Examples have run. Evidence cannot go through an `Example`: `go test` diffs
  that output against `// Output:` verbatim, and an evidence line is dynamic.
- The record names the documented file rather than the function, because that
  is the unit the site quotes and the supervisor keys coverage by.
- `TestStopExampleServerRefusesToStopALentServer` covers both directions;
  removing the guard fails the lent case and leaves the owned one passing.

Ten Examples keep their own server: six never start a daemon at all, and one
embeds its socket name in a shell command it runs inside tmux.
The modernize linter is right: the hand-written loop says nothing the
standard library does not say more plainly, and the package already
imports slices.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant