mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
* feat(board): Board Program registry — generic trigger/dedup/originate/LEARN engine
One registry (foundation/policy/board_programs.py) + one BoardProgramEngine +
one orchestrator loop replace the bespoke roadmap/spotlight loops, behavior-
preserved: same sources, dispatch routing, one-open-cycle dedup (ledger rows
auto-close when their exploration task goes terminal, so x_feature's
complete-at-propose flow can't wedge), and live per-program interval
overrides with the tick capped at 1h.
program_armed() is the single arming chokepoint: the settings-store
board_program.<key>.enabled override when present, else the legacy flag —
routed through BoardProgramEngine, RoadmapEngine.run_cycle, and XEngine's
spotlight gate, so the panel toggle can never be a silent no-op against a
legacy boot flag.
LEARN: board_program_cycles (migration 087) accrues per-item CEO decisions
(exact attribution by exploration_task_id where the caller holds it) and
feeds the last closed cycles back into both exploration prompts. The
strategy engine's idle signal now opens a roadmap cycle (enabled+dedup
respected) instead of only nudging.
Per-project scoping (migration 088, projects.board_programs, dual polarity):
plain keys opt a project INTO project-scoped programs; "!key" opts it OUT
of an org-scoped program's outputs (default eligible — parity). Enforced at
propose_roadmap (names the excluded project) and defensively at materialize;
validation rejects unknown keys and meaningless polarity both directions.
API: GET /api/board-programs + POST /api/board-programs/{key}/run-now
(CEO-gated); settings keys for both migrated programs.
* feat(panel): Board Programs card + per-project program controls
Business page gains a Programs tab: per-program rows (role, trigger, scope,
open-cycle badge), enabled switch on the settings-store key, Run now
(disabled while a cycle is open). The edit-project dialog gains the
program controls next to the CI-watch/video toggles: participates-in
checkboxes for project-scoped programs, excluded-from checkboxes for
org-scoped outputs.
* test(board): full-gate hermeticity — mypy casts + shared-DB purge fixtures
make quality runs one pytest process over all suites against the shared
persistent DB: integration collects before unit, so the board-programs API
test's committed run-now state (settings-store overrides, an open cycle row,
its board_roadmap task) poisoned 13 downstream unit tests that pass in
isolation. The polluter now purges its own committed state in fixture
teardown, and the four consumer files get an autouse per-test purge
(board_program.% settings keys, ledger rows, open exploration tasks) so
they are hermetic regardless of collection order. Also the four
cast("UUID", ...) sites the tests-scope mypy run requires.
* feat(panel): re-home per-project program controls onto the settings page
Wave C deleted the edit-project dialog these controls originally landed in;
they now live on the project settings page's budget/ops card next to the
CI-watch/video toggles — participates-in switches for project-scoped
programs, excluded-from switches for org-scoped outputs, dual-polarity
tooltips, order-independent dirty tracking. Nine makeProject test fixtures
gain the required board_programs field the rebase left behind.
---------
Co-authored-by: Renn F <rennf93@users.noreply.github.com>
59 lines
1.8 KiB
Python
59 lines
1.8 KiB
Python
"""Migration 087 tests — board_program_cycles table.
|
|
|
|
NOT a real alembic round-trip — the suite builds the test DB via
|
|
Base.metadata.create_all (see conftest); a real `alembic upgrade head` +
|
|
`downgrade -1` round trip against a scratch Postgres (:55432) was run
|
|
manually and confirmed clean (create + drop, no errors) as part of building
|
|
this migration. See `alembic/versions/087_board_program_cycles.py`.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
import pytest
|
|
from roboco.db.tables import BoardProgramCycleTable
|
|
|
|
if TYPE_CHECKING:
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_board_program_cycle_row_defaults(db_session: AsyncSession) -> None:
|
|
"""A freshly-inserted row gets zeroed counters and an empty decisions list."""
|
|
row = BoardProgramCycleTable(program_key="roadmap")
|
|
db_session.add(row)
|
|
await db_session.flush()
|
|
await db_session.refresh(row)
|
|
|
|
assert row.items_proposed == 0
|
|
assert row.items_approved == 0
|
|
assert row.items_rejected == 0
|
|
assert row.decisions == []
|
|
assert row.opened_at is not None
|
|
assert row.closed_at is None
|
|
assert row.exploration_task_id is None
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_board_program_cycle_round_trips_decisions(
|
|
db_session: AsyncSession,
|
|
) -> None:
|
|
"""The decisions JSON column stores/returns a list of dicts byte-for-byte."""
|
|
decisions = [
|
|
{"item_ref": "item-1", "verdict": "approved", "reason": None},
|
|
{"item_ref": "item-2", "verdict": "rejected", "reason": "not now"},
|
|
]
|
|
row = BoardProgramCycleTable(
|
|
program_key="roadmap",
|
|
items_proposed=2,
|
|
items_approved=1,
|
|
items_rejected=1,
|
|
decisions=decisions,
|
|
)
|
|
db_session.add(row)
|
|
await db_session.flush()
|
|
await db_session.refresh(row)
|
|
|
|
assert row.decisions == decisions
|