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:
Renn F
2026-06-21 20:31:42 +02:00
parent 23e6ee579b
commit 8cf697816f
27 changed files with 847 additions and 60 deletions
@@ -92,7 +92,8 @@ def _ready_task(task_id: Any, agent_id: Any) -> MagicMock:
],
commits=[{"sha": "abc"}],
documents=[],
dev_notes="",
# i_am_done obligates the developer's dev_notes section (>=40 chars).
dev_notes="Implemented the change and added tests covering the new path.",
)
@@ -265,6 +266,41 @@ async def test_i_am_done_blocks_when_no_progress() -> None:
task_svc.submit_qa.assert_not_awaited()
# ---------------------------------------------------------------------------
# Role note-section obligation: dev_notes must be filled (note(scope='handoff'))
# ---------------------------------------------------------------------------
@pytest.mark.asyncio
async def test_i_am_done_blocks_when_dev_notes_empty() -> None:
"""i_am_done obligates the developer's dev_notes section; an empty
dev_notes (the dev never called note(scope='handoff')) fails the gate."""
agent_id = uuid4()
task_id = uuid4()
t = _ready_task(task_id, agent_id)
t.dev_notes = ""
task_svc = AsyncMock()
task_svc.get.return_value = t
task_svc.agent_for.return_value = MagicMock(
id=agent_id, role="developer", team="backend", slug=None
)
journal_svc = AsyncMock()
journal_svc.has_reflect_for_task.return_value = True
journal_svc.has_decision_for_task.return_value = True
journal_svc.latest_decision_at.return_value = datetime.now(UTC)
journal_svc.has_learning_for_task.return_value = False
journal_svc.has_struggle_for_task.return_value = False
deps = _make_deps(task=task_svc, journal=journal_svc)
c = Choreographer(deps)
env = await c.i_am_done(agent_id, task_id, "done")
body = env.as_dict()
assert body["error"] == "tracing_gap"
assert "dev_notes>=min" in body["missing"]
assert "scope='handoff'" in body["remediate"]
task_svc.submit_qa.assert_not_awaited()
# ---------------------------------------------------------------------------
# E.5 happy path: all gates pass → submit_qa runs (NO catch-up)
# ---------------------------------------------------------------------------