This repository was archived by the owner on Dec 3, 2026. It is now read-only.
Repository navigation
feat: streaming events: records, progress and warnings as they happen; --json-stream - #166
Closed
gold-silver-copper wants to merge 5 commits into
Closed
gold-silver-copper wants to merge 5 commits into
gold-silver-copper wants to merge 5 commits into
Conversation
…olved invocation Every `meta --json` command prints one Envelope (`meta_plugin::Envelope`): success, command, results (one row per repo a step ran in, or per record a command returned), skipped, warnings, message and error with a code from a closed set. The 27 JSON shapes are gone, and so is loop_lib's JsonOutput. `meta --fields a,b.c --json` keeps only those fields of each row. The host resolves each invocation once and sends plugins a Request: cwd, the workspace (root, config, listed root, members, worktree dir and hooks), the scope, the worktree set, the selected projects (name, path, abs, repo, tags, depends_on, present, nested), depth, plugin and data dirs and a closed `meta` of options. Plugins stop finding the workspace from the process's working directory, so --config and --primary reach every command. Paths that aren't UTF-8 cross the wire (path_bytes in the Envelope). Plugins answer with one Response (plan, results, message, delegate or error, each with warnings and skipped); the request and response travel in files (META_REQUEST, META_RESPONSE), so a plugin keeps the terminal and never prints JSON. Plan steps take ok_codes and secret_env; ErrorCode gains auth, network, rate-limited (retry_after) and failed. meta-git, meta-project, meta-cargo and meta-mcp are ported; docs, skills and tests read the Envelope.
|
Warning Review limit reached
This review includes 86 billable files and costs up to $21.50.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 59 minutes for your next included review. View limit details
|
gold-silver-copper
force-pushed
the
feat/stream-events
branch
2 times, most recently
from
November 4, 2026 22:34
377e4f2 to
e0349a4
Compare
- `meta -rv git clone URL d --meta-depth 1` suggested `meta -rv -r --depth 1 ...`, which clap refuses (-r twice). Whether -r or --depth was typed before the command is now read cluster-aware (MetaOptions::typed_has), so `-rv` counts as -r. - From a nested meta repo, `meta -r --tag backend --exclude api exec` said it "names a repo outside" and gave an -A line that runs in repos nobody named, whenever -A's selection succeeded. The -A tip now comes only when one --include/--exclude value or --tag names nothing where -r starts but something -A reaches; it says "a repo or tag". - `meta project lsit --json` suggested `meta project list --json`, which fails, and `meta --json project lsit` dropped --json. The near-miss line now keeps meta's options typed before the command and moves the ones typed after it there (MetaOptions::lift). Each has a test that fails without the fix. Fixes the round-6 must-fixes of [[tasks/harmony-3074]].
…; --json-stream
A plugin writes events (meta_plugin::Event: record, progress, warning) to
the file META_EVENTS names, one JSON line each, at most 64 KiB; in Rust
through Ctx::{emit, record, progress}. On Unix it is a FIFO meta reads as
it goes, so a writer waits while meta is behind; on Windows a file meta
follows. meta shows records and warnings as they arrive (progress on a
terminal only), folds them into its one Envelope under --json, and under
the new --json-stream prints one {"event": …} line each, a step event as
each step of a plan ends, then {"envelope": …} as the last line. A plugin
that writes a step event, an unreadable line or one too long fails with
plugin-failed. Programs a plugin starts never get META_REQUEST,
META_RESPONSE or META_EVENTS.
gold-silver-copper
force-pushed
the
feat/stream-events
branch
from
November 5, 2026 00:13
e0349a4 to
cae59c9
Compare
Contributor
Author
|
Folded into gitkb/meta#165 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Stacked on gitkb/meta#165 (this branch holds its commit too and targets main; its own change is the last commit,
git diff refactor/request-envelope...feat/stream-events: +683/−34 in 15 files). This is item K30a, moved out of #165 by that PR's size tripwire.What changes for a user
record,progress,warning) while it runs, and meta shows records and warnings as they arrive (progress only on a terminal's stderr).meta --jsonis unchanged: one Envelope. Records and warnings that arrived as events are in it, in arrival order (before the response's own); progress is left out.meta --json-stream …(new, one of meta's options, before the command): one{"event": …}line per event as it happens, including astepevent as each step of a plan ends (exec, rawmeta git …, any plugin's plan), then{"envelope": …}: the same Envelope--jsonprints. It conflicts with--json.The protocol (SDK)
meta_plugin::event::Event(serde tagtype):Record(ProjectResult)(the same type asResults.records),Progress { done, total?, project?, message? },Warning(Warning)(the same type aswarnings[]),Step(ProjectResult)(meta's own: a plugin that sends one fails).META_EVENTSnames a per-call path; one JSON event per line, at most 64 KiB (event::MAX_LINE). A Rust plugin usesCtx::{emit, record, progress}; a scriptprintf '%s\n' "$event" >> "$META_EVENTS". Without the variable (a test calling the plugin directly)Ctxkeeps records for the response.Decisions taken alone
unsafe(pre_exec,CreateNamedPipeW), and the workspace forbidsunsafe_code; the design's own tripwire allows a per-call path inMETA_EVENTS. On Unix meta makes a FIFO (nix::unistd::mkfifo; rustix has no mkfifoat on macOS) in the call's private folder and reads it non-blocking from a thread (10 ms idle wait, cut short when the call ends), so a writer blocks while meta is behind and nothing piles up. On Windows there is no named-pipe server without FFI, so it is a file meta follows: no backpressure there (recorded; a stream command that never ends, PR 5a, would grow the file).META_REQUEST,META_RESPONSEandMETA_EVENTSfrom every program it starts, unless the caller set them (meta calling a plugin): a plugin's git or hook can't write its answer (part of RT-13, early).loop_lib::LoopConfig::on_donetells the host as each step ends; only--json-streamuses it.Tests
+3 cargo tests (
meta_cli/tests/plugin_routing.rs), +1 SDK unit test:a_record_a_plugin_streams_is_shown_before_it_ends: a script plugin's record is on meta's stdout while the plugin still waits.json_folds_what_a_plugin_streamed_into_its_one_envelope: streamed records and warnings in the Envelope, progress dropped; a plugin'sstepevent fails it (plugin-failed).json_stream_is_a_line_per_event_then_the_envelope_json_prints: one step line per repo, last line equal to--json's Envelope.box2 at cae59c9: fmt and clippy
-D warningsclean;cargo test --workspace638 passed, 0 failed (one hints test failed in the first full run and passed in 3 single reruns and a second full run: not explained, recorded);bats tests/618/618. 50meta project listcalls on box2: 0.41 s (not benched before).CI and the 10-minute macOS ceiling: at e0349a4 the macOS integration job took 10m44s, over the ceiling. The events reader waited out its 10 ms poll at the end of every plugin call; cae59c9 wakes it when the call ends. The ceiling was not raised. CI at cae59c9 (run 41939742520): all jobs green. The macOS integration job took 10m35s on its first attempt (over the 10-minute ceiling) and 8m45s on a rerun of the same head (job 126962227910). Identical code, so the 1m50s gap is the runner: in the bats log,
context(no plugin call, no code from this PR on its path) took 13.0 s and then 10.4 s. #165's job in the same window took 7m58s.Per-command cost, one quick check on box2 (debug builds of #165 a40f382 and this head, same machine, 20 interleaved runs each, median wall time, 3-repo workspace):
meta --versionmeta contextmeta -r project list(a plugin call)meta git status(a plugin call)No cost found beyond noise, so no fix: commands that start no plugin run none of this PR's code, and a plugin call adds a FIFO, a reader thread and a wake-up at its end (cae59c9 removed the up-to-10 ms wait there). Not measured on macOS itself (no Mac here). Owner decision: the slowdown is accepted for now; these numbers are a note for the later performance pass.
Also carries #165's a40f382 (meta#161's three round-6 must-fixes), so this branch holds them too.
Not verified
Windows (CI's job is the check;
meta_pluginandloop_libwere checked forx86_64-pc-windows-gnuon box2). MCP progress (PR 10) andoutput = "stream"(PR 5a) are later PRs.Try it
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.