Files
cleveragents-core/tools/controller
drew abff38a274 refactor(controller): batch F — ControllerForgejoConfig + parser strict mode (items 16, 17)
Final two items from the consolidated adversarial-review punch list.

ITEM 16 — ControllerForgejoConfig:
Previously ``master/__main__.py:build_cfg_stub`` reached into
``tools/_mcp_common.ForgejoCfg`` via sys.path injection and mutated
``cfg.owner`` / ``cfg.repo`` after construction. That inverted the
dependency direction (the controller is the new system; it shouldn't
reach into legacy pipeline modules) and tied controller deployments
to whatever schema ForgejoCfg happened to have.

Replaced with ``master/forgejo_cfg.py``: a dataclass owning exactly
the fields ``_claim_runtime`` reads (token, request_timeout_s,
api_retries, claim_ttl_seconds) plus the controller's own
(owner, repo). ``from_environment(owner, repo)`` reads the same env
vars the legacy ForgejoCfg used (FORGEJO_TOKEN, CONTROLLER_FORGEJO_*
tunables) so operators don't have to relearn anything.

``build_cfg_stub`` is now a 1-line delegate to ``from_environment``;
no sys.path mutation, no cross-package import.

ITEM 17 — parser coverage validator + strict mode:
Master startup now calls ``validate_parser_coverage()`` (already
exposed by Phase 1j's parser registry) and logs the gap loudly:

  WARNING CI parser coverage: 3/10 real (7 stub: ['bandit', 'build',
  'radon', 'robot_framework', 'semgrep', 'slipcover', 'vulture']).
  Stub-parser gates fall back to raw_log_excerpt; implementers see
  the log but not structured findings.

Operators who want the strict plan-v10 "STUCK on unknown tool"
behaviour set ``CONTROLLER_STRICT_PARSER_COVERAGE=1``; master then
refuses to start (exit 2) until every EXPECTED_PARSER has a real
implementation. Default off: ship-stubs is the migration-friendly
path; strict is the after-everything-is-implemented gate.

Tests:
- test_forgejo_cfg.py (+13 tests): dataclass shape, env resolution
  (defaults, FORGEJO_TOKEN preferred over CONTROLLER_FORGEJO_TOKEN,
  malformed env raises), no-sys-path-injection AST audit + returns
  the typed dataclass.
- test_entry_points.py (+2 tests): strict-mode blocks startup +
  default mode only warns.

Total: 647 controller tests pass (+12 net), 0 regressions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 15:40:45 -04:00
..