Commit Graph

2 Commits

Author SHA1 Message Date
AleFlyX
44a0558305 fix: export the socket namespace under the lazy router profile
`DEEPTUTOR_CHAT_ENGINE=typescript-native` builds the app with `lazy=True`, and
in that profile RouterLoader stores routing patterns on a DeferredRouter
instead of the routers themselves, so `_router_loader.records` stays empty.
collect_api() reads the socket routes from those records because OpenAPI has
no socket namespace, so under that profile the artifact would lose all nine
paths.

Pin the eager loader before anything imports the app, the way
scripts/build_router_index.py already does. Verified by running `--check` in
both profiles: without the pin the lazy profile reports drift, with it both
report the committed surface.
2026-11-26 21:35:51 +08:00
AleFlyX
d518a3c587 feat: export the CLI and API surface the docs are checked against
The doc contract checks need the truth about what the CLI and the backend
actually expose. Reconstructing that from source with `ast` cannot see
registration that only exists at runtime (the imperative
`for action in (...): app.command(action)(...)` loop in deeptutor_cli/module.py,
`add_typer` aliases), so it has to guess and the guesses rot.

Export the surface from the live objects instead:

- CLI: `typer.main.get_command(app)` walks the Click tree, so loop-registered
  commands, aliases and Typer's default naming all come out correctly.
- HTTP: `app.openapi()["paths"]`, which resolves include prefixes and expands
  the lazy router loader.
- WebSocket: FastAPI omits socket routes from OpenAPI, so they come from the
  repo's own `RouterLoader.records` joined with the manifest prefixes.

The artifact is committed at docs/tests/docs_surface.json and rendered
deterministically (sorted, indent=2, trailing newline), so `--check` is a
byte comparison. Nothing reads it yet; the next commits switch the tests over
and add the freshness gate.

20 CLI groups, 610 HTTP paths, 9 WebSocket paths as of this commit.
2026-11-26 21:35:16 +08:00