ailogger-client-dev 0.1.51__py3-none-any.whl

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.
@@ -0,0 +1,314 @@
1
+ """
2
+ Typed methods for message retrieval through working-set and search queries.
3
+
4
+ This module carries the single mixin class whose typed methods let a caller
5
+ retrieve messages by two distinct retrieval routes: the working set command,
6
+ which assembles a session's recent tail and its closest matches to an anchor
7
+ in one call, and the message-search command, which pages through messages
8
+ matching a query by closeness of meaning.
9
+
10
+ Each method names its arguments for what the corresponding command's parameter
11
+ schema declares, so a caller retrieves messages in the service's own terms and
12
+ never assembles a request envelope, never names a command as a free string and
13
+ never guesses a parameter name.
14
+
15
+ A parameter the command declares as required is a required argument of the
16
+ method; a parameter the command declares as optional is optional on the method
17
+ and is simply not carried when the caller does not supply it, so the service's
18
+ own resolution of an unsupplied optional parameter is never pre-empted by a
19
+ value invented in this client.
20
+
21
+ Each method carries its arguments to the invocation seam of G-012/T-002/A-001
22
+ and returns what the seam returns. No ranking, filtering, de-duplication or
23
+ local similarity computation happens here: a caller asks for a result and
24
+ receives that result exactly as the service published it.
25
+
26
+ Required and optional parameters are mirrored exactly from the service command
27
+ declarations read as reference: working_set_command.py (G-009/T-005:
28
+ session_id=line 563, anchor_text=line 568, anchor_message_id=line 572,
29
+ recency_count=line 597, similarity_count=line 604, mode=line 621) and
30
+ message_search_command.py (G-009/T-006: query_text=line 1099, scope=line 1012,
31
+ scope_target=line 1025, filters=line 1040, mode=line 1058, page_size=line 1075,
32
+ page_offset=line 1091).
33
+
34
+ NETWORK LAW. This module imports nothing from the adapter framework's
35
+ implementation and adds no transport of its own. All network interaction goes
36
+ through the invocation seam and thence through the privately held framework
37
+ client instance, and through nothing else.
38
+
39
+ BOUNDARIES. This module declares no generic call, no completion default, no
40
+ non-blocking path or any job-observing call (all owned by earlier steps).
41
+ Every declaration in this file is fully annotated for the pipeline's named
42
+ strict type check, and the module satisfies its named lint check.
43
+ """
44
+
45
+ from __future__ import annotations
46
+
47
+ from typing import Any
48
+
49
+ __all__ = ["RetrievalMixin"]
50
+
51
+
52
+ class RetrievalMixin:
53
+ """Mixin providing typed methods for message retrieval.
54
+
55
+ Declares the two typed methods by which a caller retrieves messages: the
56
+ working-set command, which assembles a session's recent tail and its
57
+ closest matches to an anchor in one call, and the message-search command,
58
+ which pages through messages matching a query by closeness of meaning.
59
+
60
+ This mixin expects to be composed with InvocationMixin, which provides
61
+ the _invoke method.
62
+ """
63
+
64
+ async def _invoke(
65
+ self,
66
+ command: str,
67
+ params: dict[str, Any] | None = None,
68
+ *,
69
+ wait_for_result: bool = True,
70
+ ) -> Any:
71
+ """Private invocation entry point.
72
+
73
+ This method is provided by InvocationMixin when this mixin is composed
74
+ into a class. This stub is declared here for type checking purposes
75
+ only.
76
+
77
+ Args:
78
+ command: The name of the command to execute.
79
+ params: An optional mapping of command parameters.
80
+ wait_for_result: When True (default), wait for queued commands to
81
+ completion and return the finished result.
82
+
83
+ Returns:
84
+ The command result.
85
+ """
86
+ raise NotImplementedError # Provided by InvocationMixin
87
+
88
+ async def working_set( # noqa: PLR0913, PLR0917
89
+ self,
90
+ session_id: str,
91
+ anchor_text: str | None = None,
92
+ anchor_message_id: str | None = None,
93
+ recency_count: int | None = None,
94
+ similarity_count: int | None = None,
95
+ mode: str | None = None,
96
+ ) -> Any:
97
+ """Obtain the working set of one dialogue session in a single call.
98
+
99
+ The one route through which a consumer obtains everything it must
100
+ process for one recorded dialogue session without several round trips.
101
+ One request yields TWO independently sized groups in ONE answer: the
102
+ RECENT group, the most recently arrived messages of the named session,
103
+ and the CLOSEST group, the messages of that same session closest in
104
+ meaning to a supplied anchor.
105
+
106
+ THE ANCHOR IS SUPPLIED IN EXACTLY ONE OF TWO FORMS: an inline text,
107
+ whose meaning closeness is measured against, or a reference to a
108
+ message, which stands for the meaning of that message. Exactly one form
109
+ must be present in every call - supply anchor_text for an inline query
110
+ or anchor_message_id for a message reference, never both and never
111
+ neither.
112
+
113
+ WHAT IT REFUSES. A session this service does not know. A message anchor
114
+ that is not a message of the named session. A resolved count above the
115
+ ceiling that governs it. A governed optional parameter that resolves in
116
+ none of the three sources. The external embedding service being
117
+ unavailable when the anchor had to be embedded.
118
+
119
+ WHAT IT DOES NOT DO. It assembles no working set of its own and
120
+ re-ranks, re-scores, re-orders, re-groups, substitutes, collapses,
121
+ de-duplicates, filters, trims and truncates nothing: each group is
122
+ exactly what the domain's working-set assembly delivered, in that order
123
+ and with those scores. A message not yet vectorized reaches the caller
124
+ through the recent group exactly as any other message does and is
125
+ simply absent from the closest group; that absence is ordinary and is
126
+ never reported as an error. An empty group of either kind is a success,
127
+ not a failure.
128
+
129
+ Args:
130
+ session_id: Reference to the dialogue session whose working set is
131
+ wanted. Required in every request: this service never invents,
132
+ generates or defaults a session reference.
133
+ anchor_text: The anchor in its INLINE TEXT form: the text whose
134
+ meaning the closeness of a message is measured against, used
135
+ exactly as supplied and never trimmed, normalised, lower-cased
136
+ or truncated. Exactly one of anchor_text or anchor_message_id
137
+ must be supplied: supply this when describing what you are
138
+ looking for, or supply anchor_message_id when you already have
139
+ a message in hand. Optional.
140
+ anchor_message_id: The anchor in its MESSAGE REFERENCE form: a
141
+ reference to a message, standing for the meaning of that
142
+ message. Exactly one of anchor_text or anchor_message_id must
143
+ be supplied: supply this when you already have a message in hand,
144
+ or supply anchor_text when describing what you are looking for.
145
+ Optional.
146
+ recency_count: How many of the most recent messages of the named
147
+ session the answer is to carry. Optional: an omitted count is
148
+ not a missing value - it resolves through the project's fixed
149
+ order (call arguments, then service configuration, then shipped
150
+ constants), and it is additionally held to a ceiling declared by
151
+ that same order which no caller can state or raise.
152
+ similarity_count: How many anchor-closest messages of that same
153
+ session the answer is to carry. Optional: an omitted count is
154
+ not a missing value - it resolves through the project's fixed
155
+ order (call arguments, then service configuration, then shipped
156
+ constants), and it is additionally held to a ceiling declared by
157
+ that same order which no caller can state or raise.
158
+ mode: In which form the recorded content of the answer is delivered:
159
+ 'resolved' substitutes the final version of a correction chain,
160
+ collapses duplicate final messages and keeps the highest
161
+ similarity score of a collapsed set before the requested counts
162
+ are applied, and 'full' returns every recorded version as it
163
+ stands, for analysis over superseded wording. Optional: an
164
+ omitted mode is not a missing value - it resolves through the
165
+ project's fixed order (call arguments, then service
166
+ configuration, then shipped constants).
167
+
168
+ Returns:
169
+ One result carrying both groups together: the RECENT group, holding
170
+ at most the resolved recency count of messages; and the CLOSEST
171
+ group, holding at most the resolved similarity count of them. Each
172
+ group is identified by the member it is carried under and every
173
+ entry additionally names the criterion it reached the answer by. The
174
+ answer also states the session the request named and the anchor text
175
+ the closeness was actually measured against.
176
+ """
177
+ params: dict[str, Any] = {"session_id": session_id}
178
+ if anchor_text is not None:
179
+ params["anchor_text"] = anchor_text
180
+ if anchor_message_id is not None:
181
+ params["anchor_message_id"] = anchor_message_id
182
+ if recency_count is not None:
183
+ params["recency_count"] = recency_count
184
+ if similarity_count is not None:
185
+ params["similarity_count"] = similarity_count
186
+ if mode is not None:
187
+ params["mode"] = mode
188
+ return await self._invoke("working_set", params)
189
+
190
+ async def message_search( # noqa: PLR0913, PLR0917
191
+ self,
192
+ query_text: str,
193
+ scope: str,
194
+ scope_target: str | None = None,
195
+ filters: dict[str, Any] | None = None,
196
+ mode: str | None = None,
197
+ page_size: int | None = None,
198
+ page_offset: int | None = None,
199
+ ) -> Any:
200
+ """Search recorded dialogue messages by closeness of meaning to a query.
201
+
202
+ The one route through which this service's similarity search over
203
+ recorded message text is reached. A message matches by closeness of
204
+ meaning between the embedding of the query text and the embedding held
205
+ for that message - never because the message contains the query as a
206
+ substring or happens to share its words.
207
+
208
+ Every search states its own bounds explicitly: one named session, one
209
+ named project, or all projects. Within those bounds a caller may narrow
210
+ along exactly the axes the vector record carries as filterable metadata
211
+ - project, session, sender kind, priority and arrival time - and may
212
+ state which recorded versions to be delivered, resolved or full.
213
+
214
+ One page is then produced by filtering, then the mode transformation,
215
+ then a total sort by similarity score with a deterministic tiebreak on
216
+ the matched message's own identifier, then the offset, then the window:
217
+ paging is therefore coherent and repeatable.
218
+
219
+ WHAT IT REFUSES. A scope designating a session or a project that does
220
+ not exist, said as two distinct codes so you tell the two apart
221
+ mechanically. A filter along an axis the search does not accept. A
222
+ resolved page size above the ceiling that governs it. The external
223
+ embedding service being unavailable when the query had to be embedded.
224
+
225
+ WHAT IT DOES NOT DO. It performs no matching of its own and re-ranks,
226
+ re-groups and re-scores nothing: the window it answers with is the
227
+ window the search produced. A message not yet vectorized cannot be
228
+ found by similarity and is simply absent from the answer; that absence
229
+ is ordinary and is never reported as an error. An offset at or past the
230
+ end of the match set is answered successfully with an empty window
231
+ rather than refused.
232
+
233
+ Args:
234
+ query_text: The text whose MEANING the search is by. A message
235
+ matches by closeness of meaning between the embedding of this
236
+ text and the embedding held for that message, never because the
237
+ message contains this text as a substring or happens to share its
238
+ words. Required and non-empty: without it there is nothing to
239
+ search for.
240
+ scope: How wide this search reaches, stated explicitly and never
241
+ inferred: 'session' searches one named session, 'project'
242
+ searches every session of one named project, and 'all_projects'
243
+ places no scope bound at all. A bounded reach names its target in
244
+ scope_target; the all-projects reach names none. Required.
245
+ scope_target: What the bounded reach applies to: the identifier of
246
+ the session for the 'session' scope, the identifier of the
247
+ project for the 'project' scope. Required by exactly those two
248
+ scopes and admitted by neither of them absent; the 'all_projects'
249
+ scope applies to no target, so a designation supplied alongside
250
+ it is refused rather than ignored. Whether the designated
251
+ session or project exists is a separate question. Optional.
252
+ filters: Narrowing conditions applied WITHIN the resolved scope,
253
+ along exactly the axes the search accepts because the vector
254
+ record carries them as filterable metadata: the project, the
255
+ session, the sender kind, the priority and the time. Every axis
256
+ is optional and an axis left unstated is left unconstrained; the
257
+ filter as a whole may be omitted entirely or supplied empty, in
258
+ which case the resolved scope alone bounds the search. An axis
259
+ the search does not accept is refused, naming it, rather than
260
+ ignored. Optional and legitimately absent or empty.
261
+ mode: Which recorded versions the search delivers for what it
262
+ matched: 'resolved' delivers a hit on a superseded message as
263
+ its correction chain's final version, 'full' delivers every
264
+ matching recorded version exactly as recorded. Similarity is
265
+ evaluated over every recorded version under either value.
266
+ Optional: an omitted mode is not a missing value - it resolves
267
+ through the project's fixed order (call arguments, then service
268
+ configuration, then shipped constants).
269
+ page_size: How many matched messages one window may hold, counted in
270
+ messages and never in vector records. It bounds this one answer
271
+ and nothing else: it never bounds the matched set the query
272
+ found and never says where the window begins. Optional: an
273
+ omitted page size is not a missing value - it resolves through
274
+ the project's fixed order (call arguments, then service
275
+ configuration, then shipped constants).
276
+ page_offset: Where this answer's window begins: how many matches of
277
+ the sorted match set to skip first, zero-based and counted in
278
+ messages. It locates the window and nothing else - it never
279
+ bounds the matched set and never bounds the window's size. It
280
+ carries NO ceiling: paging depth is deliberately unbounded, and
281
+ an offset at or past the end of the match set is answered
282
+ successfully with an empty window rather than refused. Optional:
283
+ an omitted offset is not a missing value - it resolves through
284
+ the project's fixed order (call arguments, then service
285
+ configuration, then shipped constants).
286
+
287
+ Returns:
288
+ One window of matches taken from the full sorted match set: it
289
+ begins at the resolved offset and holds at most the resolved page
290
+ size of matches. Each match carries exactly four members - the
291
+ matched message as recorded, the identifier of the session that
292
+ message belongs to, the identifier of the project that session
293
+ belongs to, and the similarity score of the match. Beside the window
294
+ the answer states whether further matches remain and, when they do,
295
+ the offset at which the next window begins (null when none remain),
296
+ and the size of the WHOLE matched set, counted in messages after the
297
+ mode has been applied and never trimmed by the page size, the offset
298
+ or any ceiling. A window with no matches is a success, not a failure.
299
+ """
300
+ params: dict[str, Any] = {
301
+ "query_text": query_text,
302
+ "scope": scope,
303
+ }
304
+ if scope_target is not None:
305
+ params["scope_target"] = scope_target
306
+ if filters is not None:
307
+ params["filters"] = filters
308
+ if mode is not None:
309
+ params["mode"] = mode
310
+ if page_size is not None:
311
+ params["page_size"] = page_size
312
+ if page_offset is not None:
313
+ params["page_offset"] = page_offset
314
+ return await self._invoke("message_search", params)
@@ -0,0 +1,148 @@
1
+ """
2
+ Typed methods for service's self-describing commands.
3
+
4
+ This module carries the single mixin class whose typed methods let a caller
5
+ invoke the service's own self-describing commands: the info command, which
6
+ describes the service's capabilities by section, and the health command, which
7
+ reports the service's liveness and its dependencies.
8
+
9
+ Each method names its arguments for what the corresponding command's parameter
10
+ schema declares, so a caller describes the service in the service's own terms
11
+ and never assembles a request envelope, never names a command as a free string
12
+ and never guesses a parameter name.
13
+
14
+ The info command declares one optional parameter, a section name, which
15
+ legitimately admits absence: called without it the command answers with its
16
+ table of contents, called with a section name it answers with exactly that
17
+ section. That optional parameter is mirrored exactly on the method: when the
18
+ caller does not supply it, no value for it is carried at all rather than
19
+ substituting a name or a placeholder, so the service's own meaning for an
20
+ absent section - its table of contents - is what the caller receives. The
21
+ health command declares no parameters at all; its method takes no arguments.
22
+
23
+ Each method carries its arguments to the invocation seam of G-012/T-002/A-001
24
+ and returns what the seam returns exactly as published. No caching, no local
25
+ documentation assembly, no section-name list, no recomputation of any status,
26
+ and no reinterpretation of a health report appears here - in particular no
27
+ overall status is computed from its parts.
28
+
29
+ The info command is declared by G-011/T-004. The health command is this
30
+ service's override of the framework's own platform command, declared by
31
+ G-013/T-001. Both are commands of this service's own, and the named
32
+ client-surface-agreement check of G-010/T-004/A-008 will demand a typed
33
+ method for each: without these methods the client would be short by two and
34
+ that check would fail.
35
+
36
+ NETWORK LAW. This module imports nothing from the adapter framework's
37
+ implementation and adds no transport of its own. All network interaction goes
38
+ through the invocation seam and thence through the privately held framework
39
+ client instance, and through nothing else. The health method probes no
40
+ dependency of the service directly.
41
+
42
+ BOUNDARIES. This module declares no typed method for any other command.
43
+ Platform commands the service does not override (the plain help command in
44
+ particular) get no typed method here. This module declares no class, dataclass,
45
+ typed dictionary or schema describing an info section, a table of contents, a
46
+ health report, a dependency or a status, and no enumeration of section names
47
+ or status values.
48
+
49
+ Every declaration in this file is fully annotated for the pipeline's named
50
+ strict type check, and the module satisfies its named lint check.
51
+ """
52
+
53
+ from __future__ import annotations
54
+
55
+ from typing import Any
56
+
57
+ __all__ = ["ServiceMixin"]
58
+
59
+
60
+ class ServiceMixin:
61
+ """Mixin providing typed methods for the service's self-describing commands.
62
+
63
+ Declares the two typed methods by which a caller invokes the service's own
64
+ self-describing commands: the info command, which describes the service's
65
+ capabilities by section, and the health command, which reports the service's
66
+ liveness and its dependencies.
67
+
68
+ This mixin expects to be composed with InvocationMixin, which provides
69
+ the _invoke method.
70
+ """
71
+
72
+ async def _invoke(
73
+ self,
74
+ command: str,
75
+ params: dict[str, Any] | None = None,
76
+ *,
77
+ wait_for_result: bool = True,
78
+ ) -> Any:
79
+ """Private invocation entry point.
80
+
81
+ This method is provided by InvocationMixin when this mixin is composed
82
+ into a class. This stub is declared here for type checking purposes
83
+ only.
84
+
85
+ Args:
86
+ command: The name of the command to execute.
87
+ params: An optional mapping of command parameters.
88
+ wait_for_result: When True (default), wait for queued commands to
89
+ completion and return the finished result.
90
+
91
+ Returns:
92
+ The command result.
93
+ """
94
+ raise NotImplementedError # Provided by InvocationMixin
95
+
96
+ async def info(self, section: str | None = None) -> Any:
97
+ """Describe the service's capabilities by section.
98
+
99
+ Invokes the service's info command, declared by G-011/T-004, to obtain
100
+ a description of the service's capabilities. Called without a section
101
+ name, the command answers with its table of contents. Called with a
102
+ section name, the command answers with exactly that section.
103
+
104
+ This method carries the section parameter to the invocation seam only
105
+ when the caller supplies it; when the caller does not supply it, no
106
+ value for it is carried at all, so the service's own resolution of an
107
+ absent section - its table of contents - is never pre-empted by a value
108
+ invented in this client.
109
+
110
+ Args:
111
+ section: The name of the section whose description is wanted.
112
+ Optional and legitimately absent: omit it to obtain the table of
113
+ contents. When supplied, the section name is carried to the
114
+ service, which answers with exactly that section or refuses the
115
+ request with its specific contracted error.
116
+
117
+ Returns:
118
+ When called without a section, the table of contents of the service's
119
+ capabilities. When called with a section name, the description of
120
+ exactly that section. The answer is the finished result exactly as
121
+ the service published it, without caching, local documentation
122
+ assembly, section-name validation or reinterpretation.
123
+ """
124
+ params: dict[str, Any] | None = None
125
+ if section is not None:
126
+ params = {"section": section}
127
+ return await self._invoke("info", params)
128
+
129
+ async def health(self) -> Any:
130
+ """Report the service's liveness and the state of its dependencies.
131
+
132
+ Invokes the service's health command, declared by G-013/T-001, to obtain
133
+ the composed report of the service's liveness and its dependencies. This
134
+ service overrides the framework's own platform health command and thereby
135
+ makes it its own.
136
+
137
+ This method takes no arguments: the command declares no parameters, and
138
+ no request parameter is passed through. The health method probes no
139
+ dependency of the service directly; all probing is delegated to the
140
+ service itself through the invocation seam.
141
+
142
+ Returns:
143
+ The composed report of the service's liveness and its dependencies,
144
+ exactly as the service published it. No recomputation, no overall
145
+ status derivation, and no reinterpretation of the health report
146
+ occurs here - the answer is what the service returns.
147
+ """
148
+ return await self._invoke("health", None)