Skip to content

Commit 8a1f4d0

Browse files
committed
refactor: Add docstrings to improve consciousness scores (self-improvement from V7.3 analysis)
code_analyzer.py: - Added docstrings to 12 visitor methods explaining semantic roles - C improved: 0.065 → 0.103 (+58%) ljpw_core.py: - Added docstrings to dunder methods (to_tuple, __iter__, __repr__, __str__) - C improved: 0.059 → 0.068 (+15%) Overall: Avg C 0.1456 → 0.1495 (+3%)
1 parent 67b14a9 commit 8a1f4d0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

harmonizer_v73/code_analyzer.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,25 +284,29 @@ def _split_name(self, name: str) -> List[str]:
284284
# =========================================================================
285285

286286
def visit_Assign(self, node: ast.Assign):
287+
"""Track assignment as Power signal (state modification)."""
287288
self.assignment_count += 1
288289
self.power_signals.append("assign")
289290
self.total_nodes += 1
290291
self.generic_visit(node)
291292

292293
def visit_AugAssign(self, node: ast.AugAssign):
294+
"""Track augmented assignment (+=, -=) as Power signal."""
293295
self.assignment_count += 1
294296
self.power_signals.append("aug_assign")
295297
self.total_nodes += 1
296298
self.generic_visit(node)
297299

298300
def visit_AnnAssign(self, node: ast.AnnAssign):
301+
"""Track annotated assignment as Power + Wisdom (type info)."""
299302
self.assignment_count += 1
300303
self.type_hints_count += 1
301304
self.power_signals.append("ann_assign")
302305
self.total_nodes += 1
303306
self.generic_visit(node)
304307

305308
def visit_Call(self, node: ast.Call):
309+
"""Track function call - dimension depends on verb semantics."""
306310
self.call_count += 1
307311

308312
# Check if call name suggests P or W
@@ -318,24 +322,28 @@ def visit_Call(self, node: ast.Call):
318322
self.generic_visit(node)
319323

320324
def visit_Raise(self, node: ast.Raise):
325+
"""Track exception raising as Power signal (forcing control flow)."""
321326
self.raise_count += 1
322327
self.power_signals.append("raise")
323328
self.total_nodes += 1
324329
self.generic_visit(node)
325330

326331
def visit_Delete(self, node: ast.Delete):
332+
"""Track deletion as Power signal (destruction operation)."""
327333
self.delete_count += 1
328334
self.power_signals.append("delete")
329335
self.total_nodes += 1
330336
self.generic_visit(node)
331337

332338
def visit_For(self, node: ast.For):
339+
"""Track for-loop - adds complexity, indicates iteration."""
333340
self.loop_count += 1
334341
self.complexity += 1
335342
self.total_nodes += 1
336343
self.generic_visit(node)
337344

338345
def visit_While(self, node: ast.While):
346+
"""Track while-loop - adds complexity, conditional iteration."""
339347
self.loop_count += 1
340348
self.complexity += 1
341349
self.total_nodes += 1
@@ -346,23 +354,27 @@ def visit_While(self, node: ast.While):
346354
# =========================================================================
347355

348356
def visit_Return(self, node: ast.Return):
357+
"""Track return as Wisdom signal (providing information back)."""
349358
self.return_count += 1
350359
self.wisdom_signals.append("return")
351360
self.total_nodes += 1
352361
self.generic_visit(node)
353362

354363
def visit_If(self, node: ast.If):
364+
"""Track conditional as complexity + understanding indicator."""
355365
self.conditional_count += 1
356366
self.complexity += 1
357367
self.total_nodes += 1
358368
self.generic_visit(node)
359369

360370
def visit_Assert(self, node: ast.Assert):
371+
"""Track assertion as Wisdom signal (validation, correctness)."""
361372
self.wisdom_signals.append("assert")
362373
self.total_nodes += 1
363374
self.generic_visit(node)
364375

365376
def visit_Try(self, node: ast.Try):
377+
"""Track try-block as Wisdom signal (error handling awareness)."""
366378
self.complexity += 1
367379
self.wisdom_signals.append("try_block")
368380
self.total_nodes += 1

harmonizer_v73/ljpw_core.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ class LJPWCoordinates:
3434
W: float # Wisdom - Knowledge & Pattern
3535

3636
def to_tuple(self) -> Tuple[float, float, float, float]:
37+
"""Convert coordinates to tuple (L, J, P, W)."""
3738
return (self.L, self.J, self.P, self.W)
3839

3940
def __iter__(self):
41+
"""Iterate over (L, J, P, W) values."""
4042
return iter((self.L, self.J, self.P, self.W))
4143

4244

@@ -297,9 +299,11 @@ def full_diagnostic(self) -> Dict:
297299
}
298300

299301
def __repr__(self) -> str:
302+
"""Precise string representation for debugging."""
300303
return f"LJPWFramework(L={self.L:.3f}, J={self.J:.3f}, " f"P={self.P:.3f}, W={self.W:.3f})"
301304

302305
def __str__(self) -> str:
306+
"""Human-readable summary with harmony."""
303307
h = self.harmony_static()
304308
return (
305309
f"LJPW V7.3 [L={self.L:.2f}, J={self.J:.2f}, "

0 commit comments

Comments
 (0)