- mas_core: P2-maximal parser with required_profile, generator, statute schema + semantic lint + defaults-only inheritance, exact-host discovery with typed failures and same-origin redirects, pure policy resolver - mas_conformance: vendored spec fixtures (drift-tested) + property and statute cases - mas CLI: parse / explain / discover / lint-statute / test - mas-gateway: generic mail -> MAS event -> HTTP (MTA pipe + webhook) - examples: static great-service.example statute, reference ticket service - docs/experiment-review.md: first-pass findings; live MTA test still open Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 623586@bnt-lap001 Assistant-Session: 10b30928-5b3b-4c11-9934-5ecca07367d8
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Serve a static MAS statute directory for local experiments.
|
|
|
|
python examples/statute/serve.py examples/statute/great-service.example --port 8080
|
|
|
|
This is deliberately not a statute server framework: it is a static file
|
|
server that labels `/.well-known/mas` as application/json, which
|
|
`mas discover` requires. Production deployments should use their normal web
|
|
server with an equivalent rule, e.g. for nginx:
|
|
|
|
location = /.well-known/mas { default_type application/json; }
|
|
"""
|
|
|
|
import argparse
|
|
import functools
|
|
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
|
|
|
|
|
|
class StatuteHandler(SimpleHTTPRequestHandler):
|
|
def guess_type(self, path):
|
|
if path.rstrip("/").endswith("/.well-known/mas"):
|
|
return "application/json"
|
|
return super().guess_type(path)
|
|
|
|
|
|
def make_server(root: str, host: str = "127.0.0.1", port: int = 8080) -> ThreadingHTTPServer:
|
|
return ThreadingHTTPServer((host, port), functools.partial(StatuteHandler, directory=root))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("root")
|
|
ap.add_argument("--host", default="127.0.0.1")
|
|
ap.add_argument("--port", type=int, default=8080)
|
|
a = ap.parse_args()
|
|
print(f"serving {a.root} on http://{a.host}:{a.port}/.well-known/mas")
|
|
make_server(a.root, a.host, a.port).serve_forever()
|