tensorfs 0.3.81__tar.gz → 0.3.83__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.

Potentially problematic release.


This version of tensorfs might be problematic. Click here for more details.

Files changed (184) hide show
  1. {tensorfs-0.3.81 → tensorfs-0.3.83}/Cargo.lock +2 -2
  2. {tensorfs-0.3.81 → tensorfs-0.3.83}/Cargo.toml +1 -1
  3. {tensorfs-0.3.81 → tensorfs-0.3.83}/PKG-INFO +1 -1
  4. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/catalog.rs +18 -4
  5. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ensure/flight.rs +54 -0
  6. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ensure.rs +74 -15
  7. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/gc.rs +1 -0
  8. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/meta.rs +1 -4
  9. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/store.rs +31 -7
  10. tensorfs-0.3.83/crates/tensorfs-core/src/transport/decisions.rs +37 -0
  11. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/http.rs +65 -6
  12. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/ledger.rs +6 -2
  13. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/mod.rs +1 -0
  14. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/pull.rs +25 -3
  15. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/ranged.rs +56 -35
  16. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/speculate.rs +223 -65
  17. tensorfs-0.3.83/crates/tensorfs-core/src/transport/tests/tail.rs +461 -0
  18. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/tests.rs +52 -1
  19. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/fetch_faults.rs +280 -6
  20. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/hub_tls.rs +107 -5
  21. {tensorfs-0.3.81 → tensorfs-0.3.83}/pyproject.toml +1 -1
  22. tensorfs-0.3.81/crates/tensorfs-core/src/transport/tests/tail.rs +0 -225
  23. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/Cargo.toml +0 -0
  24. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/build.rs +0 -0
  25. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/examples/h3-swiglu-layout.md +0 -0
  26. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/examples/optional-cache-backfill.md +0 -0
  27. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/examples/resident-conversion.md +0 -0
  28. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/examples/resident_conversion_profile.rs +0 -0
  29. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/asset_update.rs +0 -0
  30. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/b64.rs +0 -0
  31. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/bin/tfs/ckpt.rs +0 -0
  32. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/bin/tfs/conform.rs +0 -0
  33. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/bin/tfs/ensure.rs +0 -0
  34. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/bin/tfs/fetch.rs +0 -0
  35. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/bin/tfs/ingest.rs +0 -0
  36. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/bin/tfs/main.rs +0 -0
  37. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/bin/tfs/rd.rs +0 -0
  38. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/bin/tfs/repo.rs +0 -0
  39. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/bin/tfs/snap.rs +0 -0
  40. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/bin/tfs/watch.rs +0 -0
  41. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/cache_roots.rs +0 -0
  42. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/canon.rs +0 -0
  43. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/capability.rs +0 -0
  44. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/catalog/lock.rs +0 -0
  45. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/cbor.rs +0 -0
  46. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/checkpoint.rs +0 -0
  47. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/checkpoint_root.rs +0 -0
  48. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/corpus.rs +0 -0
  49. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/derived/adoption.rs +0 -0
  50. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/derived/companion_tests.rs +0 -0
  51. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/derived/estimate.rs +0 -0
  52. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/derived/graft_tests.rs +0 -0
  53. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/derived/group_commit_tests.rs +0 -0
  54. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/derived/history_cost_tests.rs +0 -0
  55. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/derived/part_rows_tests.rs +0 -0
  56. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/derived/progress.rs +0 -0
  57. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/derived/resume_tests.rs +0 -0
  58. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/derived/retention.rs +0 -0
  59. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/derived/roots.rs +0 -0
  60. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/derived.rs +0 -0
  61. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/descriptors.rs +0 -0
  62. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/disk.rs +0 -0
  63. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/dtype.rs +0 -0
  64. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/durability.rs +0 -0
  65. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ensure/admission.rs +0 -0
  66. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/err.rs +0 -0
  67. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/fetch.rs +0 -0
  68. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/filesystem_identity.rs +0 -0
  69. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/fill.rs +0 -0
  70. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/fit.rs +0 -0
  71. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/header.rs +0 -0
  72. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/home.rs +0 -0
  73. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ids.rs +0 -0
  74. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/carrier.rs +0 -0
  75. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/convert.rs +0 -0
  76. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/custody.rs +0 -0
  77. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/fingerprint.rs +0 -0
  78. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/gguf.rs +0 -0
  79. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/h3_lora.rs +0 -0
  80. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/journal.rs +0 -0
  81. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/mod.rs +0 -0
  82. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/narrow.rs +0 -0
  83. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/preflight.rs +0 -0
  84. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/routes/anima.routes.json +0 -0
  85. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/routes/anima.spec.json +0 -0
  86. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/routes/sdxl.routes.json +0 -0
  87. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/routes/sdxl.spec.json +0 -0
  88. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/routes.rs +0 -0
  89. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/source.rs +0 -0
  90. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/stamp.rs +0 -0
  91. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/ingest/transaction.rs +0 -0
  92. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/jcs.rs +0 -0
  93. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/lib.rs +0 -0
  94. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/limits.rs +0 -0
  95. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/machine.rs +0 -0
  96. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/manifest.rs +0 -0
  97. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/project.rs +0 -0
  98. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/providers.rs +0 -0
  99. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/read.rs +0 -0
  100. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/receipt.rs +0 -0
  101. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/reclaim.rs +0 -0
  102. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/registry.rs +0 -0
  103. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/relation.rs +0 -0
  104. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/repo_cache.rs +0 -0
  105. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/repository.rs +0 -0
  106. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/sha256.rs +0 -0
  107. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/source_artifact.rs +0 -0
  108. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/spec.rs +0 -0
  109. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/staging.rs +0 -0
  110. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/stats.rs +0 -0
  111. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/storage.rs +0 -0
  112. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/api.rs +0 -0
  113. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/http_reuse_tests.rs +0 -0
  114. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/hub.rs +0 -0
  115. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/memory.rs +0 -0
  116. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/pace.rs +0 -0
  117. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/policy.rs +0 -0
  118. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/prefix.rs +0 -0
  119. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/transport/push.rs +0 -0
  120. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/unsynced.rs +0 -0
  121. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/src/vectors.rs +0 -0
  122. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/additive_fields.rs +0 -0
  123. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/anima_hf_profile.rs +0 -0
  124. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/as_is.rs +0 -0
  125. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/catalog_owner_probe.c +0 -0
  126. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/checkpoint_roots.rs +0 -0
  127. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/civitai_anima.rs +0 -0
  128. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/civitai_sdxl_profile.rs +0 -0
  129. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/ensure.rs +0 -0
  130. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/fd_budget.rs +0 -0
  131. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/fd_headroom.rs +0 -0
  132. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/fetch_url_progress.rs +0 -0
  133. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/fit.rs +0 -0
  134. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/fixtures/repo_apply/blobs.jsonl +0 -0
  135. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/fixtures/repo_apply/expected_list.jsonl +0 -0
  136. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/fixtures/repo_apply/expected_repository.json +0 -0
  137. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/fixtures/repo_apply/expected_rows.jsonl +0 -0
  138. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/fixtures/repo_apply/header.cbor +0 -0
  139. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/fixtures/repo_apply/manifest.json +0 -0
  140. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/fixtures/repo_apply/mutation.json +0 -0
  141. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/foreign_json.rs +0 -0
  142. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/h3_lora.rs +0 -0
  143. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/h3_swiglu.rs +0 -0
  144. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/home.rs +0 -0
  145. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/import_tree.rs +0 -0
  146. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/instrument_profiles.rs +0 -0
  147. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/liveness.rs +0 -0
  148. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/qwen_image21_profile.rs +0 -0
  149. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/read_plan.rs +0 -0
  150. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/reclaim.rs +0 -0
  151. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/reclaim_run.rs +0 -0
  152. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/repo_cache.rs +0 -0
  153. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/repo_store.rs +0 -0
  154. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/resident_admission.rs +0 -0
  155. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/routed_single_file.rs +0 -0
  156. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/sha256_backends.rs +0 -0
  157. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/sharded_cas.rs +0 -0
  158. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/source_artifacts.rs +0 -0
  159. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/source_download.rs +0 -0
  160. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/source_plan.rs +0 -0
  161. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/source_prefixes.rs +0 -0
  162. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/source_preflight.rs +0 -0
  163. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/staging.rs +0 -0
  164. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/store_boundaries.rs +0 -0
  165. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/tensor_schema.rs +0 -0
  166. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/transfer_memory.rs +0 -0
  167. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/trust_index.rs +0 -0
  168. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/version.rs +0 -0
  169. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-core/tests/write_through.rs +0 -0
  170. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-py/Cargo.toml +0 -0
  171. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-py/src/docs.rs +0 -0
  172. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-py/src/ensure.rs +0 -0
  173. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-py/src/errors.rs +0 -0
  174. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-py/src/ingest.rs +0 -0
  175. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-py/src/lib.rs +0 -0
  176. {tensorfs-0.3.81 → tensorfs-0.3.83}/crates/tensorfs-py/src/store.rs +0 -0
  177. {tensorfs-0.3.81 → tensorfs-0.3.83}/python/tensorfs/__init__.py +0 -0
  178. {tensorfs-0.3.81 → tensorfs-0.3.83}/python/tensorfs/_derived_channel.py +0 -0
  179. {tensorfs-0.3.81 → tensorfs-0.3.83}/python/tensorfs/_ext.pyi +0 -0
  180. {tensorfs-0.3.81 → tensorfs-0.3.83}/python/tensorfs/_source_channel.py +0 -0
  181. {tensorfs-0.3.81 → tensorfs-0.3.83}/python/tensorfs/_tensors.py +0 -0
  182. {tensorfs-0.3.81 → tensorfs-0.3.83}/python/tensorfs/derived.py +0 -0
  183. {tensorfs-0.3.81 → tensorfs-0.3.83}/python/tensorfs/errors.py +0 -0
  184. {tensorfs-0.3.81 → tensorfs-0.3.83}/python/tensorfs/py.typed +0 -0
