openworkproof 1.0.0__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.
Files changed (39) hide show
  1. openworkproof/__init__.py +1 -0
  2. openworkproof/acceptance.py +3006 -0
  3. openworkproof/cli.py +164 -0
  4. openworkproof/composition.py +832 -0
  5. openworkproof/evidence.py +8281 -0
  6. openworkproof/execution_adapter.py +256 -0
  7. openworkproof/external_acceptor.py +211 -0
  8. openworkproof/mcp_server.py +2939 -0
  9. openworkproof/mcp_transport.py +72 -0
  10. openworkproof/models.py +3380 -0
  11. openworkproof/policy.py +2494 -0
  12. openworkproof/predicates.py +333 -0
  13. openworkproof/repo_pipeline/__init__.py +74 -0
  14. openworkproof/repo_pipeline/analysis.py +152 -0
  15. openworkproof/repo_pipeline/errors.py +64 -0
  16. openworkproof/repo_pipeline/models.py +80 -0
  17. openworkproof/repo_pipeline/output.py +68 -0
  18. openworkproof/repo_pipeline/reader.py +47 -0
  19. openworkproof/repo_pipeline/sources.py +120 -0
  20. openworkproof/repo_pipeline/traversal.py +253 -0
  21. openworkproof/repo_tools.py +8382 -0
  22. openworkproof/runtime_context.py +189 -0
  23. openworkproof/schema_registry.py +623 -0
  24. openworkproof/schemas/v0.1/acceptance-receipt.schema.json +1 -0
  25. openworkproof/schemas/v0.1/acceptance-rejection-receipt.schema.json +1 -0
  26. openworkproof/schemas/v0.1/action-receipt.schema.json +1 -0
  27. openworkproof/schemas/v0.1/capability-grant.schema.json +1 -0
  28. openworkproof/schemas/v0.1/schema-registry.json +1 -0
  29. openworkproof/schemas/v0.1/work-order.schema.json +1 -0
  30. openworkproof/signing.py +421 -0
  31. openworkproof/state.py +765 -0
  32. openworkproof/team_network_client.py +419 -0
  33. openworkproof/trusted_helper.py +269 -0
  34. openworkproof-1.0.0.dist-info/METADATA +578 -0
  35. openworkproof-1.0.0.dist-info/RECORD +39 -0
  36. openworkproof-1.0.0.dist-info/WHEEL +5 -0
  37. openworkproof-1.0.0.dist-info/entry_points.txt +2 -0
  38. openworkproof-1.0.0.dist-info/licenses/LICENSE +202 -0
  39. openworkproof-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,72 @@
1
+ """MCP (Model Context Protocol) transport for OpenWorkProof.
2
+
3
+ Exposes the protocol coordinators as MCP tools over stdio. Tools carry the
4
+ same JSON protocol messages as the CLI transport:
5
+
6
+ - ``owp_status(ledger)`` — replay a ledger and return its state
7
+ - ``owp_run_tests(ledger, payload)`` — forward one run-tests execution
8
+ - ``owp_repo_read(ledger, payload)`` — forward one repo-read execution
9
+
10
+ Run with ``python -m openworkproof.mcp_transport`` (stdio server).
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import json
16
+ from pathlib import Path
17
+ from typing import Any
18
+
19
+ from mcp.server.fastmcp import FastMCP
20
+
21
+ from openworkproof import cli as cli_module
22
+
23
+ mcp = FastMCP("openworkproof")
24
+
25
+ _SCHEMA = "openworkproof/mcp/0.1"
26
+
27
+
28
+ @mcp.tool()
29
+ def owp_status(ledger: str) -> dict[str, Any]:
30
+ """Replay an OpenWorkProof ledger and return its authoritative state."""
31
+ try:
32
+ result = cli_module.cli_status(ledger)
33
+ result["schema_version"] = _SCHEMA
34
+ return result
35
+ except cli_module.CliError as error:
36
+ return {"schema_version": _SCHEMA, "error": str(error)}
37
+
38
+
39
+ @mcp.tool()
40
+ def owp_run_tests(ledger: str, payload: str) -> dict[str, Any]:
41
+ """Forward one run-tests execution payload (JSON string)."""
42
+ return _forward(cli_module.cli_run_tests, ledger, payload)
43
+
44
+
45
+ @mcp.tool()
46
+ def owp_repo_read(ledger: str, payload: str) -> dict[str, Any]:
47
+ """Forward one repo-read execution payload (JSON string)."""
48
+ return _forward(cli_module.cli_repo_read, ledger, payload)
49
+
50
+
51
+ def _forward(forwarder, ledger: str, payload: str) -> dict[str, Any]:
52
+ try:
53
+ parsed = json.loads(payload)
54
+ except (TypeError, ValueError) as error:
55
+ return {"schema_version": _SCHEMA, "error": f"payload is not JSON: {error}"}
56
+ if type(parsed) is not dict:
57
+ return {"schema_version": _SCHEMA, "error": "payload must be an object"}
58
+ try:
59
+ result = forwarder(Path(ledger), parsed)
60
+ except cli_module.CliError as error:
61
+ return {"schema_version": _SCHEMA, "error": str(error)}
62
+ result["schema_version"] = _SCHEMA
63
+ return result
64
+
65
+
66
+ def main() -> None:
67
+ """Run the stdio MCP server."""
68
+ mcp.run(transport="stdio")
69
+
70
+
71
+ if __name__ == "__main__":
72
+ main()