synth-code 0.0.1__py3-none-macosx_15_0_arm64.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.
Files changed (110) hide show
  1. synth_code/__init__.py +0 -0
  2. synth_code/account.py +551 -0
  3. synth_code/account_http.py +86 -0
  4. synth_code/account_refusal.py +80 -0
  5. synth_code/accounting.py +148 -0
  6. synth_code/activity_grouping.py +149 -0
  7. synth_code/agent_panels.py +127 -0
  8. synth_code/approvals.py +397 -0
  9. synth_code/blobs.py +31 -0
  10. synth_code/cli.py +734 -0
  11. synth_code/client.py +413 -0
  12. synth_code/composer_delivery.py +139 -0
  13. synth_code/conversation.py +949 -0
  14. synth_code/daemon.py +34 -0
  15. synth_code/edition.py +306 -0
  16. synth_code/enrollment.py +304 -0
  17. synth_code/file_edit_facts.py +10 -0
  18. synth_code/freeze.py +234 -0
  19. synth_code/grant.py +59 -0
  20. synth_code/history.py +140 -0
  21. synth_code/history_generated.py +219 -0
  22. synth_code/history_wire.py +166 -0
  23. synth_code/image_input.py +109 -0
  24. synth_code/image_preview.py +105 -0
  25. synth_code/legacy_history.py +161 -0
  26. synth_code/live_turns.py +171 -0
  27. synth_code/model_picker.py +311 -0
  28. synth_code/native/manifest.json +1 -0
  29. synth_code/native/synth-code-runtime +0 -0
  30. synth_code/native.py +95 -0
  31. synth_code/oauth.py +284 -0
  32. synth_code/operator.py +116 -0
  33. synth_code/pack_source.py +65 -0
  34. synth_code/panel_request.py +291 -0
  35. synth_code/panels.py +40 -0
  36. synth_code/plugin_host.py +459 -0
  37. synth_code/protocol.py +35 -0
  38. synth_code/provider.py +313 -0
  39. synth_code/provider_fault.py +173 -0
  40. synth_code/provider_frames.py +571 -0
  41. synth_code/recommendation.py +324 -0
  42. synth_code/report.py +72 -0
  43. synth_code/research_events.py +44 -0
  44. synth_code/research_trace.py +449 -0
  45. synth_code/rex_view.py +58 -0
  46. synth_code/runtime_refusal.py +108 -0
  47. synth_code/schema/budgets.json +17 -0
  48. synth_code/schema/history-v2.json +1002 -0
  49. synth_code/session.py +291 -0
  50. synth_code/shoal.py +564 -0
  51. synth_code/side_panel.py +309 -0
  52. synth_code/skills.py +269 -0
  53. synth_code/slash.py +425 -0
  54. synth_code/source_view.py +135 -0
  55. synth_code/starter.json +13 -0
  56. synth_code/stdio.py +75 -0
  57. synth_code/stream.py +142 -0
  58. synth_code/subscriptions.py +267 -0
  59. synth_code/synth_authority.py +362 -0
  60. synth_code/synth_extra.py +32 -0
  61. synth_code/terminal.py +817 -0
  62. synth_code/terminal_journal.py +284 -0
  63. synth_code/terminal_layout.py +643 -0
  64. synth_code/terminal_surfaces.py +470 -0
  65. synth_code/terminal_viewport.py +125 -0
  66. synth_code/tool_render.py +86 -0
  67. synth_code/transcript_frames.py +212 -0
  68. synth_code/transcript_placement.py +63 -0
  69. synth_code/transcript_rows.py +456 -0
  70. synth_code/transport.py +243 -0
  71. synth_code/v001_history.py +468 -0
  72. synth_code/view.py +854 -0
  73. synth_code/views/__init__.py +93 -0
  74. synth_code/views/charts.py +196 -0
  75. synth_code/views/curses_adapter.py +116 -0
  76. synth_code/views/engine.py +170 -0
  77. synth_code/views/model.py +226 -0
  78. synth_code/views/primitives.py +270 -0
  79. synth_code/views/tiling.py +124 -0
  80. synth_code-0.0.1.dist-info/METADATA +50 -0
  81. synth_code-0.0.1.dist-info/RECORD +110 -0
  82. synth_code-0.0.1.dist-info/WHEEL +5 -0
  83. synth_code-0.0.1.dist-info/entry_points.txt +6 -0
  84. synth_code-0.0.1.dist-info/licenses/temper/LICENSE-APACHE +190 -0
  85. synth_code-0.0.1.dist-info/licenses/temper/LICENSE-MIT +21 -0
  86. synth_code-0.0.1.dist-info/licenses/temper/SOURCE.json +433 -0
  87. synth_code-0.0.1.dist-info/top_level.txt +2 -0
  88. synth_code_plugins/_sdk/__init__.py +19 -0
  89. synth_code_plugins/_sdk/callback_wire.py +240 -0
  90. synth_code_plugins/_sdk/callbacks.py +317 -0
  91. synth_code_plugins/_sdk/compliance.py +51 -0
  92. synth_code_plugins/_sdk/contracts.py +236 -0
  93. synth_code_plugins/_sdk/discovery.py +75 -0
  94. synth_code_plugins/_sdk/job_binding.py +71 -0
  95. synth_code_plugins/_sdk/lifecycle.py +50 -0
  96. synth_code_plugins/_sdk/lifecycle_generated.py +15 -0
  97. synth_code_plugins/_sdk/manifest.py +269 -0
  98. synth_code_plugins/_sdk/pack.py +332 -0
  99. synth_code_plugins/_sdk/push.py +98 -0
  100. synth_code_plugins/_sdk/records.py +26 -0
  101. synth_code_plugins/_sdk/registry.py +491 -0
  102. synth_code_plugins/_sdk/schemas.py +210 -0
  103. synth_code_plugins/_sdk/sources.py +230 -0
  104. synth_code_plugins/_sdk/surfaces.py +54 -0
  105. synth_code_plugins/_sdk/tools.py +172 -0
  106. synth_code_plugins/_sdk/worker_memory.py +49 -0
  107. synth_code_plugins/core/SKILL.md +6 -0
  108. synth_code_plugins/core/__init__.py +21 -0
  109. synth_code_plugins/core/plugin.toml +44 -0
  110. synth_code_plugins/core/source.py +18 -0
