mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
* feat(release): add release-manager feature flag (default off) * feat(release): change classification + semver-bump derivation * feat(release): readiness audit (changelog/version-ref/docs/migration/gate) * feat(release): release-manager engine proposes a gated release * feat(release): fail-closed release executor (bump, gate, publish) * feat(release): CEO approve/reject release-proposal surface * docs(release): document the gated release manager * feat(memory): add org-memory feature flags (default off) * feat(memory): add playbooks table + status enum + migration * feat(memory): playbook service with auditor curation transitions * feat(memory): playbooks RAG index plugin * feat(memory): index a playbook into RAG on approval * feat(memory): distill a high-signal lesson at task completion * feat(memory): keep private journal reflections out of the shared RAG corpus * feat(memory): draft_playbook verb + auditor curation verbs * fix(ci): resolve mypy tests/ errors blocking the gate (UUID casts, annotations) * feat(memory): auto-inject similar lessons/playbooks into the briefing * feat(memory): auditor playbook review queue (api + panel) * docs(memory): document the org-memory loop + playbook verbs * fix(provisioning): idempotent pitch provisioning (reuse product/project by slug on re-approval) * fix(memory): add chunks_playbooks to the chunk schema + isolate release route tests - Migration 030's CHUNK_TABLES was missing chunks_playbooks, breaking the IndexType<->migration parity guard once the PLAYBOOKS index landed. The upgrade is ALTER ... IF EXISTS so adding it is safe on any DB shape. - The release-route fixture's approve/reject paths call db.commit() (real behavior), so a held proposal outlived the per-test rollback and leaked into engine tests that read the global list_open_release_proposals(). Tear down source=release_manager rows after each test. - Make the gather_snapshot real-repo smoke version-agnostic (semver match) so it stops pinning the literal repo version. * chore(release): 0.13.0 * ++ --------- Co-authored-by: Renn F <rennf93@users.noreply.github.com>
129 lines
4.1 KiB
Python
129 lines
4.1 KiB
Python
"""External-PR review dedupe is repo-scoped (git_url), not project-scoped.
|
|
|
|
A monorepo registers several cell-projects on one repo. Ingesting the same PR
|
|
for a sibling project — or re-pointing an existing review task to a sibling —
|
|
must NOT open a second review (the duplicate the operator hit: PR #131 reviewed
|
|
once per cell-project after a re-point). Re-review on a new head SHA still works.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING, Any, cast
|
|
from uuid import UUID, uuid4
|
|
|
|
import pytest
|
|
from roboco.db.tables import AgentTable, ProjectTable
|
|
from roboco.foundation import identity as _foundation
|
|
from roboco.models.base import AgentRole, AgentStatus, Team
|
|
from roboco.services.task import get_task_service
|
|
|
|
if TYPE_CHECKING:
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
SYSTEM_UUID = _foundation.AGENTS["system"].uuid
|
|
_REPO = "https://github.com/rennf93/guard-core-app"
|
|
_OTHER_REPO = "https://github.com/rennf93/other-app"
|
|
|
|
|
|
def _pr(head_sha: str, number: int = 131) -> dict[str, Any]:
|
|
return {
|
|
"number": number,
|
|
"url": f"{_REPO}/pull/{number}",
|
|
"title": "build(deps): bump the dependencies",
|
|
"head_sha": head_sha,
|
|
}
|
|
|
|
|
|
async def _seed(db: AsyncSession, slug: str, git_url: str) -> ProjectTable:
|
|
if await db.get(AgentTable, SYSTEM_UUID) is None:
|
|
db.add(
|
|
AgentTable(
|
|
id=SYSTEM_UUID,
|
|
name="System",
|
|
slug=f"system-{uuid4().hex[:8]}",
|
|
role=AgentRole.SYSTEM,
|
|
team=None,
|
|
status=AgentStatus.ACTIVE,
|
|
model_config={},
|
|
system_prompt="x",
|
|
capabilities=[],
|
|
permissions={},
|
|
metrics={},
|
|
)
|
|
)
|
|
await db.flush()
|
|
project = ProjectTable(
|
|
id=uuid4(),
|
|
name=slug,
|
|
slug=slug,
|
|
git_url=git_url,
|
|
assigned_cell=Team.BACKEND,
|
|
created_by=SYSTEM_UUID,
|
|
)
|
|
db.add(project)
|
|
await db.flush()
|
|
return project
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_sibling_project_same_pr_is_deduped(db_session: AsyncSession) -> None:
|
|
fe = await _seed(db_session, "gca-frontend", _REPO)
|
|
be = await _seed(db_session, "gca-backend", _REPO)
|
|
svc = get_task_service(db_session)
|
|
|
|
first = await svc.ingest_external_pr(
|
|
project_id=cast("UUID", fe.id),
|
|
pr=_pr("abc123"),
|
|
created_by=SYSTEM_UUID,
|
|
team=Team.FRONTEND,
|
|
)
|
|
assert first is not None # first review opens
|
|
# Same PR + same head, sibling project on the SAME repo → no second review.
|
|
dup = await svc.ingest_external_pr(
|
|
project_id=cast("UUID", be.id),
|
|
pr=_pr("abc123"),
|
|
created_by=SYSTEM_UUID,
|
|
team=Team.BACKEND,
|
|
)
|
|
assert dup is None
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_exists_is_repo_scoped(db_session: AsyncSession) -> None:
|
|
fe = await _seed(db_session, "gca-frontend", _REPO)
|
|
be = await _seed(db_session, "gca-backend", _REPO)
|
|
svc = get_task_service(db_session)
|
|
await svc.ingest_external_pr(
|
|
project_id=cast("UUID", fe.id),
|
|
pr=_pr("abc123"),
|
|
created_by=SYSTEM_UUID,
|
|
team=Team.FRONTEND,
|
|
)
|
|
|
|
# The sibling project sees the existing review (the fix); a new head SHA does not.
|
|
be_id = cast("UUID", be.id)
|
|
assert await svc.external_review_task_exists(be_id, 131, "abc123") is True
|
|
assert await svc.external_review_task_exists(be_id, 131, "newsha") is False
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_different_repo_not_deduped(db_session: AsyncSession) -> None:
|
|
fe = await _seed(db_session, "gca-frontend", _REPO)
|
|
other = await _seed(db_session, "other", _OTHER_REPO)
|
|
svc = get_task_service(db_session)
|
|
await svc.ingest_external_pr(
|
|
project_id=cast("UUID", fe.id),
|
|
pr=_pr("abc123"),
|
|
created_by=SYSTEM_UUID,
|
|
team=Team.FRONTEND,
|
|
)
|
|
|
|
# A genuinely different repo with the same PR number is reviewed independently.
|
|
created = await svc.ingest_external_pr(
|
|
project_id=cast("UUID", other.id),
|
|
pr=_pr("abc123"),
|
|
created_by=SYSTEM_UUID,
|
|
team=Team.BACKEND,
|
|
)
|
|
assert created is not None
|