Skip to content

Fix #51: drop the unused env-var channel from PythonBridge - #102

Closed
corgab wants to merge 2 commits into
mainfrom
fix/51-remove-dead-env-channel
Closed

Fix #51: drop the unused env-var channel from PythonBridge#102
corgab wants to merge 2 commits into
mainfrom
fix/51-remove-dead-env-channel

Conversation

@corgab

@corgab corgab commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Summary

PythonBridge::buildEnvironment() exported region, bucket and device_arn as environment variables that no script in bin/python ever read. The live channel for those values is the driver_config key of the JSON payload, which every provider already consumes. This PR removes the dead channel end to end.

Plan

  1. Confirm no Python script reads os.environ/getenv and that providers/aws.py takes region, bucket and device ARN from its config dict.
  2. Remove buildEnvironment() and let the Process inherit the parent environment untouched, which is exactly what keeps boto3's credential chain (IAM roles, profiles, AWS_*) working.
  3. Remove the $driverConfig parameter that existed only to feed the mapping: on the PythonExecutor contract, on the bridge, and at the five driver call sites.
  4. Drop the five tests that exercised only the dead mapping; add one test that pins the inheritance guarantee instead.

Changes

  • src/Bridge/PythonBridge.php: execute(string $script, array $payload); Process built without an env argument; buildEnvironment() deleted; docblock explains the inheritance guarantee and that driver_config is the only settings channel.
  • src/Contracts/PythonExecutor.php: same signature change, docblock states implementations must not need a second channel for driver settings.
  • src/Drivers/AbstractQuantumDriver.php: the five execute() calls no longer pass $this->config (the payload already carries it).
  • tests/Unit/Bridge/PythonBridgeTest.php: five buildEnvironment() tests removed; new test runs a fake interpreter that echoes a variable set in the parent and asserts it comes back.
  • tests/Unit/Drivers/{AbstractQuantumDriver,AwsBraketDriver,LocalSimulatorDriver}Test.php: with() expectations updated to the two-argument shape.
  • CLAUDE.md: the PythonBridge convention bullet now describes the inheritance behaviour instead of the removed non-null filter.

Tests

  • vendor/bin/pint --test passes.
  • vendor/bin/pest --compact: 787 tests, 1276 assertions, 1 skipped (791 before: −5 dead-channel tests, +1 inheritance test).

Closes #51


Generated by Claude Code

buildEnvironment() mapped region, bucket and device_arn to environment
variables no script in bin/python ever read; the providers take the same
values from the driver_config key of the JSON payload. The mapping, the
$driverConfig parameter it existed for (on the PythonExecutor contract,
the bridge and every driver call site) and its five tests are removed.

The child process now inherits the parent environment untouched, which is
what preserves boto3's credential chain; a test pins that behaviour.

Closes #51
The child receives Symfony Process's default inherited environment; under
non-CLI SAPIs Process drops request-context variables, so 'untouched' was
too strong. The inheritance test now says what it pins: the observable
guarantee from the docblock, not how the Process is constructed.
@corgab

corgab commented Sep 10, 2026

Copy link
Copy Markdown
Owner Author

Chiusa: Il PythonBridge intero sarà rimosso con la migrazione a PHP nativo (Issue #112).

@corgab corgab closed this Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[maintainability] PythonBridge exports env vars no Python script reads; a second, unused config channel

1 participant