feat(core): introduce Directive StrEnum for control-plane decisions#477
feat(core): introduce Directive StrEnum for control-plane decisions#477
Conversation
Add ouroboros.core.directive as an additive, caller-free vocabulary for control-plane decisions (continue / evaluate / evolve / unstuck / retry / compact / wait / cancel / converge). Decision sites are currently distributed across evaluation/, evolution/, resilience/, orchestrator/, and observability/, each with its own ad-hoc signals. This commit introduces only the shared type and its terminal set; no decision site is modified. Follow-up changes will migrate sites incrementally so each migration is independently reviewable. - src/ouroboros/core/directive.py: Directive StrEnum, per-member docstrings, and a module-level _TERMINAL_DIRECTIVES frozenset exposed through is_terminal (CANCEL, CONVERGE). - src/ouroboros/core/__init__.py: lazy re-export of Directive. - tests/unit/core/test_directive.py: value/terminality/membership/re-export coverage (10 tests). Verification: - uv run ruff check src/ouroboros/core/directive.py src/ouroboros/core/__init__.py tests/unit/core/test_directive.py - uv run ruff format --check <same paths> - uv run pytest tests/unit/core/ -q # 296 passed
There was a problem hiding this comment.
Review — ouroboros-agent[bot]
Verdict: APPROVE
Reviewing commit
f3a9ab0for PR #477
Review record:
959e4035-4e28-4cfa-b010-8b6c0197f02f
Blocking Findings
No in-scope blocking findings remained after policy filtering.
Non-blocking Suggestions
None.
Design Notes
The change is narrowly scoped and internally consistent: it adds a small Directive vocabulary module, exposes it through the existing lazy-export boundary, and covers the public API/terminality contract with focused unit tests. I did not find a diff-scoped runtime or API issue. The local environment does not have pytest installed, so full test execution was not possible here; direct import validation of the new module/export path succeeded.
Recovery Notes
First recoverable review artifact generated from codex analysis log.
Reviewed by ouroboros-agent[bot] via Codex deep analysis
|
Aligning with #476 (Phase 2 framing): this PR is in scope and unchanged. The No code change needed. |
Expand the module docstring to connect Directive explicitly to the Agent OS layering introduced by the Phase 2 RFC (Q00#476): directives occupy the control layer and are the runtime-level syscalls through which decision sites express control flow. Also record two posture decisions that were implicit before: - Directives describe workflow control, not capability policy. Capability visibility/execution decisions stay in the policy layer and in policy.* events, never interleaved with directive semantics. - Existing local enums (e.g. StepAction) are mapped into this vocabulary incrementally rather than replaced in a single change. The docstring records the reference StepAction -> Directive mapping so callers and reviewers can see the migration path at the type's site of truth. No behavior or API change.
|
Correction to my earlier alignment note —
New commit: |
There was a problem hiding this comment.
Review — ouroboros-agent[bot]
Verdict: APPROVE
Reviewing commit
1606c6efor PR #477
Review record:
3f8074cc-a3d7-4d48-a8e2-03002eb8e82e
Blocking Findings
No in-scope blocking findings remained after policy filtering.
Non-blocking Suggestions
| 1 | src/ouroboros/core/directive.py:13 | Documentation | The module docstring’s Directive layer bullet has malformed emphasis markup (**...* ...)*), which makes the rendered layering explanation harder to read even though it does not affect runtime behavior. |
| 2 | tests/unit/core/test_directive.py:53 | Nice-to-have test | test_required_members_present only checks that the expected names are a subset of the enum. If the intent is to lock the initial vocabulary exactly, an equality assertion would catch accidental additions as well as removals/renames. |
Design Notes
The change is structurally sound: Directive is introduced as an isolated StrEnum, re-exported through the existing lazy core boundary, and covered by focused unit tests for value stability, terminality, and package export behavior. I did not find a diff-scoped runtime or API-contract regression.
Recovery Notes
First recoverable review artifact generated from codex analysis log.
Reviewed by ouroboros-agent[bot] via Codex deep analysis
Summary
DirectiveStrEnumfor control-plane decisions (continue,evaluate,evolve,unstuck,retry,compact,wait,cancel,converge).Motivation
First step of #472. Post-#280,
docs/guides/mcp-bridge.mdrecords two Known Limitations:evolve_stepnot receiving the bridge manager, and no dynamic upstream-server addition. #471 frames these as control-plane symptoms — decision sites acrossevaluation/,evolution/,resilience/,orchestrator/, andobservability/each emit ad-hoc signals (enums, booleans, literal strings) with no shared vocabulary, which is why new plumbing is required on every handler added post-#280.#472 proposes introducing that shared vocabulary. This PR lands only the type and its invariants, with no caller modifications, matching the surgical-PR pattern established by recent merges (e.g., #470, #438, #444). Downstream migrations of individual decision sites become their own review units.
Changes
src/ouroboros/core/directive.py— newDirectiveStrEnum. Each member has a short docstring stating precondition and effect. Terminality is exposed throughis_terminal, backed by a module-level_TERMINAL_DIRECTIVESfrozenset. Exactly two terminal members:CANCEL,CONVERGE.src/ouroboros/core/__init__.py— lazy re-export ofDirectivealongsideResultand the core type aliases, preserving the existing lazy-loader pattern used for every other core symbol.tests/unit/core/test_directive.py— 10 unit tests covering:StrEnumsubstitutability)CANCELandCONVERGE; everything else is non-terminal)Directive(value)round-tripouroboros.coreNot changed
No existing decision site is migrated in this PR. Migration is deferred so each call site becomes its own small, reviewable change:
evaluation/terminal branches — follow-up PRevolution/convergence /resilience/stagnation handlers — follow-up PRsorchestrator/routing — follow-up PRVerification
Result:
296 passed(10 new), ruff clean, format clean.References