docs: close source comment remediation

This commit is contained in:
fy59 2026-09-02 23:01:25 +02:00
parent 356cfd125c
commit 4fc5a8ea48
11 changed files with 167 additions and 73 deletions

View file

@ -619,6 +619,7 @@ Translation of historical evidence must preserve the historical checkpoint exact
- DOCUMENTATION_INVENTORY_AUDIT=PASS_WITH_FINDINGS - DOCUMENTATION_INVENTORY_AUDIT=PASS_WITH_FINDINGS
- DOCUMENTATION_FINDING_REMEDIATION=PASS - DOCUMENTATION_FINDING_REMEDIATION=PASS
- DOCUMENTATION_LANGUAGE_NORMALIZATION=IN_PROGRESS - DOCUMENTATION_LANGUAGE_NORMALIZATION=IN_PROGRESS
- SOURCE_COMMENT_AUDIT=NEXT - SOURCE_COMMENT_AUDIT=PASS
- PRODUCT_DEFINITION=NOT_STARTED - SOURCE_COMMENT_REMEDIATION=PASS
- PRODUCT_DEFINITION=NEXT
- PROMPT_TREE=NOT_STARTED - PROMPT_TREE=NOT_STARTED

View file

@ -0,0 +1,99 @@
# Lardon3D — Source Comment Audit
## Status
```text
SOURCE_COMMENT_AUDIT=PASS
SOURCE_COMMENT_REMEDIATION=PASS
SOURCE_COMMENT_SCOPE=include/lardon3d/** + src/**
SOURCE_COMMENT_LANGUAGE=ENGLISH
SOURCE_CODE_BEHAVIOR_CHANGED=NO
```
The audit covered 148 C/C++ source/header files under `include/lardon3d/**` and `src/**`.
The initial static inventory reported:
```text
comment blocks 807
raw non-English lexical candidates 33
actual French comment blocks 29
English false positives 4
stale-contract candidates 0
raw unannotated-public declarations 324
```
## Remediation
All 29 actual French source comments were translated to English.
The four raw language-detector false positives were already English and were left unchanged.
The remediation touched comments only. A file-level lexical comparison removed comments entirely and verified that every non-comment source
byte remained identical before and after the declared replacements.
No executable UI/error string was changed in this pass. UI language is a separate explicitly scoped
implementation pass.
## Stale and misleading comments
The lexical stale-contract pass found zero candidate comments.
No scientific threshold, schema version, Task Kind, resource contract, persistence identity or FROZEN
boundary was changed by this audit.
## Public API adjacency heuristic
The first inventory reported 324 public declarations without an immediately adjacent comment.
That number is **informational only**, not 324 defects.
The repository Source Comment Contract requires comments where WHY, CONTRACT, INVARIANT, OWNERSHIP,
IDENTITY, persistence ordering, restart, cancellation, concurrency, resource accounting or a FROZEN
boundary is non-obvious. It does not require one redundant comment for every getter, thin wrapper,
paired create/load/list function or declaration already covered by a surrounding contract block.
Therefore absence of an adjacent comment alone is not a valid
`UNDER_COMMENTED`/`SEVERELY_UNDER_COMMENTED` finding.
Future audits must review semantic contract coverage rather than using declaration adjacency as a
blanket failure criterion.
## Source Comment Contract
Production source comments:
- are English;
- explain non-obvious WHY/CONTRACT/INVARIANT facts;
- preserve ownership and lifetime boundaries;
- preserve persistence/restart ordering;
- preserve concurrency/resource-accounting boundaries;
- preserve scientific identity and FROZEN constraints;
- do not paraphrase obvious code line-by-line;
- are updated when behavior changes.
## Validation
The remediation runner requires:
```text
branch = docs-audit
no unrelated worktree changes
all expected old comments match exactly once
file-level source with all comments removed remains byte-for-byte identical
no strong French-comment candidate remains
git diff --check passes
```
## Phase state
```text
DOCUMENTATION_FINDING_REMEDIATION=PASS
DOCUMENTATION_LANGUAGE_NORMALIZATION=IN_PROGRESS
SOURCE_COMMENT_AUDIT=PASS
SOURCE_COMMENT_REMEDIATION=PASS
PRODUCT_DEFINITION=NEXT
PROMPT_TREE=NOT_STARTED
```