@@ -439,7 +439,7 @@ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
439
439
 
440
440
  [[package]]
441
441
  name = "tensorfs-core"
442
- version = "0.3.81"
442
+ version = "0.3.83"
443
443
  dependencies = [
444
444
  "fs2",
445
445
  "libc",
@@ -454,7 +454,7 @@ dependencies = [
454
454
 
455
455
  [[package]]
456
456
  name = "tensorfs-py"
457
- version = "0.3.81"
457
+ version = "0.3.83"
458
458
  dependencies = [
459
459
  "pyo3",
460
460
  "tensorfs-core",
@@ -3,5 +3,5 @@ resolver = "2"
3
3
  members = ["crates/tensorfs-core", "crates/tensorfs-py"]
4
4
 
5
5
  [workspace.package]
6
- version = "0.3.81"
6
+ version = "0.3.83"
7
7
  edition = "2021"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tensorfs
3
- Version: 0.3.81
3
+ Version: 0.3.83
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Rust
@@ -52,10 +52,7 @@ const SCHEMA: &[(&str, &[&str])] = &[
52
52
  ];
53
53
 
54
54
  fn sql(what: impl AsRef<str>, error: rusqlite::Error) -> Refusal {
55
- Refusal {
56
- code: Code::IO_FAILED,
57
- detail: format!("{}: {error}", what.as_ref()),
58
- }
55
+ crate::store::classify_sql(what, error)
59
56
  }
60
57
 
61
58
  fn io(what: impl AsRef<str>, error: std::io::Error) -> Refusal {
@@ -1639,6 +1636,23 @@ impl Drop for WriterGuard {
1639
1636
  mod tests {
1640
1637
  use super::*;
1641
1638
 
1639
+ #[test]
1640
+ fn a_full_database_is_a_capacity_verdict_not_an_io_failure() {
1641
+ let db = Connection::open_in_memory().unwrap();
1642
+ db.execute_batch(
1643
+ "PRAGMA page_size = 512; CREATE TABLE t (x BLOB); PRAGMA max_page_count = 3;",
1644
+ )
1645
+ .unwrap();
1646
+ let full = db
1647
+ .execute("INSERT INTO t VALUES (zeroblob(65536))", [])
1648
+ .unwrap_err();
1649
+ assert_eq!(sql("record", full).code, Code::CAPACITY_EXHAUSTED);
1650
+ let other = db
1651
+ .execute("INSERT INTO missing VALUES (1)", [])
1652
+ .unwrap_err();
1653
+ assert_eq!(sql("record", other).code, Code::IO_FAILED);
1654
+ }
1655
+
1642
1656
  fn temporary(name: &str) -> PathBuf {
1643
1657
  std::env::temp_dir().join(format!(
1644
1658
  "tensorfs-catalog-{name}-{}-{}",
@@ -13,6 +13,8 @@ use fs2::FileExt;
13
13
 
14
14
  use crate::canon::{self, Fields, Value};
15
15
  use crate::err::{refuse, Code, Refusal, Result};
16
+ use crate::ids::ObjectRef;
17
+ use crate::storage::{self, HeldKey};
16
18
  use crate::store::Store;
17
19
  use crate::transport::PullCancellation;
18
20
 
@@ -123,6 +125,8 @@ impl Record {
123
125
  pub(super) struct Flight {
124
126
  _lock: File,
125
127
  record: PathBuf,
128
+ /// The closure this flight holds from GC (see [`held_objects`]).
129
+ objects: PathBuf,
126
130
  pub manifest: String,
127
131
  /// Another process's flight for this manifest was running when this one asked.
128
132
  pub joined: bool,
@@ -155,12 +159,22 @@ impl Flight {
155
159
  }
156
160
  Ok(Flight {
157
161
  _lock: lock,
162
+ objects: record.with_extension("objects"),
158
163
  record,
159
164
  manifest: manifest.to_string(),
160
165
  joined,
161
166
  })
162
167
  }
163
168
 
169
+ /// Hold `objects` (the closure, manifest included) from GC for the life of the flight.
170
+ pub fn hold(&self, objects: &[ObjectRef]) -> Result<()> {
171
+ let lines: String = objects
172
+ .iter()
173
+ .map(|o| format!("{} {}\n", o.sha256, o.length))
174
+ .collect();
175
+ fs::write(&self.objects, lines).map_err(|e| io("write held objects", e))
176
+ }
177
+
164
178
  pub fn record(&self, record: &Record) -> Result<()> {
165
179
  let temp = self
166
180
  .record
@@ -178,6 +192,7 @@ impl Drop for Flight {
178
192
  fn drop(&mut self) {
179
193
  // The record goes first: once the lock is free, nothing may read a stale one.
180
194
  let _ = fs::remove_file(&self.record);
195
+ let _ = fs::remove_file(&self.objects);
181
196
  }
182
197
  }
183
198
 
@@ -214,3 +229,42 @@ pub(super) fn live(store: &Store, except: &str) -> Result<Vec<(String, Option<Re
214
229
  }
215
230
  Ok(flights)
216
231
  }
232
+
233
+ /// Every resident object a live flight's closure names, as GC holds. An ensure counts the
234
+ /// objects already resident as held when it plans, and lands the rest unreferenced until its
235
+ /// pull is recorded; a collection in between (its own admission's, or another process's)
236
+ /// must not take either, or the pull re-buys them past the space it was admitted for.
237
+ pub(crate) fn held_objects(store: &Store) -> Result<Vec<HeldKey>> {
238
+ if !store.root().join("tmp/ensure").is_dir() {
239
+ return Ok(Vec::new());
240
+ }
241
+ let dir = dir(store)?;
242
+ let mut holds = Vec::new();
243
+ for (manifest, _) in live(store, "")? {
244
+ let Ok(lines) = fs::read_to_string(dir.join(format!("{manifest}.objects"))) else {
245
+ continue;
246
+ };
247
+ for line in lines.lines() {
248
+ let Some((hex, length)) = line.split_once(' ') else {
249
+ continue;
250
+ };
251
+ let Ok(length) = length.parse() else {
252
+ continue;
253
+ };
254
+ let (kind, key) = if store.manifest_path(hex).is_file() {
255
+ ("manifest", storage::manifest_key(hex)?)
256
+ } else if store.contains(hex) {
257
+ ("blob", storage::blob_key(hex)?)
258
+ } else {
259
+ continue;
260
+ };
261
+ holds.push(HeldKey {
262
+ key,
263
+ kind: kind.into(),
264
+ length,
265
+ sha256: hex.to_string(),
266
+ });
267
+ }
268
+ }
269
+ Ok(holds)
270
+ }
@@ -2,10 +2,11 @@
2
2
  //! the Runtime (`tensorfs.ensure`) use for model download.
3
3
  //!
4
4
  //! Resolve the closure; lead or join the Store's one flight for its manifest; admit the new
5
- //! bytes against the disk, running the GC policy when short; pull, re-attempting only an
6
- //! attempt that landed something. Events sample bytes and rate while it runs; the answer is
7
- //! an [`Ensured`] or a typed refusal. Nothing here is a timer: a retry is earned by
8
- //! measured progress, and a stalled stream is judged by the transport's own ledger.
5
+ //! bytes against the disk, running the GC policy when short; pull, re-attempting on the
6
+ //! link's weather until no object has landed for the ledger's floor. Events sample bytes and
7
+ //! rate while it runs; the answer is an [`Ensured`] or a typed refusal. Nothing here is a
8
+ //! timer: giving up is earned by measured stillness, and a stalled stream is judged by the
9
+ //! transport's own ledger.
9
10
  //!
10
11
  //! The Hub CA is process trust ([`crate::transport::trust_roots`]); callers name it once.
11
12
 
@@ -13,6 +14,7 @@ mod admission;
13
14
  mod flight;
14
15
 
15
16
  pub use admission::{relieve, Relief};
17
+ pub(crate) use flight::held_objects;
16
18
 
17
19
  use std::sync::atomic::{AtomicU32, AtomicU64, Ordering};
18
20
  use std::sync::{Arc, Condvar, Mutex};
@@ -190,6 +192,11 @@ impl store::Progress for Meter {
190
192
  self.moved.fetch_add(bytes, Ordering::Relaxed);
191
193
  }
192
194
  fn admitted(&self) {}
195
+ fn discarded(&self, bytes: u64) {
196
+ let _ = (self.moved).fetch_update(Ordering::Relaxed, Ordering::Relaxed, |moved| {
197
+ Some(moved.saturating_sub(bytes))
198
+ });
199
+ }
193
200
  }
194
201
 
195
202
  /// The fetch's live counters, shared by the pull's callbacks and the sampler.
@@ -220,25 +227,40 @@ pub fn ensure(request: &Request<'_>) -> Result<Ensured> {
220
227
  });
221
228
  }
222
229
  };
223
- say(Phase::Resolving, 0, 0, 0.0, 0);
224
- let closure = transport::resolve_closure(&request.pull(request.store))?;
225
230
  let tick = Duration::from_secs_f64(EVENT_SECONDS);
231
+ // Resolving says so once per tick: a hub that takes its time is time passing on the
232
+ // caller's display, never silence, and the caller's cancellation still ends it.
233
+ let resolving = || say(Phase::Resolving, 0, 0, 0.0, 0);
234
+ resolving();
235
+ let closure = ticking(tick, &resolving, || {
236
+ transport::resolve_closure(&request.pull(request.store))
237
+ })?;
238
+ let declared = closure.manifest.length + closure.objects.iter().map(|o| o.length).sum::<u64>();
226
239
  let flight = Flight::lead(
227
240
  request.store,
228
241
  &closure.manifest.sha256,
229
242
  request.cancellation.as_ref(),
230
243
  tick,
231
- &|record| {
232
- let record = record.unwrap_or_default();
233
- say(
244
+ // Before the leader has written its record (it is still planning or admitting), the
245
+ // closure still says how big this is: never a 0/0 bar.
246
+ &|record| match record {
247
+ Some(record) => say(
234
248
  Phase::Waiting,
235
249
  record.bytes_done,
236
250
  record.bytes_total,
237
251
  0.0,
238
252
  0,
239
- );
253
+ ),
254
+ None => say(Phase::Waiting, 0, declared, 0.0, 0),
240
255
  },
241
256
  )?;
257
+ // A killed pull strands its partial `put-` temps, and GC, the only other reaper, never
258
+ // runs while a model is leased. Each temp carries its writer's lock, so this takes only
259
+ // the dead ones.
260
+ let _ = request.store.reap();
261
+ let mut closure_objects = closure.objects.clone();
262
+ closure_objects.push(closure.manifest.clone());
263
+ flight.hold(&closure_objects)?;
242
264
  let session = format!("ensure-{}", &closure.manifest.sha256[..12]);
243
265
  let (plan, _) = FetchPlan::of(request.store, &session, &closure.manifest, &closure.objects)?;
244
266
  let total = plan.declared_bytes();
@@ -332,8 +354,30 @@ pub fn ensure(request: &Request<'_>) -> Result<Ensured> {
332
354
  })
333
355
  }
334
356
 
335
- /// Pull until done. An attempt that failed on the link is re-attempted only when it landed
336
- /// at least one object; one that landed nothing is `STALLED`.
357
+ /// Run `work`, calling `tick` once per `every` until it returns.
358
+ fn ticking<T>(every: Duration, tick: &(dyn Fn() + Sync), work: impl FnOnce() -> T) -> T {
359
+ let stop = (Mutex::new(false), Condvar::new());
360
+ std::thread::scope(|scope| {
361
+ scope.spawn(|| {
362
+ let mut stopped = stop.0.lock().unwrap();
363
+ loop {
364
+ stopped = stop.1.wait_timeout(stopped, every).unwrap().0;
365
+ if *stopped {
366
+ return;
367
+ }
368
+ tick();
369
+ }
370
+ });
371
+ let out = work();
372
+ *stop.0.lock().unwrap() = true;
373
+ stop.1.notify_all();
374
+ out
375
+ })
376
+ }
377
+
378
+ /// Pull until done. A pull that failed on the link is re-attempted; one that landed nothing
379
+ /// waits a sample first. The ensure is `STALLED` only once no object has landed for the
380
+ /// ledger's own floor: a blip that spent one attempt's asks in milliseconds measured nothing.
337
381
  fn attempts(
338
382
  request: &Request<'_>,
339
383
  store: &Store,
@@ -342,6 +386,13 @@ fn attempts(
342
386
  on_plan: &(dyn Fn(&FetchPlan) + Sync),
343
387
  on_object: &(dyn Fn(&ObjectRef, u64, ObjectSource) + Sync),
344
388
  ) -> Result<transport::PullReport> {
389
+ let sample = Duration::from_secs_f64(request.sample_seconds);
390
+ let floor = sample * transport::STILL_SAMPLES;
391
+ let mut waits = transport::Ledger::with_resolution(sample);
392
+ if let Some(cancellation) = &request.cancellation {
393
+ waits = waits.with_cancellation(cancellation.clone());
394
+ }
395
+ let mut advanced = Instant::now();
345
396
  loop {
346
397
  let attempt = counters.attempt.fetch_add(1, Ordering::Relaxed) + 1;
347
398
  let landed = counters.landed_objects.load(Ordering::Relaxed);
@@ -352,13 +403,21 @@ fn attempts(
352
403
  match transport::pull(&pull) {
353
404
  Ok(report) => return Ok(report),
354
405
  Err(refusal) if request.cancelled() || !weather(refusal.code) => return Err(refusal),
355
- Err(refusal) if counters.landed_objects.load(Ordering::Relaxed) == landed => {
406
+ Err(_) if counters.landed_objects.load(Ordering::Relaxed) != landed => {
407
+ advanced = Instant::now();
408
+ }
409
+ Err(refusal) if advanced.elapsed() > floor => {
356
410
  return Err(Refusal {
357
411
  code: Code::STALLED,
358
- detail: format!("attempt {attempt} landed nothing: {refusal}"),
412
+ detail: format!(
413
+ "no object landed for {:.1} s over {attempt} attempt(s), past the \
414
+ {:.1} s floor: {refusal}",
415
+ advanced.elapsed().as_secs_f64(),
416
+ floor.as_secs_f64()
417
+ ),
359
418
  })
360
419
  }
361
- Err(_) => {}
420
+ Err(_) => waits.pause(sample, transport::Deadline::none())?,
362
421
  }
363
422
  }
364
423
  }
@@ -140,6 +140,7 @@ pub fn session_holds(store: &Store) -> Result<(Vec<HeldKey>, Vec<String>)> {
140
140
  holds.extend(crate::derived::retained_objects(store)?);
141
141
  holds.extend(crate::source_artifact::held_objects(store)?);
142
142
  holds.extend(crate::checkpoint_root::held_objects(store)?);
143
+ holds.extend(crate::ensure::held_objects(store)?);
143
144
  // A full snapshot obligation wins over a runtime-only pin of the same manifest.
144
145
  holds.sort_by(|left, right| {
145
146
  left.key
@@ -16,10 +16,7 @@ use crate::limits;
16
16
  use crate::store::Store;
17
17
 
18
18
  fn sql(what: impl AsRef<str>, error: rusqlite::Error) -> Refusal {
19
- Refusal {
20
- code: Code::IO_FAILED,
21
- detail: format!("{}: {error}", what.as_ref()),
22
- }
19
+ crate::store::classify_sql(what, error)
23
20
  }
24
21
 
25
22
  fn io(what: impl AsRef<str>, error: std::io::Error) -> Refusal {
@@ -185,6 +185,20 @@ pub(crate) fn classify_io(what: impl AsRef<str>, e: std::io::Error) -> Refusal {
185
185
  }
186
186
  }
187
187
 
188
+ /// SQLite's "database or disk is full" is the disk's verdict, exactly as ENOSPC is. As
189
+ /// IO_FAILED it read as a transient catalog fault and bought the object three more times.
190
+ pub(crate) fn classify_sql(what: impl AsRef<str>, e: rusqlite::Error) -> Refusal {
191
+ let full = matches!(&e, rusqlite::Error::SqliteFailure(f, _) if f.code == rusqlite::ErrorCode::DiskFull);
192
+ Refusal {
193
+ code: if full {
194
+ Code::CAPACITY_EXHAUSTED
195
+ } else {
196
+ Code::IO_FAILED
197
+ },
198
+ detail: format!("{}: {e}", what.as_ref()),
199
+ }
200
+ }
201
+
188
202
  /// The short local spelling used by every call site in this module.
189
203
  fn io(what: impl AsRef<str>, e: std::io::Error) -> Refusal {
190
204
  classify_io(what, e)
@@ -286,6 +300,10 @@ impl Fault {
286
300
  pub trait Progress: Send + Sync {
287
301
  fn moved(&self, bytes: u64);
288
302
  fn admitted(&self);
303
+ /// `bytes` already announced as moved were thrown away: the stream behind a candidate
304
+ /// failed or proved to be the wrong object. Progress that kept them would claim bytes
305
+ /// the store does not have, and a pull that re-asks would pass 100% before it ends.
306
+ fn discarded(&self, _bytes: u64) {}
289
307
  }
290
308
 
291
309
  #[derive(Clone)]
@@ -1453,15 +1471,21 @@ impl Store {
1453
1471
  let mut buf = vec![0u8; BUF];
1454
1472
  let mut len: u64 = 0;
1455
1473
  let mut first = true;
1474
+ let discard = |len: u64, refusal: Refusal| {
1475
+ if let Some(sink) = &self.progress {
1476
+ sink.discarded(len);
1477
+ }
1478
+ cleanup(&tmp, refusal)
1479
+ };
1456
1480
  loop {
1457
1481
  let n = match r.read(&mut buf) {
1458
1482
  Ok(0) => break,
1459
1483
  Ok(n) => n,
1460
- Err(e) => return cleanup(&tmp, io("read source", e)),
1484
+ Err(e) => return discard(len, io("read source", e)),
1461
1485
  };
1462
1486
  h.update(&buf[..n]);
1463
1487
  if let Err(e) = f.write_all(&buf[..n]) {
1464
- return cleanup(&tmp, io("write temp", e));
1488
+ return discard(len, io("write temp", e));
1465
1489
  }
1466
1490
  len += n as u64;
1467
1491
  self.moved(n as u64);
@@ -1473,7 +1497,7 @@ impl Store {
1473
1497
  fault.hit("written");
1474
1498
  if self.flushes() {
1475
1499
  if let Err(e) = f.sync_all() {
1476
- return cleanup(&tmp, io("fsync temp", e));
1500
+ return discard(len, io("fsync temp", e));
1477
1501
  }
1478
1502
  }
1479
1503
  fault.hit("fsync");
@@ -1481,8 +1505,8 @@ impl Store {
1481
1505
  let hex = sha256::hex(&h.finish());
1482
1506
  if let Some(want) = expect {
1483
1507
  if want.length != len {
1484
- return cleanup(
1485
- &tmp,
1508
+ return discard(
1509
+ len,
1486
1510
  Refusal {
1487
1511
  code: Code::LENGTH_MISMATCH,
1488
1512
  detail: format!("expected {} bytes, streamed {len}", want.length),
@@ -1490,8 +1514,8 @@ impl Store {
1490
1514
  );
1491
1515
  }
1492
1516
  if want.sha256 != hex {
1493
- return cleanup(
1494
- &tmp,
1517
+ return discard(
1518
+ len,
1495
1519
  Refusal {
1496
1520
  code: Code::OBJECT_ID_MISMATCH,
1497
1521
  detail: format!("expected sha256:{}, streamed sha256:{hex}", want.sha256),
@@ -0,0 +1,37 @@
1
+ //! One line per transport decision (a hedge, a replacement, a win), appended to the
2
+ //! Store's own bounded log so a slow tail is visible after the fact: run 2322 and sasori
3
+ //! left nothing on disk to say whether a hedge fired. Never per chunk, never fatal.
4
+ use crate::ids::ObjectRef;
5
+ use crate::store::Store;
6
+ use std::fs::{self, OpenOptions};
7
+ use std::io::Write;
8
+ use std::time::{SystemTime, UNIX_EPOCH};
9
+
10
+ /// Past this the log rotates to `transport.log.1`, so it holds at most twice this.
11
+ const ROTATE_BYTES: u64 = 4 << 20;
12
+
13
+ /// How a line names one object: its digest prefix and length.
14
+ pub(super) fn object(object: &ObjectRef) -> String {
15
+ format!(
16
+ "{} {}",
17
+ &object.sha256[..object.sha256.len().min(16)],
18
+ object.length
19
+ )
20
+ }
21
+
22
+ pub(super) fn record(store: &Store, kind: &str, subject: &str, detail: &str) {
23
+ let dir = store.root().join("logs");
24
+ let path = dir.join("transport.log");
25
+ let _ = fs::create_dir_all(&dir);
26
+ if fs::metadata(&path).is_ok_and(|meta| meta.len() > ROTATE_BYTES) {
27
+ let _ = fs::rename(&path, dir.join("transport.log.1"));
28
+ }
29
+ let at = SystemTime::now()
30
+ .duration_since(UNIX_EPOCH)
31
+ .map(|since| since.as_secs_f64())
32
+ .unwrap_or(0.0);
33
+ let line = format!("{at:.3} {kind} {subject} {detail}\n");
34
+ if let Ok(mut file) = OpenOptions::new().create(true).append(true).open(&path) {
35
+ let _ = file.write_all(line.as_bytes());
36
+ }
37
+ }
@@ -154,6 +154,33 @@ fn stream_verdict(judge: Judge, ledger: &Ledger, advanced: Instant, phase: &str)
154
154
  )
155
155
  }
156
156
 
157
+ /// Connect, TLS and the request write are phases a live peer answers at once, so on the
158
+ /// CONTROL plane too their silence past the ledger's patience is the peer's verdict: the
159
+ /// exchange's own failure code, which `hub::call` re-asks. Before a byte of the pull has
160
+ /// moved this is the only bound a black-holed hub meets. The head wait is never judged this
161
+ /// way: a live hub may take its time, and a dead one is found by TCP keepalive.
162
+ fn handshake_verdict(
163
+ judge: Judge,
164
+ ledger: &Ledger,
165
+ advanced: Instant,
166
+ phase: &str,
167
+ fail: Code,
168
+ ) -> Result<()> {
169
+ stream_verdict(judge, ledger, advanced, phase)?;
170
+ if judge != Judge::Transfer || advanced.elapsed() <= ledger.patience() {
171
+ return Ok(());
172
+ }
173
+ refuse(
174
+ fail,
175
+ format!(
176
+ "the peer was silent {:.1} s during {phase} against the {:.1} s this pull's \
177
+ measured pace allows",
178
+ advanced.elapsed().as_secs_f64(),
179
+ ledger.patience().as_secs_f64(),
180
+ ),
181
+ )
182
+ }
183
+
157
184
  impl Judge {
158
185
  fn silent_is_stall(self) -> bool {
159
186
  matches!(self, Judge::Stream | Judge::Silence)
@@ -503,7 +530,13 @@ fn connect(
503
530
  // sample. Cancellation and existing silence rules remain active
504
531
  // without imposing a new total connection deadline.
505
532
  transfer_verdict(judge, ledger, since, "a TCP connection")?;
506
- stream_verdict(judge, ledger, since, "TCP connect")?;
533
+ // A silent address is that address's verdict, not the URL's: an IPv6 route
534
+ // that drops SYNs while IPv4 answers must not stall every ask of a pull.
535
+ if let Err(silent) = handshake_verdict(judge, ledger, since, "TCP connect", fail) {
536
+ ledger.check_running()?;
537
+ last = Some(std::io::Error::new(ErrorKind::TimedOut, silent.detail));
538
+ continue 'addresses;
539
+ }
507
540
  let tick = deadline
508
541
  .remaining()?
509
542
  .map_or(ledger.sample(), |left| left.min(ledger.sample()));
@@ -538,6 +571,7 @@ fn connect(
538
571
  detail: format!("configure connected socket: {error}"),
539
572
  })?;
540
573
  let _ = socket.set_nodelay(true);
574
+ keepalive(&socket, ledger);
541
575
  return Ok(socket);
542
576
  }
543
577
  refuse(
@@ -550,6 +584,19 @@ fn connect(
550
584
  )
551
585
  }
552
586
 
587
+ /// TCP keepalive at the ledger's own resolution: probes start after the noise floor of
588
+ /// silence and a peer that answers none of `STILL_SAMPLES` probes, a sample apart, is gone.
589
+ /// A live hub that is merely slow ACKs every probe and is waited for; a dead host or a
590
+ /// dropped tunnel fails the read as weather, which the caller asks again.
591
+ fn keepalive(socket: &TcpStream, ledger: &Ledger) {
592
+ use rustix::net::sockopt;
593
+ let second = Duration::from_secs(1);
594
+ let _ = sockopt::set_socket_keepalive(socket, true);
595
+ let _ = sockopt::set_tcp_keepidle(socket, ledger.floor().max(second));
596
+ let _ = sockopt::set_tcp_keepintvl(socket, ledger.sample().max(second));
597
+ let _ = sockopt::set_tcp_keepcnt(socket, crate::transport::ledger::STILL_SAMPLES);
598
+ }
599
+
553
600
  #[allow(clippy::too_many_arguments)]
554
601
  fn tls_handshake(
555
602
  host: &str,
@@ -576,7 +623,7 @@ fn tls_handshake(
576
623
  Ok(n) if n > 0 => advanced = Instant::now(),
577
624
  Ok(_) => {}
578
625
  Err(e) if would_block(&e) => {
579
- stream_verdict(judge, ledger, advanced, "TLS handshake")?;
626
+ handshake_verdict(judge, ledger, advanced, "TLS handshake", fail)?;
580
627
  }
581
628
  Err(e) => return refuse(fail, format!("TLS handshake write: {e}")),
582
629
  }
@@ -587,10 +634,22 @@ fn tls_handshake(
587
634
  Ok(_) => {
588
635
  advanced = Instant::now();
589
636
  // A certificate or protocol verdict is this client's, and re-asking reaches
590
- // it again: refused typed, never retried as weather. The alert goes out so
591
- // the origin logs why.
637
+ // it again: refused typed, never retried as weather. The peer's own alert or
638
+ // a garbled record is the link's weather and is asked again. The alert goes
639
+ // out so the origin logs why.
592
640
  if let Err(e) = conn.process_new_packets() {
593
641
  let _ = conn.write_tls(sock);
642
+ let verdict = matches!(
643
+ e,
644
+ rustls::Error::InvalidCertificate(_)
645
+ | rustls::Error::NoCertificatesPresented
646
+ | rustls::Error::UnsupportedNameType
647
+ | rustls::Error::InvalidCertRevocationList(_)
648
+ | rustls::Error::PeerIncompatible(_)
649
+ );
650
+ if !verdict {
651
+ return refuse(fail, format!("{host}: TLS handshake failed: {e}"));
652
+ }
594
653
  return refuse(
595
654
  Code::TLS_UNTRUSTED,
596
655
  format!(
@@ -600,7 +659,7 @@ fn tls_handshake(
600
659
  }
601
660
  }
602
661
  Err(e) if would_block(&e) => {
603
- stream_verdict(judge, ledger, advanced, "TLS handshake")?;
662
+ handshake_verdict(judge, ledger, advanced, "TLS handshake", fail)?;
604
663
  }
605
664
  Err(e) => return refuse(fail, format!("TLS handshake read: {e}")),
606
665
  }
@@ -1277,7 +1336,7 @@ fn write_all(
1277
1336
  Err(e) => return refuse(fail, format!("the connection failed mid-write: {e}")),
1278
1337
  }
1279
1338
  }
1280
- stream_verdict(judge, ledger, advanced, "request write")?;
1339
+ handshake_verdict(judge, ledger, advanced, "request write", fail)?;
1281
1340
  if let Some(bound) = silence {
1282
1341
  if advanced.elapsed() > bound {
1283
1342
  return refuse(
@@ -375,7 +375,9 @@ impl Ledger {
375
375
  /// which is not a failed attempt, or — when it states none — this pull's patience,
376
376
  /// which is (`true`). The hub's rule, applied to every origin.
377
377
  pub(crate) fn retry_wait(&self, stated: Option<Duration>) -> (Duration, bool) {
378
- match stated.filter(|wait| !wait.is_zero()) {
378
+ // A wait no clock can hold is no statement (and `Instant + wait` would panic).
379
+ let representable = |wait: &Duration| Instant::now().checked_add(*wait).is_some();
380
+ match stated.filter(|wait| !wait.is_zero() && representable(wait)) {
379
381
  Some(wait) => (wait, false),
380
382
  None => (self.patience(), true),
381
383
  }
@@ -383,7 +385,9 @@ impl Ledger {
383
385
 
384
386
  /// Sleep `wait` in sampling ticks; cancellation and the caller's deadline end it.
385
387
  pub(crate) fn pause(&self, wait: Duration, deadline: Deadline) -> Result<()> {
386
- let until = Instant::now() + wait;
388
+ let until = Instant::now()
389
+ .checked_add(wait)
390
+ .unwrap_or_else(|| Instant::now() + self.patience());
387
391
  loop {
388
392
  self.check_running()?;
389
393
  let now = Instant::now();
@@ -33,6 +33,7 @@
33
33
  //! to a loopback listener it starts itself, and nothing here reads the environment.
34
34
 
35
35
  mod api;
36
+ mod decisions;
36
37
  mod http;
37
38
  mod hub;
38
39
  mod ledger;