methodic-research 0.35.0__tar.gz → 0.36.0__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 (58) hide show
  1. {methodic_research-0.35.0/src/methodic_research.egg-info → methodic_research-0.36.0}/PKG-INFO +1 -1
  2. {methodic_research-0.35.0 → methodic_research-0.36.0}/pyproject.toml +1 -1
  3. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/__init__.py +6 -0
  4. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/chronicle.py +4 -0
  5. methodic_research-0.36.0/src/methodic/feed.py +170 -0
  6. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/types.py +73 -1
  7. {methodic_research-0.35.0 → methodic_research-0.36.0/src/methodic_research.egg-info}/PKG-INFO +1 -1
  8. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic_research.egg-info/SOURCES.txt +2 -0
  9. methodic_research-0.36.0/tests/test_feed.py +135 -0
  10. {methodic_research-0.35.0 → methodic_research-0.36.0}/LICENSE +0 -0
  11. {methodic_research-0.35.0 → methodic_research-0.36.0}/README.md +0 -0
  12. {methodic_research-0.35.0 → methodic_research-0.36.0}/setup.cfg +0 -0
  13. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/activity.py +0 -0
  14. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/api_keys.py +0 -0
  15. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/assets.py +0 -0
  16. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/cli.py +0 -0
  17. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/collections.py +0 -0
  18. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/datasets.py +0 -0
  19. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/errata.py +0 -0
  20. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/errors.py +0 -0
  21. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/experiments.py +0 -0
  22. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/feedback.py +0 -0
  23. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/imports.py +0 -0
  24. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/me.py +0 -0
  25. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/pending.py +0 -0
  26. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/publications.py +0 -0
  27. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/reports.py +0 -0
  28. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/research_prompts.py +0 -0
  29. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/runs.py +0 -0
  30. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/search.py +0 -0
  31. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/tags.py +0 -0
  32. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/transport.py +0 -0
  33. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/upload_tracker.py +0 -0
  34. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic/variations.py +0 -0
  35. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic_research.egg-info/dependency_links.txt +0 -0
  36. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic_research.egg-info/entry_points.txt +0 -0
  37. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic_research.egg-info/requires.txt +0 -0
  38. {methodic_research-0.35.0 → methodic_research-0.36.0}/src/methodic_research.egg-info/top_level.txt +0 -0
  39. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_activity.py +0 -0
  40. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_api_keys.py +0 -0
  41. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_assets.py +0 -0
  42. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_cli.py +0 -0
  43. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_client.py +0 -0
  44. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_collections.py +0 -0
  45. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_config.py +0 -0
  46. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_datasets.py +0 -0
  47. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_distill.py +0 -0
  48. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_experiments.py +0 -0
  49. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_feedback.py +0 -0
  50. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_imports.py +0 -0
  51. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_pending.py +0 -0
  52. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_pending_reasons.py +0 -0
  53. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_reports.py +0 -0
  54. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_research_prompts.py +0 -0
  55. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_runs.py +0 -0
  56. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_search.py +0 -0
  57. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_upload_tracker.py +0 -0
  58. {methodic_research-0.35.0 → methodic_research-0.36.0}/tests/test_variations.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: methodic-research
3
- Version: 0.35.0
3
+ Version: 0.36.0
4
4
  Summary: Python client for the Chronicle experiment platform
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Documentation, https://docs.methodiclabs.ai
@@ -8,7 +8,7 @@ name = "methodic-research"
8
8
  # methodic-lib-publish.yml overwrites this from versions.toml at build
9
9
  # time, so the published artifact has a single source of truth. Kept
10
10
  # here for local `pip install -e conductor/`.
11
- version = "0.35.0"
11
+ version = "0.36.0"
12
12
  description = "Python client for the Chronicle experiment platform"
13
13
  requires-python = ">=3.11"
14
14
  license = "Apache-2.0"
@@ -18,6 +18,7 @@ from methodic.errors import (
18
18
  ServerError,
19
19
  )
20
20
  from methodic.experiments import Experiment, ExperimentsAPI
21
+ from methodic.feed import FeedAPI
21
22
  from methodic.feedback import FeedbackAPI
22
23
  from methodic.pending import PendingAPI
23
24
  from methodic.publications import PublicationsAPI
