muse-code-sdk 1.3.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 (60) hide show
  1. muse_code_sdk-1.3.0/LICENSE +21 -0
  2. muse_code_sdk-1.3.0/PKG-INFO +47 -0
  3. muse_code_sdk-1.3.0/README.md +28 -0
  4. muse_code_sdk-1.3.0/pyproject.toml +43 -0
  5. muse_code_sdk-1.3.0/setup.cfg +4 -0
  6. muse_code_sdk-1.3.0/src/muse_code/__init__.py +129 -0
  7. muse_code_sdk-1.3.0/src/muse_code/connection/__init__.py +49 -0
  8. muse_code_sdk-1.3.0/src/muse_code/connection/connection.py +905 -0
  9. muse_code_sdk-1.3.0/src/muse_code/connection/discovery.py +55 -0
  10. muse_code_sdk-1.3.0/src/muse_code/connection/spawn.py +1067 -0
  11. muse_code_sdk-1.3.0/src/muse_code/connection/validation.py +149 -0
  12. muse_code_sdk-1.3.0/src/muse_code/errors.py +199 -0
  13. muse_code_sdk-1.3.0/src/muse_code/facade/__init__.py +89 -0
  14. muse_code_sdk-1.3.0/src/muse_code/facade/approval.py +279 -0
  15. muse_code_sdk-1.3.0/src/muse_code/facade/client.py +444 -0
  16. muse_code_sdk-1.3.0/src/muse_code/facade/discarded.py +45 -0
  17. muse_code_sdk-1.3.0/src/muse_code/facade/gap_fill.py +483 -0
  18. muse_code_sdk-1.3.0/src/muse_code/facade/host_death.py +254 -0
  19. muse_code_sdk-1.3.0/src/muse_code/facade/session.py +977 -0
  20. muse_code_sdk-1.3.0/src/muse_code/facade/turn_handle.py +440 -0
  21. muse_code_sdk-1.3.0/src/muse_code/facade/turn_submit.py +289 -0
  22. muse_code_sdk-1.3.0/src/muse_code/fold/__init__.py +82 -0
  23. muse_code_sdk-1.3.0/src/muse_code/fold/item_store.py +268 -0
  24. muse_code_sdk-1.3.0/src/muse_code/fold/session_fold.py +785 -0
  25. muse_code_sdk-1.3.0/src/muse_code/fold/state_store.py +141 -0
  26. muse_code_sdk-1.3.0/src/muse_code/pending/__init__.py +53 -0
  27. muse_code_sdk-1.3.0/src/muse_code/pending/pending_command_set.py +842 -0
  28. muse_code_sdk-1.3.0/src/muse_code/py.typed +0 -0
  29. muse_code_sdk-1.3.0/src/muse_code/replay.py +144 -0
  30. muse_code_sdk-1.3.0/src/muse_code/sync_facade.py +493 -0
  31. muse_code_sdk-1.3.0/src/muse_code_sdk.egg-info/PKG-INFO +47 -0
  32. muse_code_sdk-1.3.0/src/muse_code_sdk.egg-info/SOURCES.txt +58 -0
  33. muse_code_sdk-1.3.0/src/muse_code_sdk.egg-info/dependency_links.txt +1 -0
  34. muse_code_sdk-1.3.0/src/muse_code_sdk.egg-info/requires.txt +1 -0
  35. muse_code_sdk-1.3.0/src/muse_code_sdk.egg-info/top_level.txt +1 -0
  36. muse_code_sdk-1.3.0/tests/test_asyncio_cancellation.py +253 -0
  37. muse_code_sdk-1.3.0/tests/test_compatibility_row.py +189 -0
  38. muse_code_sdk-1.3.0/tests/test_connection.py +735 -0
  39. muse_code_sdk-1.3.0/tests/test_connection_error_arms.py +624 -0
  40. muse_code_sdk-1.3.0/tests/test_docs_generation.py +94 -0
  41. muse_code_sdk-1.3.0/tests/test_facade_approval.py +750 -0
  42. muse_code_sdk-1.3.0/tests/test_facade_gap_fill.py +920 -0
  43. muse_code_sdk-1.3.0/tests/test_facade_persistent_approval.py +142 -0
  44. muse_code_sdk-1.3.0/tests/test_facade_turn.py +1217 -0
  45. muse_code_sdk-1.3.0/tests/test_host_discovery.py +618 -0
  46. muse_code_sdk-1.3.0/tests/test_item_store.py +169 -0
  47. muse_code_sdk-1.3.0/tests/test_manifests.py +130 -0
  48. muse_code_sdk-1.3.0/tests/test_muse_serve_child.py +1121 -0
  49. muse_code_sdk-1.3.0/tests/test_pending_command_corpus.py +181 -0
  50. muse_code_sdk-1.3.0/tests/test_pending_command_set.py +528 -0
  51. muse_code_sdk-1.3.0/tests/test_pending_command_wire_binding.py +145 -0
  52. muse_code_sdk-1.3.0/tests/test_publish_shape.py +369 -0
  53. muse_code_sdk-1.3.0/tests/test_session_fold.py +1161 -0
  54. muse_code_sdk-1.3.0/tests/test_source_closure.py +98 -0
  55. muse_code_sdk-1.3.0/tests/test_spawn_handshake.py +162 -0
  56. muse_code_sdk-1.3.0/tests/test_state_store.py +155 -0
  57. muse_code_sdk-1.3.0/tests/test_sync_facade.py +869 -0
  58. muse_code_sdk-1.3.0/tests/test_tolerance_corpus.py +62 -0
  59. muse_code_sdk-1.3.0/tests/test_transcript_replay.py +113 -0
  60. muse_code_sdk-1.3.0/tests/test_typing_gates.py +193 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Meta Platforms, Inc. and affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: muse-code-sdk
3
+ Version: 1.3.0
4
+ Summary: Muse Code SDK for MSP: asyncio-first facade over the generated wire types (muse-code-msp), with a thin sync wrapper.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/meta-models/muse-code-sdk
7
+ Project-URL: Repository, https://github.com/meta-models/muse-code-sdk
8
+ Project-URL: Issues, https://github.com/meta-models/muse-code-sdk/issues
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Typing :: Typed
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: pydantic==2.13.5
18
+ Dynamic: license-file
19
+
20
+ # `muse-code-sdk`
21
+
22
+ The MSP Python facade (spec `specs/638-muse-sdk-python`; the Python tier of
23
+ tdd SS7.3, chartered by issue #638). Mirrors `@muse-code/sdk`
24
+ (`clients/sdk-ts`): asyncio-first — async iterators for turn streams,
25
+ awaitable approvals — with a thin sync loop-runner for scripts and
26
+ notebooks.
27
+
28
+ **One runtime dependency**: `pydantic`, exact-pinned (the ADR 638 D2
29
+ supply-chain exception, #211 O-3 form). The generated wire types live in
30
+ `muse-code-msp` (`clients/msp-py`) and are never restated here.
31
+
32
+ **Status: S0 skeleton.** The facade surface lands slice by slice
33
+ (`specs/638-muse-sdk-python/plan.md` S1–S4); the first acceptance milestone
34
+ is the quickstart journey against a release-built host. Python 3.10+.
35
+
36
+ ## The loop
37
+
38
+ ```sh
39
+ cd projects/tbh
40
+ python3 -m pip install -r clients/py-dev-requirements.txt
41
+ python3 -m pip install -e clients/msp-py -e clients/sdk-py
42
+ pytest clients/sdk-py/tests
43
+ mypy --strict clients/msp-py/src clients/sdk-py/src
44
+ ```
45
+
46
+ CI runs exactly this in the non-required, path-filtered `tbh-muse-sdk-py`
47
+ workflow, on the floor Python (3.10) and a current one.
@@ -0,0 +1,28 @@
1
+ # `muse-code-sdk`
2
+
3
+ The MSP Python facade (spec `specs/638-muse-sdk-python`; the Python tier of
4
+ tdd SS7.3, chartered by issue #638). Mirrors `@muse-code/sdk`
5
+ (`clients/sdk-ts`): asyncio-first — async iterators for turn streams,
6
+ awaitable approvals — with a thin sync loop-runner for scripts and
7
+ notebooks.
8
+
9
+ **One runtime dependency**: `pydantic`, exact-pinned (the ADR 638 D2
10
+ supply-chain exception, #211 O-3 form). The generated wire types live in
11
+ `muse-code-msp` (`clients/msp-py`) and are never restated here.
12
+
13
+ **Status: S0 skeleton.** The facade surface lands slice by slice
14
+ (`specs/638-muse-sdk-python/plan.md` S1–S4); the first acceptance milestone
15
+ is the quickstart journey against a release-built host. Python 3.10+.
16
+
17
+ ## The loop
18
+
19
+ ```sh
20
+ cd projects/tbh
21
+ python3 -m pip install -r clients/py-dev-requirements.txt
22
+ python3 -m pip install -e clients/msp-py -e clients/sdk-py
23
+ pytest clients/sdk-py/tests
24
+ mypy --strict clients/msp-py/src clients/sdk-py/src
25
+ ```
26
+
27
+ CI runs exactly this in the non-required, path-filtered `tbh-muse-sdk-py`
28
+ workflow, on the floor Python (3.10) and a current one.
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ # >=77: the floor that understands PEP 639 (SPDX license + license-files).
3
+ requires = ["setuptools>=77"]
4
+ build-backend = "setuptools.build_meta"
5
+
6
+ [project]
7
+ name = "muse-code-sdk"
8
+ version = "1.3.0"
9
+ description = "Muse Code SDK for MSP: asyncio-first facade over the generated wire types (muse-code-msp), with a thin sync wrapper."
10
+ readme = "README.md"
11
+ requires-python = ">=3.10"
12
+ license = "MIT"
13
+ license-files = ["LICENSE"]
14
+ # Exactly ONE runtime dependency, exact-pinned: the ADR 638 D2 supply-chain
15
+ # exception (#211 O-3 form). Any second dependency is an owner escalation;
16
+ # bumps are deliberate reviewed PRs (see the ADR's review policy).
17
+ # muse-code-msp is deliberately NOT declared: it is not on the registry yet,
18
+ # and promoting it is the owner escalation decided with the first publish
19
+ # (the @muse-code/msp devDependency precedent; test_publish_shape pins this).
20
+ dependencies = ["pydantic==2.13.5"]
21
+ classifiers = [
22
+ # Alpha states the withheld promise: D-065 (ADR 29534 D1) permits the
23
+ # publish, but D-013's stability promise and conformance claim stay
24
+ # withheld — experimental surfaces may change (ADR 25304 D3).
25
+ "Development Status :: 3 - Alpha",
26
+ "Intended Audience :: Developers",
27
+ "Operating System :: OS Independent",
28
+ "Programming Language :: Python :: 3",
29
+ "Typing :: Typed",
30
+ ]
31
+
32
+ [project.urls]
33
+ # The mirror is the one public venue (ADR 638 D6); a published manifest never
34
+ # names the private producer repository.
35
+ Homepage = "https://github.com/meta-models/muse-code-sdk"
36
+ Repository = "https://github.com/meta-models/muse-code-sdk"
37
+ Issues = "https://github.com/meta-models/muse-code-sdk/issues"
38
+
39
+ [tool.setuptools.packages.find]
40
+ where = ["src"]
41
+
42
+ [tool.setuptools.package-data]
43
+ muse_code = ["py.typed"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,129 @@
1
+ """Muse Code SDK for MSP: the asyncio-first Python facade.
2
+
3
+ Owning spec: ``specs/638-muse-sdk-python`` (governing ADR
4
+ ``docs/adr/638-muse-sdk-python.md``). Wire shapes are imported from the
5
+ generated ``muse_code_msp`` package, never restated here (INV-638-01/02).
6
+
7
+ S1 (the transport-less core) is in: the SS4 fold (``muse_code.fold``), the
8
+ SS4.13 pending set (``muse_code.pending``), the transcript replay runner
9
+ (``muse_code.replay``), and the typed error family (``muse_code.errors``).
10
+ S2 is in: the NDJSON connection machine, the owned-process spawn path, host
11
+ discovery, and the strict fingerprint gate (``muse_code.connection``). S3 is in:
12
+ the asyncio facade (``muse_code.facade`` — ``MuseClient``, ``Session``,
13
+ ``Turn``) with the host-death discharge, the approval/user-input round trip,
14
+ the SS4.8 gap splice-fill, and the sync loop-runner wrapper
15
+ (``muse_code.sync_facade`` — ``SyncMuseClient``).
16
+ """
17
+
18
+ from __future__ import annotations
19
+
20
+ from typing import Final
21
+
22
+ from .errors import (
23
+ GapFillFailureReason,
24
+ MuseForeignSessionError,
25
+ MuseGapFillError,
26
+ MuseSessionDiscardedError,
27
+ )
28
+ from .fold import ItemStore, SessionFold, SessionStateStore
29
+ from .pending import PendingCommandSet
30
+ from .replay import Transcript, load_transcript, replay_into_fold, transcript_dirs
31
+
32
+ __all__ = [
33
+ "EXPECTED_SCHEMA_FINGERPRINT",
34
+ "ApprovalDecisionInput",
35
+ "ApprovalFailure",
36
+ "ApprovalFailureHandler",
37
+ "ApprovalHandler",
38
+ "DiscardedSessions",
39
+ "GapFillFailureHandler",
40
+ "GapFillFailureReason",
41
+ "HostDeathDischarge",
42
+ "HostDeathNotification",
43
+ "ItemStore",
44
+ "MuseClient",
45
+ "MuseClientOptions",
46
+ "MuseClientSpawnOptions",
47
+ "MuseForeignSessionError",
48
+ "MuseGapFillError",
49
+ "MuseHostDiedError",
50
+ "MuseSessionDiscardedError",
51
+ "PendingCommandSet",
52
+ "PendingCommandView",
53
+ "ResumeSessionOptions",
54
+ "SendUserTurnOptions",
55
+ "Session",
56
+ "SessionApplyOutcome",
57
+ "SessionDurabilityProfile",
58
+ "SessionFold",
59
+ "SessionFoldView",
60
+ "SessionGapBuffered",
61
+ "SessionGapOverlap",
62
+ "SessionStateStore",
63
+ "StartSessionOptions",
64
+ "SyncMuseClient",
65
+ "SyncSession",
66
+ "SyncTurn",
67
+ "Transcript",
68
+ "TransportEof",
69
+ "Turn",
70
+ "TurnOutcome",
71
+ "is_abnormal_host_death",
72
+ "is_launch_failure",
73
+ "load_transcript",
74
+ "read_session_durability",
75
+ "replay_into_fold",
76
+ "transcript_dirs",
77
+ ]
78
+
79
+ EXPECTED_SCHEMA_FINGERPRINT: Final[str] = (
80
+ "sha256:ab69549a7ebb423fce94068762da0b5ff3cdec1f8fc263dcc17248eda117f852"
81
+ )
82
+ """The stable schema-bundle fingerprint this SDK was built against.
83
+
84
+ The one deliberately duplicated fact (spec 638 FR-638-006, the 14990 FR-006
85
+ pattern): ``clients/sdk-py/tests/test_manifests.py`` binds it to
86
+ ``schema/msp/stable/manifest.json``, so a schema advance that forgets the
87
+ Python SDK reds this lane instead of drifting silently.
88
+ """
89
+
90
+ # D-063 lockstep (ADR 25304 D4): the release train bumps pyproject.toml, the
91
+ # distribution-metadata authority; this constant is aligned at publication
92
+ # time (the publish itself is owner-run, permitted by D-065, ADR 29534 D1).
93
+ __version__: Final[str] = "1.3.0"
94
+
95
+ # The facade is imported last so the constants above are already bound: the
96
+ # spawn path reads ``EXPECTED_SCHEMA_FINGERPRINT`` (lazily, at initialize
97
+ # time), and importing the facade first would risk a partially initialized
98
+ # module.
99
+ from .facade import ( # noqa: E402
100
+ ApprovalDecisionInput,
101
+ ApprovalFailure,
102
+ ApprovalFailureHandler,
103
+ ApprovalHandler,
104
+ DiscardedSessions,
105
+ GapFillFailureHandler,
106
+ HostDeathDischarge,
107
+ HostDeathNotification,
108
+ MuseClient,
109
+ MuseClientOptions,
110
+ MuseClientSpawnOptions,
111
+ MuseHostDiedError,
112
+ PendingCommandView,
113
+ ResumeSessionOptions,
114
+ SendUserTurnOptions,
115
+ Session,
116
+ SessionApplyOutcome,
117
+ SessionDurabilityProfile,
118
+ SessionFoldView,
119
+ SessionGapBuffered,
120
+ SessionGapOverlap,
121
+ StartSessionOptions,
122
+ TransportEof,
123
+ Turn,
124
+ TurnOutcome,
125
+ is_abnormal_host_death,
126
+ is_launch_failure,
127
+ read_session_durability,
128
+ )
129
+ from .sync_facade import SyncMuseClient, SyncSession, SyncTurn # noqa: E402
@@ -0,0 +1,49 @@
1
+ """The MSP connection plane (spec 638 FR-638-011..018): the transport-less
2
+ NDJSON connection machine, the owned-process spawn path, and host discovery.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ from .connection import (
8
+ Connection,
9
+ DuplexTransport,
10
+ MspError,
11
+ NotificationHandler,
12
+ Params,
13
+ ProtocolError,
14
+ ProtocolErrorHandler,
15
+ RetryDelay,
16
+ ServerRequestHandler,
17
+ create_uuid_v7_mint,
18
+ )
19
+ from .discovery import discover_muse_bin
20
+ from .spawn import (
21
+ ConnectionOptions,
22
+ ExitClassification,
23
+ MspHandshake,
24
+ MuseServeChild,
25
+ ProcessExit,
26
+ SpawnedMspConnection,
27
+ spawn_msp_connection,
28
+ )
29
+
30
+ __all__ = [
31
+ "Connection",
32
+ "ConnectionOptions",
33
+ "DuplexTransport",
34
+ "ExitClassification",
35
+ "MspError",
36
+ "MspHandshake",
37
+ "MuseServeChild",
38
+ "NotificationHandler",
39
+ "Params",
40
+ "ProcessExit",
41
+ "ProtocolError",
42
+ "ProtocolErrorHandler",
43
+ "RetryDelay",
44
+ "ServerRequestHandler",
45
+ "SpawnedMspConnection",
46
+ "create_uuid_v7_mint",
47
+ "discover_muse_bin",
48
+ "spawn_msp_connection",
49
+ ]