cli-watch-kit 0.1.0__tar.gz → 0.1.1__tar.gz

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.
Files changed (56) hide show
  1. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/PKG-INFO +5 -3
  2. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/README.md +4 -2
  3. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/pyproject.toml +1 -1
  4. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/app.py +10 -0
  5. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/claude.py +10 -3
  6. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/cli.py +10 -4
  7. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/daemon/engine.py +4 -3
  8. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/source.py +8 -0
  9. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/test_claude.py +27 -0
  10. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/test_engine.py +31 -2
  11. cli_watch_kit-0.1.1/tests/test_two_sessions.py +175 -0
  12. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/test_watcher.py +32 -0
  13. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/uv.lock +4 -4
  14. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/.editorconfig +0 -0
  15. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/.github/workflows/ci.yml +0 -0
  16. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/.github/workflows/publish.yml +0 -0
  17. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/.gitignore +0 -0
  18. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/.python-version +0 -0
  19. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/CLAUDE.md +0 -0
  20. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/LICENSE +0 -0
  21. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/scripts/hooks/commit-msg +0 -0
  22. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/scripts/hooks/pre-commit +0 -0
  23. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/__init__.py +0 -0
  24. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/atomic.py +0 -0
  25. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/budget.py +0 -0
  26. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/changelog.py +0 -0
  27. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/client.py +0 -0
  28. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/daemon/__init__.py +0 -0
  29. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/daemon/cache.py +0 -0
  30. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/daemon/lifecycle.py +0 -0
  31. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/daemon/scheduler.py +0 -0
  32. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/daemon/server.py +0 -0
  33. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/daemon/transport.py +0 -0
  34. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/durations.py +0 -0
  35. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/events.py +0 -0
  36. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/locks.py +0 -0
  37. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/paths.py +0 -0
  38. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/py.typed +0 -0
  39. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/sinks.py +0 -0
  40. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/src/cli_watch_kit/timers.py +0 -0
  41. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/conftest.py +0 -0
  42. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/fakeapp/__init__.py +0 -0
  43. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/fakeapp/app.py +0 -0
  44. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/fakeapp/catalog.py +0 -0
  45. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/fakeapp/cli.py +0 -0
  46. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/fakeapp/daemon.py +0 -0
  47. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/fakeapp/source.py +0 -0
  48. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/fakeapp/timers.py +0 -0
  49. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/test_batching.py +0 -0
  50. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/test_budget.py +0 -0
  51. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/test_claude_fallback.py +0 -0
  52. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/test_daemon.py +0 -0
  53. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/test_events.py +0 -0
  54. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/test_locks.py +0 -0
  55. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/test_transport.py +0 -0
  56. {cli_watch_kit-0.1.0 → cli_watch_kit-0.1.1}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: cli-watch-kit
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Build a `watch` command for a CLI: poll a source, report changes as JSON events, share one rate-limited daemon between all watchers
5
5
  Project-URL: Homepage, https://github.com/fprochazka/cli-watch-kit
6
6
  Project-URL: Repository, https://github.com/fprochazka/cli-watch-kit
@@ -57,7 +57,7 @@ uv add 'cli-watch-kit[claude-code]' # also messages into a Claude Code session
57
57
  - `PollItem.state` is a dict private to one resource that lives as long as the resource: the place for an ETag, work held back for a later poll, or a stateful poller object. It starts empty after a daemon restart; only the snapshot survives one.
