parmana 1.0.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 (54) hide show
  1. parmana-1.0.0/LICENSE +0 -0
  2. parmana-1.0.0/PKG-INFO +45 -0
  3. parmana-1.0.0/README.md +22 -0
  4. parmana-1.0.0/parmana/__init__.py +38 -0
  5. parmana-1.0.0/parmana/api/__init__.py +21 -0
  6. parmana-1.0.0/parmana/api/execution_api.py +73 -0
  7. parmana-1.0.0/parmana/api/policy_api.py +56 -0
  8. parmana-1.0.0/parmana/api/receipt_api.py +58 -0
  9. parmana-1.0.0/parmana/api/replay_api.py +59 -0
  10. parmana-1.0.0/parmana/api/transaction_api.py +84 -0
  11. parmana-1.0.0/parmana/api/trust_record_api.py +55 -0
  12. parmana-1.0.0/parmana/api/verification_api.py +58 -0
  13. parmana-1.0.0/parmana/client.py +121 -0
  14. parmana-1.0.0/parmana/config/__init__.py +0 -0
  15. parmana-1.0.0/parmana/config/client_config.py +10 -0
  16. parmana-1.0.0/parmana/config/transport.py +23 -0
  17. parmana-1.0.0/parmana/errors/__init__.py +9 -0
  18. parmana-1.0.0/parmana/errors/api_error.py +19 -0
  19. parmana-1.0.0/parmana/errors/network_error.py +22 -0
  20. parmana-1.0.0/parmana/errors/runtime_error.py +22 -0
  21. parmana-1.0.0/parmana/models/__init__.py +34 -0
  22. parmana-1.0.0/parmana/models/authority.py +22 -0
  23. parmana-1.0.0/parmana/models/authorization.py +19 -0
  24. parmana-1.0.0/parmana/models/business_transaction.py +56 -0
  25. parmana-1.0.0/parmana/models/execution.py +50 -0
  26. parmana-1.0.0/parmana/models/intent.py +24 -0
  27. parmana-1.0.0/parmana/models/override.py +25 -0
  28. parmana-1.0.0/parmana/models/policy.py +16 -0
  29. parmana-1.0.0/parmana/models/receipt.py +25 -0
  30. parmana-1.0.0/parmana/models/replay.py +16 -0
  31. parmana-1.0.0/parmana/models/replay_result.py +20 -0
  32. parmana-1.0.0/parmana/models/trust_record.py +37 -0
  33. parmana-1.0.0/parmana/models/verification.py +23 -0
  34. parmana-1.0.0/parmana/serialization/__init__.py +7 -0
  35. parmana-1.0.0/parmana/serialization/decoder.py +119 -0
  36. parmana-1.0.0/parmana/serialization/encoder.py +62 -0
  37. parmana-1.0.0/parmana/transport/__init__.py +0 -0
  38. parmana-1.0.0/parmana/transport/http_transport.py +144 -0
  39. parmana-1.0.0/parmana/types/__init__.py +0 -0
  40. parmana-1.0.0/parmana/types/json.py +0 -0
  41. parmana-1.0.0/parmana/version.py +15 -0
  42. parmana-1.0.0/parmana.egg-info/PKG-INFO +45 -0
  43. parmana-1.0.0/parmana.egg-info/SOURCES.txt +52 -0
  44. parmana-1.0.0/parmana.egg-info/dependency_links.txt +1 -0
  45. parmana-1.0.0/parmana.egg-info/requires.txt +1 -0
  46. parmana-1.0.0/parmana.egg-info/top_level.txt +1 -0
  47. parmana-1.0.0/pyproject.toml +53 -0
  48. parmana-1.0.0/setup.cfg +4 -0
  49. parmana-1.0.0/tests/test_client.py +9 -0
  50. parmana-1.0.0/tests/test_decoder.py +103 -0
  51. parmana-1.0.0/tests/test_encoder.py +90 -0
  52. parmana-1.0.0/tests/test_execution_api.py +123 -0
  53. parmana-1.0.0/tests/test_replay_api.py +65 -0
  54. parmana-1.0.0/tests/test_verification_api.py +70 -0
