feat(standards): codify codegen, ship generic Tier-B infra, add get_app_template + prompts; fix docs:// regressions
P0: fix doc:// -> docs:// across standards src/server/registry and regenerate stale mongo-ops bundle. P1: build recipe + spec-first routing now document the openapi-first codegen fast path (models/routes with --inject-request/--package). P4: CRUD template documents the model-vs-document id rule (BaseDocument owns id). P5: authless guidance (omit security keys). P6: template gains generic infra (http_cache, keyed SSE bus, KV port+in-memory+Redis), interfaces/openapi.py + .dockerignore + generic build test registered as components, and a get_app_template tool; genericity matrix marks LLM pool + human-in-loop as reference-app patterns. P7: intake/build/start_app/trial prompts. P8: template ships tests/integration/test_openapi_app_builds.py. Rebuilt standards + openapi-first bundles and re-collected.
This commit is contained in:
@@ -2,105 +2,70 @@
|
||||
"module": "mongo_ops.registry",
|
||||
"content": {
|
||||
"path": "mongo_ops.registry",
|
||||
"docstring": "Model registration for multi-service initialization.",
|
||||
"docstring": "# Summary\n\nModel registration for multi-service initialization.",
|
||||
"objects": {
|
||||
"Dict": {
|
||||
"name": "Dict",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.registry.Dict",
|
||||
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
|
||||
"docstring": null
|
||||
},
|
||||
"List": {
|
||||
"name": "List",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.registry.List",
|
||||
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
|
||||
"docstring": null
|
||||
},
|
||||
"Optional": {
|
||||
"name": "Optional",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.registry.Optional",
|
||||
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
|
||||
"docstring": null
|
||||
},
|
||||
"Type": {
|
||||
"name": "Type",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.registry.Type",
|
||||
"signature": "<bound method Alias.signature of Alias('Type', 'typing.Type')>",
|
||||
"docstring": null
|
||||
},
|
||||
"AsyncIOMotorDatabase": {
|
||||
"name": "AsyncIOMotorDatabase",
|
||||
"kind": "alias",
|
||||
"path": "mongo_ops.registry.AsyncIOMotorDatabase",
|
||||
"signature": "<bound method Alias.signature of Alias('AsyncIOMotorDatabase', 'motor.motor_asyncio.AsyncIOMotorDatabase')>",
|
||||
"docstring": null
|
||||
},
|
||||
"CacheBackend": {
|
||||
"name": "CacheBackend",
|
||||
"kind": "class",
|
||||
"path": "mongo_ops.registry.CacheBackend",
|
||||
"signature": "<bound method Alias.signature of Alias('CacheBackend', 'mongo_ops.cache.backend.CacheBackend')>",
|
||||
"docstring": null,
|
||||
"signature": null,
|
||||
"docstring": "Abstract interface for cache backends.\n\nImplementations store byte-encoded values keyed by string, track usage\nstatistics, and manage their own lifecycle. The in-memory and Redis\nbackends both implement this contract.",
|
||||
"members": {
|
||||
"get": {
|
||||
"name": "get",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.CacheBackend.get",
|
||||
"signature": "<bound method Alias.signature of Alias('get', 'mongo_ops.cache.backend.CacheBackend.get')>",
|
||||
"docstring": null
|
||||
"signature": "get(key: str)",
|
||||
"docstring": "Fetch a value from the cache.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n Optional[bytes]: The cached bytes, or None on a miss."
|
||||
},
|
||||
"set": {
|
||||
"name": "set",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.CacheBackend.set",
|
||||
"signature": "<bound method Alias.signature of Alias('set', 'mongo_ops.cache.backend.CacheBackend.set')>",
|
||||
"docstring": null
|
||||
"signature": "set(key: str, value: bytes, ttl: int | None = None)",
|
||||
"docstring": "Store a value in the cache.\n\nArgs:\n key (str):\n The cache key.\n value (bytes):\n The byte-encoded value to store.\n ttl (Optional[int]):\n Time-to-live in seconds. When None, the backend default\n applies."
|
||||
},
|
||||
"delete": {
|
||||
"name": "delete",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.CacheBackend.delete",
|
||||
"signature": "<bound method Alias.signature of Alias('delete', 'mongo_ops.cache.backend.CacheBackend.delete')>",
|
||||
"docstring": null
|
||||
"signature": "delete(key: str)",
|
||||
"docstring": "Remove a key from the cache.\n\nArgs:\n key (str):\n The cache key."
|
||||
},
|
||||
"exists": {
|
||||
"name": "exists",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.CacheBackend.exists",
|
||||
"signature": "<bound method Alias.signature of Alias('exists', 'mongo_ops.cache.backend.CacheBackend.exists')>",
|
||||
"docstring": null
|
||||
"signature": "exists(key: str)",
|
||||
"docstring": "Check whether a key is present.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n bool: True if the key exists, False otherwise."
|
||||
},
|
||||
"clear_pattern": {
|
||||
"name": "clear_pattern",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.CacheBackend.clear_pattern",
|
||||
"signature": "<bound method Alias.signature of Alias('clear_pattern', 'mongo_ops.cache.backend.CacheBackend.clear_pattern')>",
|
||||
"docstring": null
|
||||
"signature": "clear_pattern(pattern: str)",
|
||||
"docstring": "Remove all keys matching a glob pattern.\n\nArgs:\n pattern (str):\n Glob-style pattern; a trailing `*` matches prefixes."
|
||||
},
|
||||
"get_stats": {
|
||||
"name": "get_stats",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.CacheBackend.get_stats",
|
||||
"signature": "<bound method Alias.signature of Alias('get_stats', 'mongo_ops.cache.backend.CacheBackend.get_stats')>",
|
||||
"docstring": null
|
||||
"signature": "get_stats()",
|
||||
"docstring": "Return a snapshot of cache statistics.\n\nReturns:\n CacheStats: A copy of the current stats counters."
|
||||
},
|
||||
"initialize": {
|
||||
"name": "initialize",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.CacheBackend.initialize",
|
||||
"signature": "<bound method Alias.signature of Alias('initialize', 'mongo_ops.cache.backend.CacheBackend.initialize')>",
|
||||
"docstring": null
|
||||
"signature": "initialize()",
|
||||
"docstring": "Start background resources owned by the backend.\n\nShould be called once during application startup, after the\nrepositories are connected."
|
||||
},
|
||||
"shutdown": {
|
||||
"name": "shutdown",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.CacheBackend.shutdown",
|
||||
"signature": "<bound method Alias.signature of Alias('shutdown', 'mongo_ops.cache.backend.CacheBackend.shutdown')>",
|
||||
"docstring": null
|
||||
"signature": "shutdown()",
|
||||
"docstring": "Stop and release background resources.\n\nShould be called once during application shutdown."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -108,43 +73,43 @@
|
||||
"name": "MongoConnectionManager",
|
||||
"kind": "class",
|
||||
"path": "mongo_ops.registry.MongoConnectionManager",
|
||||
"signature": "<bound method Alias.signature of Alias('MongoConnectionManager', 'mongo_ops.connection.MongoConnectionManager')>",
|
||||
"docstring": "Manages MongoDB connections with async lifecycle.\n\nThis class provides a singleton-like manager for the MongoDB client and \ndatabase instances, ensuring they are properly initialized and closed \nacross the application lifecycle.",
|
||||
"signature": null,
|
||||
"docstring": "Manages MongoDB connections with async lifecycle.\n\nThis class provides a singleton-like manager for the MongoDB client and\ndatabase instances, ensuring they are properly initialized and closed\nacross the application lifecycle.",
|
||||
"members": {
|
||||
"connect": {
|
||||
"name": "connect",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.MongoConnectionManager.connect",
|
||||
"signature": "<bound method Alias.signature of Alias('connect', 'mongo_ops.connection.MongoConnectionManager.connect')>",
|
||||
"docstring": "Connect to MongoDB and initialize the shared client.\n\nArgs:\n uri: MongoDB connection URI (e.g., \"mongodb://localhost:27017\").\n db_name: Name of the database to use.\n **kwargs: Additional Motor client options (e.g., maxPoolSize).\n\nReturns:\n AsyncIOMotorDatabase: The initialized database instance."
|
||||
"signature": "connect(uri: str, db_name: str, **kwargs: Any)",
|
||||
"docstring": "Connect to MongoDB and initialize the shared client.\n\nArgs:\n uri (str): MongoDB connection URI (e.g., \"mongodb://localhost:27017\").\n db_name (str): Name of the database to use.\n **kwargs: Additional Motor client options (e.g., maxPoolSize).\n\nReturns:\n AsyncIOMotorDatabase: The initialized database instance."
|
||||
},
|
||||
"disconnect": {
|
||||
"name": "disconnect",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.MongoConnectionManager.disconnect",
|
||||
"signature": "<bound method Alias.signature of Alias('disconnect', 'mongo_ops.connection.MongoConnectionManager.disconnect')>",
|
||||
"signature": "disconnect()",
|
||||
"docstring": "Close the active MongoDB connection and cleanup resources."
|
||||
},
|
||||
"get_database": {
|
||||
"name": "get_database",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.MongoConnectionManager.get_database",
|
||||
"signature": "<bound method Alias.signature of Alias('get_database', 'mongo_ops.connection.MongoConnectionManager.get_database')>",
|
||||
"signature": "get_database()",
|
||||
"docstring": "Retrieve the current database instance.\n\nReturns:\n AsyncIOMotorDatabase: The active database instance.\n\nRaises:\n RuntimeError: If connect() has not been called yet."
|
||||
},
|
||||
"get_client": {
|
||||
"name": "get_client",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.MongoConnectionManager.get_client",
|
||||
"signature": "<bound method Alias.signature of Alias('get_client', 'mongo_ops.connection.MongoConnectionManager.get_client')>",
|
||||
"signature": "get_client()",
|
||||
"docstring": "Retrieve the current client instance.\n\nReturns:\n AsyncIOMotorClient: The active Motor client instance.\n\nRaises:\n RuntimeError: If connect() has not been called yet."
|
||||
},
|
||||
"lifespan": {
|
||||
"name": "lifespan",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.MongoConnectionManager.lifespan",
|
||||
"signature": "<bound method Alias.signature of Alias('lifespan', 'mongo_ops.connection.MongoConnectionManager.lifespan')>",
|
||||
"docstring": "Async context manager for managing connection lifecycle.\n\nDesigned for use with FastAPI or other frameworks supporting \nlifespan management.\n\nArgs:\n uri: MongoDB connection URI.\n db_name: Name of the database.\n **kwargs: Additional Motor client options.\n\nYields:\n AsyncIOMotorDatabase: The active database instance.\n\nUsage:\n @asynccontextmanager\n async def lifespan(app: FastAPI):\n async with MongoConnectionManager.lifespan(uri, db_name):\n yield"
|
||||
"signature": "lifespan(uri: str, db_name: str, **kwargs: Any)",
|
||||
"docstring": "Async context manager for managing connection lifecycle.\n\nDesigned for use with FastAPI or other frameworks supporting\nlifespan management.\n\nNotes:\n Connects to MongoDB on entry, yields the active database instance\n to the context body, and disconnects on exit.\n\nUsage:\n @asynccontextmanager\n async def lifespan(app: FastAPI):\n async with MongoConnectionManager.lifespan(uri, db_name):\n yield"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -152,63 +117,63 @@
|
||||
"name": "BaseDocument",
|
||||
"kind": "class",
|
||||
"path": "mongo_ops.registry.BaseDocument",
|
||||
"signature": "<bound method Alias.signature of Alias('BaseDocument', 'mongo_ops.models.BaseDocument')>",
|
||||
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent \nMongoDB documents. It includes automatic handling of the `_id` field \nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
|
||||
"signature": null,
|
||||
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent\nMongoDB documents. It includes automatic handling of the `_id` field\nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
|
||||
"members": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.registry.BaseDocument.id",
|
||||
"signature": "<bound method Alias.signature of Alias('id', 'mongo_ops.models.BaseDocument.id')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.registry.BaseDocument.created_at",
|
||||
"signature": "<bound method Alias.signature of Alias('created_at', 'mongo_ops.models.BaseDocument.created_at')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"updated_at": {
|
||||
"name": "updated_at",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.registry.BaseDocument.updated_at",
|
||||
"signature": "<bound method Alias.signature of Alias('updated_at', 'mongo_ops.models.BaseDocument.updated_at')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"Config": {
|
||||
"name": "Config",
|
||||
"kind": "class",
|
||||
"path": "mongo_ops.registry.BaseDocument.Config",
|
||||
"signature": "<bound method Alias.signature of Alias('Config', 'mongo_ops.models.BaseDocument.Config')>",
|
||||
"signature": null,
|
||||
"docstring": null,
|
||||
"members": {
|
||||
"populate_by_name": {
|
||||
"name": "populate_by_name",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.registry.BaseDocument.Config.populate_by_name",
|
||||
"signature": "<bound method Alias.signature of Alias('populate_by_name', 'mongo_ops.models.BaseDocument.Config.populate_by_name')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"arbitrary_types_allowed": {
|
||||
"name": "arbitrary_types_allowed",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.registry.BaseDocument.Config.arbitrary_types_allowed",
|
||||
"signature": "<bound method Alias.signature of Alias('arbitrary_types_allowed', 'mongo_ops.models.BaseDocument.Config.arbitrary_types_allowed')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"json_encoders": {
|
||||
"name": "json_encoders",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.registry.BaseDocument.Config.json_encoders",
|
||||
"signature": "<bound method Alias.signature of Alias('json_encoders', 'mongo_ops.models.BaseDocument.Config.json_encoders')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"json_schema_extra": {
|
||||
"name": "json_schema_extra",
|
||||
"kind": "attribute",
|
||||
"path": "mongo_ops.registry.BaseDocument.Config.json_schema_extra",
|
||||
"signature": "<bound method Alias.signature of Alias('json_schema_extra', 'mongo_ops.models.BaseDocument.Config.json_schema_extra')>",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
}
|
||||
}
|
||||
@@ -219,63 +184,63 @@
|
||||
"name": "ModelRegistry",
|
||||
"kind": "class",
|
||||
"path": "mongo_ops.registry.ModelRegistry",
|
||||
"signature": "<bound method Class.signature of Class('ModelRegistry', 11, 149)>",
|
||||
"docstring": "Registry for managing multiple models and their collections.\n\nThis registry allows central management of collections and their \nassociated indexes, making it easier to perform mass initialization \nat application startup.",
|
||||
"signature": null,
|
||||
"docstring": "Registry for managing multiple models and their collections.\n\nThis registry allows central management of collections and their\nassociated indexes, making it easier to perform mass initialization\nat application startup.",
|
||||
"members": {
|
||||
"register": {
|
||||
"name": "register",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.ModelRegistry.register",
|
||||
"signature": "<bound method Function.signature of Function('register', 24, 48)>",
|
||||
"docstring": "Register a model with its collection and indexes.\n\nArgs:\n collection_name: Name of the MongoDB collection.\n model: Document model class (subclass of BaseDocument).\n indexes: List of index specifications (e.g., [(\"email\", 1)]).\n\nUsage:\n ModelRegistry.register(\n \"users\",\n UserDocument,\n indexes=[(\"email\", 1), (\"created_at\", -1)]\n )"
|
||||
"signature": "register(collection_name: str, model: type[BaseDocument], indexes: list[tuple] | None = None) -> None",
|
||||
"docstring": "Register a model with its collection and indexes.\n\nArgs:\n collection_name (str): Name of the MongoDB collection.\n model (type[BaseDocument]): Document model class (subclass of BaseDocument).\n indexes (list[Any]): List of index specifications. Each spec is passed\n directly to pymongo's create_index. Supported forms:\n - single field: (\"email\", 1)\n - compound: [(\"author_id\", 1), (\"created_at\", -1)]\n - with options: {\"keys\": [(\"username\", 1)], \"options\": {\"unique\": True}}\n\nExample:\n ModelRegistry.register(\"users\", UserDocument, indexes=[(\"email\", 1)])\n ModelRegistry.register(\n \"posts\",\n PostDocument,\n indexes=[[(\"author_id\", 1), (\"created_at\", -1)]],\n )"
|
||||
},
|
||||
"initialize_all": {
|
||||
"name": "initialize_all",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.ModelRegistry.initialize_all",
|
||||
"signature": "<bound method Function.signature of Function('initialize_all', 50, 67)>",
|
||||
"docstring": "Initialize all registered collections and create indexes.\n\nThis method should be called during application startup to ensure \nall necessary indexes exist in the database.\n\nArgs:\n db: Database instance. If not provided, uses the global database \n from MongoConnectionManager."
|
||||
"signature": "initialize_all(db: AsyncIOMotorDatabase | None = None) -> None",
|
||||
"docstring": "Initialize all registered collections and create indexes.\n\nThis method should be called during application startup to ensure\nall necessary indexes exist in the database.\n\nArgs:\n db (Optional[AsyncIOMotorDatabase]): Database instance. If not provided,\n uses the global database from MongoConnectionManager."
|
||||
},
|
||||
"get_model": {
|
||||
"name": "get_model",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.ModelRegistry.get_model",
|
||||
"signature": "<bound method Function.signature of Function('get_model', 69, 85)>",
|
||||
"docstring": "Retrieve a registered model by its collection name.\n\nArgs:\n collection_name: The name of the collection.\n\nReturns:\n Type[BaseDocument]: The registered model class.\n\nRaises:\n KeyError: If the model for the given collection is not registered."
|
||||
"signature": "get_model(collection_name: str) -> type[BaseDocument]",
|
||||
"docstring": "Retrieve a registered model by its collection name.\n\nArgs:\n collection_name (str): The name of the collection.\n\nReturns:\n type[BaseDocument]: The registered model class.\n\nRaises:\n KeyError: If the model for the given collection is not registered."
|
||||
},
|
||||
"list_collections": {
|
||||
"name": "list_collections",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.ModelRegistry.list_collections",
|
||||
"signature": "<bound method Function.signature of Function('list_collections', 87, 95)>",
|
||||
"docstring": "List all registered collection names.\n\nReturns:\n List[str]: A list of collection names."
|
||||
"signature": "list_collections() -> list[str]",
|
||||
"docstring": "List all registered collection names.\n\nReturns:\n list[str]: A list of collection names."
|
||||
},
|
||||
"get_cache_backend": {
|
||||
"name": "get_cache_backend",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.ModelRegistry.get_cache_backend",
|
||||
"signature": "<bound method Function.signature of Function('get_cache_backend', 97, 105)>",
|
||||
"signature": "get_cache_backend() -> CacheBackend | None",
|
||||
"docstring": "Get the registered cache backend instance.\n\nReturns:\n Optional[CacheBackend]: The cache backend, if registered."
|
||||
},
|
||||
"set_cache_backend": {
|
||||
"name": "set_cache_backend",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.ModelRegistry.set_cache_backend",
|
||||
"signature": "<bound method Function.signature of Function('set_cache_backend', 107, 119)>",
|
||||
"docstring": "Register a cache backend for all cache-enabled repositories.\n\nShould be called after MongoDB connection is established,\nbefore cache-backed repositories are used.\n\nArgs:\n backend: A CacheBackend instance (InMemoryCacheBackend\n or RedisCacheBackend)."
|
||||
"signature": "set_cache_backend(backend: CacheBackend) -> None",
|
||||
"docstring": "Register a cache backend for all cache-enabled repositories.\n\nShould be called after MongoDB connection is established,\nbefore cache-backed repositories are used.\n\nArgs:\n backend (CacheBackend): A CacheBackend instance (InMemoryCacheBackend\n or RedisCacheBackend)."
|
||||
},
|
||||
"initialize_cache": {
|
||||
"name": "initialize_cache",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.ModelRegistry.initialize_cache",
|
||||
"signature": "<bound method Function.signature of Function('initialize_cache', 121, 137)>",
|
||||
"signature": "initialize_cache() -> None",
|
||||
"docstring": "Initialize the registered cache backend.\n\nMust be called after set_cache_backend() and before any\ncache-backed repository operations. Typically called right\nafter MongoDB connection is established.\n\nRaises:\n RuntimeError: If no cache backend has been registered."
|
||||
},
|
||||
"shutdown_cache": {
|
||||
"name": "shutdown_cache",
|
||||
"kind": "function",
|
||||
"path": "mongo_ops.registry.ModelRegistry.shutdown_cache",
|
||||
"signature": "<bound method Function.signature of Function('shutdown_cache', 139, 149)>",
|
||||
"signature": "shutdown_cache() -> None",
|
||||
"docstring": "Shutdown the registered cache backend gracefully.\n\nShould be called during application shutdown to clean up\nbackground tasks (e.g., in-memory TTL cleanup)."
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user