Skip to content

OpenSIN-Code/SIN-Code-Ephemeral-Full-Stack-Mocking-Orchestration

Repository files navigation

SIN-Code Ephemeral Full-Stack Mocking Orchestration (EFSM)

Spin up a complete, isolated, ephemeral mock stack in under 2 seconds — HTTP, database, auth, queue, and storage — all in-memory, no Docker, no real services.

Python License: MIT

Part of the SIN-Code agent-engineering stack. Install all subsystems together via the SIN-Code Bundle.

Features

  • EphemeralMockServer — one class starts all five services on a single port
  • HTTP service — mock arbitrary REST endpoints with per-method registration
  • Database service — in-memory SQLite with schema setup/teardown
  • Auth service — mock OAuth2 / JWT issuance and validation (HS256, no deps)
  • Queue service — in-memory pub/sub per topic
  • Storage service — dict-based S3-like object store
  • True ephemeral — all data wiped on stop(), no external dependencies
  • Fast startup — < 2 seconds, no Docker required
  • Random port allocation — falls back automatically if preferred port is taken
  • Graceful shutdown — SIGINT / SIGTERM handlers included
  • MCP server — orchestrate mocks from AI agents via the Model Context Protocol

Installation

pip install -e .

Optional MCP server support:

pip install -e ".[mcp]"

See INSTALL.md for detailed setup instructions.

Usage

Library

from sin_code_efsm import EphemeralMockServer

server = EphemeralMockServer(port=8888)
server.start()
print(server.url)  # http://127.0.0.1:8888

server.add_endpoint("GET", "/hello", {"msg": "world"})

import httpx
r = httpx.get(f"{server.url}/http/hello")
print(r.json())  # {"msg": "world"}

server.stop()  # everything vanishes

Services

Service Prefix What it does
HTTP /http Mock REST endpoints
Database /db In-memory SQLite + HTTP SQL execution
Auth /auth OAuth2 token + JWT userinfo
Queue /queue Pub/sub per topic
Storage /storage S3-like object store

CLI

# Spin up ephemeral environment and run tests
efsm setup my-test --api https://api.example.com --db --test-cmd pytest

# Serve mock server in background
efsm setup my-test --api https://api.example.com --serve-mock

Testing

pytest tests/ -v

MCP Server

Run the MCP server for agent integration:

python -m sin_code_efsm.mcp_server

Tools exposed:

  • generate_mock(service_spec, format="json") — generate a mock service from an OpenAPI or GraphQL spec
  • orchestrate_mock(services, scenario="default") — orchestrate ephemeral mock services for integration testing

Integration

EFSM is designed to work as part of the SIN-Code ecosystem:

  • SIN-Code Bundle — orchestrates all subsystems from a single CLI (sin)
  • Orchestration — spin up mock stacks as part of CI/agent workflows
  • Verification Oracle — run integration tests against ephemeral mocks

Documentation

Note on isolation

Docker gives the strongest isolation. When Docker is not present, EFSM falls back to a resource-limited subprocess runner — convenient for local/CI use, but not a security boundary for untrusted code.

License

MIT — see LICENSE.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages