fix(timetable): config-flag observer + cleaner idempotency_key
OrganisationObserver was gated on app()->runningUnitTests() — replaced
with config('artist_advance.bootstrap_on_org_create') (default true,
phpunit.xml overrides to false). Behaviour identical, but the seam is
explicit and removable. Tracked for full convergence by new BACKLOG
entry TECH-OBSERVER-TEST-CONVERGENCE — productiegedrag = testgedrag,
geen branching, na test-cleanup.
idempotency_key for the engagement-scoped draft simplified from
'aa-' + sha1(engagement_id)[0:27] to 'aa:' + engagement_id (29 chars,
fits varchar(30)). Same uniqueness guarantee, recognisable shape.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -257,16 +257,13 @@ final class EngagementPortalController extends Controller
|
|||||||
// Pass event_id via the context bag — the schema is org-owned (not
|
// Pass event_id via the context bag — the schema is org-owned (not
|
||||||
// event-owned) and this route has no {event} parameter for the
|
// event-owned) and this route has no {event} parameter for the
|
||||||
// FormSubmissionObserver fallback. ARCH-FORM-BUILDER §17.3 footnote.
|
// FormSubmissionObserver fallback. ARCH-FORM-BUILDER §17.3 footnote.
|
||||||
// idempotency_key column is varchar(30); a SHA-1 hex digest fits in
|
// idempotency_key column is varchar(30); 'aa:' + 26-char ULID fits.
|
||||||
// 28 chars and uniquely keys "one draft per (schema, engagement)".
|
|
||||||
$key = 'aa-'.substr(hash('sha1', (string) $resolved->engagement->id), 0, 27);
|
|
||||||
|
|
||||||
return $this->submissionService->createDraft(
|
return $this->submissionService->createDraft(
|
||||||
schema: $schema,
|
schema: $schema,
|
||||||
subject: $resolved->subject,
|
subject: $resolved->subject,
|
||||||
submitter: null,
|
submitter: null,
|
||||||
context: [
|
context: [
|
||||||
'idempotency_key' => $key,
|
'idempotency_key' => 'aa:'.$resolved->engagement->id,
|
||||||
'event_id' => $resolved->eventId,
|
'event_id' => $resolved->eventId,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,15 +18,18 @@ use App\Models\Organisation;
|
|||||||
* The default seeder is idempotent — if the org already owns an
|
* The default seeder is idempotent — if the org already owns an
|
||||||
* artist_advance schema, the call is a no-op. Safe to re-run.
|
* artist_advance schema, the call is a no-op. Safe to re-run.
|
||||||
*
|
*
|
||||||
* Skipped during automated tests so existing FormSchema-counting
|
* Gated by `config('artist_advance.bootstrap_on_org_create')`. The
|
||||||
* tests aren't perturbed; tests that need the auto-seed call
|
* config defaults to true (production behaviour); phpunit.xml flips
|
||||||
* `ArtistAdvanceDefault::seedFor()` explicitly.
|
* it to false so existing FormSchema-counting tests aren't perturbed.
|
||||||
|
* Tests that need the auto-seed call `ArtistAdvanceDefault::seedFor()`
|
||||||
|
* explicitly. Tracked for removal by BACKLOG entry
|
||||||
|
* `TECH-OBSERVER-TEST-CONVERGENCE`.
|
||||||
*/
|
*/
|
||||||
final class OrganisationObserver
|
final class OrganisationObserver
|
||||||
{
|
{
|
||||||
public function created(Organisation $organisation): void
|
public function created(Organisation $organisation): void
|
||||||
{
|
{
|
||||||
if (app()->runningUnitTests()) {
|
if (! (bool) config('artist_advance.bootstrap_on_org_create', true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
25
api/config/artist_advance.php
Normal file
25
api/config/artist_advance.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
return [
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------------
|
||||||
|
| Bootstrap on organisation create
|
||||||
|
|---------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When true (production default), OrganisationObserver provisions a
|
||||||
|
| default artist_advance FormSchema for every newly-created
|
||||||
|
| Organisation per RFC-TIMETABLE v0.2 D15. When false, the observer
|
||||||
|
| no-ops and tests opt in to the seeder explicitly via
|
||||||
|
| `ArtistAdvanceDefault::seedFor()`.
|
||||||
|
|
|
||||||
|
| Tracked for removal by BACKLOG: TECH-OBSERVER-TEST-CONVERGENCE —
|
||||||
|
| once existing FormSchema-counting tests are updated to expect the
|
||||||
|
| auto-bootstrapped schema, this flag goes away (productiegedrag =
|
||||||
|
| testgedrag, geen branching).
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'bootstrap_on_org_create' => env('ARTIST_ADVANCE_BOOTSTRAP_ON_ORG_CREATE', true),
|
||||||
|
];
|
||||||
@@ -35,6 +35,7 @@
|
|||||||
<env name="PULSE_ENABLED" value="false"/>
|
<env name="PULSE_ENABLED" value="false"/>
|
||||||
<env name="TELESCOPE_ENABLED" value="false"/>
|
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||||
<env name="NIGHTWATCH_ENABLED" value="false"/>
|
<env name="NIGHTWATCH_ENABLED" value="false"/>
|
||||||
|
<env name="ARTIST_ADVANCE_BOOTSTRAP_ON_ORG_CREATE" value="false"/>
|
||||||
<ini name="memory_limit" value="512M"/>
|
<ini name="memory_limit" value="512M"/>
|
||||||
</php>
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
Reference in New Issue
Block a user