mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
Completes the note(scope='handoff') write-path (WIP 23e6ee57): every role
with a dedicated note section is now obligated to populate it, the same way
journals are obligated.
Obligations (foundation.policy.tracing):
- DEV_NOTES / PR_REVIEWER_NOTES / QUICK_CONTEXT_MIN_CHARS requirements +
checkers, wired onto i_am_done (dev_notes), delegate (quick_context), and
pr_pass / pr_fail / post_pr_review (pr_reviewer_notes).
- Fixes a latent bug: the docs-notes checker read dev_notes instead of
doc_notes (the documenter's section); the i_documented shim now feeds
doc_notes to match.
Auditor: a session-scoped note obligation on i_am_idle — the auditor owns no
delivery task and has no delivery verb, so it must have recorded an
observation within the window before going idle (JournalService.has_recent_entry).
Write-then-gate: persisted sections (dev_notes / quick_context) are
pre-written by the agent's note(scope='handoff') before the gated verb;
argument-borne sections (doc_notes / pr_reviewer_notes) are checked through a
SimpleNamespace shim, the same pattern qa_notes already uses.
Config: dev/pr_reviewer/quick_context min-chars (40/40/30), panel-tunable.
Plus per-gap remediation hints and full coverage (write-path routing,
ownership, validation->remediation, each obligation, the doc_notes fix).
Full make-quality green: 9777 passed, 95.6% coverage.
87 lines
2.8 KiB
Python
87 lines
2.8 KiB
Python
"""The PR reviewer's pr_reviewer_notes section is obligated on its verbs.
|
|
|
|
pr_pass / pr_fail (in-path gate) and post_pr_review (inbound external PR) each
|
|
require a substantive review note. The note is the verb's own argument (not yet
|
|
persisted), so it is checked through a SimpleNamespace shim against the
|
|
``pr_reviewer_notes`` field — these cover both the short-circuit (too short) and
|
|
the pass-through (long enough) at the tracing-gate helpers.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
from unittest.mock import AsyncMock, MagicMock
|
|
from uuid import uuid4
|
|
|
|
import pytest
|
|
from roboco.services.gateway.choreographer import Choreographer, ChoreographerDeps
|
|
|
|
|
|
def _make_choreographer(*, has_learning: bool = True) -> Choreographer:
|
|
base: dict[str, Any] = {
|
|
"task": AsyncMock(),
|
|
"work_session": AsyncMock(),
|
|
"git": AsyncMock(),
|
|
"a2a": AsyncMock(),
|
|
"journal": AsyncMock(),
|
|
"audit": AsyncMock(),
|
|
"evidence_repo": AsyncMock(),
|
|
}
|
|
base["journal"].has_learning_for_task.return_value = has_learning
|
|
return Choreographer(ChoreographerDeps(**base))
|
|
|
|
|
|
_LONG = "Reviewed the assembled diff end to end; the seam contract holds."
|
|
_SHORT = "looks ok"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_gate_tracing_blocks_on_short_notes() -> None:
|
|
c = _make_choreographer()
|
|
env = await c._gate_tracing(
|
|
uuid4(), uuid4(), MagicMock(), "pr_reviewer", "pr_pass", notes=_SHORT
|
|
)
|
|
assert env is not None
|
|
body = env.as_dict()
|
|
assert body["error"] == "tracing_gap"
|
|
assert "pr_reviewer_notes>=min" in body["missing"]
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_gate_tracing_passes_on_substantive_notes() -> None:
|
|
c = _make_choreographer()
|
|
env = await c._gate_tracing(
|
|
uuid4(), uuid4(), MagicMock(), "pr_reviewer", "pr_fail", notes=_LONG
|
|
)
|
|
assert env is None
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_post_pr_review_tracing_blocks_on_short_body() -> None:
|
|
c = _make_choreographer()
|
|
env = await c._pr_review_tracing_gate(
|
|
uuid4(), uuid4(), MagicMock(), "pr_reviewer", body=_SHORT
|
|
)
|
|
assert env is not None
|
|
assert "pr_reviewer_notes>=min" in env.as_dict()["missing"]
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_post_pr_review_tracing_passes_on_substantive_body() -> None:
|
|
c = _make_choreographer()
|
|
env = await c._pr_review_tracing_gate(
|
|
uuid4(), uuid4(), MagicMock(), "pr_reviewer", body=_LONG
|
|
)
|
|
assert env is None
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_missing_learning_still_blocks_even_with_long_notes() -> None:
|
|
"""The journal:learning requirement remains independent of the note."""
|
|
c = _make_choreographer(has_learning=False)
|
|
env = await c._gate_tracing(
|
|
uuid4(), uuid4(), MagicMock(), "pr_reviewer", "pr_pass", notes=_LONG
|
|
)
|
|
assert env is not None
|
|
assert "journal:learning" in env.as_dict()["missing"]
|