refactor(health): autoresearch code-health loop (-691 pts, -305 LOC)#137
refactor(health): autoresearch code-health loop (-691 pts, -305 LOC)#137
Conversation
…diction_detector in rule_graph
… in rule_graph, remove local copies
…vered by __init__.py)
…e between brain_scores and correction_tracking
…THRESHOLD - meta_rules.py: delete _detect_themes and _classify_meta_transfer_scope (cloud-only stubs with zero callers anywhere in the codebase) - rule_graph.py: import _normalize from contradiction_detector instead of redefining it; drop now-unused `import re` - judgment_decay.py: drop unused PATTERN_THRESHOLD from import block health_score 26146 -> 26136 (-10)
…ocstring schema - meta_rules_storage.py: extract shared INSERT SQL as _SQL_UPSERT_CORRECTION_PATTERN constant, shared by upsert_correction_pattern and upsert_correction_patterns_batch; eliminates 3 cross-function duplicate 6-line blocks - dedup.py: replace inline schema table in module docstring with reference to _CREATE_SQL constant, eliminating 3 duplicate blocks (docstring vs constant) health_score 26136 -> 26116 (-20); loc -8, dup_blocks -6
The 47-line module catalogue was counted as LOC (non-blank, non-comment lines). Replace with a 2-line summary; individual module docs live in each module's own docstring. Removes stale PLANNED entries and moved-module annotations. health_score 26116 -> 26070 (-46); loc -46
…8 pts) evaluator.py: drop 22-line usage example; orchestrator.py: collapse 15-item pattern list + example to 3-line inline; dedup.py: replace 13-line API example with function name list; memory_taxonomy.py: drop 18-line usage example; learning_pipeline.py: drop 16-line usage example. Co-Authored-By: Gradata <noreply@gradata.ai>
…pts) agent_graduation.py: collapse 15-line usage block to 1-liner; behavioral_engine.py: drop 18-line directive example; human_loop.py: condense 23-line API+design doc to 3 lines; middleware.py: drop 20-line class example; cluster_manager.py: collapse 20-line usage to 2-line summary. Co-Authored-By: Gradata <noreply@gradata.ai>
…pts) reflection.py: drop 20-line example; loop_detection.py: drop 19-line assert- based example; pipeline.py: drop 19-line Pipeline construction example; eval_benchmark.py: drop 18-line bench.add_case example. Co-Authored-By: Gradata <noreply@gradata.ai>
…pts) observation_hooks.py: drop 14-line store.append example; dedup.py: collapse MERGE/DROP policy note to 1 line; execute_qualify.py: drop 14-line loop.run example; reconciliation.py: drop 15-line plan/actuals example; q_learning_router.py: drop 13-line router.route example; gate_calibration.py: drop 13-line calibrator example. Co-Authored-By: Gradata <noreply@gradata.ai>
calibration.py: drop 7-line tracker.record example; task_escalation.py: drop 12-line report_outcome example (install_manifest and collaborative_filter skipped — their docstrings suppress cross-file dup blocks). Co-Authored-By: Gradata <noreply@gradata.ai>
Co-Authored-By: Gradata <noreply@gradata.ai>
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (32)
📝 Walkthrough
WalkthroughComprehensive refactoring adding a code-health verification script with three sequential gates (correctness via pytest, semantic via git diff, API via subprocess imports), consolidating documentation across pattern and enhancement modules, extracting shared SQL constants and memory-operation helpers, and reorganizing imports to externalize normalization logic. Changes
Sequence DiagramsequenceDiagram
participant Main as autoresearch_verify_codehealth.main()
participant CorrGate as correctness_gate()
participant SemGate as semantic_gate()
participant APIGate as api_gate()
participant PyTest as pytest<br/>(subprocess)
participant GitDiff as git diff<br/>(subprocess)
participant PythonImport as Python import<br/>(subprocess)
participant FileScanner as File scanner<br/>(LOC, duplicates, complexity)
Main->>CorrGate: Run correctness_gate()
CorrGate->>PyTest: Run pytest (test_brain.py, test_core_behavioral.py)<br/>with timeout
PyTest-->>CorrGate: Return pass/fail + stderr
CorrGate-->>Main: Return bool
Main->>SemGate: Run semantic_gate()
SemGate->>GitDiff: Check diffs vs feat/token-optimization<br/>for frozen globs
GitDiff-->>SemGate: Return diff status
SemGate-->>Main: Return bool
Main->>APIGate: Run api_gate()
APIGate->>PythonImport: Import public modules<br/>(subprocess with sys.path)
PythonImport-->>APIGate: Return import success/failure
APIGate-->>Main: Return bool
alt All gates pass
Main->>FileScanner: Scan files for metrics
FileScanner-->>Main: LOC, duplicates, complexity
Main->>Main: Compute health_score
Main->>Main: Print results (exit 0)
else Gate failure
Main->>Main: Print *_gate=FAIL
Main->>Main: Exit non-zero (2/3/4)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes Possibly related PRs
Suggested labels
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Categories
_detect_themes,_classify_meta_transfer_scope, unused imports, dead constants_SQL_UPSERT_CORRECTION_PATTERN,_SQL_CORRECTION_OUTPUT_TOTALS, import shared_STOP_WORDS/_POLARITY_PAIRS/_ACTION_OPPOSITES_store_memory/_decay_memorieshelpers,DecayResult._resulthelperTest plan
pytest Gradata/tests/— 3873 passed, 2 skippedGenerated with Gradata