58
58
  - **Source options** are what a watcher asks of the source besides event kinds (glab's `--logs=failed|all|none`, for example). `run_watch(source_options=...)` sends them with the subscription, `Source.check_options` validates them, and `PollItem.options` holds those of every subscriber and parent, each once, for the source to merge. A parent asks its children for kinds and options with `Wants(events, options)`.
59
59
  - An **account** (`Source.account(target, params)`) is whose rate limit a poll spends. Targets of different accounts never share a call or a budget.
60
- - Targets of one account with the same **batch key** (`Source.batch_key`) that are due within `coalesce_window` seconds go into one `poll()` call; the first poll of a new target waits up to that window (`baseline_wait`), so watchers that start a few seconds apart share it, split so that no call costs more than `batch_cost_cap`. `cost(batch)` estimates a call's cost per budget dimension; the source reports what the API said through `ctx.budget.observe(...)` and, when it knows what each response really cost (an ETag 304, a complexity header), charges that with `ctx.spend(...)`; the engine then gives back its estimate for those dimensions. An API client shared by the polls of an account finds the poll it serves with `PollContext.current()`.
60
+ - Targets of one account with the same **batch key** (`Source.batch_key`) that are due within `coalesce_window` seconds go into one `poll()` call; the first poll of a new target waits up to that window (`baseline_wait`), so watchers that start a few seconds apart share it, split so that no call costs more than `batch_cost_cap`. `cost(batch)` estimates a call's cost per budget dimension; the source reports what the API said through `ctx.budget.observe(...)` and, when it knows what each response really cost (an ETag 304, a complexity header), charges that with `ctx.spend(...)`; the engine then gives back its estimate for those dimensions. An API client shared by the polls of an account finds the poll it serves with `PollContext.current()`. A poll that handles a 429 itself, for a side request it tries again later, reports it with `ctx.rate_limited(retry_after)`, so the engine still blocks the account and does not count the poll as a success.
61
61
  - **Params** are what a watcher sends along with its subscription, such as an API key. They travel over the daemon's private socket (`0600` in a `0700` dir), reach the source per account, and never appear in the status or the log. Before it sends any, the watcher checks that the state dir and the socket (or the TCP endpoint file) belong to the user and that nobody else can write them, and over TCP that a daemon still holds the lock, so a stale port gets no token. The daemon log is `0600` too. The latest params of an account win, so `Source.account()` must check the key it gets (and raise `Unauthorized` for a bad one): otherwise one watcher with a wrong key would break the account's other watchers.
62
62
  - The **catalog** (`KindCatalog`) names the event kinds per resource kind, the groups of the filter options, and the threshold kinds the watcher computes itself. `watch_started`, `watch_degraded` and `watch_ended` are always reported.
63
63
 
@@ -150,7 +150,7 @@ if __name__ == "__main__":
150
150
  main(APP)
151
151
  ```
152
152
 
153
- `run_watch` also takes `enabled_thresholds` and `timers` (the app's `ClientTimer`s for threshold kinds), `also_subscribe` (kinds the daemon should track for a timer without the watcher reporting them), a `writer` factory for the app's own files in the resource dir (it gets a `WriterContext` with the base and resource dirs, the target, the backend for extra ops and the status output), `resource_dir`, `readme`, `sender_name`, `restart` and extra `header` lines. Only one watcher at a time writes a resource dir: a second watcher of the same target into the same base dir exits with 1 and says so, and runs with its own `--base-dir`. A CLI on another framework fills a `WatchOptions` itself, or uses `cli_watch_kit.client.Watcher` directly; that one takes no lock, so the CLI must keep two watchers of one resource out of the same dir itself.
153
+ `run_watch` also takes `enabled_thresholds` and `timers` (the app's `ClientTimer`s for threshold kinds), `also_subscribe` (kinds the daemon should track for a timer without the watcher reporting them), a `writer` factory for the app's own files in the resource dir (it gets a `WriterContext` with the base and resource dirs, the target, the backend for extra ops and the status output), `resource_dir`, `readme`, `sender_name`, `restart` and extra `header` lines. Only one watcher at a time writes a resource dir: a second watcher of the same target into the same base dir waits up to 5 s for the first one to finish, then exits with 1 and says so, and runs with its own `--base-dir`. Watchers of one target in different base dirs, such as two Claude Code sessions with their own scratchpads, always work: they share one resource of the daemon, and each gets every event into its own files and stream, also across a daemon restart or drain, one of them ending first, or one starting later. A CLI on another framework fills a `WatchOptions` itself, or uses `cli_watch_kit.client.Watcher` directly; that one takes no lock, so the CLI must keep two watchers of one resource out of the same dir itself.
154
154
 
155
155
  An app with requests the daemon should serve within the budget (fetching a log for a watcher, for example) puts them in `Source.ops`; a watcher calls them with `backend.call(op, payload, params)`. A source whose targets relay other targets (an MR and its head pipeline) returns them from `Source.children`.
156
156
 
@@ -171,6 +171,8 @@ An app with requests the daemon should serve within the budget (fetching a log f
171
171
 
172
172
  With the `claude-code` extra, `--events-stream=auto` (the default) sends the events into the Claude Code session that started the watcher, when that session accepts messages, as `<envelope_tag resource="issue ABC-123" seq="1-2">` blocks. cc-blackbox does the delivery: session lookup, the protocol check, burst batching, the 64 KB cap, the receiver's rate limit, and the end of the watch when the session is gone. The resource dir then lives in the session's scratchpad. Without the extra, `auto` uses stdout, and under Claude Code the header says which extra to install; `claude-message` fails with the same hint. Nothing imports cc-blackbox until a stream needs it.
173
173
 
174
+ Only the message with `watch_started` names the resource dir and the changelog; its `watch_started` drops the summary's `dir`, and `WatchApp.announced` can rewrite it further (glab-watch makes its threads dir relative there). A message's sender id is `<WatchApp.sender>:<pid>` (default: the app's name), and its sender name is what `run_watch(sender_name=...)` says (default: `<command> <target key>`).
175
+
174
176
  ## Developing
175
177
 
176
178
  ```bash
@@ -26,7 +26,7 @@ uv add 'cli-watch-kit[claude-code]' # also messages into a Claude Code session
26
26
  - `PollItem.state` is a dict private to one resource that lives as long as the resource: the place for an ETag, work held back for a later poll, or a stateful poller object. It starts empty after a daemon restart; only the snapshot survives one.
27
27
  - **Source options** are what a watcher asks of the source besides event kinds (glab's `--logs=failed|all|none`, for example). `run_watch(source_options=...)` sends them with the subscription, `Source.check_options` validates them, and `PollItem.options` holds those of every subscriber and parent, each once, for the source to merge. A parent asks its children for kinds and options with `Wants(events, options)`.
28
28
  - An **account** (`Source.account(target, params)`) is whose rate limit a poll spends. Targets of different accounts never share a call or a budget.
29
- - Targets of one account with the same **batch key** (`Source.batch_key`) that are due within `coalesce_window` seconds go into one `poll()` call; the first poll of a new target waits up to that window (`baseline_wait`), so watchers that start a few seconds apart share it, split so that no call costs more than `batch_cost_cap`. `cost(batch)` estimates a call's cost per budget dimension; the source reports what the API said through `ctx.budget.observe(...)` and, when it knows what each response really cost (an ETag 304, a complexity header), charges that with `ctx.spend(...)`; the engine then gives back its estimate for those dimensions. An API client shared by the polls of an account finds the poll it serves with `PollContext.current()`.
29
+ - Targets of one account with the same **batch key** (`Source.batch_key`) that are due within `coalesce_window` seconds go into one `poll()` call; the first poll of a new target waits up to that window (`baseline_wait`), so watchers that start a few seconds apart share it, split so that no call costs more than `batch_cost_cap`. `cost(batch)` estimates a call's cost per budget dimension; the source reports what the API said through `ctx.budget.observe(...)` and, when it knows what each response really cost (an ETag 304, a complexity header), charges that with `ctx.spend(...)`; the engine then gives back its estimate for those dimensions. An API client shared by the polls of an account finds the poll it serves with `PollContext.current()`. A poll that handles a 429 itself, for a side request it tries again later, reports it with `ctx.rate_limited(retry_after)`, so the engine still blocks the account and does not count the poll as a success.
30
30
  - **Params** are what a watcher sends along with its subscription, such as an API key. They travel over the daemon's private socket (`0600` in a `0700` dir), reach the source per account, and never appear in the status or the log. Before it sends any, the watcher checks that the state dir and the socket (or the TCP endpoint file) belong to the user and that nobody else can write them, and over TCP that a daemon still holds the lock, so a stale port gets no token. The daemon log is `0600` too. The latest params of an account win, so `Source.account()` must check the key it gets (and raise `Unauthorized` for a bad one): otherwise one watcher with a wrong key would break the account's other watchers.
31
31
  - The **catalog** (`KindCatalog`) names the event kinds per resource kind, the groups of the filter options, and the threshold kinds the watcher computes itself. `watch_started`, `watch_degraded` and `watch_ended` are always reported.
32
32
 
@@ -119,7 +119,7 @@ if __name__ == "__main__":
119
119
  main(APP)
120
120
  ```
121
121
 
122
- `run_watch` also takes `enabled_thresholds` and `timers` (the app's `ClientTimer`s for threshold kinds), `also_subscribe` (kinds the daemon should track for a timer without the watcher reporting them), a `writer` factory for the app's own files in the resource dir (it gets a `WriterContext` with the base and resource dirs, the target, the backend for extra ops and the status output), `resource_dir`, `readme`, `sender_name`, `restart` and extra `header` lines. Only one watcher at a time writes a resource dir: a second watcher of the same target into the same base dir exits with 1 and says so, and runs with its own `--base-dir`. A CLI on another framework fills a `WatchOptions` itself, or uses `cli_watch_kit.client.Watcher` directly; that one takes no lock, so the CLI must keep two watchers of one resource out of the same dir itself.
122
+ `run_watch` also takes `enabled_thresholds` and `timers` (the app's `ClientTimer`s for threshold kinds), `also_subscribe` (kinds the daemon should track for a timer without the watcher reporting them), a `writer` factory for the app's own files in the resource dir (it gets a `WriterContext` with the base and resource dirs, the target, the backend for extra ops and the status output), `resource_dir`, `readme`, `sender_name`, `restart` and extra `header` lines. Only one watcher at a time writes a resource dir: a second watcher of the same target into the same base dir waits up to 5 s for the first one to finish, then exits with 1 and says so, and runs with its own `--base-dir`. Watchers of one target in different base dirs, such as two Claude Code sessions with their own scratchpads, always work: they share one resource of the daemon, and each gets every event into its own files and stream, also across a daemon restart or drain, one of them ending first, or one starting later. A CLI on another framework fills a `WatchOptions` itself, or uses `cli_watch_kit.client.Watcher` directly; that one takes no lock, so the CLI must keep two watchers of one resource out of the same dir itself.
123
123
 
124
124
  An app with requests the daemon should serve within the budget (fetching a log for a watcher, for example) puts them in `Source.ops`; a watcher calls them with `backend.call(op, payload, params)`. A source whose targets relay other targets (an MR and its head pipeline) returns them from `Source.children`.
125
125
 
@@ -140,6 +140,8 @@ An app with requests the daemon should serve within the budget (fetching a log f
140
140
 
141
141
  With the `claude-code` extra, `--events-stream=auto` (the default) sends the events into the Claude Code session that started the watcher, when that session accepts messages, as `<envelope_tag resource="issue ABC-123" seq="1-2">` blocks. cc-blackbox does the delivery: session lookup, the protocol check, burst batching, the 64 KB cap, the receiver's rate limit, and the end of the watch when the session is gone. The resource dir then lives in the session's scratchpad. Without the extra, `auto` uses stdout, and under Claude Code the header says which extra to install; `claude-message` fails with the same hint. Nothing imports cc-blackbox until a stream needs it.
142
142
 
143
+ Only the message with `watch_started` names the resource dir and the changelog; its `watch_started` drops the summary's `dir`, and `WatchApp.announced` can rewrite it further (glab-watch makes its threads dir relative there). A message's sender id is `<WatchApp.sender>:<pid>` (default: the app's name), and its sender name is what `run_watch(sender_name=...)` says (default: `<command> <target key>`).
144
+
143
145
  ## Developing
144
146
 
145
147
  ```bash
@@ -54,7 +54,7 @@ packages = ["src/cli_watch_kit"]
54
54
 
55
55
  [dependency-groups]
56
56
  dev = [
57
- "cc-blackbox>=0.11,<0.12",
57
+ "cc-blackbox>=0.11,<0.13",
58
58
  "mypy>=1.15",
59
59
  "pytest>=8.0",
60
60
  "ruff>=0.14",
@@ -12,6 +12,7 @@ from pathlib import Path
12
12
  from typing import Any
13
13
 
14
14
  from cli_watch_kit import __version__ as LIB_VERSION
15
+ from cli_watch_kit.events import Event
15
16
  from cli_watch_kit.paths import AppPaths
16
17
  from cli_watch_kit.source import Source
17
18
 
@@ -36,6 +37,11 @@ class WatchApp:
36
37
  - `env_prefix`: the prefix of the override variables. Default: `name` in upper case with `_`, plus `_`.
37
38
  - `files_dir_name`: the name of the dir the watchers' files go under, in the session scratchpad or the temp
38
39
  dir (`linear-cli`). Default: `name`.
40
+ - `sender`: the sender id of a Claude Code message is `<sender>:<pid>`. Default: `name`. An app that kept the name
41
+ of an older daemon dir sets it to keep the sender id its readers know (glab-watch: `glab-watch`).
42
+ - `announced`: rewrites the `watch_started` event of the message that names the resource dir, after the library
43
+ dropped the summary's `dir`. It gets the event and the resource dir; glab-watch makes its threads dir relative.
44
+ stdout and the changelog keep the full event. Default: no further change.
39
45
  - `client_poll_ms`, `lease_timeout`: how often watchers poll the engine and how long a subscription lives
40
46
  without a poll. Default: 5000 ms and 20 s. `<PREFIX>CLIENT_POLL_MS` and `<PREFIX>LEASE_TIMEOUT` override both,
41
47
  for the daemon and for `--no-daemon` alike.
@@ -51,6 +57,8 @@ class WatchApp:
51
57
  command: str = ""
52
58
  env_prefix: str = ""
53
59
  files_dir_name: str = ""
60
+ sender: str = ""
61
+ announced: Callable[[Event, Path], Event] | None = None
54
62
  client_poll_ms: int | None = None
55
63
  lease_timeout: float | None = None
56
64
  _made: dict[str, Source[Any]] = field(default_factory=dict, init=False, compare=False, repr=False)
@@ -60,6 +68,8 @@ class WatchApp:
60
68
  object.__setattr__(self, "command", self.name)
61
69
  if not self.env_prefix:
62
70
  object.__setattr__(self, "env_prefix", self.name.upper().replace("-", "_") + "_")
71
+ if not self.sender:
72
+ object.__setattr__(self, "sender", self.name)
63
73
 
64
74
  def make_source(self) -> Source[Any]:
65
75
  """The source, built once."""
@@ -6,7 +6,7 @@ messaging protocol is one it speaks, batches the events that arrive within 3 s i
6
6
  64 KB, keeps below the session's rate limit, notices when the session is gone, and moves the events to stdout when
7
7
  messaging stops working. Without the extra, `auto` falls back to stdout and says which extra to install.
8
8
 
9
- Each message is a `<{envelope_tag} resource="..." seq="...">` block for one resource, sent as `<app>:<pid>` under a
9
+ Each message is a `<{envelope_tag} resource="..." seq="...">` block for one resource, sent as `<sender>:<pid>` under a
10
10
  sender name the app chooses. Only the message with `watch_started` names the resource dir and the changelog.
11
11
  Delivery is best effort: the receiver may rate-limit a message, or hold it until its user approves it. The changelog
12
12
  always has every event.
@@ -148,6 +148,13 @@ def _without_announced_dir(event: Event, directory: Path) -> Event:
148
148
  return Event(event.kind, event.resource, event.seq, event.observed_at, {**event.data, "summary": summary})
149
149
 
150
150
 
151
+ def _announced(app: WatchApp, event: Event, directory: Path) -> Event:
152
+ event = _without_announced_dir(event, directory)
153
+ if app.announced is not None and event.kind == WATCH_STARTED:
154
+ return app.announced(event, directory)
155
+ return event
156
+
157
+
151
158
  def message_envelope(app: WatchApp, resource: str, changelog: Path) -> EventEnvelope[Event]:
152
159
  """`<tag resource="…" seq="…">`. The message with `watch_started` also names the resource dir and the changelog.
153
160
  Above 64 KB the body becomes a count per kind that points at the changelog."""
@@ -159,7 +166,7 @@ def message_envelope(app: WatchApp, resource: str, changelog: Path) -> EventEnve
159
166
  payload=_event_payload,
160
167
  announce_on=WATCH_STARTED,
161
168
  announce_attributes={"dir": str(changelog.parent), "changelog": str(changelog)},
162
- announced=lambda event: _without_announced_dir(event, changelog.parent),
169
+ announced=lambda event: _announced(app, event, changelog.parent),
163
170
  record=str(changelog),
164
171
  )
165
172
 
@@ -184,7 +191,7 @@ def claude_message_sink(
184
191
  return MessageEventSink(
185
192
  session,
186
193
  message_envelope(app, resource, changelog),
187
- sender=f"{app.name}:{os.getpid()}",
194
+ sender=f"{app.sender}:{os.getpid()}",
188
195
  sender_name=sender_name,
189
196
  status=status.line,
190
197
  priority=cast(Priority, priority),
@@ -35,7 +35,7 @@ from cli_watch_kit.daemon.lifecycle import daemon_running, stop_daemon
35
35
  from cli_watch_kit.daemon.transport import DaemonFiles, DaemonTimeout, DaemonUnavailable, request
36
36
  from cli_watch_kit.durations import format_duration, parse_duration
37
37
  from cli_watch_kit.events import LIFECYCLE_KINDS, FilterError
38
- from cli_watch_kit.locks import FileLock
38
+ from cli_watch_kit.locks import FileLock, LockTimeout
39
39
  from cli_watch_kit.paths import sanitize_part
40
40
  from cli_watch_kit.sinks import Sink, StatusOutput
41
41
  from cli_watch_kit.source import Target
@@ -43,6 +43,8 @@ from cli_watch_kit.timers import ClientTimer
43
43
 
44
44
  EXIT_USAGE = 2
45
45
  DIR_LOCK = ".watcher.lock"
46
+ # How long a watcher waits for the resource dir: a stopped watcher unsubscribes and flushes its stream for a moment.
47
+ DIR_LOCK_WAIT = 5.0
46
48
  """The lock file in a resource dir that keeps a second watcher of the same resource out of it."""
47
49
 
48
50
 
@@ -194,7 +196,8 @@ def run_watch(
194
196
  raise _Usage(f"a {target.kind} watch never produces {unknown}, so it cannot also subscribe to it")
195
197
  timeout = _duration("--timeout", options.timeout)
196
198
  idle_after = _duration("--idle-after", options.idle_after)
197
- session = find_session() if options.events_stream != "stdout" else None
199
+ # The files go to the session's scratchpad whatever the stream, so the agent finds them next to its others.
200
+ session = find_session()
198
201
  scratchpad = getattr(session, "scratchpad_dir", None) if session is not None else None
199
202
  base = app.paths.base_dir(options.base_dir, scratchpad)
200
203
  changelog = Changelog(resource_dir(base, target), target.key, readme)
@@ -212,10 +215,13 @@ def run_watch(
212
215
  status.line(f"error: {exc}")
213
216
  return exc.code if isinstance(exc, _Usage) else EXIT_USAGE
214
217
  # One watcher per resource dir: two would interleave their seq numbers in one events.jsonl and overwrite each
215
- # other's baseline. The OS releases the lock when the watcher dies.
218
+ # other's baseline. The OS releases the lock when the watcher dies. A watcher that was just stopped, so that this
219
+ # one can replace it, may still be finishing, so wait for it a moment before refusing.
216
220
  changelog.dir.mkdir(parents=True, exist_ok=True)
217
221
  dir_lock = FileLock(changelog.dir / DIR_LOCK)
218
- if not dir_lock.try_acquire():
222
+ try:
223
+ dir_lock.acquire(DIR_LOCK_WAIT)
224
+ except LockTimeout:
219
225
  status.line(
220
226
  f"error: another watcher already watches {target.key} into {changelog.dir}; stop that one first, or give"
221
227
  " this one its own --base-dir"
@@ -694,9 +694,10 @@ class Engine:
694
694
  if refund:
695
695
  account.budget.charge(refund, self.clock())
696
696
  now = self.clock()
697
- limited = next((o.error for o in outcomes.values() if isinstance(o.error, RateLimited)), None)
698
- if limited is not None:
699
- account.budget.on_rate_limited(limited.retry_after, now)
697
+ limits = [o.error.retry_after for o in outcomes.values() if isinstance(o.error, RateLimited)] + ctx.rate_limits
698
+ if limits:
699
+ known = [r for r in limits if r is not None]
700
+ account.budget.on_rate_limited(max(known) if known else None, now)
700
701
  elif any(o.error is None for o in outcomes.values()):
701
702
  account.budget.on_success()
702
703
  windows = account.budget.windows()
@@ -172,6 +172,8 @@ class PollContext:
172
172
  """What the engine charged before the call."""
173
173
  spent: dict[str, float] = field(default_factory=dict)
174
174
  """What :meth:`spend` charged so far."""
175
+ rate_limits: list[float | None] = field(default_factory=list)
176
+ """The `Retry-After` of each 429 :meth:`rate_limited` reported so far, `None` where the API sent none."""
175
177
 
176
178
  def spend(self, cost: Mapping[str, float]) -> None:
177
179
  """Charge what a request really cost. The estimate of each dimension spent on is refunded after the poll."""
@@ -179,6 +181,12 @@ class PollContext:
179
181
  for dim, amount in cost.items():
180
182
  self.spent[dim] = self.spent.get(dim, 0.0) + amount
181
183
 
184
+ def rate_limited(self, retry_after: float | None) -> None:
185
+ """Report a 429 that the poll handled itself, such as a side request it tries again later. The engine then
186
+ blocks the account for `retry_after` as it does for a poll that failed with :class:`RateLimited`, and does not
187
+ count the poll as a success. Reporting the 429 of such a failed poll as well changes nothing."""
188
+ self.rate_limits.append(retry_after)
189
+
182
190
  @staticmethod
183
191
  def current() -> PollContext | None:
184
192
  """The context of the poll the calling task runs in, or `None` outside a poll (in an extra op, say).
@@ -9,6 +9,7 @@ import socket
9
9
  import tempfile
10
10
  import threading
11
11
  from collections.abc import Iterator
12
+ from dataclasses import replace
12
13
  from io import StringIO
13
14
  from pathlib import Path
14
15
  from types import SimpleNamespace
@@ -119,6 +120,16 @@ def test_a_burst_goes_out_as_one_message_in_the_apps_envelope(receiver: Receiver
119
120
  assert '{"kind":"note_added","seq":4,"data":{"notes":1}}' in content
120
121
 
121
122
 
123
+ def test_an_app_can_choose_the_sender_id(receiver: Receiver, clock: Clock, tmp_path: Path) -> None:
124
+ app = replace(APP, sender="demo")
125
+ session = cast(Any, fake_session(receiver.path))
126
+ status = StatusOutput(app.status_prefix)
127
+ sink = claude_message_sink(app, session, RESOURCE, "demo watch item a", tmp_path / "e.jsonl", "next", status)
128
+ sink.emit([event("watch_ended", 1, reason="done")])
129
+ assert wait_frames(receiver, 1)[0]["from"] == f"demo:{os.getpid()}"
130
+ sink.close()
131
+
132
+
122
133
  def test_only_the_first_watch_started_message_names_the_dir_and_the_changelog(
123
134
  receiver: Receiver, clock: Clock, tmp_path: Path
124
135
  ) -> None:
@@ -140,6 +151,22 @@ def test_only_the_first_watch_started_message_names_the_dir_and_the_changelog(
140
151
  sink.close()
141
152
 
142
153
 
154
+ def test_an_app_can_rewrite_the_announcing_watch_started(receiver: Receiver, clock: Clock, tmp_path: Path) -> None:
155
+ def relative_files(event: Event, directory: Path) -> Event:
156
+ files = Path(event.data["summary"]["files"]).relative_to(directory)
157
+ return replace(event, data={**event.data, "summary": {**event.data["summary"], "files": str(files)}})
158
+
159
+ app = replace(APP, announced=relative_files)
160
+ changelog = tmp_path / "res" / "events.jsonl"
161
+ envelope = message_envelope(app, RESOURCE, changelog)
162
+ summary = {"dir": str(tmp_path / "res"), "files": str(tmp_path / "res" / "files")}
163
+ content = envelope.format([event("watch_started", 1, summary=summary), event("note_added", 2)], announce=True)
164
+ assert '"summary":{"files":"files"}' in content
165
+ assert '"summary":{"files":"files"}' not in message_envelope(APP, RESOURCE, changelog).format(
166
+ [event("watch_started", 1, summary=summary)], announce=True
167
+ )
168
+
169
+
143
170
  def test_watch_ended_is_sent_at_once_and_priority_is_passed(receiver: Receiver, clock: Clock, tmp_path: Path) -> None:
144
171
  sink = sink_for(receiver, clock, tmp_path / "e.jsonl", "later")
145
172
  sink.emit([event("status_changed", 9, to="done"), event("watch_ended", 10, reason="done")])
@@ -11,9 +11,9 @@ from cli_watch_kit.daemon.engine import Engine, EngineError
11
11
  from cli_watch_kit.daemon.scheduler import Scheduler
12
12
  from cli_watch_kit.daemon.server import handle
13
13
  from cli_watch_kit.events import LIFECYCLE_KINDS
14
- from cli_watch_kit.source import PollItem, Target, Unauthorized, Wants
14
+ from cli_watch_kit.source import PollContext, PollItem, PollOutcome, Target, Unauthorized, Wants
15
15
  from conftest import Clock
16
- from fakeapp.source import FakeSource, World
16
+ from fakeapp.source import FakeSource, Snapshot, World
17
17
 
18
18
  ITEM = Target("item", "a")
19
19
  ALL_ITEM = frozenset({"status_changed", "note_added"})
@@ -606,3 +606,32 @@ def test_two_resubscribers_with_different_baselines_each_get_their_own_gap(clock
606
606
  ]
607
607
 
608
608
  run(scenario())
609
+
610
+
611
+ class SideRequestLimited(FakeSource):
612
+ """A source whose poll succeeds but whose side request got a 429 that the poll handled itself."""
613
+
614
+ retry_after: float | None = 40.0
615
+
616
+ async def poll(self, batch: Sequence[PollItem[Snapshot]], ctx: PollContext) -> Mapping[str, PollOutcome[Snapshot]]:
617
+ outcomes = await super().poll(batch, ctx)
618
+ ctx.rate_limited(self.retry_after)
619
+ return outcomes
620
+
621
+
622
+ def test_a_429_the_poll_handled_itself_still_blocks_the_account_and_is_no_success(clock: Clock) -> None:
623
+ world = World(items={"a": {"status": "open"}})
624
+ engine = Engine(SideRequestLimited(world), clock=clock)
625
+
626
+ async def scenario() -> None:
627
+ sub = await engine.subscribe("client-a", ITEM, ALL_ITEM)
628
+ budget = engine.accounts[""].budget
629
+ backoff = budget.backoff
630
+ await engine.poll_due_once()
631
+ assert kinds(engine.poll("client-a", {sub["subscription_id"]: 0}), sub["subscription_id"]) == ["watch_started"]
632
+ assert budget.rate_limited_count == 1
633
+ assert budget.blocked_until - clock() == pytest.approx(40.0)
634
+ # A success would have reset the backoff; the 429 doubled it instead.
635
+ assert budget.backoff == backoff * 2
636
+
637
+ run(scenario())
@@ -0,0 +1,175 @@
1
+ """Two watchers of one target from two Claude Code sessions: each writes its own base dir (its session's scratchpad)
2
+ and its own stream, and both share one resource of one real daemon process.
3
+
4
+ Only a second watcher into the same base dir is refused; different base dirs always work, also across a daemon
5
+ restart, a drain, one watcher ending first, and one watcher starting later.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import json
11
+ import os
12
+ import signal
13
+ import subprocess
14
+ from pathlib import Path
15
+ from typing import Any
16
+
17
+ import pytest
18
+
19
+ from cli_watch_kit.app import CodeStamp, WatchApp
20
+ from cli_watch_kit.daemon.lifecycle import daemon_running, ensure_daemon
21
+ from cli_watch_kit.daemon.transport import request as daemon_request
22
+ from fakeapp.app import APP
23
+ from fakeapp.source import World
24
+ from test_daemon import DaemonEnv, _watch, daemon_env, wait_for
25
+
26
+ __all__ = ["daemon_env"] # the fixture, imported for pytest
27
+
28
+
29
+ def _start(env: DaemonEnv, base: Path, *extra: str) -> subprocess.Popen[str]:
30
+ return _watch(["item", "a", "--events-stream=stdout", "--base-dir", str(base), *extra], env.env())
31
+
32
+
33
+ def _events(base: Path) -> list[dict[str, Any]]:
34
+ path = base / "item" / "a" / "events.jsonl"
35
+ if not path.exists():
36
+ return []
37
+ return [json.loads(line) for line in path.read_text().splitlines()]
38
+
39
+
40
+ def _kinds(base: Path) -> list[str]:
41
+ return [e["kind"] for e in _events(base)]
42
+
43
+
44
+ def _wait_kinds(base: Path, kinds: list[str], timeout: float = 20) -> None:
45
+ wait_for(lambda: _kinds(base) == kinds, timeout, f"{kinds} in {base} (have {_kinds(base)})")
46
+
47
+
48
+ def _finish(watch: subprocess.Popen[str], base: Path) -> list[dict[str, Any]]:
49
+ """Wait for the watcher's end; check that its stream and its changelog agree and that its seq has no gap."""
50
+ out, err = watch.communicate(timeout=30)
51
+ assert watch.returncode == 0, err
52
+ events = _events(base)
53
+ assert [json.loads(line) for line in out.splitlines()] == events, err
54
+ assert [e["seq"] for e in events] == list(range(1, len(events) + 1)), events
55
+ return events
56
+
57
+
58
+ def _comparable(events: list[dict[str, Any]]) -> list[tuple[str, Any]]:
59
+ return [(e["kind"], {k: v for k, v in e["data"].items() if k != "snapshot_hash"}) for e in events]
60
+
61
+
62
+ def _status(env: DaemonEnv) -> dict[str, Any]:
63
+ return daemon_request(env.files, {"op": "status"})
64
+
65
+
66
+ def _one_resource_with(env: DaemonEnv, subscriptions: int) -> bool:
67
+ resources = [r for r in _status(env)["resources"] if r["resource"] == "item a"]
68
+ return len(resources) == 1 and resources[0]["subscriptions"] == subscriptions
69
+
70
+
71
+ def test_two_watchers_in_two_base_dirs_share_one_resource_and_each_gets_every_event(daemon_env: DaemonEnv) -> None:
72
+ one, two = daemon_env.root / "one", daemon_env.root / "two"
73
+ first, second = _start(daemon_env, one, "--timeout=8s"), _start(daemon_env, two, "--timeout=8s")
74
+ _wait_kinds(one, ["watch_started"])
75
+ _wait_kinds(two, ["watch_started"])
76
+ wait_for(lambda: _one_resource_with(daemon_env, 2), 10, "one resource with two subscriptions")
77
+ daemon_env.world(World(items={"a": {"status": "review", "notes": 1}}))
78
+ _wait_kinds(one, ["watch_started", "status_changed", "note_added"])
79
+ _wait_kinds(two, ["watch_started", "status_changed", "note_added"])
80
+ a, b = _finish(first, one), _finish(second, two)
81
+ assert _comparable(a) == _comparable(b)
82
+ assert [e["kind"] for e in a] == ["watch_started", "status_changed", "note_added", "watch_ended"]
83
+ for base in (one, two):
84
+ assert json.loads((base / "item" / "a" / "baseline.json").read_text())["snapshot"] == {
85
+ "status": "review",
86
+ "notes": 1,
87
+ }
88
+
89
+
90
+ @pytest.mark.skipif(os.name == "nt", reason="uses SIGSTOP")
91
+ @pytest.mark.parametrize("how", ["restart", "drain"])
92
+ def test_after_a_restart_or_a_drain_each_of_two_watchers_gets_the_gap_once(daemon_env: DaemonEnv, how: str) -> None:
93
+ one, two = daemon_env.root / "one", daemon_env.root / "two"
94
+ first, second = _start(daemon_env, one, "--timeout=10s"), _start(daemon_env, two, "--timeout=10s")
95
+ _wait_kinds(one, ["watch_started"])
96
+ _wait_kinds(two, ["watch_started"])
97
+ hello = daemon_request(daemon_env.files, {"op": "hello"})
98
+ # Freeze both watchers, so neither comes back before the world changed.
99
+ for watch in (first, second):
100
+ os.kill(watch.pid, signal.SIGSTOP)
101
+ if how == "restart":
102
+ os.kill(hello["pid"], signal.SIGKILL)
103
+ wait_for(lambda: not daemon_running(daemon_env.files), 10, "the daemon to die")
104
+ else:
105
+ newer = WatchApp(APP.name, APP.source, APP.daemon_module, APP.app_protocol, "1.2.4", APP.status_prefix, "t")
106
+ newer.__dict__["code"] = CodeStamp("newer", hello["code_mtime"] + 100)
107
+ assert ensure_daemon(newer)["pid"] != hello["pid"]
108
+ daemon_env.world(World(items={"a": {"status": "review", "notes": 1}}))
109
+ os.kill(first.pid, signal.SIGCONT)
110
+ # The first watcher brings the resource back from its baseline; the second comes later, to a resource that the
111
+ # new daemon already polls, and still gets the gap from its own baseline.
112
+ _wait_kinds(one, ["watch_started", "watch_started", "status_changed", "note_added"])
113
+ os.kill(second.pid, signal.SIGCONT)
114
+ a, b = _finish(first, one), _finish(second, two)
115
+ expected = ["watch_started", "watch_started", "status_changed", "note_added", "watch_ended"]
116
+ assert [e["kind"] for e in a] == expected
117
+ assert [e["kind"] for e in b] == expected
118
+ assert _comparable(a)[2:4] == _comparable(b)[2:4]
119
+
120
+
121
+ def test_when_one_watcher_ends_the_other_keeps_the_resource_and_its_events(daemon_env: DaemonEnv) -> None:
122
+ one, two = daemon_env.root / "one", daemon_env.root / "two"
123
+ short, long = _start(daemon_env, one, "--timeout=30s"), _start(daemon_env, two, "--timeout=8s")
124
+ _wait_kinds(one, ["watch_started"])
125
+ _wait_kinds(two, ["watch_started"])
126
+ wait_for(lambda: _one_resource_with(daemon_env, 2), 10, "one resource with two subscriptions")
127
+ short.send_signal(signal.SIGTERM)
128
+ ended = _finish(short, one)
129
+ assert ended[-1]["data"]["reason"] == "signal SIGTERM"
130
+ wait_for(lambda: _one_resource_with(daemon_env, 1), 10, "the resource to keep its second subscription")
131
+ daemon_env.world(World(items={"a": {"status": "review"}}))
132
+ _wait_kinds(two, ["watch_started", "status_changed"])
133
+ assert [e["kind"] for e in _finish(long, two)] == ["watch_started", "status_changed", "watch_ended"]
134
+ assert _kinds(one) == ["watch_started", "watch_ended"]
135
+
136
+
137
+ def test_a_later_watcher_gets_watch_started_with_the_current_state_and_no_backlog(daemon_env: DaemonEnv) -> None:
138
+ one, two = daemon_env.root / "one", daemon_env.root / "two"
139
+ early = _start(daemon_env, one, "--timeout=10s")
140
+ _wait_kinds(one, ["watch_started"])
141
+ daemon_env.world(World(items={"a": {"status": "review", "notes": 1}}))
142
+ _wait_kinds(one, ["watch_started", "status_changed", "note_added"])
143
+ late = _start(daemon_env, two, "--timeout=6s")
144
+ _wait_kinds(two, ["watch_started"])
145
+ started = _events(two)[0]
146
+ assert started["data"]["summary"] == {"status": "review", "notes": 1}
147
+ assert json.loads((two / "item" / "a" / "baseline.json").read_text())["snapshot"] == {
148
+ "status": "review",
149
+ "notes": 1,
150
+ }
151
+ wait_for(lambda: _one_resource_with(daemon_env, 2), 10, "one resource with two subscriptions")
152
+ daemon_env.world(World(items={"a": {"status": "review", "notes": 2}}))
153
+ _wait_kinds(two, ["watch_started", "note_added"])
154
+ assert [e["kind"] for e in _finish(late, two)] == ["watch_started", "note_added", "watch_ended"]
155
+ assert [e["kind"] for e in _finish(early, one)] == [
156
+ "watch_started",
157
+ "status_changed",
158
+ "note_added",
159
+ "note_added",
160
+ "watch_ended",
161
+ ]
162
+
163
+
164
+ def test_a_second_watcher_into_the_same_base_dir_is_refused_while_another_dir_works(daemon_env: DaemonEnv) -> None:
165
+ one = daemon_env.root / "one"
166
+ first = _start(daemon_env, one, "--timeout=60s")
167
+ _wait_kinds(one, ["watch_started"])
168
+ refused = _start(daemon_env, one, "--timeout=4s")
169
+ out, err = refused.communicate(timeout=30)
170
+ assert refused.returncode == 1 and out == ""
171
+ assert "another watcher already watches item a" in err
172
+ other = _start(daemon_env, daemon_env.root / "two", "--timeout=2s")
173
+ assert [e["kind"] for e in _finish(other, daemon_env.root / "two")] == ["watch_started", "watch_ended"]
174
+ first.send_signal(signal.SIGTERM)
175
+ assert [e["kind"] for e in _finish(first, one)] == ["watch_started", "watch_ended"]
@@ -12,6 +12,7 @@ import time
12
12
  from collections.abc import Callable, Iterator, Mapping
13
13
  from dataclasses import replace
14
14
  from pathlib import Path
15
+ from types import SimpleNamespace
15
16
  from typing import Any
16
17
 
17
18
  import pytest
@@ -353,6 +354,7 @@ def test_a_second_watcher_of_the_same_resource_dir_is_refused(
353
354
  tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
354
355
  ) -> None:
355
356
  monkeypatch.setattr(cli, "default_backend", lambda app, no_daemon: ScriptedBackend([]))
357
+ monkeypatch.setattr(cli, "DIR_LOCK_WAIT", 0.2)
356
358
  app = WatchApp("inproc", FakeSource(), "unused.daemon", 1, "0", "inproc: ", "inproc-watcher")
357
359
  options = WatchOptions(timeout="1s", events_stream="stdout", base_dir=tmp_path)
358
360
  (tmp_path / "item" / "a").mkdir(parents=True)
@@ -364,6 +366,36 @@ def test_a_second_watcher_of_the_same_resource_dir_is_refused(
364
366
  assert cli.run_watch(app, TARGET, options) == 0
365
367
 
366
368
 
369
+ def test_a_watcher_waits_for_a_stopped_one_that_is_still_finishing(
370
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch
371
+ ) -> None:
372
+ monkeypatch.setattr(cli, "default_backend", lambda app, no_daemon: ScriptedBackend([]))
373
+ app = WatchApp("inproc", FakeSource(), "unused.daemon", 1, "0", "inproc: ", "inproc-watcher")
374
+ options = WatchOptions(timeout="1s", events_stream="stdout", base_dir=tmp_path)
375
+ (tmp_path / "item" / "a").mkdir(parents=True)
376
+ old = FileLock(tmp_path / "item" / "a" / cli.DIR_LOCK)
377
+ assert old.try_acquire()
378
+ finishing = threading.Timer(1.0, old.release)
379
+ finishing.start()
380
+ try:
381
+ assert cli.run_watch(app, TARGET, options) == 0
382
+ finally:
383
+ finishing.cancel()
384
+ old.release()
385
+ assert (tmp_path / "item" / "a" / "events.jsonl").is_file()
386
+
387
+
388
+ def test_a_stdout_watcher_under_a_session_writes_into_its_scratchpad(
389
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch
390
+ ) -> None:
391
+ monkeypatch.setattr(cli, "default_backend", lambda app, no_daemon: ScriptedBackend([]))
392
+ monkeypatch.setattr(cli, "find_session", lambda: SimpleNamespace(scratchpad_dir=tmp_path / "scratchpad"))
393
+ app = WatchApp("inproc", FakeSource(), "unused.daemon", 1, "0", "inproc: ", "inproc-watcher")
394
+ monkeypatch.delenv(app.paths.base_dir_env, raising=False)
395
+ assert cli.run_watch(app, TARGET, WatchOptions(timeout="1s", events_stream="stdout")) == 0
396
+ assert (tmp_path / "scratchpad" / "inproc" / "item" / "a" / "events.jsonl").is_file()
397
+
398
+
367
399
  class StuckSink(StdoutSink):
368
400
  """A sink whose reader stopped reading: every write blocks."""
369
401
 
@@ -72,14 +72,14 @@ wheels = [
72
72
 
73
73
  [[package]]
74
74
  name = "cc-blackbox"
75
- version = "0.11.0"
75
+ version = "0.12.0"
76
76
  source = { registry = "https://pypi.org/simple" }
77
77
  dependencies = [
78
78
  { name = "pyyaml" },
79
79
  ]
80
- sdist = { url = "https://files.pythonhosted.org/packages/c2/0c/8fb5ce8780428461e2fc7a02037d3d095c563352fa103180457721452eac/cc_blackbox-0.11.0.tar.gz", hash = "sha256:89ea517dcbc289abc7015d1f5d1ba4ca2b109f56241f4a81348b6e69ee34b193", size = 186221, upload-time = "2026-11-17T15:15:46.264Z" }
80
+ sdist = { url = "https://files.pythonhosted.org/packages/95/ef/90455eb34c669f5a53e920ac04d4a2d1b7f42905b197e33f786ae3a07df2/cc_blackbox-0.12.0.tar.gz", hash = "sha256:72e1fdf22ad56cbbf0ebb60aac0269e9ace34fbe41f612778266e4a2a9f4fa0e", size = 193812, upload-time = "2026-11-18T14:49:31.835Z" }
81
81
  wheels = [
82
- { url = "https://files.pythonhosted.org/packages/f2/eb/4d736f129a5651a78a7c8509910dd760d898f014009e437405f4a227e594/cc_blackbox-0.11.0-py3-none-any.whl", hash = "sha256:4051cb5fd82247404a3c02779f7a256e5e5cd5dc85e7af58231a520571baa103", size = 115375, upload-time = "2026-11-17T15:15:44.788Z" },
82
+ { url = "https://files.pythonhosted.org/packages/7c/7e/26517c36136184c3b931cbbd576e2406771ed6f2d3d407d01046e1196b12/cc_blackbox-0.12.0-py3-none-any.whl", hash = "sha256:0a2f5438b38e8bc2af2853839d78e646ca2c1a6c4ff5a0b041f8242adae9ef3a", size = 120736, upload-time = "2026-11-18T14:49:30.074Z" },
83
83
  ]
84
84
 
85
85
  [[package]]
@@ -111,7 +111,7 @@ provides-extras = ["claude-code"]
111
111
 
112
112
  [package.metadata.requires-dev]
113
113
  dev = [
114
- { name = "cc-blackbox", specifier = ">=0.11,<0.12" },
114
+ { name = "cc-blackbox", specifier = ">=0.11,<0.13" },
115
115
  { name = "mypy", specifier = ">=1.15" },
116
116
  { name = "pytest", specifier = ">=8.0" },
117
117
  { name = "ruff", specifier = ">=0.14" },
File without changes
File without changes
File without changes