View file

@ -9,9 +9,9 @@
#include <lardon3d/visual_index.h> #include <lardon3d/visual_index.h>
typedef struct { typedef struct {
uint32_t generated_count; // paires nouvellement créées uint32_t generated_count; // newly created pairs
uint32_t skipped_count; // paires déjà existantes (idempotence) uint32_t skipped_count; // already existing pairs (idempotent reuse)
uint32_t queried_count; // candidats retournés par le Visual Index uint32_t queried_count; // candidates returned by the Visual Index
} Lardon3DCandidatePairGenStats; } Lardon3DCandidatePairGenStats;
Lardon3DVisualIndexResult lardon3d_candidate_pair_generate( Lardon3DVisualIndexResult lardon3d_candidate_pair_generate(

View file

@ -42,7 +42,7 @@ bool lardon3d_project_enqueue_image_import(Lardon3DAppState *state, uint64_t sca
bool lardon3d_image_import_reconstruct(const Lardon3DTaskDurableSnapshot *snapshot, void *context, bool lardon3d_image_import_reconstruct(const Lardon3DTaskDurableSnapshot *snapshot, void *context,
Lardon3DTaskKindBinding *binding); Lardon3DTaskKindBinding *binding);
/* Compatibilité TUI : handle léger sur une tâche de la queue, sans thread. */ /* TUI compatibility: lightweight handle over a Queue Task, with no private thread. */
Lardon3DImportTask *lardon3d_import_task_create(void); Lardon3DImportTask *lardon3d_import_task_create(void);
bool lardon3d_import_task_start(Lardon3DImportTask *task, Lardon3DAppState *state, bool lardon3d_import_task_start(Lardon3DImportTask *task, Lardon3DAppState *state,
const char *source_directory); const char *source_directory);

View file

@ -325,11 +325,11 @@ const char *lardon3d_resource_decision_name(
Lardon3DResourcePressure lardon3d_resource_governor_pressure( Lardon3DResourcePressure lardon3d_resource_governor_pressure(
Lardon3DResourceGovernor *governor Lardon3DResourceGovernor *governor
); );
/* Enregistre les métriques d'un lot terminé pour l'adaptation dynamique /* Records metrics from one completed batch for dynamic adaptation of future
* de la taille des lots futurs. batch_size est le nombre d'éléments dont le * batch sizes. batch_size is the number of items whose processing was validated
* traitement a é validé dans ce lot. peak_memory_bytes == 0 signifie que * in this batch. peak_memory_bytes == 0 means the measurement is unknown and
* la mesure est inconnue et n'alimente jamais l'adaptation mémoire. Le buffer * never feeds memory adaptation. The buffer is bounded to 8 entries per Task
* est borné (8 entrées par classe de tâche). Thread-safe. */ * class. Thread-safe. */
bool lardon3d_resource_governor_record_batch( bool lardon3d_resource_governor_record_batch(
Lardon3DResourceGovernor *governor, Lardon3DResourceGovernor *governor,
Lardon3DResourceTaskClass task_class, Lardon3DResourceTaskClass task_class,

View file

@ -108,8 +108,8 @@ Lardon3DTask *lardon3d_task_create_typed(
Lardon3DTaskUserdataDestroy userdata_destroy Lardon3DTaskUserdataDestroy userdata_destroy
); );
void lardon3d_task_destroy(Lardon3DTask *task); void lardon3d_task_destroy(Lardon3DTask *task);
/* Exécute le callback dans le thread appelant. Le callback est invoqué hors /* Executes the callback on the calling thread. The callback runs outside
* mutex de tâche; le contract d'exécution et l'état appartiennent à la tâche. * the Task mutex; the execution contract and state remain owned by the Task.
*/ */
bool lardon3d_task_start( bool lardon3d_task_start(
Lardon3DTask *task, Lardon3DTask *task,
@ -169,16 +169,16 @@ Lardon3DTask *lardon3d_task_restore_typed(
void *userdata, void *userdata,
Lardon3DTaskUserdataDestroy userdata_destroy Lardon3DTaskUserdataDestroy userdata_destroy
); );
/* Une restauration typée réussie transfère userdata/userdata_destroy à la /* A successful typed restore transfers userdata/userdata_destroy ownership
* tâche. En cas d'échec, l'appelant en reste propriétaire. */ * to the Task. On failure, the caller retains ownership. */
bool lardon3d_task_kind_is_valid(const char *task_kind); bool lardon3d_task_kind_is_valid(const char *task_kind);
bool lardon3d_task_kind( bool lardon3d_task_kind(
const Lardon3DTask *task, const Lardon3DTask *task,
char task_kind[LARDON3D_TASK_KIND_CAPACITY], char task_kind[LARDON3D_TASK_KIND_CAPACITY],
uint32_t *task_kind_version uint32_t *task_kind_version
); );
/* Appelé au plus une fois, hors mutex de tâche et après libération de la /* Invoked at most once, outside the Task mutex and after the terminal
* réservation terminale. Le userdata de tâche reste vivant jusqu'au retour. */ * reservation is released. Task userdata remains alive until the callback returns. */
bool lardon3d_task_set_finished_callback( bool lardon3d_task_set_finished_callback(
Lardon3DTask *task, Lardon3DTask *task,
Lardon3DTaskFinishedCallback callback, Lardon3DTaskFinishedCallback callback,
@ -190,21 +190,20 @@ bool lardon3d_task_resource_estimate(
const Lardon3DTask *task, const Lardon3DTask *task,
Lardon3DResourceEstimate *estimate Lardon3DResourceEstimate *estimate
); );
/* L'exécution ne reçoit pas de politique d'admission : c'est au gouverneur de /* Execution does not receive admission policy: the Governor must confirm
* confirmer la réservation avant l'exécution. * the reservation before execution.
*/ */
bool lardon3d_task_execution_contract( bool lardon3d_task_execution_contract(
const Lardon3DTask *task, const Lardon3DTask *task,
Lardon3DTaskExecutionContract *contract Lardon3DTaskExecutionContract *contract
); );
/* Libère la réservation courante, en obtient une nouvelle auprès du gouverneur /* Releases the current reservation, obtains a new one from the Governor,
* et met à jour le contrat. À appeler uniquement depuis le callback en cours * and updates the execution contract. Call only from the currently executing
* d'exécution. Une réponse WAIT du gouverneur est une indisponibilité * callback. A Governor WAIT is temporary unavailability: this function waits
* temporaire : la fonction attend un changement de ressources puis retente * for a resource change and retries admission without failing the Task. Batch
* l'admission sans échouer la tâche. Les bornes de lot se poursuivent après * bounds continue under the new admission. Returns false if the Task is
* cette nouvelle admission. Retourne false si la tâche est annulée * cancelled (TASK_CANCELLED), the Governor returns REJECT, or an internal
* (TASK_CANCELLED), si le gouverneur répond REJECT ou en cas d'erreur interne * error fails the Task (TASK_FAILED). */
* (TASK_FAILED). */
bool lardon3d_task_sequence_break( bool lardon3d_task_sequence_break(
Lardon3DTask *task, Lardon3DTask *task,
Lardon3DResourceGovernor *governor, Lardon3DResourceGovernor *governor,

View file

@ -42,10 +42,6 @@ typedef struct {
* serialized worker. capacity bounds pending Tasks, not terminal history; the * serialized worker. capacity bounds pending Tasks, not terminal history; the
* Governor retains resource-admission ownership and must outlive the Queue. * Governor retains resource-admission ownership and must outlive the Queue.
* *
* File d'exécution bornée, à ordre d'attente FIFO avec sélection adaptative du
* premier travail admissible, et un seul worker: ownership d'ordonnancement et
* de backpressure seulement. L'admission des demandes reste au Governneur.
*
* CONTRACT: after a successful add, the Queue owns Task and its userdata. Once * CONTRACT: after a successful add, the Queue owns Task and its userdata. Once
* the Task is terminal and its finished callback has returned, the Queue keeps * the Task is terminal and its finished callback has returned, the Queue keeps
* only a snapshot and promptly destroys the real Task outside the Queue lock. * only a snapshot and promptly destroys the real Task outside the Queue lock.
@ -73,8 +69,8 @@ Lardon3DTaskQueue *lardon3d_task_queue_create(
* starts after destruction safe. NULL is accepted. Never call destroy * starts after destruction safe. NULL is accepted. Never call destroy
* synchronously from a Task finished callback running on this Queue. */ * synchronously from a Task finished callback running on this Queue. */
void lardon3d_task_queue_destroy(Lardon3DTaskQueue *queue); void lardon3d_task_queue_destroy(Lardon3DTaskQueue *queue);
/* La file devient propriétaire de task uniquement en cas de succès. /* The Queue takes ownership of task only on success.
* Bloquante : attend une place libre si la file est pleine. A zero Task ID is * Blocking: waits for a free slot when the Queue is full. A zero Task ID is
* assigned from a nonzero monotonic sequence and is never generated twice * assigned from a nonzero monotonic sequence and is never generated twice
* during this Queue lifetime, including after terminal-history eviction or * during this Queue lifetime, including after terminal-history eviction or
* removal. Once UINT64_MAX has been generated (or consumed by a restored * removal. Once UINT64_MAX has been generated (or consumed by a restored
@ -85,8 +81,8 @@ bool lardon3d_task_queue_add(
Lardon3DTask *task, Lardon3DTask *task,
uint64_t *task_id uint64_t *task_id
); );
/* Non-bloquante : retourne false si la file est pleine ou en arrêt. /* Non-blocking: returns false if the Queue is full or stopping.
La file devient propriétaire de task uniquement en cas de succès. */ The Queue takes ownership of task only on success. */
bool lardon3d_task_queue_try_add( bool lardon3d_task_queue_try_add(
Lardon3DTaskQueue *queue, Lardon3DTaskQueue *queue,
Lardon3DTask *task, Lardon3DTask *task,

View file

@ -397,9 +397,9 @@ bool run_impl(Lardon3DTask *t, void *p) {
c->db, lardon3d_task_id(t), group_id, materialized_capture_id, c->db, lardon3d_task_id(t), group_id, materialized_capture_id,
group_id) != LARDON3D_PROJECT_DB_OK) group_id) != LARDON3D_PROJECT_DB_OK)
return lardon3d_task_fail(t, "Rétention de Capture impossible."); return lardon3d_task_fail(t, "Rétention de Capture impossible.");
/* Limite de reprise acceptée: entre le retour de S3-E et cette rétention /* Accepted recovery boundary: between S3-E returning and this durable
* durable, une identité de capture ne peut pas être déduite à posteriori * retention, Capture identity cannot be reconstructed retroactively from
* depuis les chemins/métadonnées/ID d'image. * paths, metadata, or image IDs.
*/ */
#ifdef LARDON3D_ACQUISITION_CAMPAIGN_TASK_TESTING #ifdef LARDON3D_ACQUISITION_CAMPAIGN_TASK_TESTING
const char *after_retention = const char *after_retention =

View file

@ -1797,8 +1797,8 @@ record_batch_locked(
metrics[head] = (Lardon3DBatchMetrics) { metrics[head] = (Lardon3DBatchMetrics) {
.batch_size = batch_size, .batch_size = batch_size,
.duration_ns = duration_ns, .duration_ns = duration_ns,
/* Zéro est le marqueur persistant « mesure inconnue ». La boucle /* Zero is the sentinel for an unknown measurement. The adaptation
* d'adaptation ignore explicitement ces échantillons. */ * loop explicitly ignores these samples. */
.peak_memory_bytes = peak_memory_bytes, .peak_memory_bytes = peak_memory_bytes,
}; };
head = (head + 1) % LARDON3D_BATCH_METRICS_CAPACITY; head = (head + 1) % LARDON3D_BATCH_METRICS_CAPACITY;
@ -1836,9 +1836,9 @@ adaptive_batch_limit(
% LARDON3D_BATCH_METRICS_CAPACITY; % LARDON3D_BATCH_METRICS_CAPACITY;
const Lardon3DBatchMetrics *m = &governor->batch_metrics[class_index][idx]; const Lardon3DBatchMetrics *m = &governor->batch_metrics[class_index][idx];
if (m->batch_size > 0 && m->peak_memory_bytes > 0) { if (m->batch_size > 0 && m->peak_memory_bytes > 0) {
/* Coût par élément le plus défavorable observé : une moyenne /* Use the worst observed per-item cost: an average would
* sous-estimerait le pic et laisserait un lot dépasser son * underestimate the peak and could let a batch exceed its
* budget. La stabilité de l'hôte prime sur le débit. */ * budget. Host safety takes precedence over throughput. */
uint64_t per_item = m->peak_memory_bytes / m->batch_size uint64_t per_item = m->peak_memory_bytes / m->batch_size
+ (m->peak_memory_bytes % m->batch_size != 0); + (m->peak_memory_bytes % m->batch_size != 0);
if (per_item > measured_per_item) { if (per_item > measured_per_item) {
@ -1853,9 +1853,9 @@ adaptive_batch_limit(
if (measured_per_item <= memory_bytes_per_item) { if (measured_per_item <= memory_bytes_per_item) {
return static_batch; return static_batch;
} }
/* Éviter l'overflow de la multiplication : si static_batch est trop /* Avoid multiplication overflow: if static_batch is too large to
* grand pour être multiplié sans débordement, on retourne 1 (le lot le * multiply safely, return 1 (the most conservative batch) instead of
* plus conservateur possible) plutôt que de saturer à SIZE_MAX. */ * saturating to SIZE_MAX. */
if (static_batch > UINT64_MAX / memory_bytes_per_item) { if (static_batch > UINT64_MAX / memory_bytes_per_item) {
return 1; return 1;
} }
@ -3222,10 +3222,10 @@ evaluate_locked(
) )
); );
} }
/* Le lot maximal visé est corrigé par les métriques mesurées : c'est la /* Measured metrics adjust the target maximum batch: this becomes the
* nouvelle cible du contrat, pas une réduction faute de ressources. La * contract target, not a reduction caused by current resource shortage.
* correction ne descend jamais sous minimum_batch_size pour éviter un * The adjustment never falls below minimum_batch_size, avoiding a
* WAIT persistant. */ * persistent WAIT. */
size_t adapted_maximum = adaptive_batch_limit( size_t adapted_maximum = adaptive_batch_limit(
governor, governor,
estimate->task_class, estimate->task_class,
@ -3626,7 +3626,7 @@ lardon3d_resource_governor_record_batch(
return false; return false;
} }
if (batch_size == 0) { if (batch_size == 0) {
/* No-op réussi : aucune métrique, aucun réveil inutile. */ /* Successful no-op: no metrics and no unnecessary wake-up. */
return true; return true;
} }
(void)pthread_mutex_lock(&governor->mutex); (void)pthread_mutex_lock(&governor->mutex);

View file

@ -612,8 +612,8 @@ lardon3d_task_destroy(Lardon3DTask *task)
"Annulation demandée."); "Annulation demandée.");
(void)pthread_cond_broadcast(&task->condition); (void)pthread_cond_broadcast(&task->condition);
} else { } else {
/* Une tâche locale jamais soumise peut être abandonnée sans /* A local Task that was never submitted may be abandoned without
* publier une fausse annulation métier. */ * publishing a false business-level cancellation. */
finish_locked(task, TASK_CANCELLED, "Tâche abandonnée."); finish_locked(task, TASK_CANCELLED, "Tâche abandonnée.");
task->finished_notified = true; task->finished_notified = true;
} }
@ -885,7 +885,7 @@ lardon3d_task_checkpoint(Lardon3DTask *task)
} }
enum { enum {
/* Attente bornée entre deux tentatives d'admission : 50 ms. */ /* Bounded wait between admission attempts: 50 ms. */
LARDON3D_SEQUENCE_ADMISSION_WAIT_NS = 50000000ULL, LARDON3D_SEQUENCE_ADMISSION_WAIT_NS = 50000000ULL,
}; };
@ -931,7 +931,7 @@ lardon3d_task_sequence_break(
(void)lardon3d_resource_governor_release(governor, previous); (void)lardon3d_resource_governor_release(governor, previous);
} }
for (;;) { for (;;) {
/* Vérifier pause et annulation avant chaque tentative d'admission. */ /* Check pause and cancellation before every admission attempt. */
(void)pthread_mutex_lock(&task->mutex); (void)pthread_mutex_lock(&task->mutex);
while (task->pause_requested && !task->cancel_requested) { while (task->pause_requested && !task->cancel_requested) {
task->state = TASK_PAUSED; task->state = TASK_PAUSED;
@ -962,7 +962,7 @@ lardon3d_task_sequence_break(
&next &next
); );
if (!admitted) { if (!admitted) {
/* Erreur interne : échec d'allocation ou d'instantané. */ /* Internal error: allocation or resource-snapshot failure. */
if (next) { if (next) {
(void)lardon3d_resource_governor_release(governor, next); (void)lardon3d_resource_governor_release(governor, next);
} }
@ -1079,8 +1079,8 @@ lardon3d_task_sequence_break(
(void)pthread_mutex_unlock(&task->mutex); (void)pthread_mutex_unlock(&task->mutex);
return false; return false;
case LARDON3D_RESOURCE_WAIT: case LARDON3D_RESOURCE_WAIT:
/* Indisponibilité temporaire : ne pas échouer, attendre un /* Temporary unavailability: do not fail the Task; wait for a
* changement de ressources puis retenter l'admission. */ * resource change and retry admission. */
if (next) { if (next) {
(void)lardon3d_resource_governor_release(governor, next); (void)lardon3d_resource_governor_release(governor, next);
} }
@ -1091,7 +1091,7 @@ lardon3d_task_sequence_break(
); );
break; break;
default: default:
/* Décision inconnue : erreur interne, ne jamais boucler. */ /* Unknown decision: internal error; never loop on it. */
if (next) { if (next) {
(void)lardon3d_resource_governor_release(governor, next); (void)lardon3d_resource_governor_release(governor, next);
} }

View file

@ -290,9 +290,9 @@ unlink_pending(Lardon3DTaskQueue *queue, TaskNode *previous, TaskNode *node)
} }
node->next_pending = NULL; node->next_pending = NULL;
--queue->pending_count; --queue->pending_count;
/* Chaque retrait libère une place. Plusieurs producteurs peuvent dormir /* Every removal frees one slot. Multiple producers may be asleep while
* pendant que le worker retire plusieurs tâches avant qu'ils reprennent * the worker removes several Tasks before they reacquire the mutex, so
* le mutex ; chacun de ces retraits doit donc produire un réveil. */ * every removal must signal one waiter. */
(void)pthread_cond_signal(&queue->not_full); (void)pthread_cond_signal(&queue->not_full);
} }
@ -361,12 +361,11 @@ destroy_retired(TaskNode *retired)
} }
} }
/* Parcourt la file d'attente dans son ordre FIFO et sélectionne la première /* Scans pending Tasks in FIFO order and selects the first admissible one.
* tâche admissible; une attente de ressources peut donc laisser passer une * A resource WAIT may therefore let a later Task run without removing the
* tâche antérieure sans lui faire perdre sa place dans la file. * waiting Task from its position. Terminal or rejected Tasks are removed.
* Les tâches terminales ou refusées sont retirées de la file d'attente. * A resource-waiting Task remains queued for later re-evaluation.
* Une tâche en attente de ressources reste en file et sera réévaluée. * Returns NULL when no Task can start immediately. */
* Retourne NULL si aucune tâche ne peut démarrer immédiatement. */
static TaskNode * static TaskNode *
select_admissible( select_admissible(
Lardon3DTaskQueue *queue, Lardon3DTaskQueue *queue,
@ -541,10 +540,10 @@ queue_worker(void *context)
); );
} }
} }
/* La tâche peut avoir libéré et re-réservé via sequence_break pendant /* The Task may have released and re-reserved through sequence_break
* son callback. Dans ce cas la réservation d'origine est déjà libérée * during its callback. In that case the original reservation is
* et cet appel est sans effet ; la réservation courante de la tâche a * already released and this call is a no-op; lardon3d_task_start
* é libérée par lardon3d_task_start. */ * released the Task's current reservation. */
if (reservation) { if (reservation) {
(void)lardon3d_resource_governor_release( (void)lardon3d_resource_governor_release(
queue->governor, queue->governor,
@ -763,7 +762,7 @@ lardon3d_task_queue_destroy(Lardon3DTaskQueue *queue)
free(queue); free(queue);
} }
/* Appelée sous le mutex queue. Ne signale pas not_empty sur échec. */ /* Called with the Queue mutex held. Does not signal not_empty on failure. */
static bool static bool
enqueue_locked( enqueue_locked(
Lardon3DTaskQueue *queue, Lardon3DTaskQueue *queue,