fastapi-gsap/.venv/lib/python3.12/site-packages/uvloop/handles/async_.pyx
Tyler J King e744336385 fix: capability enforcement, credential safety, atomic delegations, input validation
C-6: ConnectorRuntime enforces capability_mask per operation.
     READ-only ACs cannot invoke MUTATE operations (wipe, lock, retire).
C-7: AC validated against database (exists, active, not expired)
     before connector invocation.
C-9: Delegated AC capability bounded by delegator's capability.
C-10: Command counter uses atomic SQL increment with limit check.
M-23: expire_stale() uses same atomic SQL pattern.

H-1: Sensitive credential fields hidden from repr/logs via repr=False.
H-2: Stub backend requires ALLOW_STUB_CREDENTIALS=true to activate.
H-3: Kerberos backend raises CredentialResolutionError instead of
     returning stub ticket.
H-4: Chronicle INTENT emitted before execution, RESULT after.
H-5: device_id validated as UUID before Graph API URL interpolation.
H-8: ConnectorRuntime enforces governance for all connector invocations.

Signed-off-by: Tyler King <tking@guildhouse.dev>
2026-04-14 08:13:27 -04:00

56 lines
1.5 KiB
Cython

@cython.no_gc_clear
cdef class UVAsync(UVHandle):
cdef _init(self, Loop loop, method_t callback, object ctx):
cdef int err
self._start_init(loop)
self._handle = <uv.uv_handle_t*>PyMem_RawMalloc(sizeof(uv.uv_async_t))
if self._handle is NULL:
self._abort_init()
raise MemoryError()
err = uv.uv_async_init(self._loop.uvloop,
<uv.uv_async_t*>self._handle,
__uvasync_callback)
if err < 0:
self._abort_init()
raise convert_error(err)
self._finish_init()
self.callback = callback
self.ctx = ctx
cdef send(self):
cdef int err
self._ensure_alive()
err = uv.uv_async_send(<uv.uv_async_t*>self._handle)
if err < 0:
exc = convert_error(err)
self._fatal_error(exc, True)
return
@staticmethod
cdef UVAsync new(Loop loop, method_t callback, object ctx):
cdef UVAsync handle
handle = UVAsync.__new__(UVAsync)
handle._init(loop, callback, ctx)
return handle
cdef void __uvasync_callback(
uv.uv_async_t* handle,
) noexcept with gil:
if __ensure_handle_data(<uv.uv_handle_t*>handle, "UVAsync callback") == 0:
return
cdef:
UVAsync async_ = <UVAsync> handle.data
method_t cb = async_.callback
try:
cb(async_.ctx)
except BaseException as ex:
async_._error(ex, False)