tensorfs 0.3.50__tar.gz → 0.3.51__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 (140) hide show
  1. {tensorfs-0.3.50 → tensorfs-0.3.51}/Cargo.lock +2 -2
  2. {tensorfs-0.3.50 → tensorfs-0.3.51}/Cargo.toml +1 -1
  3. {tensorfs-0.3.50 → tensorfs-0.3.51}/PKG-INFO +1 -1
  4. tensorfs-0.3.51/crates/tensorfs-core/src/derived/companion_tests.rs +243 -0
  5. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/derived/estimate.rs +6 -0
  6. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/derived.rs +208 -7
  7. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-py/src/store.rs +26 -6
  8. {tensorfs-0.3.50 → tensorfs-0.3.51}/pyproject.toml +1 -1
  9. {tensorfs-0.3.50 → tensorfs-0.3.51}/python/tensorfs/_ext.pyi +4 -1
  10. {tensorfs-0.3.50 → tensorfs-0.3.51}/python/tensorfs/derived.py +17 -4
  11. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/Cargo.toml +0 -0
  12. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/build.rs +0 -0
  13. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/examples/h3-swiglu-layout.md +0 -0
  14. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/examples/optional-cache-backfill.md +0 -0
  15. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/examples/resident-conversion.md +0 -0
  16. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/examples/resident_conversion_profile.rs +0 -0
  17. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/asset_update.rs +0 -0
  18. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/b64.rs +0 -0
  19. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/bin/tfs/ckpt.rs +0 -0
  20. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/bin/tfs/conform.rs +0 -0
  21. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/bin/tfs/fetch.rs +0 -0
  22. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/bin/tfs/ingest.rs +0 -0
  23. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/bin/tfs/main.rs +0 -0
  24. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/bin/tfs/rd.rs +0 -0
  25. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/bin/tfs/repo.rs +0 -0
  26. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/bin/tfs/snap.rs +0 -0
  27. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/bin/tfs/watch.rs +0 -0
  28. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/cache_roots.rs +0 -0
  29. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/canon.rs +0 -0
  30. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/capability.rs +0 -0
  31. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/catalog.rs +0 -0
  32. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/cbor.rs +0 -0
  33. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/checkpoint.rs +0 -0
  34. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/checkpoint_root.rs +0 -0
  35. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/corpus.rs +0 -0
  36. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/derived/adoption.rs +0 -0
  37. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/derived/graft_tests.rs +0 -0
  38. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/derived/progress.rs +0 -0
  39. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/derived/resume_tests.rs +0 -0
  40. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/derived/retention.rs +0 -0
  41. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/derived/roots.rs +0 -0
  42. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/dtype.rs +0 -0
  43. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/durability.rs +0 -0
  44. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/err.rs +0 -0
  45. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/fetch.rs +0 -0
  46. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/fill.rs +0 -0
  47. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/fit.rs +0 -0
  48. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/gc.rs +0 -0
  49. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/header.rs +0 -0
  50. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/home.rs +0 -0
  51. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/ids.rs +0 -0
  52. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/ingest/carrier.rs +0 -0
  53. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/ingest/convert.rs +0 -0
  54. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/ingest/fingerprint.rs +0 -0
  55. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/ingest/gguf.rs +0 -0
  56. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/ingest/h3_lora.rs +0 -0
  57. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/ingest/journal.rs +0 -0
  58. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/ingest/mod.rs +0 -0
  59. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/ingest/preflight.rs +0 -0
  60. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/ingest/source.rs +0 -0
  61. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/ingest/stamp.rs +0 -0
  62. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/ingest/transaction.rs +0 -0
  63. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/jcs.rs +0 -0
  64. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/lib.rs +0 -0
  65. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/limits.rs +0 -0
  66. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/machine.rs +0 -0
  67. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/manifest.rs +0 -0
  68. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/meta.rs +0 -0
  69. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/project.rs +0 -0
  70. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/providers.rs +0 -0
  71. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/read.rs +0 -0
  72. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/receipt.rs +0 -0
  73. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/reclaim.rs +0 -0
  74. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/registry.rs +0 -0
  75. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/relation.rs +0 -0
  76. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/repo_cache.rs +0 -0
  77. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/repository.rs +0 -0
  78. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/sha256.rs +0 -0
  79. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/source_artifact.rs +0 -0
  80. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/spec.rs +0 -0
  81. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/staging.rs +0 -0
  82. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/storage.rs +0 -0
  83. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/store.rs +0 -0
  84. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/transport/api.rs +0 -0
  85. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/transport/http.rs +0 -0
  86. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/transport/hub.rs +0 -0
  87. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/transport/ledger.rs +0 -0
  88. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/transport/mod.rs +0 -0
  89. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/transport/policy.rs +0 -0
  90. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/transport/prefix.rs +0 -0
  91. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/transport/pull.rs +0 -0
  92. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/transport/push.rs +0 -0
  93. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/transport/ranged.rs +0 -0
  94. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/transport/speculate.rs +0 -0
  95. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/transport/tests.rs +0 -0
  96. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/src/vectors.rs +0 -0
  97. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/checkpoint_roots.rs +0 -0
  98. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/fetch_url_progress.rs +0 -0
  99. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/fit.rs +0 -0
  100. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/fixtures/repo_apply/blobs.jsonl +0 -0
  101. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/fixtures/repo_apply/expected_list.jsonl +0 -0
  102. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/fixtures/repo_apply/expected_repository.json +0 -0
  103. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/fixtures/repo_apply/expected_rows.jsonl +0 -0
  104. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/fixtures/repo_apply/header.cbor +0 -0
  105. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/fixtures/repo_apply/manifest.json +0 -0
  106. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/fixtures/repo_apply/mutation.json +0 -0
  107. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/h3_lora.rs +0 -0
  108. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/h3_swiglu.rs +0 -0
  109. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/home.rs +0 -0
  110. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/import_tree.rs +0 -0
  111. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/instrument_profiles.rs +0 -0
  112. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/liveness.rs +0 -0
  113. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/qwen_image21_profile.rs +0 -0
  114. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/read_plan.rs +0 -0
  115. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/reclaim.rs +0 -0
  116. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/reclaim_run.rs +0 -0
  117. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/repo_cache.rs +0 -0
  118. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/repo_store.rs +0 -0
  119. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/resident_admission.rs +0 -0
  120. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/sha256_backends.rs +0 -0
  121. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/sharded_cas.rs +0 -0
  122. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/source_artifacts.rs +0 -0
  123. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/source_plan.rs +0 -0
  124. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/source_prefixes.rs +0 -0
  125. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/source_preflight.rs +0 -0
  126. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/staging.rs +0 -0
  127. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/store_boundaries.rs +0 -0
  128. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/tensor_schema.rs +0 -0
  129. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/version.rs +0 -0
  130. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-core/tests/write_through.rs +0 -0
  131. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-py/Cargo.toml +0 -0
  132. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-py/src/docs.rs +0 -0
  133. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-py/src/errors.rs +0 -0
  134. {tensorfs-0.3.50 → tensorfs-0.3.51}/crates/tensorfs-py/src/lib.rs +0 -0
  135. {tensorfs-0.3.50 → tensorfs-0.3.51}/python/tensorfs/__init__.py +0 -0
  136. {tensorfs-0.3.50 → tensorfs-0.3.51}/python/tensorfs/_derived_channel.py +0 -0
  137. {tensorfs-0.3.50 → tensorfs-0.3.51}/python/tensorfs/_source_channel.py +0 -0
  138. {tensorfs-0.3.50 → tensorfs-0.3.51}/python/tensorfs/_tensors.py +0 -0
  139. {tensorfs-0.3.50 → tensorfs-0.3.51}/python/tensorfs/errors.py +0 -0
  140. {tensorfs-0.3.50 → tensorfs-0.3.51}/python/tensorfs/py.typed +0 -0
@@ -421,7 +421,7 @@ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
421
421
 
422
422
  [[package]]
423
423
  name = "tensorfs-core"
424
- version = "0.3.50"
424
+ version = "0.3.51"
425
425
  dependencies = [
426
426
  "fs2",
427
427
  "libc",
@@ -435,7 +435,7 @@ dependencies = [
435
435
 
436
436
  [[package]]
437
437
  name = "tensorfs-py"
438
- version = "0.3.50"
438
+ version = "0.3.51"
439
439
  dependencies = [
440
440
  "pyo3",
441
441
  "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.50"
6
+ version = "0.3.51"
7
7
  edition = "2021"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tensorfs
3
- Version: 0.3.50
3
+ Version: 0.3.51
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Rust
@@ -0,0 +1,243 @@
1
+ use super::*;
2
+ use crate::repository::Mutation;
3
+ use crate::repository::RepositoryName;
4
+ use crate::store::Fault;
5
+
6
+ fn fixture() -> (Store, Meta, String) {
7
+ let root = std::env::temp_dir().join(format!(
8
+ "tensorfs-companions-{}",
9
+ crate::meta::now_nanos_unique()
10
+ ));
11
+ let store = Store::init(&root).unwrap();
12
+ let meta = Meta::open(&store).unwrap();
13
+ (store, meta, format!("sha256:{}", "c1".repeat(32)))
14
+ }
15
+
16
+ fn release(meta: &Meta, writer: Begin) {
17
+ release_guards(meta, Some(writer.writer_hold), writer.source_leases);
18
+ }
19
+
20
+ fn declaration() -> Declaration {
21
+ let mut d = super::tests::created_declaration();
22
+ d.files = vec![
23
+ ("LICENSE".into(), b"research licence\n".to_vec()),
24
+ ("Notice".into(), b"Exact attribution\n".to_vec()),
25
+ ];
26
+ d.max_new_bytes += d
27
+ .files
28
+ .iter()
29
+ .map(|(_, data)| data.len() as u64)
30
+ .sum::<u64>();
31
+ d
32
+ }
33
+
34
+ fn write_weight(store: &Store, meta: &Meta, id: &str) -> Part {
35
+ add_part(
36
+ store,
37
+ meta,
38
+ id,
39
+ 1,
40
+ ("model", "weight", "value"),
41
+ &mut vec![0x31; 2048].as_slice(),
42
+ )
43
+ .unwrap()
44
+ .part
45
+ }
46
+
47
+ #[test]
48
+ fn companion_intent_resumes_and_published_checkpoint_checks_out_real_files() {
49
+ let (store, meta, id) = fixture();
50
+ let mut d = declaration();
51
+ let encoded = d.canonical_work_bytes().unwrap();
52
+ assert_eq!(
53
+ Declaration::parse_text(std::str::from_utf8(&encoded).unwrap()).unwrap(),
54
+ d
55
+ );
56
+ let writer = begin(&store, &meta, &id, 1, d.clone(), None).unwrap();
57
+ let part = write_weight(&store, &meta, &id);
58
+ let (_, progress) =
59
+ checkpoint_progress(&store, &meta, &id, 1, "request", "model", None).unwrap();
60
+ fence(&meta, &id, 1).unwrap();
61
+ release(&meta, writer);
62
+ crate::gc::collect(store.root(), false).unwrap();
63
+ let mut changed = d.clone();
64
+ changed.files[0].1 = b"changed licence\n".to_vec();
65
+ assert_eq!(
66
+ begin(&store, &meta, &id, 2, changed, progress.head.as_ref())
67
+ .err()
68
+ .unwrap()
69
+ .code,
70
+ Code::TRANSACTION_CONFLICT
71
+ );
72
+ let writer = begin(&store, &meta, &id, 2, d.clone(), progress.head.as_ref()).unwrap();
73
+ assert_eq!(completed(&meta, &id, 2).unwrap().0.len(), 1);
74
+ let receipt = commit(&store, &meta, &id, 2).unwrap();
75
+ release(&meta, writer);
76
+ assert!(receipt
77
+ .added_objects
78
+ .contains(&ObjectRef::of(&d.files[0].1)));
79
+ let manifest = checkpoint::load_manifest(&store, &receipt.manifest).unwrap();
80
+ assert_eq!(
81
+ manifest
82
+ .entries()
83
+ .iter()
84
+ .map(|(n, _)| n.as_str())
85
+ .collect::<Vec<_>>(),
86
+ ["LICENSE", "Notice", "model.cozytensors"]
87
+ );
88
+ let header = checkpoint::load_header(&store, &receipt.header).unwrap();
89
+ assert_eq!(header.components[0].1[0].1.parts[0].1, part);
90
+ // Documents participate in normal model-closure fetching as well as ordinary checkout.
91
+ let walk = checkpoint::walk_cozytensors(&store, &manifest).unwrap();
92
+ assert!(walk
93
+ .objects
94
+ .iter()
95
+ .any(|r| r.kind == "model_asset" && r.obj == ObjectRef::of(&d.files[1].1)));
96
+ store
97
+ .apply_repository(
98
+ None,
99
+ &Mutation::PutCheckpoint {
100
+ repo: RepositoryName::new("research", "reference-image").unwrap(),
101
+ manifest: receipt.manifest.clone(),
102
+ },
103
+ &Fault::default(),
104
+ )
105
+ .unwrap();
106
+ dispose(&store, &meta, &id).unwrap();
107
+ crate::gc::collect(store.root(), false).unwrap();
108
+ let out = store.root().join("published-readback");
109
+ crate::project::checkout(&store, &manifest, &out, true).unwrap();
110
+ assert_eq!(std::fs::read(out.join("LICENSE")).unwrap(), d.files[0].1);
111
+ assert_eq!(std::fs::read(out.join("Notice")).unwrap(), d.files[1].1);
112
+ std::fs::remove_dir_all(store.root()).unwrap();
113
+ }
114
+
115
+ #[test]
116
+ fn ordinary_companions_survive_derivation_without_copying_tensor_backing_files() {
117
+ let (store, meta, id) = fixture();
118
+ let mut source_declaration = declaration();
119
+ // Same exact ObjectRef as the tensor: the named asset role must survive deduplication.
120
+ source_declaration
121
+ .files
122
+ .push(("Tensor-shaped.txt".into(), vec![0x31; 2048]));
123
+ source_declaration.max_new_bytes += 2048;
124
+ let writer = begin(&store, &meta, &id, 1, source_declaration, None).unwrap();
125
+ let part = write_weight(&store, &meta, &id);
126
+ let source = commit(&store, &meta, &id, 1).unwrap();
127
+ release(&meta, writer);
128
+ let mut manifest = Draft::of(&checkpoint::load_manifest(&store, &source.manifest).unwrap());
129
+ manifest.entries.push((
130
+ "tensor-backing.bin".into(),
131
+ Entry::File(part.segments()[0].clone()),
132
+ ));
133
+ manifest.entries.sort_by(|a, b| a.0.cmp(&b.0));
134
+ let source_manifest = store.put_manifest(&manifest.seal().unwrap()).unwrap().obj;
135
+ store
136
+ .apply_repository(
137
+ None,
138
+ &Mutation::PutCheckpoint {
139
+ repo: RepositoryName::new("research", "source").unwrap(),
140
+ manifest: source_manifest.clone(),
141
+ },
142
+ &Fault::default(),
143
+ )
144
+ .unwrap();
145
+ let next = format!("sha256:{}", "c2".repeat(32));
146
+ let mut d = super::tests::created_declaration();
147
+ d.sources = vec![Source {
148
+ alias: "source".into(),
149
+ manifest: source_manifest,
150
+ }];
151
+ d.components[0].source = Some("source".into());
152
+ d.components[0].source_component = Some("model".into());
153
+ d.components[0].add.clear();
154
+ d.max_new_bytes = 0;
155
+ let writer = begin(&store, &meta, &next, 1, d.clone(), None).unwrap();
156
+ let derived = commit(&store, &meta, &next, 1).unwrap();
157
+ release(&meta, writer);
158
+ let manifest = checkpoint::load_manifest(&store, &derived.manifest).unwrap();
159
+ assert_eq!(
160
+ manifest
161
+ .entries()
162
+ .iter()
163
+ .map(|(n, _)| n.as_str())
164
+ .collect::<Vec<_>>(),
165
+ [
166
+ "LICENSE",
167
+ "Notice",
168
+ "Tensor-shaped.txt",
169
+ "model.cozytensors"
170
+ ]
171
+ );
172
+ assert!(derived.added_objects.is_empty());
173
+ let header = checkpoint::load_header(&store, &derived.header).unwrap();
174
+ assert_eq!(header.components[0].1[0].1.parts[0].1, part);
175
+ // Two source documents may only disagree when the caller explicitly chooses new bytes.
176
+ let mut sources = load_sources(&store, &d).unwrap();
177
+ let mut other = SourceData {
178
+ fact: sources[0].fact.clone(),
179
+ manifest: sources[0].manifest.clone(),
180
+ header: sources[0].header.clone(),
181
+ };
182
+ let mut draft = Draft::of(&other.manifest);
183
+ draft.entries[0].1 = Entry::File(ObjectRef::of(b"different licence"));
184
+ other.manifest = draft.seal().unwrap();
185
+ sources.push(other);
186
+ assert_eq!(
187
+ companion_files(&d, &sources).unwrap_err().code,
188
+ Code::TRANSACTION_CONFLICT
189
+ );
190
+ d.files
191
+ .push(("LICENSE".into(), b"explicit licence".to_vec()));
192
+ assert_eq!(
193
+ companion_files(&d, &sources).unwrap()["LICENSE"],
194
+ ObjectRef::of(b"explicit licence")
195
+ );
196
+ std::fs::remove_dir_all(store.root()).unwrap();
197
+ }
198
+
199
+ #[test]
200
+ fn companion_paths_size_count_and_quotas_are_native_refusals() {
201
+ for path in [
202
+ "../LICENSE",
203
+ "/LICENSE",
204
+ "model.cozytensors",
205
+ "model.cozytensors/LICENSE",
206
+ "a//b",
207
+ "a\\b",
208
+ ] {
209
+ let mut d = declaration();
210
+ d.files = vec![(path.into(), b"x".to_vec())];
211
+ assert!(d.normalize_and_validate().is_err(), "accepted {path}");
212
+ }
213
+ let mut d = declaration();
214
+ d.files = vec![
215
+ ("a".into(), vec![]),
216
+ ("a-other".into(), vec![]),
217
+ ("a/b".into(), vec![]),
218
+ ];
219
+ assert_eq!(
220
+ d.normalize_and_validate().unwrap_err().code,
221
+ Code::PATH_ILLEGAL
222
+ );
223
+ d.files = vec![("a".into(), vec![1; MAX_COMPANION_BYTES + 1])];
224
+ assert_eq!(d.normalize_and_validate().unwrap_err().code, Code::SIZE_CAP);
225
+ d.files = (0..17).map(|i| (format!("doc{i}"), vec![])).collect();
226
+ assert_eq!(
227
+ d.normalize_and_validate().unwrap_err().code,
228
+ Code::COUNT_CAP
229
+ );
230
+ d.files = (0..9)
231
+ .map(|i| (format!("doc{i}"), vec![1; MAX_COMPANION_BYTES]))
232
+ .collect();
233
+ assert_eq!(d.normalize_and_validate().unwrap_err().code, Code::SIZE_CAP);
234
+ d = declaration();
235
+ d.max_new_bytes = 2048;
236
+ assert_eq!(
237
+ d.normalize_and_validate().unwrap_err().code,
238
+ Code::QUOTA_EXHAUSTED
239
+ );
240
+ d = super::tests::created_declaration();
241
+ let bytes = d.canonical_work_bytes().unwrap();
242
+ assert!(!String::from_utf8(bytes).unwrap().contains("\"files\""));
243
+ }
@@ -77,6 +77,12 @@ pub fn estimate_write(
77
77
  })
78
78
  .collect();
79
79
  let mut result = WriteEstimate::default();
80
+ for (_, data) in &declaration.files {
81
+ let length = data.len() as u64;
82
+ result.payload_bytes += length;
83
+ result.largest_part_bytes = result.largest_part_bytes.max(length);
84
+ result.parts += 1;
85
+ }
80
86
  for component in &declaration.components {
81
87
  for tensor in &component.add {
82
88
  for part in &tensor.parts {
@@ -16,17 +16,17 @@ pub use adoption::adopt_checkpoint;
16
16
  use progress::read as read_progress;
17
17
  pub use retention::{release_retention, retain_result, RetainedResult};
18
18
 
19
- use std::collections::HashSet;
19
+ use std::collections::{BTreeMap, HashSet};
20
20
  use std::io::Read;
21
21
 
22
22
  use crate::canon::{as_arr, as_obj, as_str, Fields, Value};
23
23
  use crate::checkpoint::{self, build_manifest};
24
24
  use crate::dtype::{checked_bytes, Dtype};
25
25
  use crate::err::{refuse, Code, Refusal, Result};
26
- use crate::header::{Body, Closure, Header, Part, Tensor};
26
+ use crate::header::{Asset, Body, Closure, Header, Part, Tensor};
27
27
  use crate::ids::{ascii_name, prefixed, ObjectRef};
28
28
  use crate::limits;
29
- use crate::manifest::Manifest;
29
+ use crate::manifest::{Draft, Entry, Manifest};
30
30
  use crate::meta::{Hold, Meta};
31
31
  use crate::read::{self, ReadLease};
32
32
  use crate::store::Store;
@@ -179,6 +179,8 @@ pub struct Declaration {
179
179
  pub sources: Vec<Source>,
180
180
  pub components: Vec<ComponentDeclaration>,
181
181
  pub configs: Vec<ConfigDeclaration>,
182
+ /// Bounded immutable ordinary companion files, locked into the work intent.
183
+ pub files: Vec<(String, Vec<u8>)>,
182
184
  pub order: Vec<(String, String)>,
183
185
  pub max_new_bytes: u64,
184
186
  }
@@ -245,6 +247,8 @@ impl Declaration {
245
247
  );
246
248
  }
247
249
 
250
+ validate_files(&mut self.files)?;
251
+
248
252
  for source in &self.sources {
249
253
  name("source alias", &source.alias)?;
250
254
  if source.manifest.length == 0 {
@@ -499,8 +503,8 @@ impl Declaration {
499
503
  }
500
504
 
501
505
  fn planned_additions(&self) -> Result<(u64, usize)> {
502
- let mut bytes = 0u64;
503
- let mut objects = 0usize;
506
+ let mut bytes: u64 = self.files.iter().map(|(_, data)| data.len() as u64).sum();
507
+ let mut objects = self.files.len();
504
508
  for component in &self.components {
505
509
  for tensor in &component.add {
506
510
  for part in &tensor.parts {
@@ -550,6 +554,15 @@ impl Declaration {
550
554
  fn from_value(v: &Value) -> Result<Declaration> {
551
555
  let mut f = Fields::new("DerivedDeclaration", v)?;
552
556
  let max_new_bytes = f.req_uint("max_new_bytes")?;
557
+ let mut files = Vec::new();
558
+ if let Some(value) = f.opt("files") {
559
+ for (path, value) in as_obj("DerivedDeclaration", "files", value)? {
560
+ files.push((
561
+ path.clone(),
562
+ decode_file(as_str("companion", "data", value)?)?,
563
+ ));
564
+ }
565
+ }
553
566
  let work_fingerprint = f
554
567
  .opt("work_fingerprint")
555
568
  .map(|value| {
@@ -696,6 +709,7 @@ impl Declaration {
696
709
  sources,
697
710
  components,
698
711
  configs,
712
+ files,
699
713
  order,
700
714
  max_new_bytes,
701
715
  })
@@ -848,6 +862,17 @@ impl Declaration {
848
862
  ),
849
863
  ),
850
864
  ];
865
+ if !self.files.is_empty() {
866
+ fields.push((
867
+ "files",
868
+ Value::map(
869
+ self.files
870
+ .iter()
871
+ .map(|(path, data)| (path.clone(), Value::str(crate::b64::encode(data))))
872
+ .collect(),
873
+ ),
874
+ ));
875
+ }
851
876
  if let Some(fingerprint) = &self.work_fingerprint {
852
877
  fields.push(("work_fingerprint", Value::str(fingerprint.clone())));
853
878
  }
@@ -855,6 +880,121 @@ impl Declaration {
855
880
  }
856
881
  }
857
882
 
883
+ /// Companion documents are intentionally small; their bytes live in the immutable intent.
884
+ pub const MAX_COMPANION_FILES: usize = 16;
885
+ pub const MAX_COMPANION_BYTES: usize = 64 << 10;
886
+ /// Leaves declaration space below Runtime's one-MiB transport ceiling after base64.
887
+ pub const MAX_COMPANION_TOTAL_BYTES: usize = 512 << 10;
888
+
889
+ pub fn decode_file(encoded: &str) -> Result<Vec<u8>> {
890
+ if encoded.len() > MAX_COMPANION_BYTES.div_ceil(3) * 4 {
891
+ return refuse(Code::SIZE_CAP, "companion file exceeds 64 KiB");
892
+ }
893
+ let data = crate::b64::decode(encoded)?;
894
+ if data.len() > MAX_COMPANION_BYTES {
895
+ return refuse(Code::SIZE_CAP, "companion file exceeds 64 KiB");
896
+ }
897
+ Ok(data)
898
+ }
899
+
900
+ fn validate_files(files: &mut [(String, Vec<u8>)]) -> Result<()> {
901
+ if files.len() > MAX_COMPANION_FILES {
902
+ return refuse(
903
+ Code::COUNT_CAP,
904
+ "at most 16 companion files may be declared",
905
+ );
906
+ }
907
+ if files.iter().map(|(_, data)| data.len()).sum::<usize>() > MAX_COMPANION_TOTAL_BYTES {
908
+ return refuse(Code::SIZE_CAP, "companion files exceed 512 KiB in total");
909
+ }
910
+ files.sort_by(|a, b| a.0.cmp(&b.0));
911
+ let mut paths = vec!["model.cozytensors".to_string()];
912
+ for (path, data) in files.iter() {
913
+ crate::manifest::check_path(path)?;
914
+ if data.len() > MAX_COMPANION_BYTES {
915
+ return refuse(Code::SIZE_CAP, "companion file exceeds 64 KiB");
916
+ }
917
+ paths.push(path.clone());
918
+ }
919
+ validate_companion_paths(&mut paths)
920
+ }
921
+
922
+ fn validate_companion_paths(paths: &mut [String]) -> Result<()> {
923
+ paths.sort();
924
+ if paths.windows(2).any(|pair| pair[0] == pair[1]) {
925
+ return refuse(
926
+ Code::PATH_ILLEGAL,
927
+ "companion paths collide with checkpoint or other files",
928
+ );
929
+ }
930
+ let names: HashSet<_> = paths.iter().map(String::as_str).collect();
931
+ for path in paths.iter() {
932
+ for (at, _) in path.match_indices('/') {
933
+ if names.contains(&path[..at]) {
934
+ return refuse(Code::PATH_ILLEGAL, "companion path traverses another file");
935
+ }
936
+ }
937
+ }
938
+ Ok(())
939
+ }
940
+
941
+ fn companion_files(
942
+ declaration: &Declaration,
943
+ sources: &[SourceData],
944
+ ) -> Result<BTreeMap<String, ObjectRef>> {
945
+ let mut files = BTreeMap::new();
946
+ let explicit: HashSet<_> = declaration
947
+ .files
948
+ .iter()
949
+ .map(|(path, _)| path.as_str())
950
+ .collect();
951
+ for source in sources {
952
+ let mut backing: HashSet<_> = source
953
+ .header
954
+ .tensors()
955
+ .flat_map(|(_, _, tensor)| tensor.parts.iter())
956
+ .flat_map(|(_, part)| part.segments())
957
+ .map(|o| (o.sha256.clone(), o.length))
958
+ .collect();
959
+ backing.insert((source.fact.header.sha256.clone(), source.fact.header.length));
960
+ for (path, entry) in source.manifest.entries() {
961
+ let Entry::File(object) = entry else { continue };
962
+ // A named asset is an explicit semantic role, even when CAS deduplication
963
+ // makes its bytes identical to a tensor part. Only unindexed backing aliases
964
+ // disappear from the derived manifest.
965
+ let named_asset = source.header.assets.iter().any(|(name, asset)| {
966
+ name == path
967
+ && asset.logical_sha256 == object.sha256
968
+ && asset.logical_length == object.length
969
+ });
970
+ if (backing.contains(&(object.sha256.clone(), object.length)) && !named_asset)
971
+ || explicit.contains(path.as_str())
972
+ {
973
+ continue;
974
+ }
975
+ if let Some(previous) = files.insert(path.clone(), object.clone()) {
976
+ if previous != *object {
977
+ return refuse(Code::TRANSACTION_CONFLICT,
978
+ format!("sources disagree on companion {path:?}; explicitly declare replacement bytes"));
979
+ }
980
+ }
981
+ }
982
+ }
983
+ files.extend(
984
+ declaration
985
+ .files
986
+ .iter()
987
+ .map(|(path, data)| (path.clone(), ObjectRef::of(data))),
988
+ );
989
+ let mut paths: Vec<_> = files
990
+ .keys()
991
+ .cloned()
992
+ .chain(std::iter::once("model.cozytensors".into()))
993
+ .collect();
994
+ validate_companion_paths(&mut paths)?;
995
+ Ok(files)
996
+ }
997
+
858
998
  fn selected_components(declaration: &Declaration, source_alias: &str) -> Vec<String> {
859
999
  let mut components: Vec<String> = declaration
860
1000
  .components
@@ -1916,7 +2056,19 @@ fn build_header(
1916
2056
  configs.sort_by(|a, b| a.0.cmp(&b.0));
1917
2057
  let header = Header {
1918
2058
  configs,
1919
- assets: Vec::new(),
2059
+ assets: companion_files(declaration, sources)?
2060
+ .into_iter()
2061
+ .filter(|(_, object)| object.length != 0)
2062
+ .map(|(path, object)| {
2063
+ let asset = Asset {
2064
+ logical_sha256: object.sha256.clone(),
2065
+ logical_length: object.length,
2066
+ media_type: "application/octet-stream".into(),
2067
+ segments: vec![object],
2068
+ };
2069
+ (path, asset)
2070
+ })
2071
+ .collect(),
1920
2072
  encodings,
1921
2073
  components,
1922
2074
  };
@@ -1972,6 +2124,7 @@ fn inspect_retained_source(
1972
2124
  ) -> Result<SourceInspection> {
1973
2125
  let alias = "source".to_string();
1974
2126
  let mut declaration = Declaration {
2127
+ files: Vec::new(),
1975
2128
  work_fingerprint: None,
1976
2129
  sources: vec![Source {
1977
2130
  alias: alias.clone(),
@@ -2927,6 +3080,23 @@ pub fn add_config<R: Read>(
2927
3080
  config,
2928
3081
  });
2929
3082
  row.normalize();
3083
+ let declaration = declaration(row)?;
3084
+ let (planned, _) = declaration.planned_additions()?;
3085
+ let config_bytes: u64 = row
3086
+ .added_configs
3087
+ .iter()
3088
+ .map(|c| c.config.len() as u64)
3089
+ .sum();
3090
+ if !declaration.files.is_empty()
3091
+ && planned
3092
+ .checked_add(config_bytes)
3093
+ .is_none_or(|n| n > declaration.max_new_bytes)
3094
+ {
3095
+ return refuse(
3096
+ Code::QUOTA_EXHAUSTED,
3097
+ "configs and companion/tensor additions exceed output grant",
3098
+ );
3099
+ }
2930
3100
  txn.commit()?;
2931
3101
  Ok(())
2932
3102
  }
@@ -2997,6 +3167,16 @@ fn added_objects(row: &TransactionRow) -> Vec<ObjectRef> {
2997
3167
  .iter()
2998
3168
  .flat_map(|added| added.part.segments().iter().cloned())
2999
3169
  .collect();
3170
+ if matches!(row.state, TransactionState::Committed(_)) {
3171
+ if let Ok(declaration) = declaration(row) {
3172
+ objects.extend(
3173
+ declaration
3174
+ .files
3175
+ .iter()
3176
+ .map(|(_, data)| ObjectRef::of(data)),
3177
+ );
3178
+ }
3179
+ }
3000
3180
  objects.sort_by(|a, b| (&a.sha256, a.length).cmp(&(&b.sha256, b.length)));
3001
3181
  objects.dedup();
3002
3182
  objects
@@ -3070,7 +3250,22 @@ pub fn commit(
3070
3250
  )?;
3071
3251
  admit_registry(store, &registry_adoptions)?;
3072
3252
  let header_ref = checkpoint::put_doc(store, &header)?;
3073
- let manifest = build_manifest(&header, &header_ref, &closure)?;
3253
+ let mut manifest = Draft::of(&build_manifest(&header, &header_ref, &closure)?);
3254
+ for (_, data) in &declaration.files {
3255
+ let expected = ObjectRef::of(data);
3256
+ store.put_stream(
3257
+ &mut &data[..],
3258
+ Some(&expected),
3259
+ &crate::store::Fault::default(),
3260
+ )?;
3261
+ }
3262
+ manifest.entries.extend(
3263
+ companion_files(&declaration, &sources)?
3264
+ .into_iter()
3265
+ .map(|(path, object)| (path, Entry::File(object))),
3266
+ );
3267
+ manifest.entries.sort_by(|a, b| a.0.cmp(&b.0));
3268
+ let manifest = manifest.seal()?;
3074
3269
  let manifest_ref = store.put_manifest(&manifest)?.obj;
3075
3270
  store.read_manifest(&manifest_ref)?;
3076
3271
  let walk = checkpoint::walk(store, &manifest)?;
@@ -3382,6 +3577,7 @@ mod tests {
3382
3577
  .spec
3383
3578
  .object_id();
3384
3579
  Declaration {
3580
+ files: Vec::new(),
3385
3581
  work_fingerprint: Some(format!("sha256:{}", "44".repeat(32))),
3386
3582
  sources: Vec::new(),
3387
3583
  components: vec![ComponentDeclaration {
@@ -3410,6 +3606,7 @@ mod tests {
3410
3606
 
3411
3607
  fn inherited_declaration(manifest: ObjectRef) -> Declaration {
3412
3608
  Declaration {
3609
+ files: Vec::new(),
3413
3610
  work_fingerprint: Some(format!("sha256:{}", "44".repeat(32))),
3414
3611
  sources: vec![Source {
3415
3612
  alias: "source".into(),
@@ -4021,6 +4218,7 @@ mod tests {
4021
4218
  &transaction,
4022
4219
  1,
4023
4220
  Declaration {
4221
+ files: Vec::new(),
4024
4222
  work_fingerprint: Some(format!("sha256:{}", "44".repeat(32))),
4025
4223
  sources: vec![Source {
4026
4224
  alias: "source".into(),
@@ -4056,3 +4254,6 @@ mod resume_tests;
4056
4254
 
4057
4255
  #[cfg(test)]
4058
4256
  mod graft_tests;
4257
+
4258
+ #[cfg(test)]
4259
+ mod companion_tests;