fix(node): bind blob byte queries to their response snapshot (#5019)

TypeScript remote `toArrow` and `toArray` could combine scalar values
from query snapshot A with Blob payloads from a later snapshot B. Cached
table schemas and native descriptor layouts could also leave descriptors
in a `blobMode: "bytes"` result.

Discover Blob fields and snapshot provenance from the executed query
stream, recognizing canonical native v2 descriptors as well as
extension-marked fields. Fetch payloads through an independent Rust
snapshot handle bound to the query version and immutable dataset
identity, without changing the live table. Preserve aliases, nested
fields, NULL/empty values, explicit row IDs, and scalar-only results.
Hybrid byte queries require matching provenance from both actual
responses. Missing or mismatched server provenance fails explicitly;
logical-input validation and local materialization remain unchanged.

Manual integration validation at `4daf354df`: all five real SDK/NAPI →
Sophon REST scenarios passed. Both `toArrow` and `toArray` retain A
bytes across overwrite and reject same-name/same-URI recreation even
when version and row IDs are reused. A previously cached handle
discovers a subsequently added Blob field. Ten actual payload fetches
include the two expected identity rejections; later queries on the same
live handle read B. The canonical-descriptor and Blob regression suites
pass 119 tests, with independent source and wire-evidence review.
Earlier broader SDK and hybrid evidence is retained within its
unchanged-source scope.

This is local REST interoperability evidence, not deployed
Cloud/header-forwarding acceptance. Remote bytes require the
authoritative server version/identity and fetch-echo contract. CI and
formal review remain merge requirements; this follow-up does not close
ENT-3556 or Blob V2 GA.
This commit is contained in:
Xuanwo
2026-11-14 20:52:50 +08:00
committed by GitHub
parent 2f496322ef
commit beda423318
7 changed files with 828 additions and 13 deletions
+25
View File
@@ -349,6 +349,31 @@ impl Table {
Ok(Query::new(self.inner_ref()?.query()))
}
/// Whether this handle reads an in-process dataset.
#[napi]
pub fn is_native(&self) -> napi::Result<bool> {
Ok(self.inner_ref()?.as_native().is_some())
}
/// Constrain deferred blob reads by the producing query response.
#[napi(catch_unwind)]
pub async fn query_snapshot_with_identity(
&self,
version: String,
identity: String,
) -> napi::Result<Self> {
// Keep u64 query versions exact across the JavaScript boundary.
let version = version
.parse::<u64>()
.map_err(|_| napi::Error::from_reason("Invalid query snapshot version"))?;
let snapshot = self
.inner_ref()?
.query_snapshot_with_identity(version, &identity)
.await
.default_error()?;
Ok(Self::new(snapshot))
}
/// Return a read-only table handle pinned to the current query revision.
#[napi(catch_unwind)]
pub async fn query_snapshot(&self) -> napi::Result<Self> {