Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/api/src/cora/operation/_conduct_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

A slice cannot import a sibling slice (the cross-slice-independence fitness),
so this BC-level module owns the shared pipeline, mirroring `_conduct_wire`
(shared HTTP/MCP shapes) and `_resolved_steps_replay` (the resume-side read).
(shared HTTP/MCP shapes) and `_recipe_expansion/_resolved_steps_replay` (the resume-side read).
The pin is emitted inline rather than via a dedicated command slice:
`ResolvedStepsRecorded` is an internal provenance event with no operator
entry point, exactly like `RecipeExpansionRecorded`.
Expand All @@ -29,7 +29,7 @@
from cora.infrastructure.kernel import Kernel
from cora.infrastructure.ports import EventStore
from cora.infrastructure.ports.event_store import StoredEvent
from cora.operation._recipe_replay import (
from cora.operation._recipe_expansion import (
find_recipe_expansion_record,
pins_from_payload,
verify_bindings_hash,
Expand Down Expand Up @@ -58,7 +58,7 @@
from cora.run.aggregates.run import RunNotFoundError, load_run

if TYPE_CHECKING:
from cora.operation._pseudoaxis_expander import ConstituentResolver
from cora.operation._pseudoaxis import ConstituentResolver


def decide_resolved_steps_recorded(
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/cora/operation/_conduct_wire.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
those wire types + converters so both slices reuse them. A slice cannot
import a sibling slice (the cross-slice-independence fitness), so the shared
seam lives here, outside `features/`, exactly like the resolved-steps replay
helper (`_resolved_steps_replay`) and preparation pipeline
helper (`_recipe_expansion/_resolved_steps_replay`) and preparation pipeline
(`_conduct_preparation`).

The Conductor's `Step = SetpointStep | ActionStep | CheckStep` and
Expand Down
32 changes: 32 additions & 0 deletions apps/api/src/cora/operation/_pseudoaxis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""PseudoAxis resolution subpackage for the Operation BC.

Carved from the BC root once the private-module count crossed the ~10-file
threshold (see docs/reference/layout.md; the equipment `_bodies/` / `_pidinst/`
carve is the precedent). Groups the two private modules that resolve a virtual
(pseudo) axis into its real constituent axes at conduct time:

- `_evaluator`: `resolve_pseudoaxis_command` -- map one pseudo-axis setpoint to
the resolved constituent setpoints (`ResolvedSetpoints`).
- `_expander`: `expand_pseudoaxis_steps` -- rewrite a virtual-axis `SetpointStep`
into N sequential constituent `SetpointStep`s before the Conductor walks them,
via an injected `ConstituentResolver`.

Re-exports the public surface so consumers import from the package
(`from cora.operation._pseudoaxis import expand_pseudoaxis_steps, ConstituentResolver`).
"""

from cora.operation._pseudoaxis._evaluator import (
ResolvedSetpoints,
resolve_pseudoaxis_command,
)
from cora.operation._pseudoaxis._expander import (
ConstituentResolver,
expand_pseudoaxis_steps,
)

__all__ = [
"ConstituentResolver",
"ResolvedSetpoints",
"expand_pseudoaxis_steps",
"resolve_pseudoaxis_command",
]
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
from typing import TYPE_CHECKING
from uuid import UUID

from cora.operation._pseudoaxis_evaluator import resolve_pseudoaxis_command
from cora.operation._pseudoaxis._evaluator import resolve_pseudoaxis_command
from cora.operation.conductor import (
SetpointStep,
Step,
Expand Down
48 changes: 48 additions & 0 deletions apps/api/src/cora/operation/_recipe_expansion/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""Recipe step-resolution subpackage for the Operation BC.

Carved from the BC root once the private-module count crossed the ~10-file
threshold (see docs/reference/layout.md; the equipment `_bodies/` / `_pidinst/`
carve is the precedent). Groups the three private modules that turn a Recipe's
parameterized step tuple into the concrete `Step` list a Procedure conducts, and
that replay / verify that resolution:

- `_expand`: the pure `expand(steps, bindings) -> Step list` substitution kernel
(+ `steps_to_wire` / `canonical_json_bytes` for provenance hashing).
- `_replay`: locate + verify the genesis `RecipeExpansionRecorded` provenance
on the `conduct_procedure` path (re-expand and compare pinned hashes).
- `_resolved_steps_replay`: locate the pinned `ResolvedStepsRecorded` provenance
on the `reconduct_procedure` (resume) path.

Re-exports the public surface so consumers import from the package
(`from cora.operation._recipe_expansion import expand, find_recipe_expansion_record`).
"""

from cora.operation._recipe_expansion._expand import (
canonical_json_bytes,
expand,
steps_to_wire,
)
from cora.operation._recipe_expansion._replay import (
MismatchField,
RecipeExpansionPins,
find_recipe_expansion_record,
pins_from_payload,
verify_bindings_hash,
verify_steps_hash,
)
from cora.operation._recipe_expansion._resolved_steps_replay import (
find_resolved_steps_record,
)

__all__ = [
"MismatchField",
"RecipeExpansionPins",
"canonical_json_bytes",
"expand",
"find_recipe_expansion_record",
"find_resolved_steps_record",
"pins_from_payload",
"steps_to_wire",
"verify_bindings_hash",
"verify_steps_hash",
]
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from uuid import UUID

from cora.infrastructure.ports.event_store import StoredEvent
from cora.operation._recipe_expansion import steps_to_wire
from cora.operation._recipe_expansion._expand import steps_to_wire
from cora.operation.aggregates.procedure import (
RecipeExpansionRecordNotFoundError,
RecipeExpansionReplayMismatchError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any

from cora.operation._pseudoaxis_expander import (
from cora.operation._pseudoaxis import (
ConstituentResolver,
expand_pseudoaxis_steps,
)
Expand All @@ -52,7 +52,7 @@ class InMemoryRecipeExpander:
need to assert provenance carries the expander identity.

`constituent_resolver` defaults to None (the wiring-deferred resolver
in `_pseudoaxis_expander`, which raises for any PseudoAxis step). The
in `_pseudoaxis/_expander`, which raises for any PseudoAxis step). The
Plan.wiring-backed resolver is supplied per-call by the
conduct_procedure handler (loaded from Run.plan_id -> Plan.wires) via
the `expand_pseudoaxis` `constituent_resolver` kwarg, which takes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from cora.infrastructure.logging import get_logger
from cora.infrastructure.ports import Deny
from cora.infrastructure.routing import NIL_SENTINEL_ID
from cora.operation._resolved_steps_replay import find_resolved_steps_record
from cora.operation._recipe_expansion import find_resolved_steps_record
from cora.operation.aggregates.procedure import (
InvalidProcedureReEstablishmentBoundaryError,
ProcedureCannotResumeError,
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/cora/operation/ports/recipe_expander.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
from uuid import UUID

from cora.infrastructure.ports import EventStore
from cora.operation._pseudoaxis_expander import ConstituentResolver
from cora.operation._pseudoaxis import ConstituentResolver
from cora.operation.conductor import Step
from cora.recipe.aggregates.recipe import RecipeStep

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ def test_recipe_expansion_dispatches_every_recipe_step_arm() -> None:
structural shape).
"""
expansion_module = pytest.importorskip(
"cora.operation._recipe_expansion",
reason="_recipe_expansion module not present yet; dispatch-coverage check pending",
"cora.operation._recipe_expansion._expand",
reason="recipe-expansion module not present yet; dispatch-coverage check pending",
)
recipe_arms = get_args(_recipe_body.RecipeStep)
expander = getattr(expansion_module, "_expand_step", None)
assert expander is not None, (
"cora.operation._recipe_expansion is missing the _expand_step dispatch helper; "
"cora.operation._recipe_expansion._expand is missing the _expand_step dispatch helper; "
"the expansion module must export it so this fitness can verify dispatch coverage."
)
source = inspect.getsource(expander)
Expand Down
2 changes: 1 addition & 1 deletion apps/api/tests/unit/operation/test_pseudoaxis_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
)
from cora.infrastructure.adapters.in_memory_event_store import InMemoryEventStore
from cora.infrastructure.kernel import Kernel
from cora.operation._pseudoaxis_evaluator import (
from cora.operation._pseudoaxis import (
ResolvedSetpoints,
resolve_pseudoaxis_command,
)
Expand Down
2 changes: 1 addition & 1 deletion apps/api/tests/unit/operation/test_pseudoaxis_expander.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)
from cora.infrastructure.adapters.in_memory_event_store import InMemoryEventStore
from cora.infrastructure.event_envelope import to_new_event
from cora.operation._pseudoaxis_expander import expand_pseudoaxis_steps
from cora.operation._pseudoaxis import expand_pseudoaxis_steps
from cora.operation.conductor import (
ActionStep,
CheckStep,
Expand Down
6 changes: 3 additions & 3 deletions apps/api/tests/unit/operation/test_recipe_replay.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Unit tests for the `_recipe_replay` helpers.
"""Unit tests for the `_recipe_expansion` replay helpers.

Per [[project-run-procedure-replay-design]] §Operation BC seam
additions. The helpers locate the genesis `RecipeExpansionRecorded`
Expand All @@ -15,11 +15,11 @@
import pytest

from cora.infrastructure.ports.event_store import StoredEvent
from cora.operation._recipe_expansion import steps_to_wire
from cora.operation._recipe_replay import (
from cora.operation._recipe_expansion import (
RecipeExpansionPins,
find_recipe_expansion_record,
pins_from_payload,
steps_to_wire,
verify_bindings_hash,
verify_steps_hash,
)
Expand Down
Loading