Skip to content
Open
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
12 changes: 9 additions & 3 deletions vcs-core/packages/core/src/vcs_core/_substrate_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,7 @@ def validate_driver_ingress(
request: IngressRequest,
result: DriverIngressResult,
driver: SubstrateDriver | None = None,
schema: DriverSchema | None = None,
) -> None:
"""Three-layer validator entry point (SPI v0.1).

Expand All @@ -1518,7 +1519,7 @@ def validate_driver_ingress(
_validate_generic_invariants(result)
_validate_per_request_invariants(request, result)
if driver is not None:
_validate_storage_profile_result(driver, result)
_validate_storage_profile_result(driver, result, schema=schema)
driver.validate_result(request, result)


Expand All @@ -1533,9 +1534,14 @@ def validate_driver_ingress_result(result: DriverIngressResult) -> None:
_validate_generic_invariants(result)


def _validate_storage_profile_result(driver: SubstrateDriver, result: DriverIngressResult) -> None:
def _validate_storage_profile_result(
driver: SubstrateDriver,
result: DriverIngressResult,
*,
schema: DriverSchema | None = None,
) -> None:
"""Enforce the driver's declared storage profile against emitted transitions."""
profile = driver.describe().storage_profile
profile = (schema or driver.describe()).storage_profile
for transition in result.transitions:
path = f"transition[{transition.transition_id}]"
if profile.shape == "json-snapshot":
Expand Down
9 changes: 8 additions & 1 deletion vcs-core/packages/core/src/vcs_core/_vcscore_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
)
from vcs_core._runtime_types import ExecutionContext
from vcs_core._schema_errors import SchemaValidationError
from vcs_core._substrate_driver import CapabilitySet, CommandRequest, DriverContext, SubstrateDriver
from vcs_core._substrate_driver import CapabilitySet, CommandRequest, DriverContext, DriverSchema, SubstrateDriver
from vcs_core._world_transition_coordinator import dispatch_driver
from vcs_core.recording import NestedParentAuthorization
from vcs_core.types import (
Expand Down Expand Up @@ -803,6 +803,7 @@ def _execute_spi_driver_in_operation(
scope=scope,
params=params,
capabilities=resolved.schema.capabilities,
schema=resolved.schema,
)
if isinstance(driver, ExecutionBoundDriver) and command in driver.execution_commands:
# PD1/PD2: the driver opted into execution authority for THIS command —
Expand All @@ -824,6 +825,7 @@ def _execute_spi_driver_in_operation(
command_param_source=command_param_source,
execution_options=execution_options,
capabilities=resolved.schema.capabilities,
schema=resolved.schema,
)
_reject_execution_options_for_plain_command(binding.binding_name, command, execution_options)
params = _normalize_and_admit_driver_command_params(
Expand Down Expand Up @@ -865,6 +867,7 @@ def _execute_spi_driver_in_operation(
context,
CommandRequest(command=command, params=dict(params)),
capabilities=resolved.schema.capabilities,
schema=resolved.schema,
)
oids: tuple[str, ...] = ()
if result.effects:
Expand Down Expand Up @@ -892,6 +895,7 @@ def _execute_selectable_spi_driver(
scope: ScopeInfo,
params: dict[str, Any],
capabilities: CapabilitySet,
schema: DriverSchema,
) -> RecordedCommandOutcome:
"""The selectable arm of the dispatch bridge (B4b W2).

Expand Down Expand Up @@ -935,6 +939,7 @@ def _execute_selectable_spi_driver(
context,
CommandRequest(command=command, params=dict(params)),
capabilities=capabilities,
schema=schema,
)
bundle = manager.create_prepared_driver_candidate_bundle(
store_id,
Expand Down Expand Up @@ -1004,6 +1009,7 @@ def _execute_execution_bound_driver(
command_param_source: CommandValueSource,
execution_options: CommandExecutionOptions,
capabilities: CapabilitySet,
schema: DriverSchema,
) -> RecordedCommandOutcome:
"""The reversible-transaction wrap (PD2) around an execution-bound dispatch.

Expand Down Expand Up @@ -1082,6 +1088,7 @@ def _execute_execution_bound_driver(
context,
CommandRequest(command=command, params=dict(params)),
capabilities=capabilities,
schema=schema,
execution=capability,
)
except BaseException:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
CapabilitySet,
DriverContext,
DriverIngressResult,
DriverSchema,
EvidenceCitation,
IngressRequest,
ObservationDraft,
Expand Down Expand Up @@ -313,6 +314,7 @@ def dispatch_driver(
request: IngressRequest,
*,
capabilities: CapabilitySet | None = None,
schema: DriverSchema | None = None,
execution: Any | None = None,
) -> DriverIngressResult:
"""Validated SPI dispatch around ``driver.prepare`` / ``prepare_bound``.
Expand Down Expand Up @@ -341,7 +343,7 @@ def dispatch_driver(
result = driver.prepare_bound(context, request, execution)
else:
result = driver.prepare(context, request)
validate_driver_ingress(request, result, driver)
validate_driver_ingress(request, result, driver, schema=schema)
_check_active_surface_post_dispatch(driver, context.active_surface, result)
return result

Expand Down
11 changes: 0 additions & 11 deletions vcs-core/packages/core/tests/unit/test_binding_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,6 @@ def test_binding_surface_records_metadata_and_resolver_loads_live_driver_schema(
assert resolver.schema("runtime") is schema


@pytest.mark.xfail(
reason=(
"PR#4 (portable copy carrier + auto backend) regressed the resolved-binding-contract "
"cache: the first exec calls describe() twice and the second re-resolves instead of "
"hitting the cache (observed 3 calls, expected 1). Functionally harmless — results are "
"correct — but the caching invariant is broken. Reproduces in the public checkout "
"(public CI does not run the vcs-core unit suite). Tracked as shepherd-agents/shepherd#11 "
"and the divergence ledger known-public-bugs."
),
strict=True,
)
def test_vcscore_exec_uses_cached_resolved_binding_contract_without_runtime_describe(tmp_path) -> None:
class CountingDriver(PlainCommandDriver):
def __init__(self) -> None:
Expand Down