From ad5f04065b45942dc6a0e2a38cf4e9dfd339cd76 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 5 Dec 2026 12:40:44 -0600 Subject: [PATCH 1/5] docs(agents): Replace Python typing with native Java type rules why: AGENTS.md carried a copy-pasted Python typing section referencing object, Any, and ty in a JDK 25 multi-module JVM repository. what: - Replace ## Python typing with ## Java typing and error handling. - Document JSpecify @NullMarked, NullAway/Error Prone, Java records and Optional, JPMS module boundaries, io.github.libtmux.exception types, and @SuppressWarnings discipline. --- AGENTS.md | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d57f555b4..e57b07598 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -38,19 +38,18 @@ being made: [GitHub security advisories](https://github.com/libtmux/libtmux-java/security/advisories/new) - Cutting a release: [`RELEASING.md`](RELEASING.md) -## Python typing - -Give callers the most precise signature that covers supported behavior. Use -`object` for a parameter only when every value is valid or when the function -accepts unknown input for validation. Narrow unknown values before using them. -Reserve `Any` for an inherently dynamic interface where Python cannot express -the input contract. Explain the reason there and keep unchecked values out of -the rest of the API. - -Before weakening a type, inspect real callers and try a precise alternative. -A union can describe known alternatives, a protocol can name the operations a -caller must provide, and a type parameter can preserve the relationship between -an input and its result. Try both a supported call and a plausible misuse with -ty. Check what downstream callers infer, whether the error is understandable, -and whether existing valid calls still work. Never widen a type, cast a value, -or suppress a diagnostic solely to make the checker pass. +## Java typing and error handling + +Express contracts on JDK 25 with JSpecify `@NullMarked` packages (enforced by +NullAway and Error Prone), Java records and sealed hierarchies, `Optional` +for absent lookup results, and `AutoCloseable` resource lifecycles +(`Server.start` with `try`-with-resources) while matching observable +`libtmux/central` tmux semantics across Java, Kotlin, Scala, and Clojure +bindings. Keep `io.github.libtmux.internal` unexported in `module-info.java` and +keep `libtmux` free of runtime dependencies. + +Surface tmux and validation failures through typed +`io.github.libtmux.exception` domain exceptions documented in `@throws`. Do not +swallow exceptions in empty `catch` blocks, widen typed contracts to `Object`, +or add `@SuppressWarnings` annotations solely to silence Error Prone, NullAway, +`javac`, Kotlin, Scala, or Clojure diagnostics instead of fixing the cause. From f086d9ec708b51a1cb5b4623d975f39bc2d8d165 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 5 Dec 2026 12:41:24 -0600 Subject: [PATCH 2/5] docs(policy): Add REVIEW.md and link from AGENTS.md why: Reviewers and agents need explicit JVM module ownership, control-mode and quarantine invariants, and regression baseline rules. what: - Add root REVIEW.md declaring experimental posture, ownership across libtmux*, build-logic/, integration-tests/, module-tests/, docs/, examples/, benchmarks/, tools/mcp-swap/, and scripts/, plus falsifiable BLOCK / NO FINDINGS criteria. - Route design, planning, and review decisions to REVIEW.md under ## Which policy applies in AGENTS.md. --- AGENTS.md | 3 ++- REVIEW.md | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 REVIEW.md diff --git a/AGENTS.md b/AGENTS.md index e57b07598..0b04a0b3c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,7 +20,7 @@ These hold for every change, whatever it touches: project's own servers are only safe to find and reap by their exact root. `.github/CONTRIBUTING.md` explains what goes wrong when they share. -## Additional guidance +## Which policy applies This file routes; it does not restate. Read the policy that governs the change being made: @@ -34,6 +34,7 @@ being made: are in [`.github/CONTRIBUTING.md`](.github/CONTRIBUTING.md#checking-the-scripts). - Contribution workflow, building, testing, and pull requests: [`.github/CONTRIBUTING.md`](.github/CONTRIBUTING.md) +- Design, planning, and pull request review decisions: [REVIEW.md](REVIEW.md) - Reporting a vulnerability: [GitHub security advisories](https://github.com/libtmux/libtmux-java/security/advisories/new) - Cutting a release: [`RELEASING.md`](RELEASING.md) diff --git a/REVIEW.md b/REVIEW.md new file mode 100644 index 000000000..3ab7d5f0f --- /dev/null +++ b/REVIEW.md @@ -0,0 +1,76 @@ +# Code and architecture review (`libtmux/libtmux-java`) + +Posture: `experimental` (pre-1.0 JDK 25 and multi-language JVM modules for +tmux; align observable semantics, target resolution, capability contracts, and +error taxonomy with `libtmux/central` while expressing APIs in native Java, +Kotlin, Scala, and Clojure idioms). + +Review the complete change against ``, including untracked files. Report +all findings in one pass without editing files. Follow +[writing rules](.github/WRITING.md), [MCP rules](libtmux-mcp/AGENTS.md), and +the organization +[AI policy](https://github.com/libtmux/.github/blob/HEAD/AI_POLICY.md). + +## 1. Layer ownership + +| Layer | Modules and paths | Owns | Must not own | +| --- | --- | --- | --- | +| Core JPMS module and BOM | `libtmux/`, `libtmux-bom/` | `io.github.libtmux` (`Server`, `Session`, `Window`, `Pane`, `batch`, `catalog`, `control`, `exception`, `format`, `query`, `snapshot`, `transport`), `@NullMarked` contracts, and aligned Maven BOM publications | Runtime dependencies, transitive `org.jspecify` / Error Prone module requirements, exported `io.github.libtmux.internal`, or CLI/MCP schemas | +| JVM language and codec modules | `libtmux-jackson/`, `libtmux-kotlin/`, `libtmux-scala/`, `libtmux-scala-cats/`, `libtmux-scala-ox/`, `libtmux-clojure/`, `libtmux-clojure-core-async/` | Jackson codecs and idiomatic Kotlin, Scala 3 (direct, Cats Effect, Ox), and Clojure (`core.async`) bindings delegating to `libtmux` | Duplicated tmux wire/control-mode parsing or raw `tmux` subprocess execution | +| Outer applications | `libtmux-workspace/`, `libtmux-workspace-cli/`, `libtmux-mcp/` | Declarative YAML session builder, workspace CLI, and detached-safe MCP server over `libtmux` | Raw `tmux` subprocess workarounds for missing `libtmux` APIs or modal interactive client UIs in `libtmux-mcp` | +| Quarantine, build-logic, and suites | `libtmux-junit5/`, `build-logic/`, `integration-tests/`, `module-tests/`, `docs/`, `examples/`, `benchmarks/`, `tools/mcp-swap/`, `scripts/` | `/tmp/libtmux-java-test/` (`tmux -L` / `-S` with `-f /dev/null`) `libtmux.tmux-quarantine` and `TmuxExtension` lifecycles, Doclet/codegen plugins, staged JPMS/BOM consumers, executed guide snippets, and CI/release checks | Touching ambient `TMUX` servers, bare `/tmp/libtmux-*` paths owned by sibling ports, or sockets past the 104-byte `sun_path` limit | + +### Changing the map + +Do not `BLOCK` against `:REVIEW.md`'s prior owner row when a pull request +migrates an invariant cleanly to a single owner, updates callers, +`libtmux-bom`, `MIGRATION.md` (when public APIs break), tests, and `REVIEW.md` +in the same diff, and states the old and new owner in the pull request +description. Weigh any boundary-adapter or ownership-transfer counter-case +before blocking on placement. + +### Rejected here + +- **Caller workarounds in `libtmux-mcp`, `libtmux-workspace*`, or language + wrappers**: extend `libtmux` first when downstream modules need a tmux + capability, and check sibling Java, Kotlin, Scala, and Clojure surfaces + where applicable. +- **Nullability, module-graph, or suppression shortcuts**: keep `@NullMarked` + (NullAway in JSpecify mode), Error Prone, `module-info.java`, and + `platformCoversEveryPublishedModule` clean without `@SuppressWarnings`, empty + `catch` blocks, or runtime dependencies in `libtmux`. +- **Control-mode and subprocess lifecycle hazards**: check split-frame reads, + octal escape decoding, `%begin`/`%end`/`%error` pairing, child process + reaping, and `Server.close()` / cancellation teardown. Reject fixed + `Thread.sleep` loops where `PaneWait` / `TextWait`, format queries, or `%end` + notifications provide deterministic readiness. +- **Unquarantined tmux servers or capability-claim drift**: live tests must run + under `libtmux.tmux-quarantine` or `TmuxExtension` inside + `/tmp/libtmux-java-test/` (`tmux -L` / `-S` with `-f /dev/null`, `TMUX` and + `LIBTMUX_SOCKET*` scrubbed) and pass `everyTestModuleIsQuarantined`. + `README.md`, module READMEs, and `capabilities.json` may claim only + implemented, tested features; reject Python-era instructions + (`## Python typing`). +- **Silent partial multi-step failure**: when a `CommandChain`, workspace + build, or batch MCP call spans multiple side effects, verify what state + persisted if step `N` fails and what `io.github.libtmux.exception` error + reaches callers before retry. + +## 2. Regression baseline and decision + +1. For bug fixes and behavioural changes, reproduce the failure on `` + against a real isolated tmux server (`integration-tests/` or quarantined + module test) rather than a mocked owner. When a follow-up commit fixes a + defect introduced earlier in the same open pull request that did not exist + on ``, cite `` and prove the regression test fails + there. +2. Verify that restoring modified non-test production sources and removing + newly added production sources makes the new test fail for the expected + reason, then restore production files and pass `./gradlew + :libtmux-mcp:test check`, `./gradlew :docs:test`, and `scripts/` (`ruff`, + `ty`, `pytest`). Track any temporary upstream workaround in + `.github/workarounds.toml` when introduced. +3. Emit `BLOCK` or `NO FINDINGS` (plus optional non-blocking `NOTE` items). + Every `BLOCK` must cite the file and broken rule or failing input, and state + a concrete test, command, or code observation that would prove the finding + wrong. From 2b58181181d1e5ec5b39d61e9d0170ec91c4ab26 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 5 Dec 2026 12:42:39 -0600 Subject: [PATCH 3/5] docs(contributing): Add test-bite check and pull request template why: Behavioral fixes need a repeatable production-only revert check and a structured pull request template covering JVM module ownership and tool disclosure. what: - Add .github/PULL_REQUEST_TEMPLATE.md linking AI_POLICY.md and WRITING.md with owner/boundary, failure-before-fix, and verification/tool sections. - Link REVIEW.md and add a production-only revert test-bite command in .github/CONTRIBUTING.md. --- .github/CONTRIBUTING.md | 37 ++++++++++++++++++++++++++++---- .github/PULL_REQUEST_TEMPLATE.md | 26 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8b9a8daf9..dd60c8899 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -6,7 +6,8 @@ pass before it is proposed. How this project writes prose — README, changelog, release notes, commit messages, API documentation, and source comments — is set out separately in -[`WRITING.md`](WRITING.md). Read that before changing any of it. +[`WRITING.md`](WRITING.md). Read that before changing any of it. For layer +ownership, boundaries, and review rules, read [`REVIEW.md`](../REVIEW.md). A Gradle directory is a published artifact exactly when it declares a Maven publication, and the Gradle build fails when that set stops matching @@ -339,7 +340,34 @@ What a change is expected to carry: that say why rather than what, no abstraction without a second caller. Commit format is in [`WRITING.md`](WRITING.md). The constraints every change is -held to, whatever it touches, are in [`AGENTS.md`](../AGENTS.md). +held to, whatever it touches, are in [`AGENTS.md`](../AGENTS.md) and +[`REVIEW.md`](../REVIEW.md). + +For bug fixes and behavioural changes (against `origin/master`, or +`` when fixing a defect introduced earlier in the same pull +request), temporarily restore modified `src/main/` sources and remove newly +added `src/main/` sources while keeping `src/test/`, `integration-tests/`, and +`libtmux-junit5/` intact: + +```console +$ mapfile -t mod_jvm < <( \ + git diff --name-only -M --diff-filter=MDR origin/master..HEAD \ + | rg '(^|/)src/main/.*\.(java|kt|scala|clj)$' \ + | rg -v '^libtmux-junit5/' \ + ) && \ + mapfile -t add_jvm < <( \ + git diff --name-only -M --diff-filter=A origin/master..HEAD \ + | rg '(^|/)src/main/.*\.(java|kt|scala|clj)$' \ + | rg -v '^libtmux-junit5/' \ + ) && \ + test $(( ${#mod_jvm[@]} + ${#add_jvm[@]} )) -gt 0 && \ + { [ "${#mod_jvm[@]}" -eq 0 ] || \ + git restore --source=origin/master --worktree -- "${mod_jvm[@]}"; } && \ + { [ "${#add_jvm[@]}" -eq 0 ] || rm -f -- "${add_jvm[@]}"; } && \ + ! ./gradlew test :integration-tests:test && \ + git restore --source=HEAD --worktree -- "${mod_jvm[@]}" "${add_jvm[@]}" && \ + ./gradlew test :integration-tests:test +``` ## Review @@ -351,8 +379,9 @@ Nothing here is automated beyond the checks on the pull request, and there is no approval quorum — this is a small project and says so rather than describing a process it does not run. -Disagreement about a rule is resolved by changing the rule in this file or in -[`WRITING.md`](WRITING.md), not by making an exception in review. +Disagreement about a rule is resolved by changing the rule in this file, +[`REVIEW.md`](../REVIEW.md), or [`WRITING.md`](WRITING.md), not by making an +exception in review. ## Releases diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..e6f9ad00a --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,26 @@ + + +Closes # + +### 1. Owner and boundary + +- Rule changed and module/package that owns it: +- Sibling entry points checked (Java/Kotlin/Scala/Clojure, `CommandChain`/control, `libtmux-mcp`/`libtmux-workspace`, 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 (`` commit, or `` SHA if fixing a defect introduced in this PR): +- Failing input / command and observed failure before the fix: + +### 3. Verification and tool disclosure + +- Gates run (plus production-only revert check for behavioral fixes, or `N/A`): +- Declared workarounds in `.github/workarounds.toml` (`None` if none): +- Tool use: From e4a55cb903c9e6c2be5db5c51dcf4cf030fadf96 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 5 Dec 2026 15:50:19 -0600 Subject: [PATCH 4/5] docs(policy): Add verdict rules and cite a public source why: Outside contributors cannot read the private decisions repository the review rules cited. The decision section did not say what to do with behavior the base already has or with a gate nobody ran, or which findings block. what: - Add verdict rules: base run, existing and separate, unverified gates, behavior defects, and checks and claims - Link the organization's posture definitions - Cite libtmux.org where the text named a private repository --- AGENTS.md | 9 +++++---- REVIEW.md | 26 +++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 0b04a0b3c..7d971752c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -44,10 +44,11 @@ being made: Express contracts on JDK 25 with JSpecify `@NullMarked` packages (enforced by NullAway and Error Prone), Java records and sealed hierarchies, `Optional` for absent lookup results, and `AutoCloseable` resource lifecycles -(`Server.start` with `try`-with-resources) while matching observable -`libtmux/central` tmux semantics across Java, Kotlin, Scala, and Clojure -bindings. Keep `io.github.libtmux.internal` unexported in `module-info.java` and -keep `libtmux` free of runtime dependencies. +(`Server.start` with `try`-with-resources) while matching the observable tmux +semantics the ports document at [libtmux.org](https://libtmux.org) across Java, +Kotlin, Scala, and Clojure bindings. Keep `io.github.libtmux.internal` +unexported in `module-info.java` and keep `libtmux` free of runtime +dependencies. Surface tmux and validation failures through typed `io.github.libtmux.exception` domain exceptions documented in `@throws`. Do not diff --git a/REVIEW.md b/REVIEW.md index 3ab7d5f0f..7594e4516 100644 --- a/REVIEW.md +++ b/REVIEW.md @@ -2,9 +2,13 @@ Posture: `experimental` (pre-1.0 JDK 25 and multi-language JVM modules for tmux; align observable semantics, target resolution, capability contracts, and -error taxonomy with `libtmux/central` while expressing APIs in native Java, +error taxonomy with the libtmux ports documented at +[libtmux.org](https://libtmux.org) while expressing APIs in native Java, Kotlin, Scala, and Clojure idioms). +[Posture](https://github.com/libtmux/.github/blob/HEAD/CONTRIBUTING.md#posture) +defines `experimental`, `stable` and `private`. + Review the complete change against ``, including untracked files. Report all findings in one pass without editing files. Follow [writing rules](.github/WRITING.md), [MCP rules](libtmux-mcp/AGENTS.md), and @@ -74,3 +78,23 @@ before blocking on placement. Every `BLOCK` must cite the file and broken rule or failing input, and state a concrete test, command, or code observation that would prove the finding wrong. + +## 3. Verdict + +These rules decide which findings block. + +- **Base run**: A finding that code misbehaves shows its check run on `` + and on the change, with one line of output from each. +- **Existing and separate**: Behavior `` 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. From db8d8f69fd7c3a805838ca7097949bdc36ad3551 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 5 Dec 2026 15:51:03 -0600 Subject: [PATCH 5/5] docs(contributing): Run the test-bite check in a throwaway worktree why: The earlier command restored files in the contributor's checkout. It could erase an uncommitted edit, and it left the source reverted when a test did not bite. It counted any nonzero exit as a bite and used mapfile, which zsh lacks. what: - Run the check in a disposable git worktree at HEAD - Name the regression test in BITE_TEST, and succeed only when the runner reports that test as failed - Default the base to the remote trunk, with BITE_BASE for a pre-fix commit --- .github/CONTRIBUTING.md | 43 +++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index dd60c8899..5c25d4eed 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -350,25 +350,34 @@ added `src/main/` sources while keeping `src/test/`, `integration-tests/`, and `libtmux-junit5/` intact: ```console -$ mapfile -t mod_jvm < <( \ - git diff --name-only -M --diff-filter=MDR origin/master..HEAD \ - | rg '(^|/)src/main/.*\.(java|kt|scala|clj)$' \ - | rg -v '^libtmux-junit5/' \ - ) && \ - mapfile -t add_jvm < <( \ - git diff --name-only -M --diff-filter=A origin/master..HEAD \ - | rg '(^|/)src/main/.*\.(java|kt|scala|clj)$' \ - | rg -v '^libtmux-junit5/' \ - ) && \ - test $(( ${#mod_jvm[@]} + ${#add_jvm[@]} )) -gt 0 && \ - { [ "${#mod_jvm[@]}" -eq 0 ] || \ - git restore --source=origin/master --worktree -- "${mod_jvm[@]}"; } && \ - { [ "${#add_jvm[@]}" -eq 0 ] || rm -f -- "${add_jvm[@]}"; } && \ - ! ./gradlew test :integration-tests:test && \ - git restore --source=HEAD --worktree -- "${mod_jvm[@]}" "${add_jvm[@]}" && \ - ./gradlew test :integration-tests:test +$ : "${BITE_TEST:?set BITE_TEST to the regression test}" && \ + wt=$(mktemp -d) && \ + git worktree add --quiet --detach "$wt" HEAD && \ + ( cd "$wt" && \ + base=${BITE_BASE:-origin/master} && \ + git diff --name-only --no-renames "$base" HEAD | \ + grep -E '(^|/)src/main/.*\.(java|kt|scala|clj)$' | \ + grep -Ev '^libtmux-junit5/' \ + > bite.files && \ + git restore --source="$base" --worktree \ + --pathspec-from-file=bite.files && \ + { ./gradlew test :integration-tests:test 2>&1 | tee bite.log; \ + grep -E ' > .* FAILED$' bite.log | \ + grep -F -- "$BITE_TEST"; } ); \ + bite=$?; \ + git worktree remove --force "$wt"; \ + test "$bite" -eq 0 ``` +This runs in a disposable `git worktree` at `HEAD`, so the checkout and any +uncommitted edit stay untouched; commit the change first. Set `BITE_TEST` to +the test method's name. `BITE_BASE` defaults to `origin/master`; set it to the +pre-fix commit when the defect was introduced earlier in the same pull request. +The command succeeds only when the runner reports that test as failed, and it +prints the failure line. A missing runner, a build error or an import error +prints no such line, so it is not a bite. Check that the printed failure is the +assertion that describes the defect. + ## Review Review is the maintainer reading the diff against what this file already asks