@@ -37,6 +38,8 @@ from methodic.types import (
37
38
  ExperimentDetail,
38
39
  ExperimentListPage,
39
40
  ExperimentSummary,
41
+ FeedEvent,
42
+ FeedPage,
40
43
  GitBranch,
41
44
  GitStatus,
42
45
  GitToken,
@@ -81,6 +84,9 @@ __all__ = [
81
84
  "ExperimentListPage",
82
85
  "ExperimentSummary",
83
86
  "ExperimentsAPI",
87
+ "FeedAPI",
88
+ "FeedEvent",
89
+ "FeedPage",
84
90
  "FeedbackAPI",
85
91
  "GitBranch",
86
92
  "GitStatus",
@@ -25,6 +25,7 @@ from methodic.datasets import DatasetsAPI
25
25
  from methodic.errata import ErrataAPI
26
26
  from methodic.errors import ChronicleConfigError
27
27
  from methodic.experiments import Experiment, ExperimentsAPI
28
+ from methodic.feed import FeedAPI
28
29
  from methodic.feedback import FeedbackAPI
29
30
  from methodic.imports import ImportsAPI
30
31
  from methodic.me import MeAPI
@@ -274,6 +275,9 @@ class Chronicle:
274
275
  # Attention feed — the caller's actionable queue + event stream.
275
276
  self.pending = PendingAPI(self._transport, self)
276
277
  self.activity = ActivityAPI(self._transport, self)
278
+ # Unified event feed (event-stream.md §6): activity + needs-you + inbox
279
+ # + research, with an explicit per-section pointer (see FeedAPI.seen).
280
+ self.feed = FeedAPI(self._transport, self)
277
281
 
278
282
  @property
279
283
  def organization_id(self) -> str | None:
@@ -0,0 +1,170 @@
1
+ """Feed namespace — the caller's unified event feed.
2
+
3
+ Wraps ``GET /v1/feed`` (the JSON page) and ``POST /v1/feed/seen`` (the
4
+ per-section cursor) — the unified event stream that subsumes activity, the
5
+ actionable "needs you" items (blocked / report_approval / invites), new
6
+ reports, and research recommendations (event-stream.md §6).
7
+
8
+ Two cross-cutting lenses are preset filters, not separate calls:
9
+
10
+ - **needs-you** — ``list(actionable=True, open=True)``: blocked agents +
11
+ approvals + invites still awaiting you.
12
+ - **inbox** — ``list(recipient="me")``: items addressed to you specifically.
13
+
14
+ The list is ACL-bounded server-side (the same enumeration authorization the
15
+ experiment listing uses). Pagination is a keyset on ``seq``: the JSON body is a
16
+ bare array, the server signals more via ``X-Has-More`` and this read's
17
+ unseen/open count via ``X-Unseen-Count``, and the next (older) page is fetched
18
+ with ``before=<seq>``.
19
+
20
+ **Pointer contract (event-stream.md §4).** Reading never advances your pointer.
21
+ After you have *durably processed* the events you read, advance it explicitly
22
+ with :meth:`seen` — at-least-once: a crash between read and ack re-delivers,
23
+ never drops. (The web UI advances automatically on view; an agent must ack
24
+ deliberately.)
25
+ """
26
+
27
+ from __future__ import annotations
28
+
29
+ import logging
30
+ from typing import TYPE_CHECKING, Any, Iterator
31
+
32
+ from methodic.pending import _has_more
33
+ from methodic.transport import Transport
34
+ from methodic.types import FeedPage
35
+
36
+ if TYPE_CHECKING:
37
+ from methodic.chronicle import Chronicle
38
+
39
+ logger = logging.getLogger(__name__)
40
+
41
+
42
+ def _unseen_count(headers: Any) -> int:
43
+ """Read the ``X-Unseen-Count`` response header as an int (default 0)."""
44
+ try:
45
+ return int(str(headers.get("X-Unseen-Count", "0")).strip() or 0)
46
+ except (TypeError, ValueError):
47
+ return 0
48
+
49
+
50
+ def _bool_param(value: bool) -> str:
51
+ """Serialize a bool for the query string as serde expects (``true``/``false``)."""
52
+ return "true" if value else "false"
53
+
54
+
55
+ class FeedAPI:
56
+ """The caller's unified event feed (activity + needs-you + inbox + research)."""
57
+
58
+ def __init__(self, transport: Transport, chronicle: Chronicle) -> None:
59
+ self._t = transport
60
+ self._chronicle = chronicle
61
+
62
+ def list(
63
+ self,
64
+ *,
65
+ category: str | list[str] | None = None,
66
+ actionable: bool | None = None,
67
+ open: bool | None = None,
68
+ recipient: str | None = None,
69
+ experiment: str | None = None,
70
+ kind: str | None = None,
71
+ severity: str | None = None,
72
+ after_seq: int | None = None,
73
+ before: int | None = None,
74
+ limit: int | None = None,
75
+ order: str | None = None,
76
+ ) -> FeedPage:
77
+ """One page of feed events, newest-first (or ``score``-first for research).
78
+
79
+ Filters mirror ``GET /v1/feed``: ``category`` (a string or list of
80
+ categories), the ``actionable`` / ``open`` lens, ``recipient="me"`` for
81
+ the inbox, plus ``experiment`` / ``kind`` / ``severity``. Page with
82
+ ``limit`` + ``before=<seq>`` (older), or poll forward with
83
+ ``after_seq=<seq>``. ``order`` is ``"seq"`` (default) or ``"score"``.
84
+
85
+ The result carries ``unseen_count`` (this section's unseen/open badge)
86
+ and a ``next_page_token`` (the last event's ``seq``) when more remain;
87
+ pass it back as ``before``, or use :meth:`iter` to walk every page.
88
+ Reading does **not** advance your pointer — call :meth:`seen` after you
89
+ act.
90
+ """
91
+ params: dict[str, Any] = {}
92
+ if category is not None:
93
+ params["category"] = (
94
+ ",".join(category) if isinstance(category, list) else category
95
+ )
96
+ if actionable is not None:
97
+ params["actionable"] = _bool_param(actionable)
98
+ if open is not None:
99
+ params["open"] = _bool_param(open)
100
+ if recipient is not None:
101
+ params["recipient"] = recipient
102
+ if experiment is not None:
103
+ params["experiment"] = experiment
104
+ if kind is not None:
105
+ params["kind"] = kind
106
+ if severity is not None:
107
+ params["severity"] = severity
108
+ if after_seq is not None:
109
+ params["after_seq"] = after_seq
110
+ if before is not None:
111
+ params["before"] = before
112
+ if limit is not None:
113
+ params["limit"] = limit
114
+ if order is not None:
115
+ params["order"] = order
116
+ rows, headers = self._t.get_with_headers("/feed", params=params or None)
117
+ return FeedPage.from_list(
118
+ rows, has_more=_has_more(headers), unseen_count=_unseen_count(headers)
119
+ )
120
+
121
+ def iter(
122
+ self,
123
+ *,
124
+ category: str | list[str] | None = None,
125
+ actionable: bool | None = None,
126
+ open: bool | None = None,
127
+ recipient: str | None = None,
128
+ experiment: str | None = None,
129
+ kind: str | None = None,
130
+ severity: str | None = None,
131
+ order: str | None = None,
132
+ limit: int | None = None,
133
+ ) -> Iterator[Any]:
134
+ """Yield every matching feed event, paging server-side as needed.
135
+
136
+ Walks oldest-ward via the ``before=<seq>`` cursor. Forward polling
137
+ (``after_seq``) is a single-call concern, so it is intentionally not a
138
+ parameter here — use :meth:`list` for incremental tailing.
139
+ """
140
+ token: int | None = None
141
+ while True:
142
+ page = self.list(
143
+ category=category,
144
+ actionable=actionable,
145
+ open=open,
146
+ recipient=recipient,
147
+ experiment=experiment,
148
+ kind=kind,
149
+ severity=severity,
150
+ before=token,
151
+ limit=limit,
152
+ order=order,
153
+ )
154
+ yield from page.results
155
+ if page.next_page_token is None:
156
+ return
157
+ token = int(page.next_page_token)
158
+
159
+ def seen(self, *, section: str, through_seq: int) -> None:
160
+ """Advance your pointer for one section to a seq you have FINISHED handling.
161
+
162
+ ``section`` is ``blocked`` / ``approvals`` / ``research`` / ``passive``
163
+ (see each event's section); ``through_seq`` is the highest event ``seq``
164
+ you've durably processed. Monotonic — a lower seq is a no-op. Call this
165
+ only *after* acting on the events (at-least-once); reading never advances
166
+ the pointer.
167
+ """
168
+ self._t.post(
169
+ "/feed/seen", json={"section": section, "through_seq": through_seq}
170
+ )
@@ -425,7 +425,7 @@ class ExperimentListPage:
425
425
  )
426
426
 
427
427
 
428
- # ── Attention feed (pending + activity) ───────────────────────────────────
428
+ # ── Attention feed (pending + activity + unified feed) ─────────────────────
429
429
 
430
430
 
431
431
  @dataclass
@@ -545,6 +545,78 @@ class ActivityPage:
545
545
  return cls(results=results, next_page_token=next_token)
546
546
 
547
547
 
548
+ @dataclass
549
+ class FeedEvent:
550
+ """One row of the unified event feed from `GET /v1/feed` (event-stream.md).
551
+
552
+ The feed unifies activity, the actionable "needs you" items (``blocked`` /
553
+ ``report_approval`` / invites), new reports, and research recommendations
554
+ under one stream. `seq` is the global monotonic cursor key — the value you
555
+ pass to :meth:`FeedAPI.seen` (as ``through_seq``) and to ``before`` /
556
+ ``after_seq`` for paging. `category` is the granular content type and rolls
557
+ up into a `section` (``blocked`` / ``approvals`` / ``research`` /
558
+ ``passive``) — the unit the cursor is keyed on. `actionable` items stay open
559
+ until `resolved_at` is set. `recipient_principal_id` is set when the event is
560
+ addressed to a specific principal (the inbox lens); broadcast/resource items
561
+ use `audience` + `experiment_id` instead. `payload` is the event-specific
562
+ "what changed" blob.
563
+ """
564
+
565
+ seq: int
566
+ id: str
567
+ category: str
568
+ kind: str
569
+ created_at: str
570
+ via: str
571
+ audience: str
572
+ actionable: bool
573
+ severity: str
574
+ payload: dict[str, Any]
575
+ actor_subject: str | None = None
576
+ resource_type: str | None = None
577
+ resource_id: str | None = None
578
+ experiment_id: str | None = None
579
+ recipient_principal_id: str | None = None
580
+ resolved_at: str | None = None
581
+ resolved_by: str | None = None
582
+ resolving_seq: int | None = None
583
+ score: float | None = None
584
+
585
+ @classmethod
586
+ def from_dict(cls, data: dict[str, Any]) -> FeedEvent:
587
+ return _from_dict(cls, data)
588
+
589
+
590
+ @dataclass
591
+ class FeedPage:
592
+ """One page of `feed.list` results plus the section unseen count + a cursor.
593
+
594
+ The server returns a **bare array** and carries page metadata in headers:
595
+ ``X-Has-More`` (it over-fetches one row to decide) and ``X-Unseen-Count``
596
+ (this read's unseen/open count for the queried section). The SDK reads both;
597
+ when more remain it builds ``next_page_token`` from the last event's ``seq``
598
+ — the ``?before`` cursor the server consumes for the next (older) page.
599
+ ``next_page_token`` is ``None`` on the last page. Use :meth:`FeedAPI.iter` to
600
+ walk every page.
601
+ """
602
+
603
+ results: list[FeedEvent]
604
+ unseen_count: int = 0
605
+ next_page_token: str | None = None
606
+
607
+ @classmethod
608
+ def from_list(
609
+ cls, rows: Any, *, has_more: bool, unseen_count: int = 0
610
+ ) -> FeedPage:
611
+ results = [FeedEvent.from_dict(r) for r in (rows or [])]
612
+ next_token = None
613
+ if has_more and results:
614
+ next_token = str(results[-1].seq)
615
+ return cls(
616
+ results=results, unseen_count=unseen_count, next_page_token=next_token
617
+ )
618
+
619
+
548
620
  @dataclass
549
621
  class BulkApproveResult:
550
622
  """Per-asset outcome within a `BulkApproveResponse`.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: methodic-research
3
- Version: 0.35.0
3
+ Version: 0.36.0
4
4
  Summary: Python client for the Chronicle experiment platform
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Documentation, https://docs.methodiclabs.ai
@@ -12,6 +12,7 @@ src/methodic/datasets.py
12
12
  src/methodic/errata.py
13
13
  src/methodic/errors.py
14
14
  src/methodic/experiments.py
15
+ src/methodic/feed.py
15
16
  src/methodic/feedback.py
16
17
  src/methodic/imports.py
17
18
  src/methodic/me.py
@@ -42,6 +43,7 @@ tests/test_config.py
42
43
  tests/test_datasets.py
43
44
  tests/test_distill.py
44
45
  tests/test_experiments.py
46
+ tests/test_feed.py
45
47
  tests/test_feedback.py
46
48
  tests/test_imports.py
47
49
  tests/test_pending.py
@@ -0,0 +1,135 @@
1
+ """Tests for the Feed namespace (the caller's unified event feed)."""
2
+
3
+ from methodic import Chronicle
4
+
5
+ BASE = "http://localhost:8080"
6
+
7
+
8
+ def _chronicle():
9
+ return Chronicle(server_url=BASE, api_key="sk_user_test")
10
+
11
+
12
+ def _event(**overrides):
13
+ base = {
14
+ "seq": 42,
15
+ "id": "11111111-1111-1111-1111-111111111111",
16
+ "category": "activity",
17
+ "kind": "run.succeeded",
18
+ "created_at": "2026-06-02T12:00:00Z",
19
+ "via": "direct",
20
+ "audience": "experiment_readers",
21
+ "actionable": False,
22
+ "severity": "info",
23
+ "payload": {"foo": "bar"},
24
+ "experiment_id": "exp-1",
25
+ "recipient_principal_id": "auth0|alice",
26
+ }
27
+ base.update(overrides)
28
+ return base
29
+
30
+
31
+ def test_list_returns_typed_events_and_unseen_count(requests_mock):
32
+ requests_mock.get(
33
+ f"{BASE}/v1/feed",
34
+ json=[_event()],
35
+ headers={"X-Has-More": "false", "X-Unseen-Count": "3"},
36
+ )
37
+
38
+ page = _chronicle().feed.list(category="activity")
39
+
40
+ assert page.next_page_token is None
41
+ assert page.unseen_count == 3
42
+ assert len(page.results) == 1
43
+ ev = page.results[0]
44
+ assert ev.seq == 42
45
+ assert ev.category == "activity"
46
+ assert ev.kind == "run.succeeded"
47
+ assert ev.payload == {"foo": "bar"}
48
+ assert ev.recipient_principal_id == "auth0|alice"
49
+
50
+
51
+ def test_list_omits_optional_fields(requests_mock):
52
+ """Optional resolution/score fields absent on the wire → None."""
53
+ requests_mock.get(
54
+ f"{BASE}/v1/feed",
55
+ json=[_event()],
56
+ headers={"X-Has-More": "false"},
57
+ )
58
+
59
+ ev = _chronicle().feed.list().results[0]
60
+ assert ev.resolved_at is None
61
+ assert ev.resolving_seq is None
62
+ assert ev.score is None
63
+ # Missing X-Unseen-Count header defaults to 0.
64
+ assert _chronicle().feed.list().unseen_count == 0
65
+
66
+
67
+ def test_list_builds_cursor_from_seq(requests_mock):
68
+ requests_mock.get(
69
+ f"{BASE}/v1/feed",
70
+ json=[_event(seq=42)],
71
+ headers={"X-Has-More": "true", "X-Unseen-Count": "1"},
72
+ )
73
+
74
+ page = _chronicle().feed.list()
75
+ assert page.next_page_token == "42"
76
+
77
+
78
+ def test_list_threads_filters_and_lenses(requests_mock):
79
+ requests_mock.get(
80
+ f"{BASE}/v1/feed",
81
+ json=[],
82
+ headers={"X-Has-More": "false"},
83
+ )
84
+
85
+ _chronicle().feed.list(
86
+ category=["report_approval", "experiment_invite"],
87
+ actionable=True,
88
+ open=True,
89
+ recipient="me",
90
+ experiment="exp-1",
91
+ kind="invite.received",
92
+ severity="warning",
93
+ after_seq=10,
94
+ limit=25,
95
+ order="score",
96
+ )
97
+
98
+ qs = requests_mock.last_request.qs
99
+ assert qs["category"] == ["report_approval,experiment_invite"]
100
+ assert qs["actionable"] == ["true"]
101
+ assert qs["open"] == ["true"]
102
+ assert qs["recipient"] == ["me"]
103
+ assert qs["experiment"] == ["exp-1"]
104
+ assert qs["kind"] == ["invite.received"]
105
+ assert qs["severity"] == ["warning"]
106
+ assert qs["after_seq"] == ["10"]
107
+ assert qs["limit"] == ["25"]
108
+ assert qs["order"] == ["score"]
109
+
110
+
111
+ def test_seen_posts_section_and_through_seq(requests_mock):
112
+ requests_mock.post(f"{BASE}/v1/feed/seen", status_code=204)
113
+
114
+ _chronicle().feed.seen(section="passive", through_seq=42)
115
+
116
+ assert requests_mock.last_request.json() == {
117
+ "section": "passive",
118
+ "through_seq": 42,
119
+ }
120
+
121
+
122
+ def test_iter_walks_before_cursor(requests_mock):
123
+ requests_mock.get(
124
+ f"{BASE}/v1/feed",
125
+ [
126
+ {"json": [_event(seq=42)], "headers": {"X-Has-More": "true"}},
127
+ {"json": [_event(seq=40)], "headers": {"X-Has-More": "false"}},
128
+ ],
129
+ )
130
+
131
+ seqs = [e.seq for e in _chronicle().feed.iter()]
132
+ assert seqs == [42, 40]
133
+ assert requests_mock.call_count == 2
134
+ second = requests_mock.request_history[1]
135
+ assert second.qs["before"] == ["42"]