parmana-1.0.0/LICENSE ADDED
File without changes
parmana-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: parmana
3
+ Version: 1.0.0
4
+ Summary: Python SDK for Parmana Execution Trust Infrastructure.
5
+ Author: Parmana
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/parmana-ai/parmana
8
+ Project-URL: Documentation, https://github.com/parmana-ai/parmana/tree/main/python
9
+ Project-URL: Repository, https://github.com/parmana-ai/parmana
10
+ Keywords: ai,artificial-intelligence,autonomous-ai,agents,governance,authorization,execution,trust,policy,sdk
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Operating System :: OS Independent
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: requests>=2.32.0
22
+ Dynamic: license-file
23
+
24
+ \# Parmana Python SDK
25
+
26
+
27
+
28
+ > Proof of Human Authority in AI Systems
29
+
30
+
31
+
32
+ The official Python SDK for Parmana.
33
+
34
+
35
+
36
+ Parmana ensures AI executes only policy-compliant actions.
37
+
38
+
39
+
40
+ \## Status
41
+
42
+
43
+
44
+ Under active development.
45
+
@@ -0,0 +1,22 @@
1
+ \# Parmana Python SDK
2
+
3
+
4
+
5
+ > Proof of Human Authority in AI Systems
6
+
7
+
8
+
9
+ The official Python SDK for Parmana.
10
+
11
+
12
+
13
+ Parmana ensures AI executes only policy-compliant actions.
14
+
15
+
16
+
17
+ \## Status
18
+
19
+
20
+
21
+ Under active development.
22
+
@@ -0,0 +1,38 @@
1
+ """
2
+ Parmana Python SDK.
3
+
4
+ Proof of Human Authority in AI Systems.
5
+
6
+ Parmana ensures AI executes only policy-compliant actions.
7
+ """
8
+
9
+ from .client import ParmanaClient
10
+ from .version import __version__
11
+
12
+ from .models.authority import Authority
13
+ from .models.authorization import Authorization
14
+ from .models.intent import Intent
15
+ from .models.policy import PolicyReference
16
+ from .models.business_transaction import (
17
+ BusinessTransaction,
18
+ BusinessTransactionMetadata,
19
+ )
20
+ from .models.verification import Verification
21
+ from .models.receipt import Receipt
22
+ from .models.replay_result import ReplayResult
23
+ from .models.trust_record import ExecutionTrustRecord
24
+
25
+ __all__ = [
26
+ "__version__",
27
+ "ParmanaClient",
28
+ "Authority",
29
+ "Authorization",
30
+ "Intent",
31
+ "PolicyReference",
32
+ "BusinessTransactionMetadata",
33
+ "BusinessTransaction",
34
+ "Verification",
35
+ "Receipt",
36
+ "ReplayResult",
37
+ "ExecutionTrustRecord",
38
+ ]
@@ -0,0 +1,21 @@
1
+ """
2
+ Parmana Client APIs.
3
+ """
4
+
5
+ from .execution_api import ExecutionApi
6
+ from .verification_api import VerificationApi
7
+ from .replay_api import ReplayApi
8
+ from .receipt_api import ReceiptApi
9
+ from .policy_api import PolicyApi
10
+ from .transaction_api import TransactionApi
11
+ from .trust_record_api import TrustRecordApi
12
+
13
+ __all__ = [
14
+ "ExecutionApi",
15
+ "VerificationApi",
16
+ "ReplayApi",
17
+ "ReceiptApi",
18
+ "PolicyApi",
19
+ "TransactionApi",
20
+ "TrustRecordApi",
21
+ ]
@@ -0,0 +1,73 @@
1
+ """
2
+ Parmana Execution API.
3
+
4
+ Execute Business Transactions through the Parmana Runtime.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import Any
10
+
11
+ from parmana.config.transport import Transport
12
+ from parmana.models.business_transaction import BusinessTransaction
13
+ from parmana.models.trust_record import ExecutionTrustRecord
14
+ from parmana.serialization import encode
15
+
16
+
17
+ class ExecutionApi:
18
+ """
19
+ Execution API.
20
+
21
+ Responsibilities
22
+ ----------------
23
+ - Runtime health check
24
+ - Execute Business Transactions
25
+
26
+ This API does NOT:
27
+ - verify trust records
28
+ - replay executions
29
+ - generate receipts
30
+ - validate policies
31
+ """
32
+
33
+ def __init__(
34
+ self,
35
+ transport: Transport,
36
+ ) -> None:
37
+ self._transport = transport
38
+
39
+ def health(
40
+ self,
41
+ ) -> dict[str, Any]:
42
+ """
43
+ Returns the Runtime health status.
44
+ """
45
+
46
+ return self._transport.send(
47
+ method="GET",
48
+ path="/health",
49
+ )
50
+
51
+ def execute(
52
+ self,
53
+ transaction: BusinessTransaction,
54
+ ) -> ExecutionTrustRecord:
55
+ """
56
+ Execute a Business Transaction.
57
+
58
+ Parameters
59
+ ----------
60
+ transaction:
61
+ Business Transaction submitted to the Parmana Runtime.
62
+
63
+ Returns
64
+ -------
65
+ Execution Trust Record.
66
+ """
67
+
68
+ return self._transport.send(
69
+ method="POST",
70
+ path="/execute",
71
+ body=encode(transaction),
72
+ response_model=ExecutionTrustRecord,
73
+ )
@@ -0,0 +1,56 @@
1
+ """
2
+ Parmana Policy API.
3
+
4
+ Validate Runtime policies.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import Any
10
+
11
+ from parmana.config.transport import Transport
12
+
13
+
14
+ class PolicyApi:
15
+ """
16
+ Policy API.
17
+
18
+ Responsibilities
19
+ ----------------
20
+ - Validate Runtime policies
21
+
22
+ This API does NOT:
23
+ - execute Business Transactions
24
+ - verify trust records
25
+ - replay executions
26
+ - generate receipts
27
+ """
28
+
29
+ def __init__(
30
+ self,
31
+ transport: Transport,
32
+ ) -> None:
33
+ self._transport = transport
34
+
35
+ def validate(
36
+ self,
37
+ policy: dict[str, Any],
38
+ ) -> dict[str, Any]:
39
+ """
40
+ Validate a Runtime policy.
41
+
42
+ Parameters
43
+ ----------
44
+ policy:
45
+ Policy document.
46
+
47
+ Returns
48
+ -------
49
+ Policy validation result.
50
+ """
51
+
52
+ return self._transport.send(
53
+ method="POST",
54
+ path="/policies/validate",
55
+ body=policy,
56
+ )
@@ -0,0 +1,58 @@
1
+ """
2
+ Parmana Receipt API.
3
+
4
+ Generate cryptographic execution receipts.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from parmana.config.transport import Transport
10
+ from parmana.models.receipt import Receipt
11
+
12
+
13
+ class ReceiptApi:
14
+ """
15
+ Receipt API.
16
+
17
+ Responsibilities
18
+ ----------------
19
+ - Generate execution receipts
20
+
21
+ This API does NOT:
22
+ - execute Business Transactions
23
+ - replay executions
24
+ - verify trust records
25
+ - validate policies
26
+ """
27
+
28
+ def __init__(
29
+ self,
30
+ transport: Transport,
31
+ ) -> None:
32
+ self._transport = transport
33
+
34
+ def generate(
35
+ self,
36
+ business_transaction_id: str,
37
+ ) -> Receipt:
38
+ """
39
+ Generate an execution receipt.
40
+
41
+ Parameters
42
+ ----------
43
+ business_transaction_id:
44
+ Business Transaction identifier.
45
+
46
+ Returns
47
+ -------
48
+ Receipt.
49
+ """
50
+
51
+ return self._transport.send(
52
+ method="POST",
53
+ path="/receipt",
54
+ body={
55
+ "businessTransactionId": business_transaction_id,
56
+ },
57
+ response_model=Receipt,
58
+ )
@@ -0,0 +1,59 @@
1
+ """
2
+ Parmana Replay API.
3
+
4
+ Replay Business Transactions.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from parmana.config.transport import Transport
10
+ from parmana.models.replay_result import ReplayResult
11
+
12
+
13
+ class ReplayApi:
14
+ """
15
+ Replay API.
16
+
17
+ Responsibilities
18
+ ----------------
19
+ - Replay Business Transactions
20
+ - Verify deterministic execution
21
+
22
+ This API does NOT:
23
+ - execute Business Transactions
24
+ - verify trust records
25
+ - generate receipts
26
+ - validate policies
27
+ """
28
+
29
+ def __init__(
30
+ self,
31
+ transport: Transport,
32
+ ) -> None:
33
+ self._transport = transport
34
+
35
+ def replay(
36
+ self,
37
+ business_transaction_id: str,
38
+ ) -> ReplayResult:
39
+ """
40
+ Replay a Business Transaction.
41
+
42
+ Parameters
43
+ ----------
44
+ business_transaction_id:
45
+ Business Transaction identifier.
46
+
47
+ Returns
48
+ -------
49
+ Replay Result.
50
+ """
51
+
52
+ return self._transport.send(
53
+ method="POST",
54
+ path="/replay",
55
+ body={
56
+ "businessTransactionId": business_transaction_id,
57
+ },
58
+ response_model=ReplayResult,
59
+ )
@@ -0,0 +1,84 @@
1
+ """
2
+ Parmana Transaction API.
3
+
4
+ Retrieve Business Transactions.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from parmana.config.transport import Transport
10
+ from parmana.models.business_transaction import BusinessTransaction
11
+
12
+
13
+ class TransactionApi:
14
+ """
15
+ Transaction API.
16
+
17
+ Responsibilities
18
+ ----------------
19
+ - Retrieve Business Transactions
20
+ - List Business Transactions
21
+
22
+ This API does NOT:
23
+ - execute Business Transactions
24
+ - verify trust records
25
+ - replay executions
26
+ - generate receipts
27
+ """
28
+
29
+ def __init__(
30
+ self,
31
+ transport: Transport,
32
+ ) -> None:
33
+ self._transport = transport
34
+
35
+ def get(
36
+ self,
37
+ business_transaction_id: str,
38
+ ) -> BusinessTransaction:
39
+ """
40
+ Retrieve a Business Transaction.
41
+
42
+ Parameters
43
+ ----------
44
+ business_transaction_id:
45
+ Business Transaction identifier.
46
+
47
+ Returns
48
+ -------
49
+ Business Transaction.
50
+ """
51
+
52
+ return self._transport.send(
53
+ method="GET",
54
+ path=f"/transactions/{business_transaction_id}",
55
+ response_model=BusinessTransaction,
56
+ )
57
+
58
+ def list(
59
+ self,
60
+ *,
61
+ page: int = 1,
62
+ page_size: int = 25,
63
+ ) -> list[BusinessTransaction]:
64
+ """
65
+ List Business Transactions.
66
+
67
+ Parameters
68
+ ----------
69
+ page:
70
+ Page number.
71
+
72
+ page_size:
73
+ Number of transactions per page.
74
+
75
+ Returns
76
+ -------
77
+ List of Business Transactions.
78
+ """
79
+
80
+ return self._transport.send(
81
+ method="GET",
82
+ path=f"/transactions?page={page}&pageSize={page_size}",
83
+ response_model=list[BusinessTransaction],
84
+ )
@@ -0,0 +1,55 @@
1
+ """
2
+ Parmana Trust Record API.
3
+
4
+ Retrieve Execution Trust Records.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from parmana.config.transport import Transport
10
+ from parmana.models.trust_record import ExecutionTrustRecord
11
+
12
+
13
+ class TrustRecordApi:
14
+ """
15
+ Trust Record API.
16
+
17
+ Responsibilities
18
+ ----------------
19
+ - Retrieve Execution Trust Records
20
+
21
+ This API does NOT:
22
+ - execute Business Transactions
23
+ - verify trust records
24
+ - replay executions
25
+ - generate receipts
26
+ """
27
+
28
+ def __init__(
29
+ self,
30
+ transport: Transport,
31
+ ) -> None:
32
+ self._transport = transport
33
+
34
+ def get(
35
+ self,
36
+ business_transaction_id: str,
37
+ ) -> ExecutionTrustRecord:
38
+ """
39
+ Retrieve an Execution Trust Record.
40
+
41
+ Parameters
42
+ ----------
43
+ business_transaction_id:
44
+ Business Transaction identifier.
45
+
46
+ Returns
47
+ -------
48
+ Execution Trust Record.
49
+ """
50
+
51
+ return self._transport.send(
52
+ method="GET",
53
+ path=f"/trust-records/{business_transaction_id}",
54
+ response_model=ExecutionTrustRecord,
55
+ )
@@ -0,0 +1,58 @@
1
+ """
2
+ Parmana Verification API.
3
+
4
+ Verify Execution Trust Records.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from parmana.config.transport import Transport
10
+ from parmana.models.verification import Verification
11
+
12
+
13
+ class VerificationApi:
14
+ """
15
+ Verification API.
16
+
17
+ Responsibilities
18
+ ----------------
19
+ - Verify Execution Trust Records
20
+
21
+ This API does NOT:
22
+ - execute Business Transactions
23
+ - replay executions
24
+ - generate receipts
25
+ - validate policies
26
+ """
27
+
28
+ def __init__(
29
+ self,
30
+ transport: Transport,
31
+ ) -> None:
32
+ self._transport = transport
33
+
34
+ def verify(
35
+ self,
36
+ business_transaction_id: str,
37
+ ) -> Verification:
38
+ """
39
+ Verify an Execution Trust Record.
40
+
41
+ Parameters
42
+ ----------
43
+ business_transaction_id:
44
+ Business Transaction identifier.
45
+
46
+ Returns
47
+ -------
48
+ Verification.
49
+ """
50
+
51
+ return self._transport.send(
52
+ method="POST",
53
+ path="/verify",
54
+ body={
55
+ "businessTransactionId": business_transaction_id,
56
+ },
57
+ response_model=Verification,
58
+ )
@@ -0,0 +1,121 @@
1
+ """
2
+ Parmana Client.
3
+
4
+ Main entry point for the Parmana Python SDK.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from parmana.api.execution_api import ExecutionApi
10
+ from parmana.api.policy_api import PolicyApi
11
+ from parmana.api.receipt_api import ReceiptApi
12
+ from parmana.api.replay_api import ReplayApi
13
+ from parmana.api.transaction_api import TransactionApi
14
+ from parmana.api.trust_record_api import TrustRecordApi
15
+ from parmana.api.verification_api import VerificationApi
16
+
17
+ from parmana.transport.http_transport import HttpTransport
18
+ from parmana.version import __version__
19
+
20
+
21
+ class ParmanaClient:
22
+ """
23
+ Parmana SDK Client.
24
+
25
+ Parmana ensures AI executes only policy-compliant actions.
26
+
27
+ Example
28
+ -------
29
+ >>> client = ParmanaClient(
30
+ ... endpoint="http://localhost:3000",
31
+ ... )
32
+
33
+ >>> trust_record = client.execution.execute(transaction)
34
+
35
+ >>> verification = client.verification.verify(
36
+ ... transaction.business_transaction_id,
37
+ ... )
38
+ """
39
+
40
+ DEFAULT_TIMEOUT = 30
41
+
42
+ def __init__(
43
+ self,
44
+ *,
45
+ endpoint: str,
46
+ timeout: int = DEFAULT_TIMEOUT,
47
+ debug: bool = False,
48
+ ) -> None:
49
+ """
50
+ Create a Parmana SDK client.
51
+
52
+ Parameters
53
+ ----------
54
+ endpoint:
55
+ Base URL of the Parmana Runtime.
56
+
57
+ timeout:
58
+ HTTP timeout in seconds.
59
+
60
+ debug:
61
+ Enable request/response logging.
62
+ """
63
+
64
+ self._transport = HttpTransport(
65
+ endpoint=endpoint,
66
+ timeout=timeout,
67
+ debug=debug,
68
+ )
69
+
70
+ #
71
+ # APIs
72
+ #
73
+
74
+ self.execution = ExecutionApi(
75
+ self._transport,
76
+ )
77
+
78
+ self.verification = VerificationApi(
79
+ self._transport,
80
+ )
81
+
82
+ self.replay = ReplayApi(
83
+ self._transport,
84
+ )
85
+
86
+ self.receipt = ReceiptApi(
87
+ self._transport,
88
+ )
89
+
90
+ self.transactions = TransactionApi(
91
+ self._transport,
92
+ )
93
+
94
+ self.trust_records = TrustRecordApi(
95
+ self._transport,
96
+ )
97
+
98
+ self.policy = PolicyApi(
99
+ self._transport,
100
+ )
101
+
102
+ @property
103
+ def endpoint(self) -> str:
104
+ """
105
+ Parmana Runtime endpoint.
106
+ """
107
+ return self._transport.endpoint
108
+
109
+ @property
110
+ def version(self) -> str:
111
+ """
112
+ Parmana SDK version.
113
+ """
114
+ return __version__
115
+
116
+ def __repr__(self) -> str:
117
+ return (
118
+ f"{self.__class__.__name__}("
119
+ f"endpoint='{self.endpoint}', "
120
+ f"version='{self.version}')"
121
+ )
File without changes
@@ -0,0 +1,10 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class ClientConfig:
6
+ """
7
+ Parmana Client configuration.
8
+ """
9
+
10
+ endpoint: str