Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

## [Unreleased]

## [0.8.3] - 2026-11-22

### Fixed

- Catalog identifiers are now RFC 4122 version 4 UUIDs. Before, they were 16
random bytes without version or variant bits, so about five of eight imported
datasets got an id that `InPlaceApplyRequest` rejects with
`invalid_dataset_id`, and in-place transformations could not be applied to
them. Datasets imported by earlier versions keep their ids; re-import one
whose id is rejected. Found by a three-way benchmark with Statscraft and the
Python adapter.

## [0.8.2] - 2026-11-09

### Changed
Expand Down
6 changes: 5 additions & 1 deletion src/Sql/NormativeCatalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,11 @@ public static function timestamp(): string

public static function uuid(): string
{
$hex = bin2hex(random_bytes(16));
// RFC 4122 version 4: the in-place executor accepts only the 8/9/a/b variant.
$bytes = random_bytes(16);
$bytes[6] = chr((ord($bytes[6]) & 0x0f) | 0x40);
$bytes[8] = chr((ord($bytes[8]) & 0x3f) | 0x80);
$hex = bin2hex($bytes);
return substr($hex, 0, 8) . '-' . substr($hex, 8, 4) . '-' . substr($hex, 12, 4) . '-' . substr($hex, 16, 4) . '-' . substr($hex, 20);
}
}
21 changes: 21 additions & 0 deletions tests/Sql/NormativeCatalogUuidTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace OpenStatSpec\Tests\Sql;

use OpenStatSpec\Sql\NormativeCatalog;
use PHPUnit\Framework\TestCase;

final class NormativeCatalogUuidTest extends TestCase
{
public function testGeneratedIdsAreVersionFourWithTheVariantTheExecutorAccepts(): void
{
for ($i = 0; $i < 500; $i++) {
self::assertMatchesRegularExpression(
'/\A[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\z/D',
NormativeCatalog::uuid(),
);
}
}
}