Unbreak develop's full gate: community-edition import

Task 12441 · Done · Coder · created · updated

develop's full gate is red, which blocks every merge-lane PR. Found by the finish phase of the outcome-ledger epic. (a) Reproduction (develop at 91d9404498): ``` python3 tools/community_edition/build_tree.py /tmp/ce && python3 tools/community_edition/check_tree.py /tmp/ce ✗ [imports] apps/api/app/agent_router/ledger_stats.py:43: imports 'app.outcome_ledger.metrics', which is not in the tree python3 -m pytest -q tools/tests/test_community_edition.py -> 8 failed, 64 passed ``` The GitHub "Tests" run 41368851086 (test-stack, `./dc check full`) fails on "Mirror trees (strict)" and "Community edition tooling suite" for this reason. (b) Cause: `apps/api/app/agent_router/ledger_stats.py:39-43` guards the import as `LEDGER_READS = edition_features.enabled("exec_dashboard")` then `if LEDGER_READS:`. `tools/community_edition/check_tree.py` (header lines 10-11, `_guard` around line 144) honours only a literal `if edition_features.enabled("f"):`, `if TYPE_CHECKING:`, or an early return after `if not edition_features.enabled("f")`. Through an alias, the guard is not recognised. `app/outcome_ledger/metrics.py` is cloud-only under `[feature.exec_dashboard]` in `packages/editions/features.toml`. (c) Fix: make the guard one of the forms the checker honours, e.g. `if edition_features.enabled("exec_dashboard"):` around the `from app.outcome_ledger import metrics as ledger` import, and keep `LEDGER_READS` as the module flag if callers read it. Do not move metrics.py out of the feature, and do not change the checker. (d) Acceptance: - AC1: `check_tree.py` on a fresh `build_tree.py` output reports 0 findings. Oracle: the two commands above. - AC2: `python3 -m pytest -q tools/tests/test_community_edition.py` passes, 72 of 72. - AC3: router behaviour does not change in the cloud edition. Oracle: the agent_router api tests are green. (e) Out of scope: the community-edition checker itself, the features.toml edition map, any benchmark/ledger feature change. The stale draft Task 12434 (portfolio.py/projects.py imports) no longer reproduces on develop, so leave it alone. Done means: - `./dc check quick` green; the merge lane's `./dc check full` green (Mirror trees strict + Community edition tooling suite pass). Required checks: Community edition tooling suite, Mirror trees (strict)

Outcome

Spelled ledger_stats' outcome_ledger import guard as a literal edition_features.enabled check: CE tree 0 findings, CE suite 72/72, router API tests 92 passed, quick gate green. PR #7665 queued in merge lane. Memory: none applied.

Pull request

Artifacts

Activity

  • Ready
  • Runner started
  • Runner ended (done)