refactor: canonicalize JSON output and add shared synthesis agent base #91
Merged
wasabi opened 1 month ago

Summary

  • Canonical JSON printing: replaces inline print(json.dumps(..., indent=2, default=str)) with services.common.cli.print_json() across ~80 service CLIs (262 conversions). Keeps the behaviorally-distinct variants (sort_keys, custom serializers, indent=4) intact and skips the 9 analytics modules already canonicalized by the pending analytics-cli-framework PR. Removes 52 newly-unused import json lines and fixes a pre-existing infinite-recursion get_db shadowing bug in services/predictions/cli.py.
  • Shared synthesis agent base: new services/agents/base.py with SynthesisAgent (safety assert -> managed connection -> synthesize -> optional draft ai_summary -> validate_output), run_fetch() for read-only agents, and the standard --location-id/--store agent_cli. Collapses get_connection/store/run/main boilerplate from the 10 synthesis agents (wellbeing, feedback, resilience, capital_efficiency, commons, gnh, regenerator, open_source_capitalist, kokonut_commons, bio_factory) plus ebf_evidence_gap_agent; each keeps its domain synthesize_* query and documented run_*_synthesis()/main() entry points.
  • Net ~500 lines removed; new unit tests in tests/test_agents_base.py.

Verification

  • All changed files compile; zero new ruff issues vs HEAD (diffed against an archive of main).
  • ~2,300 tests green across the platform-integrity set, CLI smoke, agent suites, and changed-module suites; the full suite (4,061 tests) collects with no errors.
  • Only environmental failures observed (missing schemas/ dir in the isolated worktree, no live DB for gateway_audit) — confirmed pre-existing and unrelated.
Commits were merged into target branch
  • refactor: canonicalize JSON output and add shared synthesis agent base
    Canonical JSON printing: replace inline `print(json.dumps(..., indent=2,
    default=str))` with `services.common.cli.print_json()` across ~80 service
    CLIs (keeping sort_keys/custom-default variants and the 21 analytics
    modules already migrated on the pending framework PR intact). Also fixes
    an infinite-recursion `get_db` shadowing bug found in
    services/predictions/cli.py.
    
    Agent base: add services/agents/base.py with a shared SynthesisAgent
    (run flow: safety assert -> managed connection -> synthesize -> optional
    draft ai_summary store -> validate_output) plus run_fetch for read-only
    agents and the standard --location-id/--store agent_cli. Collapses the
    get_connection/store/run/main boilerplate from the 10 synthesis agents
    (wellbeing, feedback, resilience, capital_efficiency, commons, gnh,
    regenerator, open_source_capitalist, kokonut_commons, bio_factory) and
    ebf_evidence_gap_agent; each keeps its domain synthesize_* query and
    documented run_*_synthesis()/main() entry points.
    
    Net ~500 lines removed; zero new ruff issues vs HEAD; new unit tests in
    tests/test_agents_base.py.
    
    Generated with Codebuff
    Co-Authored-By: Codebuff <noreply@codebuff.com>
    1 month ago
  • wasabi merged 1 month ago (merge commit: cf1aabaa )
1/1
Submitter wasabi
Target main
Source refactor/dedup-json-agents
Jobs
Merge Strategy
Create Merge Commit
Watchers (1)
Reference
pr KI-91
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover