Skip to content
This repository was archived by the owner on Dec 3, 2026. It is now read-only.

fix: plugins and hooks exchange data without deadlocking; plugin discovery and plugin update report what they couldn't do [[tasks/harmony-2988]] - #152

Merged
gold-silver-copper merged 4 commits into
mainfrom
fix/plugin-exchange
Nov 1, 2026

Conversation

@gold-silver-copper

@gold-silver-copper gold-silver-copper commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Audit items W8.1-W8.3 and fuzz finding U70 (meta-improve-2026-10-31). W8.4 (the clone queue) is in #151.

What changes for users

  • A plugin can no longer deadlock meta. meta used to write the whole request to a plugin's stdin before reading any of its output. A plugin that wrote more than a pipe holds (64 KiB) before reading a request bigger than a pipe holds (many projects, or long arguments) left both programs blocked forever. meta now writes the request while it reads the plugin's output, then closes stdin and waits for the plugin. The plugin is reaped on every error path; before, a failed write returned without waiting for it.
  • Worktree hooks use the same exchange. A hook's payload is written while meta waits, and a write error is no longer thrown away. Any write error other than a broken pipe makes the hook fail with its event named, which is a warning, or an error under --strict (fix!: worktrees resolve one plan, read one record, and say what they did [[tasks/harmony-2973]] #149's rule). A hook that doesn't read its payload is still no failure (fix!: worktrees resolve one plan, read one record, and say what they did [[tasks/harmony-2973]] #149 decided that).
  • Broken plugin files are warned about. In .meta/plugins and ~/.meta/plugins, a file named meta-* that can't be started, isn't executable, exits with an error, or answers --meta-plugin-info with something that isn't plugin info now gets a warning naming it and saying why, as a timeout already did. Before, it silently wasn't a plugin. A meta-* program on PATH that isn't a plugin stays silent, since it may be any program; a timeout there is still warned about, as before. When you call a plugin by name (meta foo), the error now says why it isn't a plugin.
  • meta plugin update no longer says "up to date" for plugins it couldn't check (U70). It goes through the plugins meta installed (its manifest) whose file is still there, and checks each one. A hand-copied plugin, or a manifest entry whose file was deleted, can't make it fail. A plugin installed from a URL or a registry name, or with no recorded version, now prints Cannot check meta-<name> for updates: <why>. So does a failed GitHub lookup. A failed update is reported too. The other plugins are still checked and updated, then the command exits non-zero with Plugins not updated: <names> (not checked with --check). "All plugins are up to date" is printed only when every plugin was checked. meta plugin update <name> fails the same way for that plugin.

Before:

$ meta plugin update good
good is already up to date
$ meta plugin update --check
All plugins are up to date          # exit 0; nothing was checked

After:

$ meta plugin update good
Error: Cannot check meta-good for updates: it was not installed from a GitHub user/repo; reinstall it to update it
$ meta plugin update --check
Cannot check meta-good for updates: it was not installed from a GitHub user/repo; reinstall it to update it
Error: Plugins not checked: good   # exit 1

