b24api 2.6.1__tar.gz → 2.6.2__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 (151) hide show
  1. {b24api-2.6.1/b24api.egg-info → b24api-2.6.2}/PKG-INFO +20 -13
  2. {b24api-2.6.1 → b24api-2.6.2}/README.md +19 -12
  3. {b24api-2.6.1 → b24api-2.6.2}/b24api/batch/outcome.py +3 -3
  4. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/__init__.py +2 -1
  5. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/json.py +4 -3
  6. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/keyset_capability.py +9 -11
  7. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/page_stop.py +14 -2
  8. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/positional.py +3 -3
  9. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/reference.py +3 -3
  10. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/request.py +2 -2
  11. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/response.py +4 -4
  12. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/wire_body.py +2 -2
  13. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/budget_view.py +21 -6
  14. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/dispatch.py +67 -18
  15. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/keyset_run.py +31 -15
  16. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/outcome.py +3 -3
  17. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/program.py +1 -1
  18. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/scheduler.py +20 -5
  19. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/wave_engine.py +20 -2
  20. {b24api-2.6.1 → b24api-2.6.2}/b24api/transport/base.py +2 -2
  21. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/continuation.py +2 -2
  22. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/counted.py +2 -2
  23. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/facade.py +2 -3
  24. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/identity.py +2 -2
  25. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_context.py +21 -4
  26. b24api-2.6.2/b24api/traversal/keyset_engine.py +62 -0
  27. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_fast_stream.py +2 -2
  28. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_runtime.py +13 -3
  29. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_transaction_contract.py +0 -2
  30. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_transactions.py +87 -35
  31. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/stream.py +5 -3
  32. {b24api-2.6.1 → b24api-2.6.2/b24api.egg-info}/PKG-INFO +20 -13
  33. {b24api-2.6.1 → b24api-2.6.2}/b24api.egg-info/SOURCES.txt +1 -0
  34. {b24api-2.6.1 → b24api-2.6.2}/LICENSE +0 -0
  35. {b24api-2.6.1 → b24api-2.6.2}/MANIFEST.in +0 -0
  36. {b24api-2.6.1 → b24api-2.6.2}/b24api/__init__.py +0 -0
  37. {b24api-2.6.1 → b24api-2.6.2}/b24api/_client_traversal.py +0 -0
  38. {b24api-2.6.1 → b24api-2.6.2}/b24api/_diagnostics.py +0 -0
  39. {b24api-2.6.1 → b24api-2.6.2}/b24api/_error_types.py +0 -0
  40. {b24api-2.6.1 → b24api-2.6.2}/b24api/_sources.py +0 -0
  41. {b24api-2.6.1 → b24api-2.6.2}/b24api/batch/__init__.py +0 -0
  42. {b24api-2.6.1 → b24api-2.6.2}/b24api/batch/correlation.py +0 -0
  43. {b24api-2.6.1 → b24api-2.6.2}/b24api/batch/engine.py +0 -0
  44. {b24api-2.6.1 → b24api-2.6.2}/b24api/batch/facade.py +0 -0
  45. {b24api-2.6.1 → b24api-2.6.2}/b24api/batch/logical.py +0 -0
  46. {b24api-2.6.1 → b24api-2.6.2}/b24api/batch/stream.py +0 -0
  47. {b24api-2.6.1 → b24api-2.6.2}/b24api/batch/v3.py +0 -0
  48. {b24api-2.6.1 → b24api-2.6.2}/b24api/cli.py +0 -0
  49. {b24api-2.6.1 → b24api-2.6.2}/b24api/cli_contract.py +0 -0
  50. {b24api-2.6.1 → b24api-2.6.2}/b24api/client.py +0 -0
  51. {b24api-2.6.1 → b24api-2.6.2}/b24api/completion/__init__.py +0 -0
  52. {b24api-2.6.1 → b24api-2.6.2}/b24api/completion/closure.py +0 -0
  53. {b24api-2.6.1 → b24api-2.6.2}/b24api/completion/fast_recorder.py +0 -0
  54. {b24api-2.6.1 → b24api-2.6.2}/b24api/completion/gate.py +0 -0
  55. {b24api-2.6.1 → b24api-2.6.2}/b24api/completion/operation_stream.py +0 -0
  56. {b24api-2.6.1 → b24api-2.6.2}/b24api/completion/recorder.py +0 -0
  57. {b24api-2.6.1 → b24api-2.6.2}/b24api/completion/reference_recorder.py +0 -0
  58. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/bounded_range.py +0 -0
  59. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/command.py +0 -0
  60. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/completion.py +0 -0
  61. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/continuation.py +0 -0
  62. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/dispatch.py +0 -0
  63. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/error_base.py +0 -0
  64. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/evidence.py +0 -0
  65. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/identity_store.py +0 -0
  66. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/keyset_execution.py +0 -0
  67. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/page.py +0 -0
  68. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/policy.py +0 -0
  69. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/reference_source.py +0 -0
  70. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/report.py +0 -0
  71. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/request_summary.py +0 -0
  72. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/stream.py +0 -0
  73. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/traversal.py +0 -0
  74. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/v3_codes.py +0 -0
  75. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/violation.py +0 -0
  76. {b24api-2.6.1 → b24api-2.6.2}/b24api/contracts/wire.py +0 -0
  77. {b24api-2.6.1 → b24api-2.6.2}/b24api/encoding.py +0 -0
  78. {b24api-2.6.1 → b24api-2.6.2}/b24api/errors.py +0 -0
  79. {b24api-2.6.1 → b24api-2.6.2}/b24api/execution/__init__.py +0 -0
  80. {b24api-2.6.1 → b24api-2.6.2}/b24api/execution/boundary.py +0 -0
  81. {b24api-2.6.1 → b24api-2.6.2}/b24api/execution/cleanup.py +0 -0
  82. {b24api-2.6.1 → b24api-2.6.2}/b24api/execution/context.py +0 -0
  83. {b24api-2.6.1 → b24api-2.6.2}/b24api/execution/executor.py +0 -0
  84. {b24api-2.6.1 → b24api-2.6.2}/b24api/execution/failure.py +0 -0
  85. {b24api-2.6.1 → b24api-2.6.2}/b24api/execution/lifecycle.py +0 -0
  86. {b24api-2.6.1 → b24api-2.6.2}/b24api/execution/rate.py +0 -0
  87. {b24api-2.6.1 → b24api-2.6.2}/b24api/execution/snapshot.py +0 -0
  88. {b24api-2.6.1 → b24api-2.6.2}/b24api/execution/throttle.py +0 -0
  89. {b24api-2.6.1 → b24api-2.6.2}/b24api/migration.py +0 -0
  90. {b24api-2.6.1 → b24api-2.6.2}/b24api/py.typed +0 -0
  91. {b24api-2.6.1 → b24api-2.6.2}/b24api/redaction.py +0 -0
  92. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/__init__.py +0 -0
  93. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/binding.py +0 -0
  94. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/compatibility.py +0 -0
  95. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/counted_io.py +0 -0
  96. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/dispatch_plan.py +0 -0
  97. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/facade.py +0 -0
  98. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/fanout.py +0 -0
  99. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/run.py +0 -0
  100. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/sources.py +0 -0
  101. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/stream.py +0 -0
  102. {b24api-2.6.1 → b24api-2.6.2}/b24api/references/support.py +0 -0
  103. {b24api-2.6.1 → b24api-2.6.2}/b24api/settings.py +0 -0
  104. {b24api-2.6.1 → b24api-2.6.2}/b24api/testing/__init__.py +0 -0
  105. {b24api-2.6.1 → b24api-2.6.2}/b24api/testing/_isolation.py +0 -0
  106. {b24api-2.6.1 → b24api-2.6.2}/b24api/testing/scripted.py +0 -0
  107. {b24api-2.6.1 → b24api-2.6.2}/b24api/testing/transport.py +0 -0
  108. {b24api-2.6.1 → b24api-2.6.2}/b24api/transport/__init__.py +0 -0
  109. {b24api-2.6.1 → b24api-2.6.2}/b24api/transport/decoding.py +0 -0
  110. {b24api-2.6.1 → b24api-2.6.2}/b24api/transport/disposition.py +0 -0
  111. {b24api-2.6.1 → b24api-2.6.2}/b24api/transport/httpx.py +0 -0
  112. {b24api-2.6.1 → b24api-2.6.2}/b24api/transport/log_records.py +0 -0
  113. {b24api-2.6.1 → b24api-2.6.2}/b24api/transport/logging_shield.py +0 -0
  114. {b24api-2.6.1 → b24api-2.6.2}/b24api/transport/protocol.py +0 -0
  115. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/__init__.py +0 -0
  116. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/control_preflight.py +0 -0
  117. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/counted_batch.py +0 -0
  118. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/counted_io.py +0 -0
  119. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/counted_rules.py +0 -0
  120. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/cursor.py +0 -0
  121. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/cursor_domain.py +0 -0
  122. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/driver.py +0 -0
  123. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/facade_support.py +0 -0
  124. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/identity_ledger.py +0 -0
  125. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/inclusive_window.py +0 -0
  126. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset.py +0 -0
  127. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_auto.py +0 -0
  128. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_capability.py +0 -0
  129. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_eligibility.py +0 -0
  130. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_fast_plan.py +0 -0
  131. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_geometry.py +0 -0
  132. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_observation.py +0 -0
  133. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_ordered_admission.py +0 -0
  134. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_page_validation.py +0 -0
  135. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_plan.py +0 -0
  136. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_reporting.py +0 -0
  137. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_step.py +0 -0
  138. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/keyset_verifier.py +0 -0
  139. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/offset_rules.py +0 -0
  140. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/page_adaptation.py +0 -0
  141. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/plans.py +0 -0
  142. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/sequential.py +0 -0
  143. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/sparse.py +0 -0
  144. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/strategy_context.py +0 -0
  145. {b24api-2.6.1 → b24api-2.6.2}/b24api/traversal/values.py +0 -0
  146. {b24api-2.6.1 → b24api-2.6.2}/b24api.egg-info/dependency_links.txt +0 -0
  147. {b24api-2.6.1 → b24api-2.6.2}/b24api.egg-info/entry_points.txt +0 -0
  148. {b24api-2.6.1 → b24api-2.6.2}/b24api.egg-info/requires.txt +0 -0
  149. {b24api-2.6.1 → b24api-2.6.2}/b24api.egg-info/top_level.txt +0 -0
  150. {b24api-2.6.1 → b24api-2.6.2}/pyproject.toml +0 -0
  151. {b24api-2.6.1 → b24api-2.6.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: b24api
3
- Version: 2.6.1
3
+ Version: 2.6.2
4
4
  Summary: Bitrix24 API
5
5
  Author-email: Shkarupa Alex <shkarupa.alex@gmail.com>
6
6
  License-Expression: MIT
@@ -555,7 +555,8 @@ never reports the source as exhausted.
555
555
  For newest-first lists that resume from an inclusive timestamp and may also return pinned rows,
556
556
  `iter_list_window()` sends the oldest paging timestamp of each page unchanged, delivers rows
557
557
  repeated by the overlap once and fails as non-progress, without another request, when the boundary
558
- does not move. See
558
+ does not move. Its `page_stop` callback receives every validated page, empty closing page
559
+ included, and `PageBoundary.result` carries that page's server result for response-level fields. See
559
560
  [Inclusive timestamp windows](https://github.com/shkarupa-alex/b24api/blob/master/docs/recipes.md#inclusive-timestamp-windows).
560
561
 
561
562
  For multiple parent-bound cursor chains, `iter_cursors()` keeps cursor progress and correlation
@@ -661,17 +662,23 @@ rather than fabricating a reference outcome. Already accepted bindings retain th
661
662
  ### Keyset references
662
663
 
663
664
  `KeysetTraversal` bindings run sequentially by default (`SequentialKeysetExecution()`), unlike
664
- `iter_list_keyset()`, whose default is automatic. Pass `AutoKeysetExecution`,
665
- `RangeKeysetExecution` or `PartitionedKeysetExecution` as the traversal's `execution` to opt in. A
666
- binding with automatic, range or partitioned execution runs its own planning barrier and selection;
667
- its waves travel through the shared batch queue beside other bindings' pages, and its
668
- `ReferenceComplete` carries the binding's `keyset_selection` and, when the fast path ran, its
669
- `keyset_execution`. From its first request to its terminal event the binding holds a fixed share of
670
- `ExecutionPolicy.max_buffered_rows` and plans every wave within it; requests, pages, attempts and
671
- elapsed time stay on the one operation budget. An automatic binding whose planning floor exceeds the
672
- whole row budget waits to run alone with all of it (under `INPUT` delivery, once it is the next
673
- binding to deliver); a binding that cannot obtain its floor while no other binding can release rows
674
- fails with `BudgetExceededError`, and waiting for a share never outlasts `max_elapsed`.
665
+ `iter_list_keyset()`, whose default is automatic. Pass `AutoKeysetExecution`, `RangeKeysetExecution`
666
+ or `PartitionedKeysetExecution` as the traversal's `execution` to opt in. A binding with automatic,
667
+ range or partitioned execution runs its own planning barrier and selection; its waves and its final
668
+ confirmation pages travel through the shared batch queue beside other bindings' pages, so a cohort
669
+ of small parents shares physical batches instead of confirming each parent with a direct request.
670
+ Its `ReferenceComplete` carries the binding's `keyset_selection` and, when the fast path ran, its
671
+ `keyset_execution`. From its first request to its terminal event the binding holds a share of
672
+ `ExecutionPolicy.max_buffered_rows` and plans every wave within it; once a sequential or
673
+ boundary-only plan is chosen, the binding keeps only the rows that plan can still hold and returns
674
+ the rest to the bindings waiting for a share. Under `INPUT` delivery row capacity is granted in
675
+ binding order: while a binding waits for its share, no later binding is granted a share or reserves
676
+ an ordinary page. A binding whose batch was lost in transit ends with `ReferenceOutcomeUnknown`.
677
+ Requests, pages, attempts and elapsed time stay on the one operation budget. An automatic binding
678
+ whose planning floor exceeds the whole row budget waits to run alone with all of it (under `INPUT`
679
+ delivery, once it is the next binding to deliver); a binding that cannot obtain its floor while no
680
+ other binding can release rows fails with `BudgetExceededError`, and waiting for a share never
681
+ outlasts `max_elapsed`.
675
682
 
676
683
  Fast and automatic keyset references need `BatchDispatch`. With a `page_stop`, automatic execution
677
684
  runs sequentially and reports `PAGE_STOP`; an explicit fast mode with a `page_stop` or
@@ -524,7 +524,8 @@ never reports the source as exhausted.
524
524
  For newest-first lists that resume from an inclusive timestamp and may also return pinned rows,
525
525
  `iter_list_window()` sends the oldest paging timestamp of each page unchanged, delivers rows
526
526
  repeated by the overlap once and fails as non-progress, without another request, when the boundary
527
- does not move. See
527
+ does not move. Its `page_stop` callback receives every validated page, empty closing page
528
+ included, and `PageBoundary.result` carries that page's server result for response-level fields. See
528
529
  [Inclusive timestamp windows](https://github.com/shkarupa-alex/b24api/blob/master/docs/recipes.md#inclusive-timestamp-windows).
529
530
 
530
531
  For multiple parent-bound cursor chains, `iter_cursors()` keeps cursor progress and correlation
@@ -630,17 +631,23 @@ rather than fabricating a reference outcome. Already accepted bindings retain th
630
631
  ### Keyset references
631
632
 
632
633
  `KeysetTraversal` bindings run sequentially by default (`SequentialKeysetExecution()`), unlike
633
- `iter_list_keyset()`, whose default is automatic. Pass `AutoKeysetExecution`,
634
- `RangeKeysetExecution` or `PartitionedKeysetExecution` as the traversal's `execution` to opt in. A
635
- binding with automatic, range or partitioned execution runs its own planning barrier and selection;
636
- its waves travel through the shared batch queue beside other bindings' pages, and its
637
- `ReferenceComplete` carries the binding's `keyset_selection` and, when the fast path ran, its
638
- `keyset_execution`. From its first request to its terminal event the binding holds a fixed share of
639
- `ExecutionPolicy.max_buffered_rows` and plans every wave within it; requests, pages, attempts and
640
- elapsed time stay on the one operation budget. An automatic binding whose planning floor exceeds the
641
- whole row budget waits to run alone with all of it (under `INPUT` delivery, once it is the next
642
- binding to deliver); a binding that cannot obtain its floor while no other binding can release rows
643
- fails with `BudgetExceededError`, and waiting for a share never outlasts `max_elapsed`.
634
+ `iter_list_keyset()`, whose default is automatic. Pass `AutoKeysetExecution`, `RangeKeysetExecution`
635
+ or `PartitionedKeysetExecution` as the traversal's `execution` to opt in. A binding with automatic,
636
+ range or partitioned execution runs its own planning barrier and selection; its waves and its final
637
+ confirmation pages travel through the shared batch queue beside other bindings' pages, so a cohort
638
+ of small parents shares physical batches instead of confirming each parent with a direct request.
639
+ Its `ReferenceComplete` carries the binding's `keyset_selection` and, when the fast path ran, its
640
+ `keyset_execution`. From its first request to its terminal event the binding holds a share of
641
+ `ExecutionPolicy.max_buffered_rows` and plans every wave within it; once a sequential or
642
+ boundary-only plan is chosen, the binding keeps only the rows that plan can still hold and returns
643
+ the rest to the bindings waiting for a share. Under `INPUT` delivery row capacity is granted in
644
+ binding order: while a binding waits for its share, no later binding is granted a share or reserves
645
+ an ordinary page. A binding whose batch was lost in transit ends with `ReferenceOutcomeUnknown`.
646
+ Requests, pages, attempts and elapsed time stay on the one operation budget. An automatic binding
647
+ whose planning floor exceeds the whole row budget waits to run alone with all of it (under `INPUT`
648
+ delivery, once it is the next binding to deliver); a binding that cannot obtain its floor while no
649
+ other binding can release rows fails with `BudgetExceededError`, and waiting for a share never
650
+ outlasts `max_elapsed`.
644
651
 
645
652
  Fast and automatic keyset references need `BatchDispatch`. With a `page_stop`, automatic execution
646
653
  runs sequentially and reports `PAGE_STOP`; an explicit fast mode with a `page_stop` or
@@ -4,7 +4,7 @@ from __future__ import annotations
4
4
  from dataclasses import dataclass, field
5
5
  from typing import Self
6
6
 
7
- from b24api.contracts.json import FrozenJson, JsonValue, _freeze_json, _is_plain_int, _thaw_json
7
+ from b24api.contracts.json import FrozenJson, JsonValue, _freeze_json, _is_plain_int, thaw_json
8
8
  from b24api.contracts.policy import ReplayDisposition
9
9
  from b24api.contracts.request import ReplaySafety, Request
10
10
  from b24api.contracts.response import Response
@@ -70,7 +70,7 @@ class BatchSuccess:
70
70
  if response is not None and not isinstance(response, Response):
71
71
  raise TypeError("response must be a Response or None")
72
72
  frozen_result = _freeze_json(result)
73
- if response is not None and response.result != _thaw_json(frozen_result):
73
+ if response is not None and response.result != thaw_json(frozen_result):
74
74
  raise ValueError("batch response result must match the correlated command result")
75
75
  object.__setattr__(self, "command_index", command_index)
76
76
  object.__setattr__(self, "stable_key", stable_key)
@@ -118,7 +118,7 @@ class BatchSuccess:
118
118
  @property
119
119
  def result(self) -> JsonValue:
120
120
  """Return the result."""
121
- return _thaw_json(self._result)
121
+ return thaw_json(self._result)
122
122
 
123
123
  @property
124
124
  def decoded_rows(self) -> int:
@@ -39,7 +39,7 @@ from b24api.contracts.continuation import (
39
39
  )
40
40
  from b24api.contracts.dispatch import BatchDispatch, DeliveryOrder, DirectDispatch, DispatchSpec
41
41
  from b24api.contracts.identity_store import IdentityStore, identity_store_key
42
- from b24api.contracts.json import FrozenJson, FrozenMapping, JsonScalar, JsonValue
42
+ from b24api.contracts.json import FrozenJson, FrozenMapping, JsonScalar, JsonValue, thaw_json
43
43
  from b24api.contracts.keyset_capability import (
44
44
  KeysetCapabilityCheckName,
45
45
  KeysetCapabilityCheckOutcome,
@@ -311,5 +311,6 @@ __all__ = [
311
311
  "identity_store_key",
312
312
  "partition_command_outcomes",
313
313
  "partition_reference_outcomes",
314
+ "thaw_json",
314
315
  "traversal_control_paths",
315
316
  ]
@@ -108,11 +108,12 @@ def _freeze_json( # noqa: C901 - closed JSON scalar/container variants
108
108
  raise TypeError(f"unsupported JSON value type: {type(value).__name__}")
109
109
 
110
110
 
111
- def _thaw_json(value: FrozenJson) -> JsonValue:
111
+ def thaw_json(value: FrozenJson) -> JsonValue:
112
+ """Return a plain mutable JSON copy of a frozen value: dicts for mappings, lists for arrays."""
112
113
  if isinstance(value, FrozenMapping):
113
- return {key: _thaw_json(item) for key, item in value.items()}
114
+ return {key: thaw_json(item) for key, item in value.items()}
114
115
  if isinstance(value, tuple):
115
- return [_thaw_json(item) for item in value]
116
+ return [thaw_json(item) for item in value]
116
117
  return value
117
118
 
118
119
 
@@ -6,7 +6,7 @@ from dataclasses import dataclass
6
6
  from enum import StrEnum
7
7
  from typing import TYPE_CHECKING
8
8
 
9
- from b24api.contracts.json import FrozenJson, _freeze_json, _thaw_json
9
+ from b24api.contracts.json import FrozenJson, _freeze_json, thaw_json
10
10
  from b24api.contracts.report import PageRecord, Violation, ViolationSeverity
11
11
 
12
12
  if TYPE_CHECKING:
@@ -201,23 +201,21 @@ class KeysetCapabilityReport:
201
201
  "name": check.name,
202
202
  "outcome": check.outcome,
203
203
  "rows_selected": check.rows_selected,
204
- "out_of_interval_identities": tuple(
205
- _thaw_json(value) for value in check.out_of_interval_identities
206
- ),
204
+ "out_of_interval_identities": tuple(thaw_json(value) for value in check.out_of_interval_identities),
207
205
  "missing_in_interval_identities": tuple(
208
- _thaw_json(value) for value in check.missing_in_interval_identities
206
+ thaw_json(value) for value in check.missing_in_interval_identities
209
207
  ),
210
208
  "extra_in_interval_identities": tuple(
211
- _thaw_json(value) for value in check.extra_in_interval_identities
209
+ thaw_json(value) for value in check.extra_in_interval_identities
212
210
  ),
213
- "contradictory_identities": tuple(_thaw_json(value) for value in check.contradictory_identities),
211
+ "contradictory_identities": tuple(thaw_json(value) for value in check.contradictory_identities),
214
212
  "recheck": None
215
213
  if check.recheck is None
216
214
  else {
217
- "identities": tuple(_thaw_json(value) for value in check.recheck.identities),
218
- "still_observed": tuple(_thaw_json(value) for value in check.recheck.still_observed),
219
- "no_longer_observed": tuple(_thaw_json(value) for value in check.recheck.no_longer_observed),
220
- "contradictory": tuple(_thaw_json(value) for value in check.recheck.contradictory),
215
+ "identities": tuple(thaw_json(value) for value in check.recheck.identities),
216
+ "still_observed": tuple(thaw_json(value) for value in check.recheck.still_observed),
217
+ "no_longer_observed": tuple(thaw_json(value) for value in check.recheck.no_longer_observed),
218
+ "contradictory": tuple(thaw_json(value) for value in check.recheck.contradictory),
221
219
  "truncated": check.recheck.truncated,
222
220
  },
223
221
  }
@@ -1,10 +1,11 @@
1
1
  """Public whole-page callback and bounded-prefix stop decision."""
2
2
 
3
3
  from __future__ import annotations
4
- from dataclasses import dataclass
4
+ from dataclasses import dataclass, field
5
5
  from enum import StrEnum
6
6
  from typing import TYPE_CHECKING, Protocol
7
7
 
8
+ from b24api.contracts.json import FrozenMapping
8
9
  from b24api.contracts.report import PageRecord
9
10
  from b24api.redaction import DEFAULT_REDACTOR
10
11
 
@@ -18,11 +19,20 @@ _MAX_REASON_LENGTH = 128
18
19
 
19
20
  @dataclass(frozen=True, slots=True)
20
21
  class PageBoundary:
21
- """One validated whole page offered after all its rows were consumed."""
22
+ """One validated whole page offered after all its rows were consumed.
23
+
24
+ ``result`` is the page's immutable server result, the same snapshot a page adapter, a window
25
+ classifier and a continuation rule see as ``PageView.result``: response-level fields beside the
26
+ rows, such as a flag or a popup object, reach the application on every offered page, including
27
+ a page that admits no row. It is ``None`` only for a boundary built by application code. Only
28
+ its top-level type is checked: anything but a JSON scalar, a tuple or a ``FrozenMapping`` is
29
+ rejected, and nested values are the frozen values the library builds or the caller's concern.
30
+ """
22
31
 
23
32
  binding_id: int
24
33
  record: PageRecord
25
34
  rows: tuple[FrozenJson, ...]
35
+ result: FrozenJson = field(default=None, kw_only=True, repr=False)
26
36
 
27
37
  def __post_init__(self) -> None:
28
38
  """Keep correlation and page content immutable and exact."""
@@ -33,6 +43,8 @@ class PageBoundary:
33
43
  object.__setattr__(self, "rows", tuple(self.rows))
34
44
  if len(self.rows) != self.record.rows_admitted:
35
45
  raise ValueError("page boundary must contain all admitted rows")
46
+ if self.result is not None and not isinstance(self.result, str | int | float | tuple | FrozenMapping):
47
+ raise TypeError("result must be frozen JSON: a JSON scalar, a tuple or a FrozenMapping")
36
48
 
37
49
 
38
50
  class ContinuePage(StrEnum):
@@ -7,7 +7,7 @@ from dataclasses import dataclass, field
7
7
  from enum import StrEnum
8
8
  from typing import cast
9
9
 
10
- from b24api.contracts.json import FrozenJson, JsonValue, _freeze_json, _thaw_json
10
+ from b24api.contracts.json import FrozenJson, JsonValue, _freeze_json, thaw_json
11
11
 
12
12
  type SlotPathPart = str | int
13
13
  _LAYOUT_ID_RE = re.compile(r"^[A-Za-z0-9_.:-]{1,100}$")
@@ -107,7 +107,7 @@ class Present:
107
107
  @property
108
108
  def value(self) -> JsonValue:
109
109
  """Return a detached JSON value."""
110
- return _thaw_json(self._value)
110
+ return thaw_json(self._value)
111
111
 
112
112
  def __repr__(self) -> str:
113
113
  """Exclude caller data from diagnostics."""
@@ -201,7 +201,7 @@ class PositionalArguments:
201
201
  for part in path[1:-1]:
202
202
  parent = _existing_child(parent, part)
203
203
  last = path[-1]
204
- _set_existing_child(parent, last, _thaw_json(_freeze_json(value)))
204
+ _set_existing_child(parent, last, thaw_json(_freeze_json(value)))
205
205
  replacement = Present(root)
206
206
  revised = list(self.slots)
207
207
  revised[slot_index] = replacement
@@ -4,7 +4,7 @@ from __future__ import annotations
4
4
  from dataclasses import dataclass, field
5
5
  from typing import TYPE_CHECKING, cast
6
6
 
7
- from b24api.contracts.json import FrozenJson, JsonValue, _freeze_json, _thaw_json
7
+ from b24api.contracts.json import FrozenJson, JsonValue, _freeze_json, thaw_json
8
8
  from b24api.contracts.policy import ReplayDisposition
9
9
  from b24api.contracts.request import ParameterPath
10
10
  from b24api.redaction import DEFAULT_REDACTOR
@@ -37,7 +37,7 @@ class ParameterUpdate:
37
37
  @property
38
38
  def value(self) -> JsonValue:
39
39
  """Return a detached update value."""
40
- return _thaw_json(self._value)
40
+ return thaw_json(self._value)
41
41
 
42
42
 
43
43
  @dataclass(frozen=True, slots=True)
@@ -70,7 +70,7 @@ class Binding[C]:
70
70
  object.__setattr__(self, "summary", safe)
71
71
  object.__setattr__(self, "updates", updates)
72
72
  if self.start_cursor is not None:
73
- object.__setattr__(self, "start_cursor", _thaw_json(_freeze_json(self.start_cursor)))
73
+ object.__setattr__(self, "start_cursor", thaw_json(_freeze_json(self.start_cursor)))
74
74
 
75
75
 
76
76
  @dataclass(frozen=True, slots=True)
@@ -9,7 +9,7 @@ from types import MappingProxyType
9
9
  from typing import TypedDict, cast
10
10
 
11
11
  from b24api._diagnostics import DiagnosticContext
12
- from b24api.contracts.json import FrozenMapping, JsonValue, _freeze_json, _thaw_json
12
+ from b24api.contracts.json import FrozenMapping, JsonValue, _freeze_json, thaw_json
13
13
  from b24api.contracts.policy import IdentityCoercion
14
14
  from b24api.contracts.positional import PositionalArguments
15
15
  from b24api.contracts.request_summary import RequestSummary, RouteKind
@@ -314,7 +314,7 @@ class Request:
314
314
  """Return a mutable copy of the immutable request parameters."""
315
315
  if self._positional is not None:
316
316
  raise ValueError("positional arguments have no named parameter mapping")
317
- return cast("dict[str, JsonValue]", _thaw_json(self._parameters))
317
+ return cast("dict[str, JsonValue]", thaw_json(self._parameters))
318
318
 
319
319
  def to_wire_parameters(self) -> dict[str, JsonValue]:
320
320
  """Return the to wire parameters representation."""
@@ -10,7 +10,7 @@ from enum import StrEnum
10
10
  from typing import TYPE_CHECKING, cast
11
11
 
12
12
  from b24api.contracts.evidence import ResponseEvidence
13
- from b24api.contracts.json import FrozenJson, FrozenMapping, JsonValue, _freeze_json, _is_plain_int, _thaw_json
13
+ from b24api.contracts.json import FrozenJson, FrozenMapping, JsonValue, _freeze_json, _is_plain_int, thaw_json
14
14
  from b24api.contracts.request import PathPart, ResultSelector
15
15
 
16
16
  if TYPE_CHECKING:
@@ -198,7 +198,7 @@ class Response:
198
198
  @property
199
199
  def result(self) -> JsonValue:
200
200
  """Return the result."""
201
- return _thaw_json(self._result)
201
+ return thaw_json(self._result)
202
202
 
203
203
  def _frozen_result(self) -> FrozenJson:
204
204
  """Return the operation-internal immutable result snapshot."""
@@ -242,14 +242,14 @@ def inject_controls(
242
242
  frozen = _freeze_json(parameters)
243
243
  if not isinstance(frozen, FrozenMapping):
244
244
  raise TypeError("parameters must be a mapping")
245
- result = cast("dict[str, JsonValue]", _thaw_json(frozen))
245
+ result = cast("dict[str, JsonValue]", thaw_json(frozen))
246
246
  normalized_paths: set[tuple[PathPart, ...]] = set()
247
247
  for path, value in updates.items():
248
248
  normalized = tuple(part.casefold() if isinstance(part, str) else part for part in path.path)
249
249
  if normalized in normalized_paths:
250
250
  raise ValueError("two injected controls address the same case-insensitive path")
251
251
  normalized_paths.add(normalized)
252
- _inject_one(result, path.path, _thaw_json(_freeze_json(value)), allow_create=allow_create)
252
+ _inject_one(result, path.path, thaw_json(_freeze_json(value)), allow_create=allow_create)
253
253
  return result
254
254
 
255
255
 
@@ -5,7 +5,7 @@ from dataclasses import dataclass, field
5
5
  from typing import TYPE_CHECKING
6
6
 
7
7
  from b24api.contracts.dispatch import PORTAL_BATCH_CAP
8
- from b24api.contracts.json import FrozenMapping, _thaw_json
8
+ from b24api.contracts.json import FrozenMapping, thaw_json
9
9
  from b24api.contracts.request import ReplaySafety
10
10
 
11
11
  if TYPE_CHECKING:
@@ -32,7 +32,7 @@ class V3BatchCommand:
32
32
 
33
33
  def to_wire(self) -> dict[str, JsonValue]:
34
34
  """Return the detached ``{"method": ..., "query": ...}`` array element."""
35
- return {"method": self.method, "query": _thaw_json(self.query)}
35
+ return {"method": self.method, "query": thaw_json(self.query)}
36
36
 
37
37
 
38
38
  @dataclass(frozen=True, slots=True)
@@ -1,9 +1,11 @@
1
1
  """A fast keyset reference binding's budget view of the shared operation context.
2
2
 
3
- The binding holds one fixed row lease ``G`` in the shared row pool from activation to terminal. Its
3
+ The binding holds one row lease ``G`` in the shared row pool from activation to terminal. Its
4
4
  runtime plans and fits every wave against a projection of the operation policy that differs only in
5
5
  ``max_buffered_rows=G``; requests, attempts, pages, deadline and bytes stay on the shared context,
6
- which is the only context the engine and the executor ever receive.
6
+ which is the only context the engine and the executor ever receive. Once its plan bounds the rows
7
+ it can still hold, the binding trims ``G`` to that bound and gives the rest back to the pool; a
8
+ lease never grows.
7
9
  """
8
10
 
9
11
  from __future__ import annotations
@@ -20,7 +22,7 @@ if TYPE_CHECKING:
20
22
 
21
23
  @dataclass(slots=True, eq=False)
22
24
  class RowLease:
23
- """A fixed capacity in the shared row pool and the rows currently held against it."""
25
+ """A capacity in the shared row pool, which may only shrink, and the rows currently held against it."""
24
26
 
25
27
  capacity: int
26
28
  held: int = field(default=0, init=False)
@@ -28,7 +30,7 @@ class RowLease:
28
30
 
29
31
  @classmethod
30
32
  def of(cls, reservation: _Reservation) -> RowLease:
31
- """Lease the fixed capacity of one pool reservation."""
33
+ """Lease the capacity of one pool reservation."""
32
34
  return cls(reservation.amount, reservation)
33
35
 
34
36
  @property
@@ -37,7 +39,7 @@ class RowLease:
37
39
  return self.reservation is not None and self.reservation.amount == 0
38
40
 
39
41
  def __post_init__(self) -> None:
40
- """Validate the fixed capacity."""
42
+ """Validate the capacity."""
41
43
  if isinstance(self.capacity, bool) or not isinstance(self.capacity, int) or self.capacity < 1:
42
44
  raise ValueError("row lease capacity must be a positive integer")
43
45
 
@@ -49,6 +51,14 @@ class RowLease:
49
51
  raise BudgetExceededError("fast keyset rows exceed the binding's row lease")
50
52
  self.held += rows
51
53
 
54
+ def trim(self, capacity: int) -> None:
55
+ """Lower the capacity to ``capacity`` rows: never below the rows held, never above the capacity."""
56
+ if isinstance(capacity, bool) or not isinstance(capacity, int) or capacity < 1:
57
+ raise ValueError("row lease capacity must be a positive integer")
58
+ if not self.held <= capacity <= self.capacity:
59
+ raise RuntimeError("a row lease trims only to a capacity between its held rows and its capacity")
60
+ self.capacity = capacity
61
+
52
62
  def receipt(self, rows: int) -> None:
53
63
  """Return held rows to the lease."""
54
64
  if rows < 0 or rows > self.held:
@@ -56,7 +66,7 @@ class RowLease:
56
66
  self.held -= rows
57
67
 
58
68
 
59
- @dataclass(frozen=True, slots=True)
69
+ @dataclass(slots=True, eq=False)
60
70
  class BindingBudgetView:
61
71
  """``KeysetContext`` of one fast keyset reference binding over the shared operation context."""
62
72
 
@@ -69,6 +79,11 @@ class BindingBudgetView:
69
79
  """Project the operation policy onto the lease: only ``max_buffered_rows`` changes."""
70
80
  return cls(shared, lease, replace(shared.policy, max_buffered_rows=lease.capacity))
71
81
 
82
+ def trim(self, capacity: int) -> None:
83
+ """Trim the lease and the projection together: the policy always names the lease's capacity."""
84
+ self.lease.trim(capacity)
85
+ self.projection = replace(self.projection, max_buffered_rows=capacity)
86
+
72
87
  @property
73
88
  def policy(self) -> ExecutionPolicy:
74
89
  """Return the projection planning and every execution fit use."""
@@ -62,8 +62,10 @@ class _Reservation:
62
62
  index: int
63
63
  amount: int
64
64
  accepted: bool = False
65
- # A fast keyset lease: fixed capacity from activation to terminal, charged by its own budget view.
65
+ # A fast keyset lease: held from activation to terminal, only ever trimmed, charged by its own budget view.
66
66
  lease: bool = False
67
+ # A lease whose binding has chosen its plan: it keeps its size, so it returns rows only at terminal.
68
+ settled: bool = False
67
69
 
68
70
 
69
71
  @dataclass(slots=True)
@@ -265,6 +267,7 @@ class _RowBuffer:
265
267
  *,
266
268
  head_reserve: int = 0,
267
269
  producer_state: _ProducerState | None = None,
270
+ ordered: bool = False,
268
271
  ) -> None:
269
272
  self.maximum = maximum
270
273
  self.context = context
@@ -275,6 +278,10 @@ class _RowBuffer:
275
278
  self._condition = asyncio.Condition()
276
279
  self._reservations: list[_Reservation] = []
277
280
  self._producer_state = producer_state
281
+ # INPUT delivery: rows go to bindings in binding order, so no binding takes rows while an
282
+ # earlier one, which becomes the frontier first, waits for its lease.
283
+ self._ordered = ordered
284
+ self._lease_waiting: set[int] = set()
278
285
 
279
286
  @property
280
287
  def head_index(self) -> int:
@@ -301,6 +308,11 @@ class _RowBuffer:
301
308
  def _can_reserve(self, index: int, amount: int) -> bool:
302
309
  if self._available < amount:
303
310
  return False
311
+ # A page charged to a fast keyset lease reserves no pool rows: it cannot take the frontier's reserve.
312
+ if amount == 0:
313
+ return True
314
+ if self._behind_lease_waiter(index):
315
+ return False
304
316
  if self._head_reserve == 0 or index == self._head_index:
305
317
  return True
306
318
  # Rows the frontier holds come back to it; only the rest of its reserve must stay free. A
@@ -370,32 +382,69 @@ class _RowBuffer:
370
382
  await self.context.adjust_buffered_rows(-amount)
371
383
 
372
384
  async def lease(self, index: int, grant: Callable[[int], int | None]) -> _Reservation:
373
- """Hold one fixed capacity until terminal; ``grant`` sizes it from the free rows or asks to wait.
385
+ """Hold one capacity until terminal, never grown; ``grant`` sizes it from the free rows or asks to wait.
374
386
 
375
387
  ``grant`` runs under the pool condition, so the decision and the reservation are atomic. It
376
- may raise to refuse a lease no releaser can ever satisfy.
388
+ may raise to refuse a lease no releaser can ever satisfy. An ordered pool asks it only once no
389
+ earlier binding waits for a lease. A binding leaving the wait, with a lease or without one,
390
+ wakes the others: whether it still waits decides whether a later binding may take rows.
377
391
  """
378
392
  async with self._condition:
379
- while True:
380
- if self._closed:
381
- raise asyncio.CancelledError
382
- amount = grant(self._available)
383
- if amount is not None:
384
- break
385
- await self._condition.wait()
386
- if isinstance(amount, bool) or not 0 < amount <= self._available:
387
- raise RuntimeError("fast keyset lease exceeds the free row pool")
388
- self._available -= amount
389
- reservation = _Reservation(index, amount, lease=True)
390
- self._reservations.append(reservation)
393
+ self._lease_waiting.add(index)
394
+ try:
395
+ while True:
396
+ if self._closed:
397
+ raise asyncio.CancelledError
398
+ amount = None if self._behind_lease_waiter(index) else grant(self._available)
399
+ if amount is not None:
400
+ break
401
+ await self._condition.wait()
402
+ if isinstance(amount, bool) or not 0 < amount <= self._available:
403
+ raise RuntimeError("fast keyset lease exceeds the free row pool")
404
+ self._available -= amount
405
+ reservation = _Reservation(index, amount, lease=True)
406
+ self._reservations.append(reservation)
407
+ finally:
408
+ self._lease_waiting.discard(index)
409
+ self._condition.notify_all()
410
+ self._touch()
411
+ return reservation
412
+
413
+ def _behind_lease_waiter(self, index: int) -> bool:
414
+ """Return whether an ordered pool holds rows back from ``index`` for an earlier lease waiter."""
415
+ return self._ordered and any(waiting < index for waiting in self._lease_waiting)
416
+
417
+ async def settle_lease(self, reservation: _Reservation, amount: int) -> None:
418
+ """Fix a planned binding's lease at ``amount`` rows, give the rest back and wake the capacity waiters.
419
+
420
+ Until its binding has planned, a lease may still shrink, so a waiting INPUT frontier counts it
421
+ as releasable; settling it, trimmed or not, is the fact that frontier waits for. A lease is never
422
+ accepted, so the shared row counter holds only what its binding charged; trimming moves free
423
+ pool rows only. A pool closed meanwhile has already reclaimed the lease.
424
+ """
425
+ if not reservation.lease or amount <= 0:
426
+ raise RuntimeError("only a lease settles, and never to nothing")
427
+ async with self._condition:
428
+ if self._closed or reservation.amount == 0:
429
+ return
430
+ if amount > reservation.amount:
431
+ raise RuntimeError("a lease cannot grow")
432
+ self._available += reservation.amount - amount
433
+ reservation.amount = amount
434
+ reservation.settled = True
391
435
  self._condition.notify_all()
392
436
  self._touch()
393
- return reservation
394
437
 
395
438
  def releasable_elsewhere(self, index: int) -> bool:
396
- """Return whether a page of another binding may still return unused capacity when it settles."""
439
+ """Return whether another binding may still return capacity without this one's progress.
440
+
441
+ An unaccepted page returns its unused rows when it settles, and an unsettled lease may be trimmed
442
+ once its binding has planned, which needs no delivery.
443
+ """
397
444
  return any(
398
- reservation.index != index and not reservation.accepted and not reservation.lease
445
+ reservation.index != index
446
+ and not reservation.accepted
447
+ and (not reservation.lease or not reservation.settled)
399
448
  for reservation in self._reservations
400
449
  )
401
450