mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
feat(content): obligate role note sections like journals
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.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from unittest.mock import AsyncMock as _AsyncMock
|
||||
from unittest.mock import MagicMock as _MagicMock
|
||||
@@ -11,7 +12,13 @@ from uuid import uuid4 as _u
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from roboco.db.tables import AgentTable, JournalTable, ProjectTable, TaskTable
|
||||
from roboco.db.tables import (
|
||||
AgentTable,
|
||||
JournalEntryTable,
|
||||
JournalTable,
|
||||
ProjectTable,
|
||||
TaskTable,
|
||||
)
|
||||
from roboco.models import AgentRole, AgentStatus, Team
|
||||
from roboco.models.base import (
|
||||
JournalEntryType,
|
||||
@@ -29,7 +36,7 @@ from roboco.models.journal import (
|
||||
TaskReflectionParams,
|
||||
)
|
||||
from roboco.services.journal import JournalService
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import select, update
|
||||
from sqlalchemy.exc import IntegrityError as _IE
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -730,3 +737,52 @@ async def test_search_entries_swallows_exception(
|
||||
|
||||
results = await svc.search_entries(aid, "query")
|
||||
assert results == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_has_recent_entry_false_then_true(journal_setup: dict) -> None:
|
||||
"""No entries → False; a freshly written entry is within the window."""
|
||||
svc: JournalService = journal_setup["svc"]
|
||||
agent_id = journal_setup["agent_id"]
|
||||
task_id = journal_setup["task_id"]
|
||||
|
||||
assert await svc.has_recent_entry(agent_id, 3600) is False
|
||||
|
||||
await svc.write_entry(
|
||||
agent_id=agent_id,
|
||||
title="observation",
|
||||
content="watching the seam between FE and BE",
|
||||
scope="reflect",
|
||||
task_id=task_id,
|
||||
)
|
||||
assert await svc.has_recent_entry(agent_id, 3600) is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_has_recent_entry_excludes_entries_outside_window(
|
||||
journal_setup: dict, db_session: AsyncSession
|
||||
) -> None:
|
||||
"""An entry older than the window does not count as recent."""
|
||||
svc: JournalService = journal_setup["svc"]
|
||||
agent_id = journal_setup["agent_id"]
|
||||
task_id = journal_setup["task_id"]
|
||||
|
||||
await svc.write_entry(
|
||||
agent_id=agent_id,
|
||||
title="stale observation",
|
||||
content="recorded two hours ago",
|
||||
scope="reflect",
|
||||
task_id=task_id,
|
||||
)
|
||||
# Backdate every entry on this agent's journal to two hours ago.
|
||||
journal = await svc.get_journal_by_agent(agent_id)
|
||||
assert journal is not None
|
||||
await db_session.execute(
|
||||
update(JournalEntryTable)
|
||||
.where(JournalEntryTable.journal_id == journal.id)
|
||||
.values(timestamp=datetime.now(UTC) - timedelta(hours=2))
|
||||
)
|
||||
await db_session.flush()
|
||||
|
||||
assert await svc.has_recent_entry(agent_id, 3600) is False
|
||||
assert await svc.has_recent_entry(agent_id, 3 * 3600) is True
|
||||
|
||||
Reference in New Issue
Block a user