@@ -0,0 +1,26 @@
1
+ """Strict bounded record helpers shared by bundled pack schemas."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .contracts import JsonObject
6
+
7
+
8
+ def record(required: tuple[str, ...] = (), **properties: JsonObject) -> JsonObject:
9
+ return {
10
+ "type": "object",
11
+ "properties": properties,
12
+ **({"required": list(required)} if required else {}),
13
+ "additionalProperties": False,
14
+ }
15
+
16
+
17
+ def text(limit: int = 256) -> JsonObject:
18
+ return {"type": "string", "maxLength": limit}
19
+
20
+
21
+ def sequence(items: JsonObject, maximum: int = 32) -> JsonObject:
22
+ return {"type": "array", "maxItems": maximum, "items": items}
23
+
24
+
25
+ COUNT: JsonObject = {"type": ["integer", "null"]}
26
+ NUMBER: JsonObject = {"type": ["number", "null"]}
@@ -0,0 +1,491 @@
1
+ """Typed registration and isolated dispatch for fixture plugins."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from collections.abc import Callable, Collection, Mapping
7
+ from concurrent.futures import Future
8
+ from functools import partial
9
+ from threading import Event
10
+ from types import MappingProxyType
11
+ from typing import TypeVar
12
+
13
+ from .callback_wire import MAX_RENDER_LINE_CHARS, MAX_RENDER_ROWS
14
+ from .callbacks import CallbackCache, CallbackState, CallbackWorkers
15
+ from .contracts import (
16
+ MAX_CONTEXT_CHARS,
17
+ MAX_PAYLOAD_BYTES,
18
+ Activation,
19
+ ApprovalTier,
20
+ ContractError,
21
+ Health,
22
+ JsonObject,
23
+ Lifecycle,
24
+ Manifest,
25
+ Permission,
26
+ Pin,
27
+ Refusal,
28
+ RefusalCode,
29
+ ToolReceipt,
30
+ ViewSpec,
31
+ )
32
+ from .lifecycle import Action, PluginLifecycle
33
+ from .manifest import load_manifest
34
+ from .schemas import SchemaCatalog
35
+ from .sources import SourceCapture, SourceProjection
36
+ from .surfaces import (
37
+ ContextSnapshot,
38
+ Entrypoints,
39
+ RenderedView,
40
+ RenderRequest,
41
+ display_line,
42
+ )
43
+
44
+ __all__ = ("FixturePlugin", "PluginRegistry")
45
+
46
+ T = TypeVar("T")
47
+
48
+
49
+ def _read_context(plugin: str, callback: Callable[[], ContextSnapshot]) -> ContextSnapshot:
50
+ snapshot = callback()
51
+ if (
52
+ not isinstance(snapshot, ContextSnapshot)
53
+ or type(snapshot.text) is not str
54
+ or not isinstance(snapshot.health, Health)
55
+ ):
56
+ raise ContractError(
57
+ Refusal(
58
+ RefusalCode.OUTPUT_INVALID,
59
+ plugin,
60
+ "context",
61
+ "expected typed context text and health",
62
+ )
63
+ )
64
+ clean_text = display_line(snapshot.text)
65
+ return ContextSnapshot(clean_text[:MAX_CONTEXT_CHARS], snapshot.health)
66
+
67
+
68
+ def _render_view(
69
+ plugin: str,
70
+ callback: Callable[[RenderRequest], tuple[str, ...]],
71
+ view: ViewSpec,
72
+ sources: dict[str, SourceCapture],
73
+ cursors: dict[str, bytes],
74
+ ) -> RenderedView:
75
+ request = RenderRequest(
76
+ view,
77
+ MappingProxyType({key: source.snapshot() for key, source in sources.items()}),
78
+ MappingProxyType({key: json.loads(payload) for key, payload in cursors.items()}),
79
+ )
80
+ lines = callback(request)
81
+ if type(lines) is not tuple or len(lines) > MAX_RENDER_ROWS:
82
+ raise ContractError(
83
+ Refusal(
84
+ RefusalCode.OUTPUT_INVALID,
85
+ plugin,
86
+ request.view.id,
87
+ "renderer must return a bounded tuple of lines",
88
+ expected=MAX_RENDER_ROWS,
89
+ )
90
+ )
91
+ if any(type(line) is not str or len(line) > MAX_RENDER_LINE_CHARS for line in lines):
92
+ raise ContractError(
93
+ Refusal(
94
+ RefusalCode.OUTPUT_INVALID,
95
+ plugin,
96
+ request.view.id,
97
+ "renderer line exceeds type or character budget",
98
+ expected=MAX_RENDER_LINE_CHARS,
99
+ )
100
+ )
101
+ return RenderedView(
102
+ tuple(display_line(line) for line in lines),
103
+ tuple((key, source.health) for key, source in request.sources.items()),
104
+ )
105
+
106
+
107
+ class FixturePlugin:
108
+ """One plugin's independent source, tool, cursor, and renderer state."""
109
+
110
+ def __init__(
111
+ self,
112
+ manifest: Manifest,
113
+ schemas: SchemaCatalog,
114
+ entrypoints: Entrypoints,
115
+ workers: CallbackWorkers,
116
+ ) -> None:
117
+ self.manifest = manifest
118
+ self._schemas = schemas
119
+ self._lifecycle = PluginLifecycle()
120
+ self._workers = workers
121
+ self._context_cache: CallbackCache[ContextSnapshot] = CallbackCache()
122
+ self._view_caches: dict[str, CallbackCache[RenderedView]] = {}
123
+ self._sources = {
124
+ spec.id: SourceProjection(manifest.id, spec, schemas, self._active)
125
+ for spec in manifest.sources
126
+ }
127
+ self._panels = {spec.id: spec for spec in manifest.panels}
128
+ self._views = {spec.id: spec for spec in manifest.views}
129
+ self._cursors = {spec.id: spec for spec in manifest.cursors}
130
+ self._cursor_values: dict[str, bytes] = {}
131
+ self._verbs = (
132
+ {verb.id: verb for verb in manifest.tool.verbs} if manifest.tool is not None else {}
133
+ )
134
+ declarations = manifest.entrypoints
135
+ self._skill = self._resolve(declarations.skill, entrypoints.skills, "skill")
136
+ self._context = self._resolve(declarations.context, entrypoints.contexts, "context")
137
+ self._render = self._resolve(declarations.renderer, entrypoints.renderers, "renderer")
138
+ self._tool = self._resolve(declarations.tool, entrypoints.tools, "tool")
139
+ self._failures: dict[tuple[str, str], Refusal] = {}
140
+ self._lifecycle.advance(Action.VALIDATE)
141
+
142
+ @property
143
+ def state(self) -> Lifecycle:
144
+ if self._lifecycle.serving:
145
+ degraded = bool(
146
+ self._failures
147
+ or isinstance(self._context_cache.collect(), Refusal)
148
+ or any(isinstance(cache.collect(), Refusal) for cache in self._view_caches.values())
149
+ or any(source.refusal is not None for source in self._sources.values())
150
+ )
151
+ self._lifecycle.observe_health(degraded=degraded)
152
+ return self._lifecycle.phase
153
+
154
+ def mount(self, grants: Collection[Permission]) -> Refusal | None:
155
+ if not self._lifecycle.permits(Action.MOUNT):
156
+ return self._refusal(
157
+ RefusalCode.INACTIVE, "mount", "mount requires validated or unmounted state"
158
+ )
159
+ missing = self.manifest.permissions.difference(grants)
160
+ if missing:
161
+ return self._refusal(
162
+ RefusalCode.PERMISSION_DENIED, "mount", f"missing grants {sorted(missing)}"
163
+ )
164
+ self._lifecycle.advance(Action.MOUNT)
165
+ return None
166
+
167
+ def activate(
168
+ self,
169
+ *,
170
+ workspace_detected: bool = False,
171
+ explicit: bool = False,
172
+ ) -> Refusal | None:
173
+ if not self._lifecycle.permits(Action.ACTIVATE):
174
+ return self._refusal(
175
+ RefusalCode.INACTIVE, "activate", "activation requires mounted state"
176
+ )
177
+ trigger = self.manifest.activation
178
+ if (trigger is Activation.WORKSPACE_DETECT and not workspace_detected) or (
179
+ trigger is Activation.EXPLICIT and not explicit
180
+ ):
181
+ return self._refusal(
182
+ RefusalCode.INACTIVE, "activate", f"activation requires {trigger.value}"
183
+ )
184
+ self._lifecycle.advance(Action.ACTIVATE)
185
+ return None
186
+
187
+ def unmount(self) -> None:
188
+ self._lifecycle.advance(Action.UNMOUNT)
189
+ self._failures.clear()
190
+ self._context_cache.cancel()
191
+ self._context_cache = CallbackCache()
192
+ for cache in self._view_caches.values():
193
+ cache.cancel()
194
+ self._view_caches.clear()
195
+ self._cursor_values.clear()
196
+ for source in self._sources.values():
197
+ source.reset_live()
198
+
199
+ def skill(self) -> str | None:
200
+ return self._skill if self._active() else None
201
+
202
+ def source(self, source_id: str) -> SourceProjection | Refusal:
203
+ if not self._active():
204
+ return self._refusal(
205
+ RefusalCode.INACTIVE, source_id, "source requires an active plugin"
206
+ )
207
+ source = self._sources.get(source_id)
208
+ if source is None:
209
+ return self._refusal(RefusalCode.NOT_FOUND, source_id, "source is not declared")
210
+ return source
211
+
212
+ def context(self, revision: int) -> CallbackState[ContextSnapshot]:
213
+ if not self._active() or self._context is None:
214
+ return CallbackState(None, pending=False)
215
+ return self._context_cache.refresh(
216
+ revision,
217
+ lambda cancelled: self._workers.submit(
218
+ self.manifest.id,
219
+ "context",
220
+ partial(_read_context, self.manifest.id, self._context),
221
+ cancelled,
222
+ result_type=ContextSnapshot,
223
+ ),
224
+ )
225
+
226
+ def render(self, view_id: str) -> CallbackState[RenderedView]:
227
+ if not self._active():
228
+ return CallbackState(
229
+ self._refusal(
230
+ RefusalCode.INACTIVE,
231
+ view_id,
232
+ "render requires an active plugin",
233
+ ),
234
+ pending=False,
235
+ )
236
+ view = self._views.get(view_id)
237
+ if view is None:
238
+ return CallbackState(
239
+ self._refusal(
240
+ RefusalCode.NOT_FOUND,
241
+ view_id,
242
+ "view is not declared",
243
+ ),
244
+ pending=False,
245
+ )
246
+ assert self._render is not None
247
+ sources = self._panels[view.panel].sources
248
+ key = (
249
+ tuple(self._sources[source_id].revision for source_id in sources),
250
+ tuple(self._cursor_values.get(cursor_id) for cursor_id in view.consumes),
251
+ )
252
+ cache = self._view_caches.get(view_id)
253
+ if cache is None:
254
+ cache = CallbackCache()
255
+ self._view_caches[view_id] = cache
256
+ render = self._render
257
+
258
+ def start(cancelled: Event) -> Future[RenderedView | Refusal] | Refusal:
259
+ captured_sources = {
260
+ source_id: self._sources[source_id].capture() for source_id in sources
261
+ }
262
+ captured_cursors = {
263
+ cursor_id: self._cursor_values[cursor_id]
264
+ for cursor_id in view.consumes
265
+ if cursor_id in self._cursor_values
266
+ }
267
+ return self._workers.submit(
268
+ self.manifest.id,
269
+ view_id,
270
+ partial(
271
+ _render_view, self.manifest.id, render, view, captured_sources, captured_cursors
272
+ ),
273
+ cancelled,
274
+ result_type=RenderedView,
275
+ source_ids=sources,
276
+ )
277
+
278
+ return cache.refresh(key, start)
279
+
280
+ def await_context(self, revision: int) -> ContextSnapshot | Refusal | None:
281
+ """Collect a bounded result in fixture tests outside any paint loop."""
282
+ state = self.context(revision)
283
+ return self._context_cache.collect(wait=True) if state.pending else state.latest
284
+
285
+ def await_render(self, view_id: str) -> RenderedView | Refusal | None:
286
+ """Collect a bounded result in fixture tests outside any paint loop."""
287
+ state = self.render(view_id)
288
+ return self._view_caches[view_id].collect(wait=True) if state.pending else state.latest
289
+
290
+ def emit_cursor(self, view_id: str, cursor_id: str, value: JsonObject) -> Refusal | None:
291
+ if not self._active():
292
+ return self._refusal(
293
+ RefusalCode.INACTIVE, view_id, "cursor emission requires an active plugin"
294
+ )
295
+ view = self._views.get(view_id)
296
+ if view is None or cursor_id not in view.emits:
297
+ return self._refusal(
298
+ RefusalCode.NOT_FOUND, view_id, f"view cannot emit cursor {cursor_id!r}"
299
+ )
300
+ spec = self._cursors[cursor_id]
301
+ try:
302
+ encoded = self._schemas.encode(spec.schema_ref, cursor_id, value, MAX_PAYLOAD_BYTES)
303
+ except ContractError as error:
304
+ return error.refusal
305
+ self._cursor_values[cursor_id] = encoded
306
+ return None
307
+
308
+ def call_tool(
309
+ self,
310
+ verb_id: str,
311
+ arguments: JsonObject,
312
+ *,
313
+ approval: ApprovalTier = ApprovalTier.READ,
314
+ ) -> ToolReceipt | Refusal:
315
+ if not self._active():
316
+ return self._refusal(RefusalCode.INACTIVE, verb_id, "tool requires an active plugin")
317
+ verb = self._verbs.get(verb_id)
318
+ if verb is None:
319
+ return self._refusal(RefusalCode.NOT_FOUND, verb_id, "tool verb is not declared")
320
+ if verb.approval is not ApprovalTier.READ and approval is not verb.approval:
321
+ return self._refusal(
322
+ RefusalCode.APPROVAL_REQUIRED,
323
+ verb_id,
324
+ "tool verb approval required",
325
+ expected=verb.approval.value,
326
+ )
327
+ try:
328
+ encoded = self._schemas.encode(
329
+ verb.input_schema_ref, verb_id, arguments, MAX_PAYLOAD_BYTES
330
+ )
331
+ except ContractError as error:
332
+ return error.refusal
333
+ return self._invoke(
334
+ "tool",
335
+ verb_id,
336
+ lambda: self._call_tool(verb_id, json.loads(encoded), verb.output_schema_ref),
337
+ )
338
+
339
+ def _active(self) -> bool:
340
+ return self._lifecycle.serving
341
+
342
+ def _resolve(self, key: str | None, catalog: Mapping[str, T], subject: str) -> T | None:
343
+ if key is None:
344
+ return None
345
+ if key not in catalog:
346
+ raise ContractError(
347
+ self._refusal(
348
+ RefusalCode.MANIFEST_INVALID,
349
+ subject,
350
+ f"entrypoint {key!r} has no fixture binding",
351
+ )
352
+ )
353
+ return catalog[key]
354
+
355
+ def _invoke(self, surface: str, subject: str, callback: Callable[[], T]) -> T | Refusal:
356
+ key = (surface, subject)
357
+ try:
358
+ output = callback()
359
+ except ContractError as error:
360
+ self._failures[key] = error.refusal
361
+ return error.refusal
362
+ except Exception as error: # noqa: BLE001 - third-party callback isolation boundary
363
+ refusal = self._refusal(
364
+ RefusalCode.CALLBACK_FAILED,
365
+ subject,
366
+ f"{surface} callback raised {type(error).__name__}",
367
+ )
368
+ self._failures[key] = refusal
369
+ return refusal
370
+ self._failures.pop(key, None)
371
+ return output
372
+
373
+ def _call_tool(
374
+ self, verb_id: str, arguments: JsonObject, output_schema_ref: str
375
+ ) -> ToolReceipt:
376
+ assert self._tool is not None
377
+ receipt = self._tool(verb_id, arguments)
378
+ if not isinstance(receipt, ToolReceipt):
379
+ raise ContractError(
380
+ self._refusal(
381
+ RefusalCode.OUTPUT_INVALID,
382
+ verb_id,
383
+ "tool must return a typed receipt",
384
+ )
385
+ )
386
+ if receipt.pin is not None:
387
+ if (
388
+ not isinstance(receipt.pin, Pin)
389
+ or type(receipt.pin.view_id) is not str
390
+ or type(receipt.pin.source_id) is not str
391
+ ):
392
+ raise ContractError(
393
+ self._refusal(
394
+ RefusalCode.OUTPUT_INVALID,
395
+ verb_id,
396
+ "tool pin must be a typed source/view link",
397
+ )
398
+ )
399
+ view = self._views.get(receipt.pin.view_id)
400
+ if view is None or receipt.pin.source_id not in self._panels[view.panel].sources:
401
+ raise ContractError(
402
+ self._refusal(
403
+ RefusalCode.OUTPUT_INVALID,
404
+ verb_id,
405
+ "pin must bind a declared view to one of its sources",
406
+ )
407
+ )
408
+ encoded = self._schemas.encode(
409
+ output_schema_ref, verb_id, receipt.result, MAX_PAYLOAD_BYTES
410
+ )
411
+ return ToolReceipt(json.loads(encoded), receipt.pin)
412
+
413
+ def _refusal(
414
+ self,
415
+ code: RefusalCode,
416
+ subject: str,
417
+ detail: str,
418
+ expected: str | None = None,
419
+ ) -> Refusal:
420
+ return Refusal(code, self.manifest.id, subject, detail, expected)
421
+
422
+
423
+ class PluginRegistry:
424
+ """Fixture host with a fixed dialect/version catalog and no discovery side effects."""
425
+
426
+ def __init__(
427
+ self, dialect_versions: Mapping[str, int], *, callback_timeout_s: float = 1.0
428
+ ) -> None:
429
+ self._dialect_versions = dict(dialect_versions)
430
+ self._plugins: dict[str, FixturePlugin] = {}
431
+ self._workers = CallbackWorkers(callback_timeout_s)
432
+
433
+ def close(self) -> None:
434
+ for plugin in self._plugins.values():
435
+ plugin.unmount()
436
+ self._workers.close()
437
+
438
+ def register(
439
+ self,
440
+ manifest_toml: str,
441
+ schemas: Mapping[str, JsonObject],
442
+ entrypoints: Entrypoints,
443
+ ) -> FixturePlugin:
444
+ manifest = load_manifest(manifest_toml)
445
+ if manifest.id in self._plugins:
446
+ raise ContractError(
447
+ Refusal(
448
+ RefusalCode.DUPLICATE_PLUGIN,
449
+ manifest.id,
450
+ "plugin.toml",
451
+ "plugin ID is already registered",
452
+ )
453
+ )
454
+ catalog = SchemaCatalog(manifest.id, schemas)
455
+ for source in manifest.sources:
456
+ expected = self._dialect_versions.get(source.dialect)
457
+ if expected is None:
458
+ raise ContractError(
459
+ Refusal(
460
+ RefusalCode.DIALECT_UNKNOWN,
461
+ manifest.id,
462
+ source.id,
463
+ f"unsupported source dialect {source.dialect!r}",
464
+ actual=source.dialect,
465
+ )
466
+ )
467
+ if expected != source.dialect_version:
468
+ raise ContractError(
469
+ Refusal(
470
+ RefusalCode.DIALECT_VERSION,
471
+ manifest.id,
472
+ source.id,
473
+ "unsupported source dialect version",
474
+ expected=expected,
475
+ actual=source.dialect_version,
476
+ )
477
+ )
478
+ catalog.require(source.schema_ref, source.id)
479
+ for cursor in manifest.cursors:
480
+ catalog.require(cursor.schema_ref, cursor.id)
481
+ if manifest.tool is not None:
482
+ for verb in manifest.tool.verbs:
483
+ catalog.require(verb.input_schema_ref, verb.id)
484
+ catalog.require(verb.output_schema_ref, verb.id)
485
+
486
+ plugin = FixturePlugin(manifest, catalog, entrypoints, self._workers)
487
+ self._plugins[manifest.id] = plugin
488
+ return plugin
489
+
490
+ def get(self, plugin_id: str) -> FixturePlugin | None:
491
+ return self._plugins.get(plugin_id)