@tikoci/centrs 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,70 +0,0 @@
1
- # stream
2
-
3
- Follow live RouterOS output — `print follow`, `monitor`-style commands, and
4
- sniffer feeds — as a stream of envelopes.
5
-
6
- Status: `designed`. This file describes intent and flags; no implementation yet.
7
- See `docs/MATRIX.md` for the cell states. `stream` lands with a transport that
8
- can hold an open read (native-api first, then ssh); it is **not** a REST cell.
9
-
10
- ## Why a separate verb
11
-
12
- `stream` exists because open-ended follow is a different I/O contract than a
13
- one-shot read, and conflating it into `retrieve` would force every retrieve
14
- consumer to handle "maybe this is a stream." A caller that picks `stream` knows
15
- it is getting a sequence of frames, not a single envelope. Bounded, finite
16
- captures stay on `retrieve` (`--once`); interactive PTY stays on `terminal`
17
- (constitution: protocol selection).
18
-
19
- ## Intent
20
-
21
- - **Read-only**, validated like `retrieve` (path-shaped commands gate through
22
- `/console/inspect`). `stream` never writes.
23
- - Wraps RouterOS follow semantics: `once`, `follow`, `duration=`,
24
- `freeze-frame-interval=`. Targets are the `monitor`/`print follow`/sniffer
25
- family of menus.
26
- - **Transport:** true follow cannot ride REST (RouterOS REST has a 60s hard
27
- cap), so `stream` is **native-api / ssh-first**. `--via rest-api` is
28
- bounded-or-rejected, never a silent open-ended poll.
29
- - Not a fan-out surface in single-session mode: a single `stream` rejects N>1
30
- targets with `usage/fanout-not-supported` (constitution: target selection).
31
-
32
- ## Output contract (NDJSON stream of envelopes)
33
-
34
- - Each frame is **one envelope** (`{ ok, data?, warnings?, error?, meta }`),
35
- emitted as one NDJSON line under `--format json`. Text mode renders
36
- human-readable frames.
37
- - The stream is terminated by a final **summary envelope**: frame count,
38
- duration, and stop reason (`duration-elapsed`, `interrupted`, `eof`,
39
- `transport-error`).
40
- - A mid-stream RouterOS or transport error is itself a frame with `ok: false`;
41
- the **process exit code** reflects whether the stream *started* cleanly, not
42
- whether every frame was `ok`.
43
- - `--duration` / `--count` bound an otherwise open-ended follow; Ctrl-C stops it
44
- and still emits the summary envelope.
45
-
46
- ## Flags (planned)
47
-
48
- | Flag | Behavior |
49
- | ---- | -------- |
50
- | `--via <protocol>` | Pin transport (`native-api` or `ssh`). REST is bounded-or-rejected. |
51
- | `--duration <dur>` | Stop after this wall-clock window (maps to RouterOS `duration=`). |
52
- | `--count <n>` | Stop after N frames. |
53
- | `--freeze-frame-interval <dur>` | RouterOS `freeze-frame-interval=` passthrough. |
54
- | `--format <text\|json>` | `json` is NDJSON (one envelope per line); `text` is human frames. |
55
-
56
- `tail` is a log-scoped alias: `centrs tail <router> /log` ≈ `tail -f` over
57
- `/log print follow`.
58
-
59
- ## Open questions
60
-
61
- - Whether `stream` over ssh shells out to the RouterOS CLI follow or rides a
62
- structured channel; settle during the SSH transport work.
63
- - Backpressure / max-buffered-frames policy for a fast producer.
64
-
65
- Sequencing (decided): do **not** start `stream` until (1) a native-api
66
- *streaming* spike confirms the reader is solid as a long-lived follow channel
67
- (not just request/response), and (2) `retrieve` is further along and re-reviewed
68
- for UX — `stream` should inherit a settled retrieve shape, not race it. The
69
- native-api streaming reader already exists (`src/protocols/native-api.ts`) and is
70
- the first follow consumer.