Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ macOS is supported on a best-effort basis, and CI coverage for it is highly
limited: no job runs there, so a macOS-only regression is not caught before
merge.

Read [AGENTS.md](../AGENTS.md) for change discipline and [WRITING.md](WRITING.md)
for prose and commit conventions.
Read [AGENTS.md](../AGENTS.md) for change discipline,
[REVIEW.md](../REVIEW.md) for architecture and review rules, and
[WRITING.md](WRITING.md) for prose and commit conventions.

## Setup

Expand Down Expand Up @@ -101,7 +102,25 @@ $ /usr/bin/time -p mise exec -- bundle exec scripts/check outer
```

The same runner accepts `integration`, `packaging` and `types` separately.
It fails when a requested suite has no tests. RBS validation checks the
It fails when a requested suite has no tests.

For bug fixes and behavioral changes, confirm test bite after the fix passes by
temporarily reverting production gem sources to `origin/master` (or
`<pre_fix_head>` when fixing a defect introduced earlier in the same pull
request) while keeping `test/` at `HEAD`, verifying the regression suite fails
(substitute `integration` when the new test requires a live daemon), and
restoring `HEAD`:

```console
$ git diff --name-only --diff-filter=A origin/master..HEAD \
-- gems | \
while IFS= read -r path; do rm -f -- "$path"; done && \
git restore --source=origin/master --worktree -- gems && \
! mise exec -- bundle exec scripts/check unit && \
git restore --source=HEAD --worktree -- gems
```

RBS validation checks the
shipped declarations. `scripts/types --check` checks public declaration
coverage, source links and behavioral mappings.
Installed consumers check the argument and return types of exercised calls;
Expand Down
26 changes: 26 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!--
Open or align on an issue before sending behavioral or API pull requests.
Read REVIEW.md and .github/CONTRIBUTING.md alongside:
- https://github.com/libtmux/.github/blob/HEAD/AI_POLICY.md
- https://github.com/libtmux/.github/blob/HEAD/WRITING.md
Use N/A where a prompt does not apply (docs-only, lockfile bump, pure refactor).
-->

Closes #

### 1. Owner and boundary

- Rule changed and gem or module that owns it:
- Sibling entry points checked (`sync`/`async`, CLI/API, single/`run_group`, or `N/A`):
- Why this belongs here (owner fix, boundary adapter, or single-PR ownership transfer):

### 2. Failure before the fix (`N/A` for docs, lockfile bumps, or pure refactors)

- Baseline (`<base>` commit, or `<pre_fix_head>` SHA if fixing a defect introduced in this PR):
- Failing input or command and observed failure before the fix:

### 3. Verification and tool disclosure

- Checks run (plus production-only revert check for behavioral fixes, and `tmux -V` tested, or `N/A`):
- Capability or workaround files updated (`capabilities.json`, `examples/manifest.json`, or `None`):
- Tool use:
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ requested work.

## Which policy applies

- Design, planning, and pull request review decisions: [REVIEW.md](REVIEW.md)
- Setup, testing, tmux isolation, and pull requests:
[.github/CONTRIBUTING.md](.github/CONTRIBUTING.md).
- Documentation, user-facing text, comments, and commit messages:
Expand Down
115 changes: 115 additions & 0 deletions REVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Code and architecture review

Posture: `experimental` (pre-1.0 Ruby gem suite for `tmux`; align observable
semantics, capability claims, error categories, and target resolution with the
libtmux ports documented at [libtmux.org](https://libtmux.org) while expressing
APIs in native Ruby objects, RBS signatures, YARD contracts, and `Async` fiber
scopes).

[Posture](https://github.com/libtmux/.github/blob/HEAD/CONTRIBUTING.md#posture)
defines `experimental`, `stable` and `private`.

Review the complete change against `<base>`, including untracked files. Report
all findings in one pass without editing files. Keep total Markdown links in
this file at `64` or fewer and do not add symbolic links. See
[WRITING.md](.github/WRITING.md) and
[AI_POLICY.md](https://github.com/libtmux/.github/blob/HEAD/AI_POLICY.md).

## 1. Layer ownership

| Layer | Paths | Owns | Must not own |
| --- | --- | --- | --- |
| Core snapshots, queries, and mutations (`libtmux`) | `gems/libtmux/lib/libtmux.rb`, `gems/libtmux/lib/libtmux/{server,snapshot,entity,selection,criteria,source_query,operations,group,options,option_catalog,capabilities,catalog,metadata,support,tmux_version,errors,version}.rb`, `gems/libtmux/schema/*.json`, `gems/libtmux/sig/*.rbs` | Immutable `Snapshot` graphs, `Selection` and `Criteria` filtering, atomic `group` and mutation operations, option/hook metadata, release capability gates, and RBS contracts | `Async` fiber scheduling, `tmuxp` YAML normalization, or MCP stdio JSON-RPC framing |
| Core process, owned server, and control transport (`libtmux`) | `gems/libtmux/lib/libtmux/{control,program,owned,endpoint,process,process_wait,socket_readiness,text_wait,terminal,native_guard,child}.rb`, `gems/libtmux/libexec/program_child.rb` | Private `Server.start` daemons, synchronous `-C` control-mode framing, `%begin`/`%end`/`%error` pairing, octal escape decoding, managed `Program` children, and pipe/process cleanup | Workspace CLI flags or MCP tool schemas |
| Fiber-concurrent adapter (`libtmux-async`) | `gems/libtmux-async/lib/libtmux/async.rb`, `gems/libtmux-async/lib/libtmux/async/{server,control,process,scope,version}.rb`, `gems/libtmux-async/sig/libtmux-async.rbs` | Fiber-scheduled `Async` server, control-stream, and child-pipe lifecycles built on `libtmux` contracts | Duplicating wire grammar or option catalogs owned by `gems/libtmux` |
| Workspace loader (`libtmux-workspace`) | `gems/libtmux-workspace/lib/libtmux/workspace.rb`, `gems/libtmux-workspace/lib/libtmux/workspace/{document,normalizer,plan,apply,cli,version}.rb`, `gems/libtmux-workspace/exe/libtmux-workspace`, `gems/libtmux-workspace/sig/libtmux-workspace.rbs` | Parsing and normalizing `tmuxp` YAML/JSON documents into plans and applying them through the `libtmux` public API | Spawning raw `tmux` subprocesses or reaching into private `libtmux` internals |
| MCP server (`libtmux-mcp`) | `gems/libtmux-mcp/lib/libtmux/mcp.rb`, `gems/libtmux-mcp/lib/libtmux/mcp/{application,catalog,catalog_tool,cli,enrollment,mutations,observation,process_identity,resources,stdio_transport,version}.rb`, `gems/libtmux-mcp/exe/libtmux-mcp`, `gems/libtmux-mcp/sig/*.rbs` | Host-authorized MCP tools, resources, shell enrollment, and stdio transport delegating to `libtmux` | Re-implementing `Snapshot` parsing or control-mode framing |
| Tests, examples, and scripts | `test/{unit,integration,packaging,old_daemon,support}/`, `examples/`, `scripts/` | Sandboxed `lt-rb-` Minitest suites, installed-gem consumer checks, executable README/guide examples, and Standard-linted Ruby scripts | Touching the default `tmux` server or shipping Python comparison oracles |

### Changing the map

Do not `BLOCK` against `<base>:REVIEW.md`'s prior owner row when a pull request
migrates an invariant cleanly to a single owner, updates callers, tests, RBS
signatures, and `REVIEW.md` in the same diff, and states the old and new owner
in the pull request description. Before blocking on placement, state the
strongest case that the change is a valid boundary adapter or ownership
transfer and explain why that case fails.

### Rejected here

- **Untyped hash bags, missing RBS/YARD coverage, or stale Python rules**:
Express the contracts the ports share, documented at
[libtmux.org](https://libtmux.org), with immutable Ruby value objects,
complete `gems/*/sig/*.rbs` signatures (`rbs validate` and
`scripts/types --check`), warning-free YARD Markdown docstrings
(`scripts/docs/docs`), and `LibTmux::Error` subclasses. Keep
`## Python typing` instructions out of repository guides.
- **Swallowed exceptions, leaked descriptors, or RuboCop/Standard disables**:
Block bare `rescue => e` blocks that drop errors, unclosed pipes after failed
spawns in `libtmux` or `libtmux-async`, `untyped` RBS shortcuts where concrete
types exist, and inline lint suppressions added to dodge root causes.
- **Fixed `sleep` polling or unsandboxed `tmux` execution**: Require
`test/support/sandbox.rb` (`lt-rb-` / `libtmux-ruby-` sockets with `-S` or
`-L` and `-f /dev/null`, clearing `TMUX`, `TMUX_PANE`, and
`LIBTMUX_SOCKET*`), wait on socket readiness, control events, or bounded
process exit checks instead of sleeping, and verify no socket survives
teardown.
- **Unverified capability claims**: Root `README.md`, `gems/*/README.md`, YARD
comments, `examples/manifest.json`, and
[capabilities.json](capabilities.json) must claim only features implemented
and verified by tests in this repository.
- **Lower-layer format leaks**: `gems/libtmux` must not parse `tmuxp` workspace
files, inspect MCP protocol envelopes, branch on Minitest environment
variables, or carry test-only attributes on public entities.

## 2. Interoperability and runtime checks

1. **Rule, owner, and siblings**: Derive the invariant from `<base>` before
trusting the diff's framing. Trace to the first gem and class where the rule
breaks and check sibling entry points (`LibTmux::Server` vs
`LibTmux::Async::Server`, single operations vs `run_group`, `Server.start`
vs attached endpoints, and `libtmux-workspace` / `libtmux-mcp` CLI flags).
2. **Control-mode and subprocess lifecycle**: Check split-frame reads, octal
escape decoding, `%begin`/`%end`/`%error` pairing, pipe cleanup when child
spawn or control handshake fails, and partial multi-step failure reporting
(what `tmux` mutations already ran before failure and what error state
reaches the caller).
3. **Clean-room specification discipline**: Derive wire, control-mode, and
workspace parsers from `tmux(1)` documentation, black-box `tmux -C` runs,
and permissive (`MIT`, `ISC`, `BSD`, `Apache-2.0`) workspace specifications
without invoking Python `libtmux` or `tmuxp`.

## 3. Regression baseline and decision

- **Baseline selection (for bug fixes and behavioral changes)**: Reproduce the
failure on `<base>` before the fix. When a follow-up commit fixes a defect
introduced earlier in the same open pull request that did not exist on
`<base>`, cite `<pre_fix_head>` and prove the regression test fails there.
- **Test bite and real owners**: Exercise the real owning gem rather than
stubbing it out. Confirm that reverting production changes under `gems/`
while keeping `test/` at `HEAD` makes the regression test fail for the
expected reason.
- **Decision**: Emit `BLOCK` or `NO FINDINGS` (plus optional non-blocking
`NOTE` items). Every `BLOCK` must cite the file and invariant or failing
input, and state a concrete test, command, or code observation that would
prove the finding wrong.

## 4. Verdict

These rules decide which findings block.

- **Base run**: A finding that code misbehaves shows its check run on `<base>`
and on the change, with one line of output from each.
- **Existing and separate**: Behavior `<base>` already has does not block.
Report it as a `NOTE`, unless the change adds a promise the behavior breaks;
then the broken promise is the finding.
- **Unverified**: A gate nobody ran is unverified. Name the command that would
run it. It holds the merge until someone runs it, and it does not make the
verdict `BLOCK`.
- **Behavior defects**: A behavior defect blocks when a caller can reach it in
a supported environment, or when it breaks a promise in the pull request
description, a docstring, help text or the changelog. Otherwise it is a
`NOTE`.
- **Checks and claims**: A weakened check, a rule written in a second place and
a behavior claimed as tested with no test that bites block whether or not a
caller reaches them.
2 changes: 1 addition & 1 deletion scripts/docs/docs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DocumentationSite
manifest = ExampleManifest.new(@root)
manifest.check
FileUtils.mkdir_p(directory)
files = manifest.data.fetch("documents") + %w[AGENTS.md .github/CONTRIBUTING.md .github/WRITING.md .github/SCRIPTS.md]
files = manifest.data.fetch("documents") + %w[AGENTS.md REVIEW.md .github/CONTRIBUTING.md .github/WRITING.md .github/SCRIPTS.md]
files.each do |file|
source = File.read(File.join(@root, file))
body = YARD::Templates::Helpers::Markup::HybridMarkdown.new(source).to_html
Expand Down