Skip to content

Commit b2aab03

Browse files
Stop honoring legacy guardrails env name
1 parent 95666de commit b2aab03

2 files changed

Lines changed: 50 additions & 8 deletions

File tree

src/config/workflows.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
),
147147
],
148148
'guardrails' => [
149-
'boot' => Env::dw('DW_V2_GUARDRAILS_BOOT', 'WORKFLOW_V2_GUARDRAILS_BOOT', 'warn'),
149+
'boot' => env('DW_V2_GUARDRAILS_BOOT', 'warn'),
150150
],
151151
'structural_limits' => [
152152
'pending_activity_count' => (int) Env::dw(

tests/Unit/Config/WorkflowsConfigTest.php

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
final class WorkflowsConfigTest extends TestCase
1010
{
1111
/**
12-
* Every env var read by src/config/workflows.php. Both the DW_*
13-
* primary and WORKFLOW_* legacy names are cleared before assertions
14-
* that depend on defaults, so tests are not sensitive to what the
15-
* ambient test environment happens to export.
12+
* Environment names that can influence config defaults in tests.
13+
* This includes retired names we explicitly clear so ambient alpha-era
14+
* exports do not leak into assertions that are meant to prove the final
15+
* released contract.
1616
*
1717
* @var list<string>
1818
*/
@@ -144,9 +144,9 @@ public function testSerializerLegacyEnvironmentValueStillResolves(): void
144144
/**
145145
* A fresh installation must be able to boot with no v2 environment
146146
* variables set. The compatibility markers and history-export signing
147-
* keys default to null ("no marker required" / "unsigned"), the namespace
148-
* defaults to null ("no namespace isolation"), and every other v2 key
149-
* ships with a working fallback.
147+
* keys default to null ("no marker required" / "unsigned"), the namespace
148+
* defaults to null ("no namespace isolation"), and the remaining v2 keys
149+
* keep their shipped defaults.
150150
*/
151151
public function testV2SectionBootsWithoutEnvironmentOverrides(): void
152152
{
@@ -172,6 +172,48 @@ public function testV2SectionBootsWithoutEnvironmentOverrides(): void
172172
}
173173
}
174174

175+
public function testGuardrailsBootReadsDwNameOnly(): void
176+
{
177+
$keys = ['DW_V2_GUARDRAILS_BOOT', 'WORKFLOW_V2_GUARDRAILS_BOOT'];
178+
$previous = $this->snapshotEnv($keys);
179+
$this->clearEnv($keys);
180+
181+
putenv('DW_V2_GUARDRAILS_BOOT=throw');
182+
$_ENV['DW_V2_GUARDRAILS_BOOT'] = 'throw';
183+
$_SERVER['DW_V2_GUARDRAILS_BOOT'] = 'throw';
184+
185+
putenv('WORKFLOW_V2_GUARDRAILS_BOOT=silent');
186+
$_ENV['WORKFLOW_V2_GUARDRAILS_BOOT'] = 'silent';
187+
$_SERVER['WORKFLOW_V2_GUARDRAILS_BOOT'] = 'silent';
188+
189+
try {
190+
$config = require dirname(__DIR__, 3) . '/src/config/workflows.php';
191+
192+
$this->assertSame('throw', $config['v2']['guardrails']['boot']);
193+
} finally {
194+
$this->restoreEnv($previous);
195+
}
196+
}
197+
198+
public function testGuardrailsBootIgnoresLegacyWorkflowV2Name(): void
199+
{
200+
$keys = ['DW_V2_GUARDRAILS_BOOT', 'WORKFLOW_V2_GUARDRAILS_BOOT'];
201+
$previous = $this->snapshotEnv($keys);
202+
$this->clearEnv($keys);
203+
204+
putenv('WORKFLOW_V2_GUARDRAILS_BOOT=throw');
205+
$_ENV['WORKFLOW_V2_GUARDRAILS_BOOT'] = 'throw';
206+
$_SERVER['WORKFLOW_V2_GUARDRAILS_BOOT'] = 'throw';
207+
208+
try {
209+
$config = require dirname(__DIR__, 3) . '/src/config/workflows.php';
210+
211+
$this->assertSame('warn', $config['v2']['guardrails']['boot']);
212+
} finally {
213+
$this->restoreEnv($previous);
214+
}
215+
}
216+
175217
/**
176218
* Setting a DW_V2_* name takes effect even when the legacy
177219
* WORKFLOW_V2_* counterpart is also set — the DW_V2_* primary wins.

0 commit comments

Comments
 (0)