diff --git a/vcs-core/packages/core/src/vcs_core/_substrate_driver.py b/vcs-core/packages/core/src/vcs_core/_substrate_driver.py index a09a199..3abc7f3 100644 --- a/vcs-core/packages/core/src/vcs_core/_substrate_driver.py +++ b/vcs-core/packages/core/src/vcs_core/_substrate_driver.py @@ -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). @@ -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) @@ -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": diff --git a/vcs-core/packages/core/src/vcs_core/_vcscore_runtime.py b/vcs-core/packages/core/src/vcs_core/_vcscore_runtime.py index 5e8aa60..4959eb6 100644 --- a/vcs-core/packages/core/src/vcs_core/_vcscore_runtime.py +++ b/vcs-core/packages/core/src/vcs_core/_vcscore_runtime.py @@ -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 ( @@ -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 — @@ -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( @@ -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: @@ -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). @@ -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, @@ -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. @@ -1082,6 +1088,7 @@ def _execute_execution_bound_driver( context, CommandRequest(command=command, params=dict(params)), capabilities=capabilities, + schema=schema, execution=capability, ) except BaseException: diff --git a/vcs-core/packages/core/src/vcs_core/_world_transition_coordinator.py b/vcs-core/packages/core/src/vcs_core/_world_transition_coordinator.py index 1c9b0bf..7c61e50 100644 --- a/vcs-core/packages/core/src/vcs_core/_world_transition_coordinator.py +++ b/vcs-core/packages/core/src/vcs_core/_world_transition_coordinator.py @@ -16,6 +16,7 @@ CapabilitySet, DriverContext, DriverIngressResult, + DriverSchema, EvidenceCitation, IngressRequest, ObservationDraft, @@ -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``. @@ -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 diff --git a/vcs-core/packages/core/tests/unit/test_binding_surface.py b/vcs-core/packages/core/tests/unit/test_binding_surface.py index 862872b..16529e0 100644 --- a/vcs-core/packages/core/tests/unit/test_binding_surface.py +++ b/vcs-core/packages/core/tests/unit/test_binding_surface.py @@ -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: