datafog-core 0.5.0b2__tar.gz → 0.5.0b3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/Cargo.lock +6 -4
  2. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/PKG-INFO +4 -2
  3. {datafog_core-0.5.0b2/crates/core → datafog_core-0.5.0b3}/README.md +3 -1
  4. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/Cargo.toml +4 -2
  5. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/src/lib.rs +2 -0
  6. datafog_core-0.5.0b3/bindings/python/src/workspace/conversation.rs +166 -0
  7. datafog_core-0.5.0b3/bindings/python/src/workspace/operations.rs +84 -0
  8. datafog_core-0.5.0b3/bindings/python/src/workspace/stream.rs +346 -0
  9. datafog_core-0.5.0b3/bindings/python/src/workspace.rs +1235 -0
  10. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/test_installed.py +10 -0
  11. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/test_typing.py +143 -1
  12. datafog_core-0.5.0b3/bindings/python/tests/workspace_backup_operation_conformance.py +56 -0
  13. datafog_core-0.5.0b3/bindings/python/tests/workspace_conformance.py +280 -0
  14. datafog_core-0.5.0b3/bindings/python/tests/workspace_conversation_conformance.py +149 -0
  15. datafog_core-0.5.0b3/bindings/python/tests/workspace_operation_conformance.py +241 -0
  16. datafog_core-0.5.0b3/bindings/python/tests/workspace_streaming_conformance.py +148 -0
  17. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/Cargo.toml +1 -1
  18. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3/crates/core}/README.md +3 -1
  19. datafog_core-0.5.0b3/crates/core/examples/workspace_backup_operation_fields.rs +581 -0
  20. datafog_core-0.5.0b3/crates/core/examples/workspace_contract/conversation.rs +330 -0
  21. datafog_core-0.5.0b3/crates/core/examples/workspace_contract.rs +660 -0
  22. datafog_core-0.5.0b3/crates/core/examples/workspace_conversation_capacity.rs +286 -0
  23. datafog_core-0.5.0b3/crates/core/examples/workspace_operation_capacity.rs +337 -0
  24. datafog_core-0.5.0b3/crates/core/examples/workspace_operation_cost.rs +173 -0
  25. datafog_core-0.5.0b3/crates/core/examples/workspace_streaming_contract.rs +250 -0
  26. datafog_core-0.5.0b3/crates/core/src/workspace/buffered_restore.rs +307 -0
  27. datafog_core-0.5.0b3/crates/core/src/workspace/codec.rs +1029 -0
  28. datafog_core-0.5.0b3/crates/core/src/workspace/conversation.rs +1498 -0
  29. datafog_core-0.5.0b3/crates/core/src/workspace/operations.rs +357 -0
  30. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/workspace/policy.rs +12 -2
  31. datafog_core-0.5.0b3/crates/core/src/workspace/private_bytes.rs +22 -0
  32. datafog_core-0.5.0b3/crates/core/src/workspace/progressive_restore.rs +561 -0
  33. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/workspace.rs +217 -66
  34. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/workspace.rs +1 -1
  35. datafog_core-0.5.0b3/crates/core/tests/workspace_backup_fields.rs +173 -0
  36. datafog_core-0.5.0b3/crates/core/tests/workspace_backup_operation_fields.rs +333 -0
  37. datafog_core-0.5.0b3/crates/core/tests/workspace_buffered_restore.rs +194 -0
  38. datafog_core-0.5.0b3/crates/core/tests/workspace_conversation_dense.rs +118 -0
  39. datafog_core-0.5.0b3/crates/core/tests/workspace_conversations.rs +377 -0
  40. datafog_core-0.5.0b3/crates/core/tests/workspace_operations.rs +534 -0
  41. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/workspace_policy.rs +3 -3
  42. datafog_core-0.5.0b3/crates/core/tests/workspace_progressive_restore.rs +537 -0
  43. datafog_core-0.5.0b3/crates/core/tests/workspace_snapshot_buffer_cleanup.rs +280 -0
  44. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/pyproject.toml +1 -1
  45. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/python/datafog_core/__init__.py +15 -0
  46. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/python/datafog_core/__init__.pyi +280 -0
  47. datafog_core-0.5.0b2/crates/core/src/workspace/codec.rs +0 -272
  48. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/Cargo.toml +0 -0
  49. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/src/models.rs +0 -0
  50. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/api_key_conformance.py +0 -0
  51. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/bearer_token_conformance.py +0 -0
  52. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/capabilities_conformance.py +0 -0
  53. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/credential_overlap_conformance.py +0 -0
  54. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/credential_uri_conformance.py +0 -0
  55. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/email_context_conformance.py +0 -0
  56. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/german_conformance.py +0 -0
  57. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/jwt_conformance.py +0 -0
  58. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/npi_conformance.py +0 -0
  59. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/private_key_conformance.py +0 -0
  60. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/requirements-typing.txt +0 -0
  61. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/synthetic_fixtures.py +0 -0
  62. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/test_python49_integration.py +0 -0
  63. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/us_routing_number_conformance.py +0 -0
  64. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/bindings/python/tests/uuid_conformance.py +0 -0
  65. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/examples/german_benchmark.rs +0 -0
  66. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/examples/scan_benchmark.rs +0 -0
  67. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/account_number.rs +0 -0
  68. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/api_key.rs +0 -0
  69. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/bearer_token.rs +0 -0
  70. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/capabilities.rs +0 -0
  71. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/coverage.rs +0 -0
  72. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/credential_uri.rs +0 -0
  73. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/email_context.rs +0 -0
  74. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/german.rs +0 -0
  75. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/jwt.rs +0 -0
  76. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/lib.rs +0 -0
  77. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/model_scan.rs +0 -0
  78. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/models/gliner2-lock.json +0 -0
  79. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/models/gliner2.rs +0 -0
  80. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/models/process.rs +0 -0
  81. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/models/tests.rs +0 -0
  82. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/models.rs +0 -0
  83. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/npi.rs +0 -0
  84. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/offsets.rs +0 -0
  85. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/private_key.rs +0 -0
  86. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/scan_selection_tests.rs +0 -0
  87. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/selection_tests.rs +0 -0
  88. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/street_address.rs +0 -0
  89. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/structured.rs +0 -0
  90. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/us_routing_number.rs +0 -0
  91. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/uuid.rs +0 -0
  92. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/workspace/recall.rs +0 -0
  93. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/src/workspace/review.rs +0 -0
  94. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/account_number.rs +0 -0
  95. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/api_key.rs +0 -0
  96. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/bearer_token.rs +0 -0
  97. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/capabilities.rs +0 -0
  98. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/credential_overlaps.rs +0 -0
  99. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/credential_uri.rs +0 -0
  100. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/email_context.rs +0 -0
  101. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/german.rs +0 -0
  102. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/jwt.rs +0 -0
  103. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/model_datafog.rs +0 -0
  104. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/model_gliner2_entity_count.rs +0 -0
  105. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/npi.rs +0 -0
  106. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/private_key.rs +0 -0
  107. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/street_address.rs +0 -0
  108. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/support/synthetic_fixtures.rs +0 -0
  109. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/us_routing_number.rs +0 -0
  110. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/uuid.rs +0 -0
  111. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/workspace_recall.rs +0 -0
  112. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/crates/core/tests/workspace_review.rs +0 -0
  113. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/python/datafog_core/_gliner2_worker.py +0 -0
  114. {datafog_core-0.5.0b2 → datafog_core-0.5.0b3}/python/datafog_core/py.typed +0 -0
@@ -122,7 +122,7 @@ checksum = "914a755b7c2d4af2bdcff7ce1739e2db9a1b81a9b07123d8015786ae03c0980d"
122
122
 
123
123
  [[package]]
124
124
  name = "datafog-core"
125
- version = "0.5.0-beta.2"
125
+ version = "0.5.0-beta.3"
126
126
  dependencies = [
127
127
  "base64",
128
128
  "futures",
@@ -137,29 +137,31 @@ dependencies = [
137
137
 
138
138
  [[package]]
139
139
  name = "datafog-core-python"
140
- version = "0.5.0-beta.2"
140
+ version = "0.5.0-beta.3"
141
141
  dependencies = [
142
142
  "datafog-core",
143
143
  "pyo3",
144
144
  "pyo3-async-runtimes",
145
145
  "serde",
146
146
  "serde_json",
147
+ "zeroize",
147
148
  ]
148
149
 
149
150
  [[package]]
150
151
  name = "datafog-node"
151
- version = "0.5.0-beta.2"
152
+ version = "0.5.0-beta.3"
152
153
  dependencies = [
153
154
  "datafog-core",
154
155
  "napi",
155
156
  "napi-build",
156
157
  "napi-derive",
158
+ "serde",
157
159
  "serde_json",
158
160
  ]
159
161
 
160
162
  [[package]]
161
163
  name = "datafog-wasm"
162
- version = "0.5.0-beta.2"
164
+ version = "0.5.0-beta.3"
163
165
  dependencies = [
164
166
  "datafog-core",
165
167
  "serde",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datafog-core
3
- Version: 0.5.0b2
3
+ Version: 0.5.0b3
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: License :: OSI Approved :: MIT License
6
6
  Classifier: Programming Language :: Python :: 3
@@ -59,7 +59,9 @@ DataFog Core is a Rust library with Python, Node.js, and browser WebAssembly bin
59
59
 
60
60
  Rule-based scanning runs locally without model weights or downloads. Optional local model sessions add DataFog and GLiNER2 support in Rust, Python, and Node.js.
61
61
 
62
- **Stable:** [0.4.4](https://github.com/DataFog/datafog-core/releases/tag/v0.4.4) · **Prerelease:** [0.5.0-beta.1](https://github.com/DataFog/datafog-core/releases/tag/v0.5.0-beta.1)
62
+ **Stable:** [0.4.4](https://github.com/DataFog/datafog-core/releases/tag/v0.4.4) · **Published prerelease:** [0.5.0-beta.2](https://github.com/DataFog/datafog-core/releases/tag/v0.5.0-beta.2)
63
+
64
+ [0.5.0-beta.3 release candidate](docs/releases/0-5-0-beta-3.mdx) adds native workspace APIs, operation/conversation records and strict/progressive streaming. Publication and fresh registry verification are pending; see the [beta.3 integration guide](docs/extension-integration-0.5.0-beta.3.md).
63
65
 
64
66
  ## Quickstart
65
67
 
@@ -26,7 +26,9 @@ DataFog Core is a Rust library with Python, Node.js, and browser WebAssembly bin
26
26
 
27
27
  Rule-based scanning runs locally without model weights or downloads. Optional local model sessions add DataFog and GLiNER2 support in Rust, Python, and Node.js.
28
28
 
29
- **Stable:** [0.4.4](https://github.com/DataFog/datafog-core/releases/tag/v0.4.4) · **Prerelease:** [0.5.0-beta.1](https://github.com/DataFog/datafog-core/releases/tag/v0.5.0-beta.1)
29
+ **Stable:** [0.4.4](https://github.com/DataFog/datafog-core/releases/tag/v0.4.4) · **Published prerelease:** [0.5.0-beta.2](https://github.com/DataFog/datafog-core/releases/tag/v0.5.0-beta.2)
30
+
31
+ [0.5.0-beta.3 release candidate](docs/releases/0-5-0-beta-3.mdx) adds native workspace APIs, operation/conversation records and strict/progressive streaming. Publication and fresh registry verification are pending; see the [beta.3 integration guide](docs/extension-integration-0.5.0-beta.3.md).
30
32
 
31
33
  ## Quickstart
32
34
 
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "datafog-core-python"
3
- version = "0.5.0-beta.2"
3
+ version = "0.5.0-beta.3"
4
4
  edition = "2024"
5
5
  rust-version = "1.88"
6
6
  description = "Python bindings for datafog-core"
@@ -12,8 +12,10 @@ name = "datafog_core"
12
12
  crate-type = ["cdylib"]
13
13
 
14
14
  [dependencies]
15
- datafog-core = { version = "0.5.0-beta.2", path = "../../crates/core", features = ["models"] }
15
+ datafog-core = { version = "0.5.0-beta.3", path = "../../crates/core", features = ["models"] }
16
16
  pyo3 = { version = "0.29", features = ["abi3-py310"] }
17
17
  pyo3-async-runtimes = { version = "0.29", features = ["tokio-runtime"] }
18
18
  serde_json = "1"
19
19
  serde = "1"
20
+ # Reuse Core's wipe primitive for transient copied UTF-16 transport buffers.
21
+ zeroize = "1"
@@ -1,5 +1,6 @@
1
1
  use ::datafog_core as core;
2
2
  mod models;
3
+ mod workspace;
3
4
  use pyo3::create_exception;
4
5
  use pyo3::exceptions::{PyRuntimeError, PyTypeError, PyValueError};
5
6
  use pyo3::prelude::*;
@@ -1274,6 +1275,7 @@ fn scan_and_transform_structured(
1274
1275
  #[pymodule]
1275
1276
  fn datafog_core(module: &Bound<'_, PyModule>) -> PyResult<()> {
1276
1277
  models::register(module)?;
1278
+ workspace::register(module)?;
1277
1279
  module.add(
1278
1280
  "DataFogConfigurationError",
1279
1281
  module.py().get_type::<DataFogConfigurationError>(),
@@ -0,0 +1,166 @@
1
+ //! Exact Python transport values; conversation/admission decisions stay in Core.
2
+ use super::*;
3
+ use pyo3::types::{PyInt, PyString};
4
+
5
+ fn object<'py>(
6
+ py: Python<'py>,
7
+ value: &Bound<'py, PyAny>,
8
+ names: &[&str],
9
+ code: w::ErrorCode,
10
+ ) -> PyResult<Bound<'py, PyDict>> {
11
+ let invalid = || failure(py, code);
12
+ let object = value.cast_exact::<PyDict>().map_err(|_| invalid())?;
13
+ if object.len() != names.len()
14
+ || object
15
+ .keys()
16
+ .iter()
17
+ .any(|key| !key.is_exact_instance_of::<PyString>())
18
+ {
19
+ return Err(invalid());
20
+ }
21
+ for name in names {
22
+ if !object.contains(*name)? {
23
+ return Err(invalid());
24
+ }
25
+ }
26
+ Ok(object.clone())
27
+ }
28
+ fn required<'py>(
29
+ py: Python<'py>,
30
+ object: &Bound<'py, PyDict>,
31
+ name: &str,
32
+ code: w::ErrorCode,
33
+ ) -> PyResult<Bound<'py, PyAny>> {
34
+ object.get_item(name)?.ok_or_else(|| failure(py, code))
35
+ }
36
+ fn public_id(
37
+ py: Python<'_>,
38
+ value: &Bound<'_, PyAny>,
39
+ code: w::ErrorCode,
40
+ ) -> PyResult<w::PublicId> {
41
+ let invalid = || failure(py, code);
42
+ if let Ok(bytes) = value.cast_exact::<PyBytes>() {
43
+ return bytes.as_bytes().try_into().map_err(|_| invalid());
44
+ }
45
+ let values = value.cast_exact::<PyList>().map_err(|_| invalid())?;
46
+ if values.len() != 16 {
47
+ return Err(invalid());
48
+ }
49
+ let mut result = [0; 16];
50
+ for (index, item) in values.iter().enumerate() {
51
+ if !item.is_exact_instance_of::<PyInt>() {
52
+ return Err(invalid());
53
+ }
54
+ result[index] = item.extract::<u8>().map_err(|_| invalid())?;
55
+ }
56
+ Ok(result)
57
+ }
58
+ // Direct restoration borrows the caller string; saved context fields clone explicitly.
59
+ pub(super) fn text<'a>(
60
+ py: Python<'_>,
61
+ value: &'a Bound<'_, PyAny>,
62
+ code: w::ErrorCode,
63
+ ) -> PyResult<&'a str> {
64
+ let value = value
65
+ .cast_exact::<PyString>()
66
+ .map_err(|_| failure(py, code))?;
67
+ let text = value.to_str().map_err(|_| failure(py, code))?;
68
+ material_limit(py, text.len())?;
69
+ Ok(text)
70
+ }
71
+ pub(super) fn selector(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<w::PublicId> {
72
+ let bytes = value
73
+ .cast_exact::<PyBytes>()
74
+ .map_err(|_| failure(py, w::ErrorCode::InvalidId))?;
75
+ id(py, bytes.as_bytes())
76
+ }
77
+ pub(super) fn intent(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<w::SendIntentId> {
78
+ let code = w::ErrorCode::InvalidSendIntent;
79
+ let object = object(py, value, &["preparationId", "inputIndex"], code)?;
80
+ let preparation_id = public_id(py, &required(py, &object, "preparationId", code)?, code)?;
81
+ let index = required(py, &object, "inputIndex", code)?;
82
+ if !index.is_exact_instance_of::<PyInt>() {
83
+ return Err(failure(py, code));
84
+ }
85
+ let input_index = index.extract::<usize>().map_err(|_| failure(py, code))?;
86
+ if input_index >= w::MAX_INPUTS {
87
+ return Err(failure(py, code));
88
+ }
89
+ Ok(w::SendIntentId {
90
+ preparation_id,
91
+ input_index,
92
+ })
93
+ }
94
+ pub(super) fn inputs(
95
+ py: Python<'_>,
96
+ value: &Bound<'_, PyAny>,
97
+ ) -> PyResult<Vec<(ReviewOwned, w::Conversation)>> {
98
+ let code = w::ErrorCode::InvalidConversation;
99
+ let values = value
100
+ .cast_exact::<PyList>()
101
+ .map_err(|_| failure(py, w::ErrorCode::InvalidBatch))?;
102
+ if values.len() > w::MAX_INPUTS {
103
+ return Err(failure(py, w::ErrorCode::ResourceLimit));
104
+ }
105
+ let mut result = Vec::with_capacity(values.len());
106
+ let mut bytes = 0usize;
107
+ for (index, value) in values.iter().enumerate() {
108
+ let row = (|| -> PyResult<(ReviewOwned, w::Conversation)> {
109
+ let item = object(py, &value, &["input", "conversation"], code)?;
110
+ let input = required(py, &item, "input", code)?;
111
+ let input = input
112
+ .extract::<PyRef<'_, WorkspaceReviewInput>>()
113
+ .map_err(|_| failure(py, code))?;
114
+ bytes = bytes.saturating_add(input.text.len());
115
+ for finding in input.scanner.iter().chain(&input.user) {
116
+ bytes = bytes.saturating_add(finding_bytes(finding));
117
+ }
118
+ for correction in &input.corrections {
119
+ bytes = bytes
120
+ .saturating_add(finding_bytes(&correction.replacement))
121
+ .saturating_add(correction.candidate_key.len());
122
+ }
123
+ material_limit(py, bytes)?;
124
+ let context = object(
125
+ py,
126
+ &required(py, &item, "conversation", code)?,
127
+ &["id", "surface", "siteId", "siteIdByteBudget"],
128
+ code,
129
+ )?;
130
+ let id = public_id(py, &required(py, &context, "id", code)?, code)?;
131
+ let surface = text(py, &required(py, &context, "surface", code)?, code)?.to_owned();
132
+ let site = required(py, &context, "siteId", code)?;
133
+ let site_id = if site.is_none() {
134
+ None
135
+ } else {
136
+ Some(text(py, &site, code)?.to_owned())
137
+ };
138
+ bytes = bytes
139
+ .saturating_add(surface.len())
140
+ .saturating_add(site_id.as_ref().map_or(0, String::len));
141
+ material_limit(py, bytes)?;
142
+ let budget = required(py, &context, "siteIdByteBudget", code)?;
143
+ if !budget.is_exact_instance_of::<PyInt>() {
144
+ return Err(failure(py, code));
145
+ }
146
+ let site_id_byte_budget = budget.extract::<usize>().map_err(|_| failure(py, code))?;
147
+ Ok((
148
+ input.owned(),
149
+ w::Conversation {
150
+ id,
151
+ surface,
152
+ site_id,
153
+ site_id_byte_budget,
154
+ },
155
+ ))
156
+ })();
157
+ match row {
158
+ Ok(row) => result.push(row),
159
+ Err(error) => {
160
+ error.value(py).setattr("input_index", index)?;
161
+ return Err(error);
162
+ }
163
+ }
164
+ }
165
+ Ok(result)
166
+ }
@@ -0,0 +1,84 @@
1
+ //! Transport-only adapters for the shared content-free operation contract.
2
+ use super::*;
3
+ use pyo3::types::{PyInt, PyString};
4
+
5
+ pub(super) fn context(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<w::OperationContext> {
6
+ let invalid = || failure(py, w::ErrorCode::InvalidOperation);
7
+ let object = value.cast_exact::<PyDict>().map_err(|_| invalid())?;
8
+ if object.len() != 2
9
+ || object
10
+ .keys()
11
+ .iter()
12
+ .any(|key| !key.is_exact_instance_of::<PyString>())
13
+ {
14
+ return Err(invalid());
15
+ }
16
+ let bytes = object.get_item("id")?.ok_or_else(invalid)?;
17
+ let bytes = bytes
18
+ .cast_exact::<PyBytes>()
19
+ .map_err(|_| failure(py, w::ErrorCode::InvalidId))?;
20
+ let operation_id = id(py, bytes.as_bytes())?;
21
+ let time = object.get_item("occurredAtMs")?.ok_or_else(invalid)?;
22
+ if !time.is_exact_instance_of::<PyInt>() {
23
+ return Err(invalid());
24
+ }
25
+ let occurred_at_ms = time.extract::<u64>().map_err(|_| invalid())?;
26
+ if occurred_at_ms > w::MAX_OPERATION_TIME_MS {
27
+ return Err(invalid());
28
+ }
29
+ Ok(w::OperationContext {
30
+ id: operation_id,
31
+ occurred_at_ms,
32
+ })
33
+ }
34
+
35
+ pub(super) fn outcome(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<w::OperationOutcome> {
36
+ let invalid = || failure(py, w::ErrorCode::InvalidOperation);
37
+ let object = value.cast_exact::<PyDict>().map_err(|_| invalid())?;
38
+ if object.len() != 2
39
+ || object
40
+ .keys()
41
+ .iter()
42
+ .any(|key| !key.is_exact_instance_of::<PyString>())
43
+ {
44
+ return Err(invalid());
45
+ }
46
+ let kind = object.get_item("kind")?.ok_or_else(invalid)?;
47
+ let kind = kind.cast_exact::<PyString>().map_err(|_| invalid())?;
48
+ let kind = match kind.to_str().map_err(|_| invalid())? {
49
+ "copy_confirmed" => w::OutcomeKind::CopyConfirmed,
50
+ "user_cancelled" => w::OutcomeKind::UserCancelled,
51
+ "blocked_input" => w::OutcomeKind::BlockedInput,
52
+ "restore_blocked" => w::OutcomeKind::RestoreBlocked,
53
+ _ => return Err(invalid()),
54
+ };
55
+ let count = object.get_item("issueCount")?.ok_or_else(invalid)?;
56
+ if !count.is_exact_instance_of::<PyInt>() {
57
+ return Err(invalid());
58
+ }
59
+ let issue_count = count.extract::<usize>().map_err(|_| invalid())?;
60
+ if issue_count > w::MAX_FINDINGS {
61
+ return Err(invalid());
62
+ }
63
+ Ok(w::OperationOutcome { kind, issue_count })
64
+ }
65
+
66
+ pub(super) fn record(value: &w::OperationRecord) -> Value {
67
+ json!({"id":value.id,"kind":value.kind.as_str(),"occurredAtMs":value.occurred_at_ms,
68
+ "preparedInputs":value.prepared_inputs,"transformedSpans":value.transformed_spans})
69
+ }
70
+
71
+ pub(super) fn counts(value: w::OperationCounts) -> Value {
72
+ json!({"operations":value.operations,"preparedInputs":value.prepared_inputs,
73
+ "transformedSpans":value.transformed_spans,"confirmedHandoffs":value.confirmed_handoffs,
74
+ "reportedBlockedAttempts":value.reported_blocked_attempts})
75
+ }
76
+
77
+ // Bounds stay Core-owned; reject Python coercion before entering the native call.
78
+ pub(super) fn page_index(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<usize> {
79
+ let invalid = || failure(py, w::ErrorCode::ResourceLimit);
80
+ if !value.is_exact_instance_of::<PyInt>() {
81
+ return Err(invalid());
82
+ }
83
+ value.extract::<usize>().map_err(|_| invalid())
84
+ }