From e0775fc99f9f7816b4584589123a56dcf1a7046b Mon Sep 17 00:00:00 2001
From: Andrew Duffy <andrew@a10y.dev>
Date: Mon, 20 Apr 2026 09:41:37 -0400
Subject: [PATCH 1/6] avoid including experimental encoding in footer

Signed-off-by: Andrew Duffy <andrew@a10y.dev>
---
 vortex-array/src/session/mod.rs |  2 --
 vortex-file/src/lib.rs          |  5 +++++
 vortex-file/src/strategy.rs     | 10 ++++++----
 vortex-file/src/writer.rs       |  3 ++-
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/vortex-array/src/session/mod.rs b/vortex-array/src/session/mod.rs
index 034a369694f..4b30257d981 100644
--- a/vortex-array/src/session/mod.rs
+++ b/vortex-array/src/session/mod.rs
@@ -23,7 +23,6 @@ use crate::arrays::List;
 use crate::arrays::ListView;
 use crate::arrays::Masked;
 use crate::arrays::Null;
-use crate::arrays::Patched;
 use crate::arrays::Primitive;
 use crate::arrays::Struct;
 use crate::arrays::VarBin;
@@ -80,7 +79,6 @@ impl Default for ArraySession {
         this.register(Dict);
         this.register(List);
         this.register(Masked);
-        this.register(Patched);
         this.register(VarBin);
 
         this
diff --git a/vortex-file/src/lib.rs b/vortex-file/src/lib.rs
index 3cc3b6d0858..ce6598173a6 100644
--- a/vortex-file/src/lib.rs
+++ b/vortex-file/src/lib.rs
@@ -110,6 +110,8 @@ pub use forever_constant::*;
 pub use open::*;
 pub use strategy::*;
 use vortex_array::arrays::Dict;
+use vortex_array::arrays::Patched;
+use vortex_array::arrays::patched::use_experimental_patches;
 use vortex_array::session::ArraySessionExt;
 use vortex_bytebool::ByteBool;
 use vortex_fsst::FSST;
@@ -168,6 +170,9 @@ pub fn register_default_encodings(session: &VortexSession) {
         arrays.register(vortex_zstd::Zstd);
         #[cfg(all(feature = "zstd", feature = "unstable_encodings"))]
         arrays.register(vortex_zstd::ZstdBuffers);
+        if use_experimental_patches() {
+            arrays.register(Patched);
+        }
     }
 
     // Eventually all encodings crates should expose an initialize function. For now it's only
diff --git a/vortex-file/src/strategy.rs b/vortex-file/src/strategy.rs
index 41d9e3c2ad2..71c72ffc904 100644
--- a/vortex-file/src/strategy.rs
+++ b/vortex-file/src/strategy.rs
@@ -90,10 +90,6 @@ pub static ALLOWED_ENCODINGS: LazyLock<HashSet<ArrayId>> = LazyLock::new(|| {
     allowed.insert(Masked.id());
     allowed.insert(Dict.id());
 
-    if use_experimental_patches() {
-        allowed.insert(Patched.id());
-    }
-
     // Compressed encodings from encoding crates
     allowed.insert(ALP.id());
     allowed.insert(ALPRD.id());
@@ -111,6 +107,12 @@ pub static ALLOWED_ENCODINGS: LazyLock<HashSet<ArrayId>> = LazyLock::new(|| {
     allowed.insert(Sparse.id());
     allowed.insert(ZigZag.id());
 
+    // Experimental encodings
+
+    if use_experimental_patches() {
+        allowed.insert(Patched.id());
+    }
+
     #[cfg(feature = "zstd")]
     allowed.insert(Zstd.id());
     #[cfg(all(feature = "zstd", feature = "unstable_encodings"))]
diff --git a/vortex-file/src/writer.rs b/vortex-file/src/writer.rs
index 9861d2c0c7f..1d6052d4112 100644
--- a/vortex-file/src/writer.rs
+++ b/vortex-file/src/writer.rs
@@ -47,6 +47,7 @@ use vortex_session::SessionExt;
 use vortex_session::VortexSession;
 use vortex_session::registry::ReadContext;
 
+use crate::ALLOWED_ENCODINGS;
 use crate::Footer;
 use crate::MAGIC_BYTES;
 use crate::WriteStrategyBuilder;
@@ -147,7 +148,7 @@ impl VortexWriteOptions {
         // serialised array order is deterministic. The serialisation of arrays are done
         // parallel and with an empty context they can register their encodings to the context
         // in different order, changing the written bytes from run to run.
-        let ctx = ArrayContext::new(self.session.arrays().registry().ids().sorted().collect())
+        let ctx = ArrayContext::new(ALLOWED_ENCODINGS.iter().cloned().sorted().collect())
             // Configure a registry just to ensure only known encodings are interned.
             .with_registry(self.session.arrays().registry().clone());
         let dtype = stream.dtype().clone();

From df62054d3aa14d0ec69b3650d228ac94f6641bbc Mon Sep 17 00:00:00 2001
From: Andrew Duffy <andrew@a10y.dev>
Date: Mon, 20 Apr 2026 10:24:28 -0400
Subject: [PATCH 2/6] force registration of patched

Signed-off-by: Andrew Duffy <andrew@a10y.dev>
---
 vortex-array/src/arrays/patched/vtable/mod.rs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/vortex-array/src/arrays/patched/vtable/mod.rs b/vortex-array/src/arrays/patched/vtable/mod.rs
index 5a1cdef3edf..4478560e093 100644
--- a/vortex-array/src/arrays/patched/vtable/mod.rs
+++ b/vortex-array/src/arrays/patched/vtable/mod.rs
@@ -349,6 +349,7 @@ fn apply_patches_primitive<V: NativePType>(
 
 #[cfg(test)]
 mod tests {
+    use crate::session::ArraySessionExt;
     use rstest::rstest;
     use vortex_buffer::ByteBufferMut;
     use vortex_buffer::buffer;
@@ -588,7 +589,9 @@ mod tests {
         let dtype = array.dtype().clone();
         let len = array.len();
 
-        let ctx = ArrayContext::empty();
+        LEGACY_SESSION.arrays().register(Patched);
+
+        let ctx = ArrayContext::empty().with_registry(LEGACY_SESSION.arrays().registry().clone());
         let serialized = array
             .serialize(&ctx, &LEGACY_SESSION, &SerializeOptions::default())
             .unwrap();

From 6736c1fe798e51b297b709632c39db6083f31e4a Mon Sep 17 00:00:00 2001
From: Andrew Duffy <andrew@a10y.dev>
Date: Mon, 20 Apr 2026 10:27:50 -0400
Subject: [PATCH 3/6] fix python doctest

Signed-off-by: Andrew Duffy <andrew@a10y.dev>
---
 vortex-python/src/io.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/vortex-python/src/io.rs b/vortex-python/src/io.rs
index 1d1cb63cce7..81bfdc750f6 100644
--- a/vortex-python/src/io.rs
+++ b/vortex-python/src/io.rs
@@ -280,7 +280,7 @@ impl PyVortexWriteOptions {
     /// >>> vx.io.VortexWriteOptions.default().write(sprl, "chonky.vortex")
     /// >>> import os
     /// >>> os.path.getsize('chonky.vortex')
-    /// 216036
+    /// 215972
     /// ```
     ///
     /// Wow, Vortex manages to use about two bytes per integer! So advanced. So tiny.
@@ -292,7 +292,7 @@ impl PyVortexWriteOptions {
     /// ```python
     /// >>> vx.io.VortexWriteOptions.compact().write(sprl, "tiny.vortex")
     /// >>> os.path.getsize('tiny.vortex')
-    /// 55152
+    /// 55088
     /// ```
     ///
     /// Random numbers are not (usually) composed of random bytes!

From 65bdb7d2cb8d2ca38c159638781d286db12b4570 Mon Sep 17 00:00:00 2001
From: Andrew Duffy <andrew@a10y.dev>
Date: Mon, 20 Apr 2026 10:28:29 -0400
Subject: [PATCH 4/6] fixup

Signed-off-by: Andrew Duffy <andrew@a10y.dev>
---
 vortex-array/src/arrays/patched/vtable/mod.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vortex-array/src/arrays/patched/vtable/mod.rs b/vortex-array/src/arrays/patched/vtable/mod.rs
index 4478560e093..ad2fc9aadc7 100644
--- a/vortex-array/src/arrays/patched/vtable/mod.rs
+++ b/vortex-array/src/arrays/patched/vtable/mod.rs
@@ -349,7 +349,6 @@ fn apply_patches_primitive<V: NativePType>(
 
 #[cfg(test)]
 mod tests {
-    use crate::session::ArraySessionExt;
     use rstest::rstest;
     use vortex_buffer::ByteBufferMut;
     use vortex_buffer::buffer;
@@ -374,6 +373,7 @@ mod tests {
     use crate::patches::Patches;
     use crate::serde::SerializeOptions;
     use crate::serde::SerializedArray;
+    use crate::session::ArraySessionExt;
     use crate::validity::Validity;
 
     #[test]

From 45653f6431201b75e0d51211cebe656cd8c7fdb7 Mon Sep 17 00:00:00 2001
From: Andrew Duffy <andrew@a10y.dev>
Date: Mon, 20 Apr 2026 11:49:37 -0400
Subject: [PATCH 5/6] disable compat test for Patched until stabilized

Signed-off-by: Andrew Duffy <andrew@a10y.dev>
---
 .../compat-gen/src/fixtures/arrays/synthetic/encodings/mod.rs  | 3 ++-
 .../src/fixtures/arrays/synthetic/encodings/patched.rs         | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/mod.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/mod.rs
index b6c18064e0f..830b50450da 100644
--- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/mod.rs
+++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/mod.rs
@@ -43,7 +43,8 @@ pub fn fixtures() -> Vec<Box<dyn FlatLayoutFixture>> {
         Box::new(dict::DictFixture),
         Box::new(fsst::FsstFixture),
         Box::new(for_::FoRFixture),
-        Box::new(patched::PatchedFixture),
+        // TODO(aduffy): add back once we stabilized Patched array
+        // Box::new(patched::PatchedFixture),
         Box::new(pco::PcoFixture),
         Box::new(rle::RleFixture),
         Box::new(runend::RunEndFixture),
diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/patched.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/patched.rs
index b9a43dfb1e2..d3921b16ab6 100644
--- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/patched.rs
+++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/patched.rs
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: Apache-2.0
 // SPDX-FileCopyrightText: Copyright the Vortex contributors
 
+#![allow(dead_code)]
+
 use vortex_array::ArrayId;
 use vortex_array::ArrayRef;
 use vortex_array::ExecutionCtx;

From 94fd25fb57975b54e72ac2b2e8b806215424287b Mon Sep 17 00:00:00 2001
From: Andrew Duffy <andrew@a10y.dev>
Date: Mon, 20 Apr 2026 11:50:20 -0400
Subject: [PATCH 6/6] fix

Signed-off-by: Andrew Duffy <andrew@a10y.dev>
---
 .../src/fixtures/arrays/synthetic/encodings/patched.rs      | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/patched.rs b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/patched.rs
index d3921b16ab6..fea0c990173 100644
--- a/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/patched.rs
+++ b/vortex-test/compat-gen/src/fixtures/arrays/synthetic/encodings/patched.rs
@@ -1,8 +1,6 @@
 // SPDX-License-Identifier: Apache-2.0
 // SPDX-FileCopyrightText: Copyright the Vortex contributors
 
-#![allow(dead_code)]
-
 use vortex_array::ArrayId;
 use vortex_array::ArrayRef;
 use vortex_array::ExecutionCtx;
@@ -16,6 +14,10 @@ use vortex_session::VortexSession;
 
 use crate::fixtures::FlatLayoutFixture;
 
+#[expect(
+    dead_code,
+    reason = "This will be unused until we stabilize Patched array"
+)]
 pub struct PatchedFixture;
 
 impl FlatLayoutFixture for PatchedFixture {
