Files
roboco/tests/unit/agents/test_fable_doctrine_layer.py
Renn F 7716830322 feat(fleet): opus-fable adoption — doctrine + discipline hooks (v0.18.0 A)
Fleet behaves more like Fable 5 on existing model tiers, behind
ROBOCO_FABLE_MODE_ENABLED (config default off; armed :-true on the NAS compose,
absent from the registry compose).

- Doctrine: vendored agents/prompts/doctrine/fable.md composed into every
  agent's system prompt via fable_doctrine_layer() after base.md.
- Hooks (Claude Code): 4 non-overlapping hooks (stop-gate/bash-discipline/
  honesty-nudge/precompact) appended per-agent via _fable_hook_groups(). The
  make-quality + lint-suppression duplicates are deliberately NOT added (already
  gate-enforced); session-start skipped.
- Hooks (grok): conservative V1 — only the non-denying honesty-nudge, since a
  grok hook deny cancels the whole run.
- Flag on the feature-flags card; hook scripts shipped into the agent image.

Flag-off spawn path proven byte-identical (worktree diff, sha256 match); full
suite green (2074 unit + e2e-smoke + hook harness), mypy/xenon/ruff clean.
Fixed a real stdin bug in the vendored stop-gate hook (heredoc + pipe both
claimed stdin). Distilled from rennf93/opus-fable-playbook (MIT).
2026-07-04 06:44:40 +02:00

35 lines
1.3 KiB
Python

"""compose_prompt includes the Fable doctrine layer when the flag is on."""
from __future__ import annotations
from unittest.mock import patch
from roboco.agents.factories._base import compose_prompt
from roboco.models import AgentRole, Team
def test_doctrine_included_when_flag_enabled() -> None:
with patch("roboco.config.settings.fable_mode_enabled", True):
prompt = compose_prompt(AgentRole.DEVELOPER, Team.BACKEND, "be-dev-1")
assert "# Fable Doctrine" in prompt
assert "Turn discipline" in prompt
def test_doctrine_absent_when_flag_disabled() -> None:
with patch("roboco.config.settings.fable_mode_enabled", False):
prompt = compose_prompt(AgentRole.DEVELOPER, Team.BACKEND, "be-dev-1")
assert "# Fable Doctrine" not in prompt
def test_doctrine_frontmatter_not_leaked() -> None:
with patch("roboco.config.settings.fable_mode_enabled", True):
prompt = compose_prompt(AgentRole.DEVELOPER, Team.BACKEND, "be-dev-1")
assert "keep-coding-instructions" not in prompt
def test_doctrine_applies_to_every_role() -> None:
with patch("roboco.config.settings.fable_mode_enabled", True):
for role in AgentRole:
prompt = compose_prompt(role, None, f"probe-{role.value}")
assert "# Fable Doctrine" in prompt, f"missing for role={role.value}"