The per-adapter parity table was hand-maintained prose. An adapter that
never wired a capability (FastAPI SSR, Axum WebSocket) got its gap
relabelled "Django-only" or "out of scope — use native equivalents," and
nothing went red. The de-scope was crystallized in five mutually-ratifying
sites: the README §Stack-extensions table, the AFI fixture docstring
("channels/forms/shapes aren't AFI-common"), the core registry's
extension-hook framing, the mizan-fastapi __init__ docstring, and a
"CSRF is Django-only" comment in two adapters' session endpoints.
Replace prose-parity with conformance-generated parity:
- tests/afi/manifest.py declares the AFI-common surface as data — one list
of capabilities, one of adapters. Applicability ("—") is derived from
transport, never typed.
- tests/afi/probes.py independently inspects each backend's source for the
artifact a capability requires (comment-stripped, backend-scoped). Green
means wired; a cell can't be set by editing a word.
- tests/afi/test_capability_parity.py asserts every (capability × applicable
adapter) pair is wired. 35 unwired gaps are now loud red TFDD tests, each
naming an owed binding. No xfail/skip.
- tests/afi/parity_table.py generates the README table from the probes;
`make parity-check` fails CI on any hand-edit, like the codegen byte-parity.
Purge the five de-scope sites. The IR byte-parity gate is unchanged and green.
`make test-afi` is now intentionally red on the 35 gaps — that board is the
owed parity work, itemized; a gap turns green by being wired, never described.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
113 lines
3.5 KiB
Python
113 lines
3.5 KiB
Python
"""
|
|
The AFI fixture — a small set of @client-decorated functions designed to
|
|
exercise the protocol axes both backends must agree on:
|
|
|
|
- plain function with typed input
|
|
- plain function with no input
|
|
- two context functions sharing a param (proves bundling + param elevation)
|
|
- a mutation declaring `affects` on the context
|
|
|
|
This fixture is deliberately minimal: it exercises the axes the *IR-shape*
|
|
parity test (`test_codegen_parity.py`) needs to compare. It intentionally omits
|
|
channels / forms / shapes — NOT because those are outside the AFI (they are
|
|
AFI-common; see `manifest.py`), but because their per-adapter wiring is gated by
|
|
the *capability* parity suite (`test_capability_parity.py`), not by IR-shape.
|
|
|
|
`register_fixture()` registers the functions with mizan_core.registry.
|
|
Backend test apps import this module and call register_fixture() during
|
|
their setup so each backend's schema export sees the same registrations.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from mizan_core.client.function import client
|
|
from mizan_core.registry import register
|
|
|
|
|
|
# ─── Output shapes ──────────────────────────────────────────────────────────
|
|
|
|
|
|
class EchoOutput(BaseModel):
|
|
message: str
|
|
|
|
|
|
class WhoamiOutput(BaseModel):
|
|
email: str
|
|
authenticated: bool
|
|
|
|
|
|
class ProfileOutput(BaseModel):
|
|
user_id: int
|
|
name: str
|
|
|
|
|
|
class OrderOutput(BaseModel):
|
|
id: int
|
|
user_id: int
|
|
total: int
|
|
|
|
|
|
class StatusOutput(BaseModel):
|
|
ok: bool
|
|
|
|
|
|
# ─── Fixture functions ──────────────────────────────────────────────────────
|
|
|
|
|
|
@client
|
|
def echo(request, text: str) -> EchoOutput:
|
|
"""Echoes the input back."""
|
|
return EchoOutput(message=f"echo: {text}")
|
|
|
|
|
|
@client
|
|
def whoami(request) -> WhoamiOutput:
|
|
"""Returns the current user identity."""
|
|
return WhoamiOutput(email="anon@example.com", authenticated=False)
|
|
|
|
|
|
@client(context="user")
|
|
def user_profile(request, user_id: int) -> ProfileOutput:
|
|
"""One half of the user context."""
|
|
return ProfileOutput(user_id=user_id, name="placeholder")
|
|
|
|
|
|
@client(context="user")
|
|
def user_orders(request, user_id: int) -> list[OrderOutput]:
|
|
"""Other half of the user context — same param, proves param elevation."""
|
|
return []
|
|
|
|
|
|
@client(affects="user")
|
|
def update_profile(request, user_id: int, name: str) -> StatusOutput:
|
|
"""Mutation declaring affects on the user context."""
|
|
return StatusOutput(ok=True)
|
|
|
|
|
|
@client
|
|
def find_user(request, user_id: int) -> ProfileOutput | None:
|
|
"""Optional return — exercises Pydantic `T | None` schema introspection."""
|
|
return None
|
|
|
|
|
|
@client(merge="user")
|
|
def rename_user(request, user_id: int, name: str) -> ProfileOutput:
|
|
"""Merge target — kernel splices return value into the user context."""
|
|
return ProfileOutput(user_id=user_id, name=name)
|
|
|
|
|
|
# ─── Registration ───────────────────────────────────────────────────────────
|
|
|
|
|
|
def register_fixture() -> None:
|
|
"""Register every fixture function with mizan_core.registry."""
|
|
register(echo, "echo")
|
|
register(whoami, "whoami")
|
|
register(user_profile, "user_profile")
|
|
register(user_orders, "user_orders")
|
|
register(update_profile, "update_profile")
|
|
register(find_user, "find_user")
|
|
register(rename_user, "rename_user")
|