feat: referentiel projets dynamique + validation nommage by design
Durcit la convention de nommage des projets (dérive constatée : 'Sliding Automation', 'code_versioning'... au lieu des formes canoniques). - trilium_api.py : projets_canoniques() lit le référentiel = valeurs du label projet sur les notes de type=projet (source unique, pas de constante en dur). Note-projet CodeVersioning créée (manquait). - mcp_server.py : _valider_projet() branché dans les 6 tools de création (add_decision/history/backlog, new_conversation, create_entite, add_skill). Refuse un projet non canonique (suggestion si faute) ou inconnu (renvoi au processus de création de projet). Ne verrouille pas si référentiel illisible. - lint_audit.py : VAL-nommage aligné sur le référentiel (attrape casse, espace ET snake_case ; l'ancien 'contient un espace' ratait code_versioning). - Données : 79 notes ré-étiquetées vers les 3 formes canoniques. Quality by design : l'erreur de nommage devient impossible à l'écriture, le Lint n'est plus que le filet de sécurité.
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
@cython.no_gc_clear
|
||||
cdef class UVTimer(UVHandle):
|
||||
cdef _init(self, Loop loop, method_t callback, object ctx,
|
||||
uint64_t timeout):
|
||||
|
||||
cdef int err
|
||||
|
||||
self._start_init(loop)
|
||||
|
||||
self._handle = <uv.uv_handle_t*> PyMem_RawMalloc(sizeof(uv.uv_timer_t))
|
||||
if self._handle is NULL:
|
||||
self._abort_init()
|
||||
raise MemoryError()
|
||||
|
||||
err = uv.uv_timer_init(self._loop.uvloop, <uv.uv_timer_t*>self._handle)
|
||||
if err < 0:
|
||||
self._abort_init()
|
||||
raise convert_error(err)
|
||||
|
||||
self._finish_init()
|
||||
|
||||
self.callback = callback
|
||||
self.ctx = ctx
|
||||
self.running = 0
|
||||
self.timeout = timeout
|
||||
self.start_t = 0
|
||||
|
||||
cdef stop(self):
|
||||
cdef int err
|
||||
|
||||
if not self._is_alive():
|
||||
self.running = 0
|
||||
return
|
||||
|
||||
if self.running == 1:
|
||||
err = uv.uv_timer_stop(<uv.uv_timer_t*>self._handle)
|
||||
self.running = 0
|
||||
if err < 0:
|
||||
exc = convert_error(err)
|
||||
self._fatal_error(exc, True)
|
||||
return
|
||||
|
||||
cdef start(self):
|
||||
cdef int err
|
||||
|
||||
self._ensure_alive()
|
||||
|
||||
if self.running == 0:
|
||||
# Update libuv internal time.
|
||||
uv.uv_update_time(self._loop.uvloop) # void
|
||||
self.start_t = uv.uv_now(self._loop.uvloop)
|
||||
|
||||
err = uv.uv_timer_start(<uv.uv_timer_t*>self._handle,
|
||||
__uvtimer_callback,
|
||||
self.timeout, 0)
|
||||
if err < 0:
|
||||
exc = convert_error(err)
|
||||
self._fatal_error(exc, True)
|
||||
return
|
||||
self.running = 1
|
||||
|
||||
cdef get_when(self):
|
||||
return self.start_t + self.timeout
|
||||
|
||||
@staticmethod
|
||||
cdef UVTimer new(Loop loop, method_t callback, object ctx,
|
||||
uint64_t timeout):
|
||||
|
||||
cdef UVTimer handle
|
||||
handle = UVTimer.__new__(UVTimer)
|
||||
handle._init(loop, callback, ctx, timeout)
|
||||
return handle
|
||||
|
||||
|
||||
cdef void __uvtimer_callback(
|
||||
uv.uv_timer_t* handle,
|
||||
) noexcept with gil:
|
||||
if __ensure_handle_data(<uv.uv_handle_t*>handle, "UVTimer callback") == 0:
|
||||
return
|
||||
|
||||
cdef:
|
||||
UVTimer timer = <UVTimer> handle.data
|
||||
method_t cb = timer.callback
|
||||
|
||||
timer.running = 0
|
||||
try:
|
||||
cb(timer.ctx)
|
||||
except BaseException as ex:
|
||||
timer._error(ex, False)
|
||||
Reference in New Issue
Block a user