Skip to content

Commit 8d15044

Browse files
GitHub #369: Prepare to ship 2.0 schema and code as a clean slate (#533)
1 parent 4bfd86a commit 8d15044

5 files changed

Lines changed: 59 additions & 7 deletions

File tree

src/V2/Support/BundleIntegrityVerifier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private static function checkSchema(array $bundle, array &$findings): void
181181
'bundle.schema_version_unsupported',
182182
self::SEVERITY_ERROR,
183183
sprintf(
184-
'Bundle schema_version %d is not supported by this verifier (expected %d).',
184+
'Bundle schema_version %d is not the v2 history-export structural marker (%d); the v2 bundle shape is frozen and a different value indicates a parallel primitive that this verifier does not recognize.',
185185
$version,
186186
HistoryExport::SCHEMA_VERSION,
187187
),

src/V2/Support/HistoryExport.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,27 @@
2323
use Workflow\V2\Models\WorkflowTask;
2424
use Workflow\V2\Models\WorkflowUpdate;
2525

26+
/**
27+
* Builds the v2 workflow history-export bundle.
28+
*
29+
* The schema is defined once for the v2 release. The schema id
30+
* `durable-workflow.v2.history-export` is the canonical version anchor,
31+
* and there is no schema_version ladder within v2: the bundle has a
32+
* single, frozen shape for the lifetime of v2. The accompanying
33+
* `schema_version` field is a structural marker that must remain `1`
34+
* for the lifetime of v2; a breaking shape change requires a parallel
35+
* primitive (a new schema id alongside the existing one) under the
36+
* `parallel_primitive_only` evolution rule, never a bump within v2.
37+
*/
2638
final class HistoryExport
2739
{
2840
public const SCHEMA = 'durable-workflow.v2.history-export';
2941

42+
/**
43+
* Frozen structural marker for the v2 history-export bundle. Do not
44+
* bump this within v2 — see the class docblock for why a breaking
45+
* shape change must take the parallel-primitive route instead.
46+
*/
3047
public const SCHEMA_VERSION = 1;
3148

3249
private const INTEGRITY_CANONICALIZATION = 'json-recursive-ksort-v1';

src/V2/Support/PlatformProtocolSpecs.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class PlatformProtocolSpecs
3838
{
3939
public const SCHEMA = 'durable-workflow.v2.platform-protocol-specs.catalog';
4040

41-
public const VERSION = 11;
41+
public const VERSION = 12;
4242

4343
public const AUTHORITY_URL = 'https://durable-workflow.github.io/docs/2.0/platform-protocol-specs';
4444

@@ -420,7 +420,7 @@ private static function specs(): array
420420
'companion_doc' => 'docs/api-stability.md frozen-event tables in `durable-workflow/workflow`',
421421
],
422422
'history_export_bundle' => [
423-
'description' => 'JSON Schema for the history-export bundle that the server emits and that replay tooling consumes: ordered history events, payload references, payload codec metadata, lineage edges, and bundle manifest.',
423+
'description' => 'JSON Schema for the history-export bundle that the server emits and that replay tooling consumes: ordered history events, payload references, payload codec metadata, lineage edges, and bundle manifest. The schema is defined once for the v2 release; the schema id `durable-workflow.v2.history-export` is the canonical version anchor and the only allowed breaking change is a parallel primitive (a new schema id alongside the existing one).',
424424
'format' => self::FORMAT_JSON_SCHEMA,
425425
'spec_id' => 'durable-workflow.v2.history-export-bundle',
426426
'surface_family' => 'history_event_wire_formats',
@@ -432,11 +432,11 @@ private static function specs(): array
432432
'name' => 'history_export_bundle',
433433
'owner_repo' => 'durable-workflow/workflow',
434434
'schema_authority' => 'Workflow\\V2\\Support\\HistoryExport::SCHEMA',
435-
'version_authority' => 'Workflow\\V2\\Support\\HistoryExport::SCHEMA_VERSION',
435+
'version_authority' => 'durable-workflow.v2.history-export',
436436
],
437437
],
438-
'evolution_rule' => self::EVOLUTION_ADDITIVE_MINOR_BREAKING_MAJOR,
439-
'breaking_change_release' => 'major',
438+
'evolution_rule' => self::EVOLUTION_PARALLEL_PRIMITIVE_ONLY,
439+
'breaking_change_release' => self::EVOLUTION_PARALLEL_PRIMITIVE_ONLY,
440440
'conformance_test' => 'durable-workflow/workflow: tests/Unit/V2/HistoryExportTest.php',
441441
'status' => self::STATUS_PUBLISHED,
442442
'spec_path' => 'static/platform-protocol-specs/history-export-bundle.schema.json',

tests/Unit/V2/HistoryExportTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@
4444

4545
final class HistoryExportTest extends TestCase
4646
{
47+
public function testV2HistoryExportSchemaIsDefinedOnceForV2(): void
48+
{
49+
$this->assertSame(
50+
'durable-workflow.v2.history-export',
51+
HistoryExport::SCHEMA,
52+
'the schema id is the canonical version anchor for the v2 history-export bundle',
53+
);
54+
$this->assertSame(
55+
1,
56+
HistoryExport::SCHEMA_VERSION,
57+
'schema_version is a frozen structural marker for v2; a breaking shape change requires a parallel primitive (a new schema id), not a bump within v2',
58+
);
59+
}
60+
4761
public function testItDoesNotBackfillCommandContractsDuringExport(): void
4862
{
4963
$instance = WorkflowInstance::query()->create([

tests/Unit/V2/PlatformProtocolSpecsTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testManifestAdvertisesAuthorityIdentity(): void
2828
$manifest = PlatformProtocolSpecs::manifest();
2929

3030
$this->assertSame('durable-workflow.v2.platform-protocol-specs.catalog', $manifest['schema']);
31-
$this->assertSame(11, $manifest['version']);
31+
$this->assertSame(12, $manifest['version']);
3232
$this->assertSame(
3333
'https://durable-workflow.github.io/docs/2.0/platform-protocol-specs',
3434
$manifest['authority_url'],
@@ -225,6 +225,27 @@ public function testHistoryEventPayloadsAreFrozenViaParallelPrimitiveRule(): voi
225225
);
226226
}
227227

228+
public function testHistoryExportBundleIsFrozenViaParallelPrimitiveRule(): void
229+
{
230+
$manifest = PlatformProtocolSpecs::manifest();
231+
232+
$entry = $manifest['specs']['history_export_bundle'];
233+
$this->assertSame(
234+
'parallel_primitive_only',
235+
$entry['evolution_rule'],
236+
'the v2 history-export bundle is defined once for v2; a breaking shape change must take the parallel-primitive route, not bump a schema_version ladder within v2',
237+
);
238+
$this->assertSame(
239+
'parallel_primitive_only',
240+
$entry['breaking_change_release'],
241+
);
242+
$this->assertSame(
243+
'durable-workflow.v2.history-export',
244+
$entry['object_families'][0]['version_authority'],
245+
'the schema id is the canonical version anchor for the v2 history-export bundle; there is no separate schema_version ladder authority within v2',
246+
);
247+
}
248+
228249
public function testReleaseCheckNamesEnforcementGates(): void
229250
{
230251
$manifest = PlatformProtocolSpecs::manifest();

0 commit comments

Comments
 (0)