Code

  • meta_core::children::Owned::exchange(input) -> io::Result<Output> is the one exchange. It writes stdin on one thread and reads stderr on another (each only when piped), reads stdout itself, then waits through Owned::wait, so fix!: a meta run owns its children and the worktree sets it was making [[tasks/harmony-2972]] #147's stop path is unchanged. A broken pipe counts as success, because the exit status decides. Threads start through Builder::spawn_scoped, so a thread that can't start is an error, not a panic. If a pipe can't be served, the child is killed before it is waited for. children::output uses it, and Owned::stdin() and Owned::wait_with_output are deleted.
  • SubprocessPlugin::execute and fire_worktree_hook each call exchange instead of writing and waiting by hand.
  • probe_plugin_info returns Result<PluginInfo, NoInfo>, with NoInfo::NotAPlugin (couldn't start, failed, not plugin info) and NoInfo::NoAnswer (timeout, wait failure). Each carries the reason. SubprocessPluginManager::all leaves out a NotAPlugin on PATH silently and warns about everything else. files() keeps whether each file came from PATH, and warns about a non-executable meta-* file in a plugins folder.
  • PluginInstaller::check_update gates on GitHubShorthand::parse (the parser update_plugin already used) instead of source.contains('/'), and every "can't check" is an error saying why. The source isn't printed, because a URL may hold a credential. PluginInstaller::installed_words lists the manifest entries whose file is still there, for update-all.

Public API (crate meta_core):

// before
let mut child = children::spawn(&mut cmd)?;
if let Some(mut stdin) = child.stdin() { stdin.write_all(input)?; }
let output = child.wait_with_output()?;
// after
let output = children::spawn(&mut cmd)?.exchange(input)?;

Target revised: W8.2

  • Original: "A hook whose payload write fails is warned about."
  • Evidence: on a pipe, the only write failure that happens in practice is a broken pipe: the hook ended or closed stdin without reading. fix!: worktrees resolve one plan, read one record, and say what they did [[tasks/harmony-2973]] #149 recorded that as no failure. Warning on it would depend on timing for small payloads (a touch x hook sometimes exits before meta writes), and would fire every time for a hook that ignores a payload over 64 KiB. Under --strict it would fail a working setup.
  • New target: the write result is no longer thrown away. Any write error other than a broken pipe fails the hook, which callers turn into a warning, or an error under --strict. The hook shares the plugin exchange, which the 256 KiB / 100 KiB test covers.
  • Cost: no hook-specific test, since no other write error can be caused in a test.

Tests (each fails on origin/main)

  • a_plugin_that_writes_before_reading_a_large_request_gets_all_of_it: the plugin writes 256 KiB, then reads a request over 100 KiB. meta finishes, the plugin got the whole request, and the output is intact. On main, meta and the plugin block each other until the test's 30 s deadline kills meta.
  • unusable_files_in_plugin_folders_are_warned_about_but_not_on_path: a bad-JSON file, a file that can't start and a non-executable file, in .meta/plugins and in ~/.meta/plugins, are each warned about by meta --help. The same three on PATH are not.
  • plugin_update_names_each_plugin_it_cannot_check_and_fails: a URL-installed plugin, one with no version, and a manifest entry whose file was deleted. plugin update and plugin update --check name the first two, leave the deleted one alone and exit non-zero, and plugin update <name> fails naming it. No network is needed.
  • a_plugin_that_answers_without_reading_its_request_still_answers now sends a 100 KiB request under --strict, so the plugin always exits before meta finishes writing: a broken pipe stays no failure, for plugins and hooks alike. Checked by removing that line from exchange: the test then fails. The update test also checks that the plugin's source, which may hold a credential, is never printed.
  • tests/worktree_edge_cases.bats "a umask 002 checkout…": its fixture plugins now answer --meta-plugin-info. Before, they answered nothing, which this PR now warns about, as intended.

Verified

  • cargo nextest run --workspace (8 threads): 677 passed. bats, run locally in a sandbox (HOME, XDG and GIT_CONFIG_GLOBAL all inside it): hooks, plugin_install, help and dry_run (62 ok), plus the plugin, umask, symlinked-data and hook tests in worktree_edge_cases/worktree (6 ok). cargo clippy --workspace --all-targets --all-features -D warnings and cargo fmt --check are clean. plugin update --check with no manifest still says "All plugins are up to date" and makes no plugins folder.
  • The three new tests, copied onto origin/main 07559ab: all three fail there ("All plugins are up to date"; no warning naming meta-garbled-local; "meta and the plugin blocked each other" after 30 s).
  • Fuzz repro agent-25.sh (U70), in its own sandbox (git config --global --show-origin points into it), on main's build:
Successfully installed meta-good to ~/.meta/plugins
$ meta plugin update good
good is already up to date
exit=0
$ meta plugin update --check
All plugins are up to date
exit=0

on this branch:

Successfully installed meta-good to ~/.meta/plugins
$ meta plugin update good
Error: Cannot check meta-good for updates: it was not installed from a GitHub user/repo; reinstall it to update it
exit=1
$ meta plugin update --check
Cannot check meta-good for updates: it was not installed from a GitHub user/repo; reinstall it to update it
Error: Plugins not checked: good
exit=1
  • By hand, in a sandboxed shell pane, with a plugin that writes 256 KiB to stdout before reading its request:
drive$ meta chatty "$(head -c 102400 /dev/zero | tr "\0" r)" | wc -c
102767        # request bytes the plugin read (its stderr)
262144        # bytes meta printed
drive$ meta --help >/dev/null; echo exit=$?
Warning: Plugin …/ws/.meta/plugins/meta-plain is not executable; skipping
Warning: Plugin …/ws/.meta/plugins/meta-garbled did not answer --meta-plugin-info with its info: its answer is not plugin info (expected ident at line 1 column 2); skipping
exit=0

main's binary with the same plugin hangs until timeout 10 kills it (exit 124), and nothing is left running afterwards.

Other

  • claude-plugin/.claude-plugin/plugin.json 0.2.4 → 0.2.5, because the meta-plugins skill text changed (the rule in docs/claude_code_skills.md).

Not checked

  • macOS and Windows at runtime: the exchange uses std threads and pipes only, and Windows builds in CI.
  • A real GitHub release lookup during plugin update; there's no network here. The lookup's error is now reported instead of dropped.
  • A pipe read error during an exchange: there's no way to cause one. The code kills the child and reaps it.

Follow-ups

  • [[tasks/harmony-2994]]: plugin update uninstalls the old plugin before installing the new one, so a failed install leaves none. Also, meta plugin install user/repo records no version, so such a plugin can never be checked (now said out loud instead of "up to date"), and updating a pinned user/repo@v1 reinstalls v1. All three are in registry.rs and out of scope here.

…nd plugin update report what they couldn't do [[tasks/harmony-2988]]

- meta_core::children::Owned::exchange writes stdin while reading stdout
  and stderr, closes stdin, and reaps the child on every path; plugin
  execution, worktree hooks and children::output use it. A plugin that
  writes 256 KiB before reading a 100 KiB request no longer deadlocks.
- a hook's payload write error (other than a hook not reading it) fails
  the hook, a warning or an error under --strict
- in .meta/plugins and ~/.meta/plugins, a file that can't start, isn't
  executable, fails or answers with something but plugin info is warned
  about, naming why; meta-* on PATH stays silent
- meta plugin update checks every plugin in its manifest, names each one
  it can't check or update, and exits non-zero; never "up to date" for a
  plugin it couldn't check (U70)

Implements [[tasks/harmony-2988]]
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 16 billable files and costs up to $4.00.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 56 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 69 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: ecab1de5-3867-48f5-b7a7-ffa81ea7d66e
Commits

Reviewing files that changed from the base of the PR and between 07559ab and 7bdbacb.

Files selected for processing: 16
  • .meta/skills/meta-plugins/SKILL.md
  • README.md
  • claude-plugin/.claude-plugin/plugin.json
  • claude-plugin/skills/meta-plugins/SKILL.md
  • docs/advanced_usage.md
  • docs/architecture_overview.md
  • docs/faq_troubleshooting.md
  • docs/plugin_development.md
  • meta_cli/.claude/skills/meta-plugins/SKILL.md
  • meta_cli/src/main.rs
  • meta_cli/src/registry.rs
  • meta_cli/src/subprocess_plugins.rs
  • meta_cli/tests/plugin_discovery.rs
  • meta_core/src/children.rs
  • meta_git_lib/src/worktree/hooks.rs
  • tests/worktree_edge_cases.bats
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

…e starts threads only for piped streams [[tasks/harmony-2988]]

Review round 1 (R1, R2, R4):
- update-all goes through the manifest entries whose plugin file is still
  there, so a plugin deleted by hand can't make it fail on every run
- exchange starts the writer and stderr threads only for piped streams
  (children::output has no stdin)
- the umask bats fixture's plugins answer --meta-plugin-info, as the new
  discovery warning expects
- docs: what a meta-* program on PATH that isn't a plugin gets

Implements [[tasks/harmony-2988]]
…update never prints a source [[tasks/harmony-2988]]

Review round 2 (R3, R5): the no-read test sends 100 KiB under --strict,
so the broken-pipe path runs every time; the update test checks the
source (which may hold a credential) isn't printed.

Implements [[tasks/harmony-2988]]
…/harmony-2988]]

Review round 2 (R6): the plugin's skills changed.

Implements [[tasks/harmony-2988]]
@gold-silver-copper

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@gold-silver-copper
gold-silver-copper merged commit 4ead80f into main Nov 1, 2026
11 of 12 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant