Repository object · implementation

In an editable checkout this is the repository root. In an installed wheel it is merely a

Accepted implementation in the public catalog.

Source path
src/epistemedia/server/__init__.py
Media type
text/x-python
Object ID
em:implementation:sha256:85f4e28a6a876c082c7b7e6201529b2e9d9c3256e0ae02c03306ee3e47602b9d
Content digest
0161a354ed8def0bb0f5db6f9196b6960b7946600a51d94afff0364555209068

Source content

"""Lazy compatibility package for the ASGI gateway.

A package directory intentionally takes precedence over the legacy sibling server.py module.

It sets a non-authoritative fallback root before loading that implementation so importing the

remote CLI never requires the caller to be inside a repository. Local realm commands still

resolve and require an explicit repository through the CLI.

"""

from __future__ import annotations

import importlib.util

import os

import sys

from pathlib import Path

_file = Path(__file__).resolve().parent.parent / "server.py"

In an editable checkout this is the repository root. In an installed wheel it is merely a

harmless package fallback; remote commands do not read it, and local commands resolve a root.

os.environ.setdefault("EPISTEMEDIA_ROOT", str(Path(__file__).resolve().parents[3]))

_name = "epistemedia._server_implementation"

_spec = importlib.util.spec_from_file_location(_name, _file)

if _spec is None or _spec.loader is None: # pragma: no cover

raise ImportError(f"Unable to load Epistemedia gateway from {_file}")

_module = importlib.util.module_from_spec(_spec)

sys.modules[_name] = _module

try:

_spec.loader.exec_module(_module)

except BaseException:

sys.modules.pop(_name, None)

raise

Gateway = _module.Gateway

MCPRequestError = _module.MCPRequestError

Request = _module.Request

tool_definitions = _module.tool_definitions

app = Gateway()

__all__ = ["Gateway", "MCPRequestError", "Request", "app", "tool_definitions"]

Build receipt

Reproduce this projection

Reproducible projection
Catalog
em:catalog:sha256:9bfc972213cba2cde167386103dc2c011ee74639fb7f0794c54120fbbdef1a5d
Frontier
em:frontier:sha256:f33be3eae4c75232d56750ef9a1aa79d96274ece3417d65a75c1391bf61a81bf
Accepted commit
f92846570180dfa4511263f8ba98ecd18f7772c9
Epistemic policy
commons-balanced-v0.1
Disclosure policy
public-noninterference-v0.1
Compiler
epistemedia/0.2.0