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
@@ -107,6 +107,7 @@ async def test_delegate_blocks_when_parent_assigned_to_other_agent() -> None:
project_id=uuid4(),
status="in_progress",
assigned_to=other_pm_id,
quick_context="Decomposition planned; cells implement their slice next.",
)
task_svc = AsyncMock()
task_svc.get.return_value = parent
@@ -131,6 +132,7 @@ async def test_delegate_allows_when_parent_in_progress_and_owned() -> None:
project_id=uuid4(),
status="in_progress",
assigned_to=pm_id,
quick_context="Decomposition planned; cells implement their slice next.",
)
new_task = MagicMock(id=uuid4())
task_svc = AsyncMock()
@@ -158,6 +160,7 @@ async def test_delegate_blocks_when_subtask_cap_exceeded() -> None:
project_id=uuid4(),
status="in_progress",
assigned_to=pm_id,
quick_context="Decomposition planned; cells implement their slice next.",
)
too_many = [MagicMock(id=uuid4()) for _ in range(13)]
task_svc = AsyncMock()
@@ -184,6 +187,7 @@ async def test_delegate_allows_when_subtask_cap_within_soft_zone() -> None:
project_id=uuid4(),
status="in_progress",
assigned_to=pm_id,
quick_context="Decomposition planned; cells implement their slice next.",
)
many = [MagicMock(id=uuid4()) for _ in range(10)]
new_task = MagicMock(id=uuid4())
@@ -211,6 +215,7 @@ async def test_delegate_allows_at_zero_subtasks() -> None:
project_id=uuid4(),
status="in_progress",
assigned_to=pm_id,
quick_context="Decomposition planned; cells implement their slice next.",
)
new_task = MagicMock(id=uuid4())
task_svc = AsyncMock()
@@ -236,6 +241,7 @@ async def test_delegate_blocks_at_exact_cap_plus_one() -> None:
project_id=uuid4(),
status="in_progress",
assigned_to=pm_id,
quick_context="Decomposition planned; cells implement their slice next.",
)
# Already 12 children — adding the 13th must be blocked.
twelve = [MagicMock(id=uuid4()) for _ in range(12)]
@@ -250,3 +256,31 @@ async def test_delegate_blocks_at_exact_cap_plus_one() -> None:
body = env.as_dict()
assert body["error"] == "invalid_state"
task_svc.create_subtask.assert_not_awaited()
@pytest.mark.asyncio
async def test_delegate_blocks_when_parent_quick_context_empty() -> None:
"""delegate obligates the PM's quick_context resumption section on the
parent; an empty quick_context (PM never called note(scope='handoff'))
fails the tracing gate before any subtask is created."""
pm_id = uuid4()
parent_id = uuid4()
parent = MagicMock(
id=parent_id,
project_id=uuid4(),
status="in_progress",
assigned_to=pm_id,
quick_context="",
)
task_svc = AsyncMock()
task_svc.get.return_value = parent
task_svc.agent_for.return_value = MagicMock(role="cell_pm", team="backend")
task_svc.get_subtasks.return_value = []
deps = _make_deps(task=task_svc)
c = Choreographer(deps)
env = await c.delegate(pm_id, parent_id, _delegate_inputs())
body = env.as_dict()
assert body["error"] == "tracing_gap"
assert "quick_context>=min" in body["missing"]
task_svc.create_subtask.assert_not_awaited()