claims-cli 0.6.0__tar.gz → 0.6.1__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 (231) hide show
  1. {claims_cli-0.6.0 → claims_cli-0.6.1}/PKG-INFO +27 -3
  2. {claims_cli-0.6.0 → claims_cli-0.6.1}/README.md +26 -2
  3. {claims_cli-0.6.0 → claims_cli-0.6.1}/pyproject.toml +1 -1
  4. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/checks.py +390 -60
  5. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/record.py +8 -5
  6. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_record_versions.py +17 -0
  7. {claims_cli-0.6.0 → claims_cli-0.6.1}/.gitignore +0 -0
  8. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/__init__.py +0 -0
  9. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/__main__.py +0 -0
  10. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/adapters/__init__.py +0 -0
  11. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/adapters/array.py +0 -0
  12. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/adapters/base.py +0 -0
  13. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/adapters/cells.py +0 -0
  14. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/adapters/columnar.py +0 -0
  15. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/adapters/prose.py +0 -0
  16. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/adapters/reads.py +0 -0
  17. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/adapters/rows.py +0 -0
  18. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/adapters/sheet.py +0 -0
  19. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/adapters/sqlite.py +0 -0
  20. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/adapters/table.py +0 -0
  21. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/adapters/tree.py +0 -0
  22. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/cli.py +0 -0
  23. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/core/__init__.py +0 -0
  24. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/core/artifacts.py +0 -0
  25. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/core/checks.py +0 -0
  26. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/core/claims.py +0 -0
  27. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/core/evidence.py +0 -0
  28. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/core/manifest.py +0 -0
  29. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/core/numbers.py +0 -0
  30. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/core/outcomes.py +0 -0
  31. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/core/report.py +0 -0
  32. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/corpus.py +0 -0
  33. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/exceptions.py +0 -0
  34. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/export/__init__.py +0 -0
  35. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/export/rocrate.py +0 -0
  36. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/export/sarif.py +0 -0
  37. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/manifest.py +0 -0
  38. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/models.py +0 -0
  39. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/numbers.py +0 -0
  40. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/origins.py +0 -0
  41. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/policy.py +0 -0
  42. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/provenance.py +0 -0
  43. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/regression.py +0 -0
  44. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/renderers/__init__.py +0 -0
  45. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/renderers/sarif.py +0 -0
  46. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/reruns.py +0 -0
  47. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/resolve.py +0 -0
  48. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/stale.py +0 -0
  49. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/starter.py +0 -0
  50. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/toolchain.py +0 -0
  51. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/verify.py +0 -0
  52. {claims_cli-0.6.0 → claims_cli-0.6.1}/src/claims/why.py +0 -0
  53. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/build_fixtures.py +0 -0
  54. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_match/expected.json +0 -0
  55. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_match/repro.yaml +0 -0
  56. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_match/run0.json +0 -0
  57. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_match/run1.json +0 -0
  58. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_match/run2.json +0 -0
  59. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_member_absent/expected.json +0 -0
  60. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_member_absent/other.json +0 -0
  61. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_member_absent/repro.yaml +0 -0
  62. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_member_absent/run0.json +0 -0
  63. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_member_absent/run1.json +0 -0
  64. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_member_absent/run2.json +0 -0
  65. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_mismatch/expected.json +0 -0
  66. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_mismatch/repro.yaml +0 -0
  67. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_mismatch/run0.json +0 -0
  68. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_mismatch/run1.json +0 -0
  69. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_mismatch/run2.json +0 -0
  70. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/aggregate_mismatch/run3.json +0 -0
  71. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_missing/expected.json +0 -0
  72. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_missing/repro.yaml +0 -0
  73. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_missing/results.json +0 -0
  74. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_missing/source.txt +0 -0
  75. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_missing/table.csv +0 -0
  76. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_undeclared/expected.json +0 -0
  77. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_undeclared/repro.yaml +0 -0
  78. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_undeclared/results.json +0 -0
  79. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_undeclared/source.txt +0 -0
  80. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_undeclared/table.csv +0 -0
  81. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_unreadable/broken.json +0 -0
  82. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_unreadable/expected.json +0 -0
  83. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_unreadable/repro.yaml +0 -0
  84. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_unreadable/results.json +0 -0
  85. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_unreadable/source.txt +0 -0
  86. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/artifact_unreadable/table.csv +0 -0
  87. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/broken_pin/expected.json +0 -0
  88. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/broken_pin/repro.yaml +0 -0
  89. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/broken_pin/results.json +0 -0
  90. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/broken_pin/source.txt +0 -0
  91. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/broken_pin/table.csv +0 -0
  92. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/correspondence_match/counts.json +0 -0
  93. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/correspondence_match/doc.md +0 -0
  94. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/correspondence_match/expected.json +0 -0
  95. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/correspondence_match/repro.yaml +0 -0
  96. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/correspondence_mismatch/counts.json +0 -0
  97. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/correspondence_mismatch/doc.md +0 -0
  98. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/correspondence_mismatch/expected.json +0 -0
  99. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/correspondence_mismatch/repro.yaml +0 -0
  100. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/correspondence_side_absent/counts.json +0 -0
  101. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/correspondence_side_absent/doc.md +0 -0
  102. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/correspondence_side_absent/expected.json +0 -0
  103. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/correspondence_side_absent/repro.yaml +0 -0
  104. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/no_evidence_offered/expected.json +0 -0
  105. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/no_evidence_offered/repro.yaml +0 -0
  106. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/no_evidence_offered/results.json +0 -0
  107. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/no_evidence_offered/source.txt +0 -0
  108. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/no_evidence_offered/table.csv +0 -0
  109. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/passage_absent/expected.json +0 -0
  110. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/passage_absent/repro.yaml +0 -0
  111. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/passage_absent/results.json +0 -0
  112. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/passage_absent/source.txt +0 -0
  113. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/passage_absent/table.csv +0 -0
  114. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/passage_present/expected.json +0 -0
  115. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/passage_present/repro.yaml +0 -0
  116. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/passage_present/results.json +0 -0
  117. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/passage_present/source.txt +0 -0
  118. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/passage_present/table.csv +0 -0
  119. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/pointer_absent/expected.json +0 -0
  120. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/pointer_absent/repro.yaml +0 -0
  121. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/pointer_absent/results.json +0 -0
  122. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/pointer_absent/source.txt +0 -0
  123. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/pointer_absent/table.csv +0 -0
  124. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/pointer_escaped_key/expected.json +0 -0
  125. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/pointer_escaped_key/repro.yaml +0 -0
  126. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/pointer_escaped_key/results.json +0 -0
  127. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/pointer_escaped_key/source.txt +0 -0
  128. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/pointer_escaped_key/table.csv +0 -0
  129. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_anchor_absent/expected.json +0 -0
  130. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_anchor_absent/output.txt +0 -0
  131. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_anchor_absent/repro.yaml +0 -0
  132. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_anchor_splits_number/expected.json +0 -0
  133. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_anchor_splits_number/output.txt +0 -0
  134. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_anchor_splits_number/repro.yaml +0 -0
  135. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_anchors_ambiguous/counts.json +0 -0
  136. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_anchors_ambiguous/doc.md +0 -0
  137. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_anchors_ambiguous/expected.json +0 -0
  138. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_anchors_ambiguous/repro.yaml +0 -0
  139. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_number_as_word/counts.json +0 -0
  140. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_number_as_word/doc.md +0 -0
  141. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_number_as_word/expected.json +0 -0
  142. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_number_as_word/repro.yaml +0 -0
  143. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_table_cell_match/expected.json +0 -0
  144. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_table_cell_match/output.txt +0 -0
  145. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_table_cell_match/repro.yaml +0 -0
  146. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_table_cell_not_numeric/expected.json +0 -0
  147. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_table_cell_not_numeric/output.txt +0 -0
  148. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_table_cell_not_numeric/repro.yaml +0 -0
  149. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_value_match/counts.json +0 -0
  150. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_value_match/doc.md +0 -0
  151. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_value_match/expected.json +0 -0
  152. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/prose_value_match/repro.yaml +0 -0
  153. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_cell_match/expected.json +0 -0
  154. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_cell_match/repro.yaml +0 -0
  155. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_cell_match/results.json +0 -0
  156. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_cell_match/source.txt +0 -0
  157. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_cell_match/table.csv +0 -0
  158. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_cell_mismatch/expected.json +0 -0
  159. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_cell_mismatch/repro.yaml +0 -0
  160. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_cell_mismatch/results.json +0 -0
  161. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_cell_mismatch/source.txt +0 -0
  162. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_cell_mismatch/table.csv +0 -0
  163. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_column_absent/expected.json +0 -0
  164. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_column_absent/repro.yaml +0 -0
  165. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_column_absent/results.json +0 -0
  166. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_column_absent/source.txt +0 -0
  167. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_column_absent/table.csv +0 -0
  168. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_row_absent/expected.json +0 -0
  169. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_row_absent/repro.yaml +0 -0
  170. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_row_absent/results.json +0 -0
  171. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_row_absent/source.txt +0 -0
  172. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_row_absent/table.csv +0 -0
  173. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_row_ambiguous/expected.json +0 -0
  174. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_row_ambiguous/repro.yaml +0 -0
  175. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_row_ambiguous/results.json +0 -0
  176. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_row_ambiguous/source.txt +0 -0
  177. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/table_row_ambiguous/table.csv +0 -0
  178. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/unpinned_artifact/expected.json +0 -0
  179. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/unpinned_artifact/repro.yaml +0 -0
  180. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/unpinned_artifact/results.json +0 -0
  181. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/unpinned_artifact/source.txt +0 -0
  182. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/unpinned_artifact/table.csv +0 -0
  183. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_match/expected.json +0 -0
  184. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_match/repro.yaml +0 -0
  185. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_match/results.json +0 -0
  186. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_match/source.txt +0 -0
  187. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_match/table.csv +0 -0
  188. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_match_converted/expected.json +0 -0
  189. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_match_converted/rates.json +0 -0
  190. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_match_converted/repro.yaml +0 -0
  191. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_match_printed_precision/expected.json +0 -0
  192. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_match_printed_precision/repro.yaml +0 -0
  193. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_match_printed_precision/results.json +0 -0
  194. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_match_printed_precision/source.txt +0 -0
  195. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_match_printed_precision/table.csv +0 -0
  196. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_mismatch/expected.json +0 -0
  197. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_mismatch/repro.yaml +0 -0
  198. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_mismatch/results.json +0 -0
  199. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_mismatch/source.txt +0 -0
  200. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_mismatch/table.csv +0 -0
  201. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_mismatch_converted/expected.json +0 -0
  202. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_mismatch_converted/rates.json +0 -0
  203. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_mismatch_converted/repro.yaml +0 -0
  204. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_not_numeric/expected.json +0 -0
  205. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_not_numeric/repro.yaml +0 -0
  206. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_not_numeric/results.json +0 -0
  207. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_not_numeric/source.txt +0 -0
  208. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_not_numeric/table.csv +0 -0
  209. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_places_mismatch/expected.json +0 -0
  210. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_places_mismatch/halves.json +0 -0
  211. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_places_mismatch/repro.yaml +0 -0
  212. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_tie_either_neighbor/expected.json +0 -0
  213. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_tie_either_neighbor/halves.json +0 -0
  214. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/cases/value_tie_either_neighbor/repro.yaml +0 -0
  215. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/conformance/test_conformance.py +0 -0
  216. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/fixtures/records-0.5.6.jsonl +0 -0
  217. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_audit_regressions.py +0 -0
  218. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_claims_alone.py +0 -0
  219. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_correspondence.py +0 -0
  220. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_formats.py +0 -0
  221. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_locators.py +0 -0
  222. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_ordering.py +0 -0
  223. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_origins.py +0 -0
  224. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_provenance.py +0 -0
  225. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_read_once.py +0 -0
  226. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_recorded_version.py +0 -0
  227. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_regression.py +0 -0
  228. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_sarif.py +0 -0
  229. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_tables.py +0 -0
  230. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_toolchain.py +0 -0
  231. {claims_cli-0.6.0 → claims_cli-0.6.1}/tests/test_verify_edges.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: claims-cli
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: Check what a manuscript states against the files it names: numbers, table cells and quotations
5
5
  Project-URL: Changelog, https://github.com/elliottower/reproducible-science/blob/main/CHANGELOG.md
6
6
  Project-URL: Homepage, https://github.com/elliottower/reproducible-science
@@ -124,13 +124,37 @@ Counts every number the manuscript's text prints and says which a claim accounts
124
124
  claims export record
125
125
  ```
126
126
 
127
- Writes one record per checked assertion, for another program to read. `sarif` and `ro-crate` write the same records in those formats.
127
+ Writes one record per checked assertion, for another program to read. `sarif` and `ro-crate` write the same records in those formats. Each record names its version, `reproducible.science/claim-check/0.1-experimental`, and 0.6 also reads records under `repro.check/0.1-experimental`, the name 0.5.6 wrote. The JSON Schema is at <https://reproducible.science/schemas/claim-check-0.1-experimental.schema.json>, and the [check record](https://reproducible.science/concepts/check-record/) page describes the format.
128
128
 
129
129
  ```bash
130
130
  claims origins --repo https://github.com/owner/study=../study
131
131
  ```
132
132
 
133
- For each artifact copied from another repository, which the manifest says with `origin: {repository, commit, path}`, compares the pinned digest with the bytes of that path at that commit: `same`, `differs`, `absent`, `unknown commit` or `not checked`, each with the reason. A clone given with `--repo` is read with `git cat-file`, so committed bytes are compared and never a working tree. With `--fetch`, a GitHub repository no clone is given for is read from `raw.githubusercontent.com`; without it nothing touches the network. `claims verify` never reads an origin.
133
+ For each artifact copied from another repository, compares the pinned digest with the bytes of that path at that commit. The artifact names its source with `origin`:
134
+
135
+ ```yaml
136
+ artifacts:
137
+ - id: indices
138
+ path: artifacts/indices.json
139
+ digest: {algorithm: sha256, value: 3db72e39...}
140
+ origin:
141
+ repository: https://github.com/owner/study
142
+ commit: d4d6909cd7a99bec2416c2fe561b1a04d5bf5802
143
+ path: results/indices.json
144
+ ```
145
+
146
+ `commit` is the full 40-character id, and `path` is relative to that repository's root; a branch, a tag, a short id or a path with `..` is refused when the manifest is read. Here the copy was edited after it was taken:
147
+
148
+ ```text
149
+ DIFFERS indices: https://github.com/owner/study d4d6909cd7a9:results/indices.json
150
+ the origin's bytes do not have the pinned digest (read from /home/you/work/study)
151
+ pinned 3db72e396caeafded64ab436f341936577b90ad3767a6edb59dea9045d20c5e0
152
+ at origin 2ec7fab1cf2458f30591cc157b23cc50380644ee085a46b9b23237650456e4c4
153
+
154
+ 1 origins: 0 same, 1 differs, 0 absent, 0 unknown commit, 0 not checked
155
+ ```
156
+
157
+ Each origin is `same`, `differs`, `absent`, `unknown commit` or `not checked`, with the reason. A clone given with `--repo REPOSITORY=PATH`, or a repository named by a local path, is read with `git cat-file`, so committed bytes are compared and never a working tree. With `--fetch`, a GitHub repository no clone is given for is read from `raw.githubusercontent.com`; without it nothing touches the network. It exits 0 where every origin is `same`, 1 where one differs or is absent, and 2 where one could not be checked and none failed, or where no artifact declares an origin. `claims verify` never reads an origin, and `claims export record` carries the declared origin on each file it read.
134
158
 
135
159
  ## With `repro`
136
160
 
@@ -82,13 +82,37 @@ Counts every number the manuscript's text prints and says which a claim accounts
82
82
  claims export record
83
83
  ```
84
84
 
85
- Writes one record per checked assertion, for another program to read. `sarif` and `ro-crate` write the same records in those formats.
85
+ Writes one record per checked assertion, for another program to read. `sarif` and `ro-crate` write the same records in those formats. Each record names its version, `reproducible.science/claim-check/0.1-experimental`, and 0.6 also reads records under `repro.check/0.1-experimental`, the name 0.5.6 wrote. The JSON Schema is at <https://reproducible.science/schemas/claim-check-0.1-experimental.schema.json>, and the [check record](https://reproducible.science/concepts/check-record/) page describes the format.
86
86
 
87
87
  ```bash
88
88
  claims origins --repo https://github.com/owner/study=../study
89
89
  ```
90
90
 
91
- For each artifact copied from another repository, which the manifest says with `origin: {repository, commit, path}`, compares the pinned digest with the bytes of that path at that commit: `same`, `differs`, `absent`, `unknown commit` or `not checked`, each with the reason. A clone given with `--repo` is read with `git cat-file`, so committed bytes are compared and never a working tree. With `--fetch`, a GitHub repository no clone is given for is read from `raw.githubusercontent.com`; without it nothing touches the network. `claims verify` never reads an origin.
91
+ For each artifact copied from another repository, compares the pinned digest with the bytes of that path at that commit. The artifact names its source with `origin`:
92
+
93
+ ```yaml
94
+ artifacts:
95
+ - id: indices
96
+ path: artifacts/indices.json
97
+ digest: {algorithm: sha256, value: 3db72e39...}
98
+ origin:
99
+ repository: https://github.com/owner/study
100
+ commit: d4d6909cd7a99bec2416c2fe561b1a04d5bf5802
101
+ path: results/indices.json
102
+ ```
103
+
104
+ `commit` is the full 40-character id, and `path` is relative to that repository's root; a branch, a tag, a short id or a path with `..` is refused when the manifest is read. Here the copy was edited after it was taken:
105
+
106
+ ```text
107
+ DIFFERS indices: https://github.com/owner/study d4d6909cd7a9:results/indices.json
108
+ the origin's bytes do not have the pinned digest (read from /home/you/work/study)
109
+ pinned 3db72e396caeafded64ab436f341936577b90ad3767a6edb59dea9045d20c5e0
110
+ at origin 2ec7fab1cf2458f30591cc157b23cc50380644ee085a46b9b23237650456e4c4
111
+
112
+ 1 origins: 0 same, 1 differs, 0 absent, 0 unknown commit, 0 not checked
113
+ ```
114
+
115
+ Each origin is `same`, `differs`, `absent`, `unknown commit` or `not checked`, with the reason. A clone given with `--repo REPOSITORY=PATH`, or a repository named by a local path, is read with `git cat-file`, so committed bytes are compared and never a working tree. With `--fetch`, a GitHub repository no clone is given for is read from `raw.githubusercontent.com`; without it nothing touches the network. It exits 0 where every origin is `same`, 1 where one differs or is absent, and 2 where one could not be checked and none failed, or where no artifact declares an origin. `claims verify` never reads an origin, and `claims export record` carries the declared origin on each file it read.
92
116
 
93
117
  ## With `repro`
94
118
 
@@ -4,7 +4,7 @@ requires = [ "hatchling" ]
4
4
 
5
5
  [project]
6
6
  name = "claims-cli"
7
- version = "0.6.0"
7
+ version = "0.6.1"
8
8
  description = "Check what a manuscript states against the files it names: numbers, table cells and quotations"
9
9
  readme = "README.md"
10
10
  keywords = [ "citations", "manuscript", "open science", "provenance", "reproducibility" ]
@@ -21,15 +21,28 @@ stored, `prev_hash`, and a head file beside the record, `ledger.head`, holds the
21
21
  entries and the hash of the last. These are the `results` ledger's fields and its writer:
22
22
  `provenance_core.chain.append_event` appends under a lock held across reading the last entry and
23
23
  writing the next, so two checks running at once write two entries in a row and not two
24
- claiming one position, and it refuses to append to a chain that does not verify.
24
+ claiming one position.
25
+
26
+ **An index, so a check does not read the record.** A check needs the last state recorded for
27
+ each assertion it found, to append only what changed. `checks.index.sqlite`, beside the local
28
+ record, holds that state per assertion and where each entry starts, with the head, length and
29
+ size of the record it describes. Where those are the record's now and the last entry hashes to
30
+ the head file's head, `record` reads nothing else of the record, and its time does not grow
31
+ with the record. Otherwise it reads both records whole, checks their chains, refuses to append
32
+ to one that does not verify, and writes the index again. The tracked record has no index; it
33
+ is a copy, and the entries it lacks are copied as bytes from the local one.
25
34
 
26
35
  Reading is done here and not by `provenance_core.chain.verify`, which takes a lock by creating a file
27
36
  beside the record: `repro verify` and `repro why` must leave the working tree as it is.
28
37
 
29
38
  **What the chain shows, and what it does not.** An entry edited, removed from the middle or
30
- moved is found, with its number, and the entries from there on are shown as the record holds
31
- them and marked unverifiable. Entries cut from the end are found while the head file is as it
32
- was. A record and its head file cut back together, or deleted together and grown again, look
39
+ moved is found, with its number, where a record is read whole: by `repro why`, by `repro verify
40
+ --set-aside-record`, and by the first check whose index no longer describes the record. The
41
+ entries from there on are shown as the record holds them and marked unverifiable. A check whose
42
+ index describes the record appends after such an edit, and the edit stays where it was, since
43
+ the append rewrites no entry and the `prev_hash` after the edit still names the entry as it was
44
+ written. An entry edited at the end is found by every check. Entries cut from the end are found
45
+ while the head file is as it was. A record and its head file cut back together, or deleted together and grown again, look
33
46
  like a shorter or a new record: nothing inside the two files can show it. The local record has
34
47
  no witness outside its directory. The tracked record's head file is committed with it, so the
35
48
  repository's history holds every earlier head, and that is what makes a truncation visible to
@@ -41,13 +54,23 @@ from __future__ import annotations
41
54
 
42
55
  import collections
43
56
  import datetime
57
+ import functools
44
58
  import json
45
59
  import os
46
60
  import pathlib
61
+ import sqlite3
62
+ from collections.abc import Iterable
47
63
  from typing import Literal
48
64
 
49
65
  from provenance_core import ZERO, exclusive_lock, sha256_of_text, try_run
50
- from provenance_core.chain import ANCHOR, ChainStatus, append_event, read_anchor, write_anchor
66
+ from provenance_core.chain import (
67
+ ANCHOR,
68
+ ChainStatus,
69
+ append_event,
70
+ read_anchor,
71
+ tail_agrees,
72
+ write_anchor,
73
+ )
51
74
  from pydantic import ValidationError
52
75
 
53
76
  from claims.exceptions import ReproError
@@ -199,7 +222,9 @@ def _raw(path: pathlib.Path) -> list[str]:
199
222
  """A record's entries as stored, one per line."""
200
223
  if not path.is_file():
201
224
  return []
202
- return [line.strip() for line in path.read_text(encoding="utf-8").splitlines() if line.strip()]
225
+ # Line feeds only, as `provenance_core.chain` reads a chain: `str.splitlines` also breaks at
226
+ # U+2028 and U+2029, which a quoted passage can hold.
227
+ return [line.strip() for line in path.read_text(encoding="utf-8").split("\n") if line.strip()]
203
228
 
204
229
 
205
230
  def _parsed(raw: str) -> CheckRecord | None:
@@ -209,12 +234,18 @@ def _parsed(raw: str) -> CheckRecord | None:
209
234
  return None
210
235
 
211
236
 
212
- def _chain(path: pathlib.Path, kind: Kind, lines: list[str]) -> RecordState:
237
+ def _chain(
238
+ path: pathlib.Path,
239
+ kind: Kind,
240
+ lines: list[str],
241
+ parsed: dict[str, CheckRecord | None] | None = None,
242
+ ) -> RecordState:
213
243
  """Whether each entry follows from the one before it, and whether the head file agrees.
214
244
 
215
245
  The status is the first fault's, as in the `results` ledger: a chain edited and then cut
216
- is edited.
246
+ is edited. `parsed` holds entries already read, by line, so a line is parsed once.
217
247
  """
248
+ parsed = {} if parsed is None else parsed
218
249
  status, problems, first = ChainStatus.INTACT, [], None
219
250
 
220
251
  def fault(found: ChainStatus, entry: int, said: str) -> None:
@@ -226,7 +257,9 @@ def _chain(path: pathlib.Path, kind: Kind, lines: list[str]) -> RecordState:
226
257
 
227
258
  prev = ZERO
228
259
  for number, raw in enumerate(lines, start=1):
229
- entry = _parsed(raw)
260
+ if raw not in parsed:
261
+ parsed[raw] = _parsed(raw)
262
+ entry = parsed[raw]
230
263
  if entry is None:
231
264
  fault(ChainStatus.CORRUPT, number, f"entry {number} is not one `repro verify` wrote")
232
265
  else:
@@ -298,10 +331,13 @@ class Records:
298
331
 
299
332
  states = []
300
333
  vouched: dict[str, bool] = {}
334
+ # Each line parsed once, here and in `_chain`: a record shared by a repository's
335
+ # projects grows to megabytes, and its entries are the largest lines it holds.
336
+ parsed: dict[str, CheckRecord | None] = {}
301
337
  for kind, path, lines in (("local", self.local, here), ("tracked", self.tracked, there)):
302
338
  if path is None or not (lines or read_anchor(path)):
303
339
  continue
304
- state = _chain(path, kind, lines)
340
+ state = _chain(path, kind, lines, parsed)
305
341
  if kind == "tracked" and here and shared < min(len(here), len(there)):
306
342
  state = state.model_copy(update={"diverges_at": shared + 1})
307
343
  states.append(state)
@@ -313,31 +349,223 @@ class Records:
313
349
 
314
350
  # What the two share, then what each holds beyond it, in the order appended.
315
351
  # An entry that does not parse is counted as a fault above and holds nothing to show.
316
- read = {raw: entry for raw in (*here, *there) if (entry := _parsed(raw)) is not None}
352
+ read = {
353
+ raw: entry
354
+ for raw in (*here, *there)
355
+ if (entry := parsed[raw] if raw in parsed else _parsed(raw)) is not None
356
+ }
317
357
  beyond = sorted(
318
358
  (raw for raw in dict.fromkeys(here[shared:] + there[shared:]) if raw in read),
319
359
  key=lambda raw: read[raw].timestamp,
320
360
  )
361
+ self._read = read
362
+ self._vouched = vouched
363
+ self._order = (*(raw for raw in here[:shared] if raw in read), *beyond)
364
+ # The last way an entry holds each assertion, as stored: what `record` compares a
365
+ # check with. `history` is built from the same entries only where it is asked for.
366
+ self.latest: dict[Identity, CheckedAssertion] = {
367
+ assertion.identity: assertion
368
+ for raw in self._order
369
+ for assertion in read[raw].assertions
370
+ }
371
+ self.set_aside = tuple(
372
+ note.model_copy(update={"at": read[raw].timestamp})
373
+ for raw in self._order
374
+ if (note := read[raw].set_aside) is not None
375
+ )
376
+
377
+ @functools.cached_property
378
+ def history(self) -> dict[Identity, tuple[CheckedAssertion, ...]]:
379
+ """Each way an entry holds each assertion, oldest first, with when it was checked and
380
+ whether the chain vouches for the entry."""
321
381
  found: dict[Identity, list[CheckedAssertion]] = collections.defaultdict(list)
322
- for raw in (*(raw for raw in here[:shared] if raw in read), *beyond):
323
- entry = read[raw]
382
+ for raw in self._order:
383
+ entry = self._read[raw]
324
384
  for assertion in entry.assertions:
325
385
  found[assertion.identity].append(
326
386
  assertion.model_copy(
327
- update={"checked_at": entry.timestamp, "verifiable": vouched[raw]}
387
+ update={"checked_at": entry.timestamp, "verifiable": self._vouched[raw]}
328
388
  )
329
389
  )
330
- self.history = {identity: tuple(states) for identity, states in found.items()}
331
- self.set_aside = tuple(
332
- note.model_copy(update={"at": read[raw].timestamp})
333
- for raw in (*(raw for raw in here[:shared] if raw in read), *beyond)
334
- if (note := read[raw].set_aside) is not None
335
- )
390
+ return {identity: tuple(states) for identity, states in found.items()}
336
391
 
337
392
  def state(self, kind: Kind) -> RecordState | None:
338
393
  return next((state for state in self.states if state.kind == kind), None)
339
394
 
340
395
 
396
+ #: The index of the local record, beside it in the git directory. A cache, rebuilt from the
397
+ #: record whenever it does not describe the record's current head, and never committed.
398
+ INDEX = "checks.index.sqlite"
399
+ #: Bumped when what the index holds changes, so an index of another layout is rebuilt.
400
+ INDEX_VERSION = "1"
401
+
402
+
403
+ def _identity(identity: Identity) -> str:
404
+ return json.dumps(list(identity), ensure_ascii=False)
405
+
406
+
407
+ def _entries(path: pathlib.Path) -> list[tuple[int, str]]:
408
+ """Each entry of a record as `_raw` gives it, with the byte offset its line starts at."""
409
+ found, at = [], 0
410
+ for piece in path.read_bytes().split(b"\n") if path.is_file() else []:
411
+ if raw := piece.decode("utf-8").strip():
412
+ found.append((at, raw))
413
+ at += len(piece) + 1
414
+ return found
415
+
416
+
417
+ class Index:
418
+ """What `record` needs from the local record without reading it: the last stored state of
419
+ each assertion, and where each entry starts and what it hashes to.
420
+
421
+ Held in SQLite beside the record, with the record's head, length and size in bytes at the
422
+ time it was written. It is used only where those are the record's now and the record's last
423
+ entry hashes to the head its head file records; otherwise the record is read whole, its
424
+ chain checked, and the index written again from it. It is written whole only from a record
425
+ whose chain verifies, and then advanced only by the entries `record` appends. An entry
426
+ edited later is found by the check of the last entry where it is the last, and by a whole
427
+ read, as the module says, where it is not. Every write to it is one transaction, made after
428
+ the record's own write, so a crash between the two leaves an index describing an older
429
+ head, which is then rebuilt.
430
+ """
431
+
432
+ def __init__(self, record_path: pathlib.Path) -> None:
433
+ self.record = record_path
434
+ self.path = record_path.with_name(INDEX)
435
+ self.db = sqlite3.connect(self.path, isolation_level=None)
436
+ self.db.executescript(
437
+ "CREATE TABLE IF NOT EXISTS meta (key TEXT PRIMARY KEY, value TEXT NOT NULL);"
438
+ "CREATE TABLE IF NOT EXISTS lines "
439
+ "(seq INTEGER PRIMARY KEY, start INTEGER NOT NULL, hash TEXT NOT NULL);"
440
+ "CREATE TABLE IF NOT EXISTS latest (identity TEXT PRIMARY KEY, assertion TEXT NOT NULL);"
441
+ )
442
+
443
+ @classmethod
444
+ def open(cls, record_path: pathlib.Path) -> Index | None:
445
+ """The index, or None where it cannot be opened: then the record is read whole."""
446
+ try:
447
+ record_path.parent.mkdir(parents=True, exist_ok=True)
448
+ return cls(record_path)
449
+ except (sqlite3.Error, OSError):
450
+ return None
451
+
452
+ def close(self) -> None:
453
+ self.db.close()
454
+
455
+ def _meta(self) -> dict[str, str]:
456
+ return dict(self.db.execute("SELECT key, value FROM meta"))
457
+
458
+ def _size(self) -> int:
459
+ return self.record.stat().st_size if self.record.is_file() else 0
460
+
461
+ def current(self, tracked: pathlib.Path) -> bool:
462
+ """Whether the index describes the record as it is now, and the tracked record, if
463
+ there is one, holds no entry the local one does not: then nothing needs reading.
464
+
465
+ The record's head, length and size must be the index's, and its last entry must hash
466
+ to the head its head file records and hold the position the count gives it. The tracked
467
+ record must be absent, or have a head file whose count is no more than the local
468
+ record's and whose head is the local entry at that position.
469
+ """
470
+ try:
471
+ meta = self._meta()
472
+ if meta.get("version") != INDEX_VERSION or meta.get("size") != str(self._size()):
473
+ return False
474
+ count = int(meta.get("count", "-1"))
475
+ if count == 0:
476
+ if self.record.is_file() and self._size():
477
+ return False
478
+ else:
479
+ agreed = tail_agrees(self.record)
480
+ if agreed is None or agreed != (count, meta.get("head")):
481
+ return False
482
+ return self._follows(tracked, count) is not None
483
+ except (sqlite3.Error, OSError, ValueError):
484
+ return False
485
+
486
+ def _follows(self, tracked: pathlib.Path, count: int) -> int | None:
487
+ """How many entries the tracked record holds, where it is the beginning of the local
488
+ one by its head file; None where that cannot be told from the two head files."""
489
+ anchor = read_anchor(tracked)
490
+ if anchor is None:
491
+ return 0 if not tracked.is_file() or not tracked.stat().st_size else None
492
+ held = anchor.get("count")
493
+ if not isinstance(held, int) or held > count:
494
+ return None
495
+ if held == 0:
496
+ return 0
497
+ found = self.db.execute("SELECT hash FROM lines WHERE seq = ?", (held - 1,)).fetchone()
498
+ return held if found is not None and found[0] == anchor.get("head") else None
499
+
500
+ def latest(self, identities: Iterable[Identity]) -> dict[Identity, CheckedAssertion]:
501
+ """The last stored state of each of these assertions that the record holds."""
502
+ wanted = {_identity(identity): identity for identity in identities}
503
+ keys, found = list(wanted), {}
504
+ for start in range(0, len(keys), 500):
505
+ chunk = keys[start : start + 500]
506
+ marks = ",".join("?" * len(chunk))
507
+ rows = self.db.execute(
508
+ f"SELECT identity, assertion FROM latest WHERE identity IN ({marks})", chunk
509
+ )
510
+ for key, assertion in rows:
511
+ found[wanted[key]] = CheckedAssertion.model_validate_json(assertion)
512
+ return found
513
+
514
+ def rebuild(self, parsed: dict[str, CheckRecord]) -> None:
515
+ """Write the index again from the record as it is now. `parsed` holds the entries the
516
+ caller has read, by line; any other line is parsed here."""
517
+ entries = _entries(self.record)
518
+ anchor = read_anchor(self.record) or {}
519
+ latest: dict[str, str] = {}
520
+ rows = []
521
+ for seq, (start, raw) in enumerate(entries):
522
+ rows.append((seq, start, sha256_of_text(raw)))
523
+ entry = parsed.get(raw) or _parsed(raw)
524
+ for assertion in entry.assertions if entry is not None else ():
525
+ latest[_identity(assertion.identity)] = assertion.model_dump_json()
526
+ self.db.execute("BEGIN IMMEDIATE")
527
+ self.db.execute("DELETE FROM meta")
528
+ self.db.execute("DELETE FROM lines")
529
+ self.db.execute("DELETE FROM latest")
530
+ self.db.executemany("INSERT INTO lines VALUES (?, ?, ?)", rows)
531
+ self.db.executemany("INSERT INTO latest VALUES (?, ?)", latest.items())
532
+ self._set_meta(
533
+ count=anchor.get("count", len(rows)) if anchor else len(rows),
534
+ head=anchor.get("head", rows[-1][2] if rows else ZERO),
535
+ )
536
+ self.db.execute("COMMIT")
537
+
538
+ def advance(self, start: int, written: dict, changed: list[CheckedAssertion]) -> None:
539
+ """Add the entry just appended at byte `start`, which the record's head file now names."""
540
+ anchor = read_anchor(self.record) or {}
541
+ self.db.execute("BEGIN IMMEDIATE")
542
+ self.db.execute(
543
+ "INSERT OR REPLACE INTO lines VALUES (?, ?, ?)",
544
+ (written["seq"], start, anchor.get("head", "")),
545
+ )
546
+ self.db.executemany(
547
+ "INSERT OR REPLACE INTO latest VALUES (?, ?)",
548
+ [(_identity(assertion.identity), assertion.model_dump_json()) for assertion in changed],
549
+ )
550
+ self._set_meta(count=anchor.get("count", 0), head=anchor.get("head", ""))
551
+ self.db.execute("COMMIT")
552
+
553
+ def start_of(self, seq: int) -> int | None:
554
+ found = self.db.execute("SELECT start FROM lines WHERE seq = ?", (seq,)).fetchone()
555
+ return found[0] if found else None
556
+
557
+ def _set_meta(self, count: int, head: str) -> None:
558
+ self.db.executemany(
559
+ "INSERT OR REPLACE INTO meta VALUES (?, ?)",
560
+ [
561
+ ("version", INDEX_VERSION),
562
+ ("count", str(count)),
563
+ ("head", head),
564
+ ("size", str(self._size())),
565
+ ],
566
+ )
567
+
568
+
341
569
  def _take(behind: pathlib.Path, lines: list[str], held: int) -> None:
342
570
  """Append to one record the entries another holds beyond it, as stored, and move its head
343
571
  file."""
@@ -362,6 +590,15 @@ def record(
362
590
  tracked one as well where `tracked`. Nothing is written where every assertion is as it
363
591
  was last recorded and the tracked record, if asked for, already holds every local entry.
364
592
 
593
+ Where the local record's `Index` describes it as it is now, nothing else of the record is
594
+ read: the last entry is checked against the head file, the assertions this check found are
595
+ compared with the states the index holds for them, and the tracked record is brought up to
596
+ the local one by copying the entries it lacks. Otherwise both records are read whole, their
597
+ chains checked, and the index written again. A chain edited at its end is refused either
598
+ way. An entry edited further back is found where the records are read whole, by `repro why`
599
+ and `repro verify --set-aside-record`, and by the first check after the index stops
600
+ describing the record.
601
+
365
602
  Raises `RecordBrokenError` where the chain to append to does not verify,
366
603
  `RecordDivergedError` where the tracked record is not the beginning of the local one, and
367
604
  `OSError` where a record cannot be written.
@@ -374,54 +611,145 @@ def record(
374
611
  if written is None:
375
612
  return
376
613
 
614
+ index = Index.open(kept) if kept is not None else None
615
+ try:
616
+ _record(manifest, report, root, kept, carried, written, index, program)
617
+ if tracked and kept is not None:
618
+ with exclusive_lock(carried):
619
+ if not _carry(index, kept, carried):
620
+ _carry_reading_both(kept, carried, program)
621
+ finally:
622
+ if index is not None:
623
+ index.close()
624
+
625
+
626
+ def _record(
627
+ manifest: Manifest,
628
+ report: VerificationReport,
629
+ root: pathlib.Path,
630
+ kept: pathlib.Path | None,
631
+ carried: pathlib.Path,
632
+ written: pathlib.Path,
633
+ index: Index | None,
634
+ program: str,
635
+ ) -> None:
377
636
  # One lock across reading the last entries and writing the next, so two checks at once
378
637
  # append one after the other and the second finds what the first wrote.
379
638
  with exclusive_lock(written):
380
- found = Records(root, local)
381
- here, there = found.lines["local"], found.lines["tracked"]
382
- carried_state = found.state("tracked")
383
- if (
384
- kept is not None
385
- and _prefix(here, there) == len(here) < len(there)
386
- and carried_state is not None
387
- and carried_state.unverifiable_from is None
388
- ):
389
- # A clone, or a pull: the tracked record holds entries this clone has not seen.
390
- _take(kept, there, len(here))
391
- found = Records(root, local)
392
- state = found.state("local" if kept is not None else "tracked")
393
- if state is not None and ChainStatus(state.status) not in _SOUND:
394
- raise RecordBrokenError(state, program)
395
- changed = [
639
+ found = [
396
640
  assertion
397
641
  for claim, assessed in zip(manifest.claims, report.claims, strict=True)
398
642
  for assertion in checked(claim, assessed.decisions)
399
- if assertion.identity not in found.history
400
- or not assertion.same_as(found.history[assertion.identity][-1])
401
643
  ]
402
- if changed:
403
- append_event(
404
- written,
405
- {
406
- "schema_version": CheckRecord.model_fields["schema_version"].default,
407
- "assertions": [
408
- assertion.model_dump(mode="json", exclude={"checked_at", "verifiable"})
409
- for assertion in changed
410
- ],
411
- },
412
- )
644
+ if index is not None and index.current(carried):
645
+ latest = index.latest(assertion.identity for assertion in found)
646
+ ready = True
647
+ else:
648
+ records = _read_whole(root, kept, program)
649
+ latest, ready = records.latest, False
650
+ if index is not None:
651
+ try:
652
+ index.rebuild(records._read)
653
+ ready = True
654
+ except (sqlite3.Error, OSError):
655
+ ready = False
656
+ changed = [
657
+ assertion
658
+ for assertion in found
659
+ if assertion.identity not in latest or not assertion.same_as(latest[assertion.identity])
660
+ ]
661
+ if not changed:
662
+ return
663
+ start = written.stat().st_size if written.is_file() else 0
664
+ # The chain has been checked above, whole or at its end against the head file, so the
665
+ # append checks only that the last entry is the one the head file records.
666
+ appended = append_event(
667
+ written,
668
+ {
669
+ "schema_version": CheckRecord.model_fields["schema_version"].default,
670
+ "assertions": [
671
+ assertion.model_dump(mode="json", exclude={"checked_at", "verifiable"})
672
+ for assertion in changed
673
+ ],
674
+ },
675
+ whole_chain=False,
676
+ )
677
+ if ready and index is not None:
678
+ try:
679
+ index.advance(start, appended, changed)
680
+ except sqlite3.Error:
681
+ # The index now describes an older head, and the next check rebuilds it.
682
+ pass
683
+
684
+
685
+ def _read_whole(root: pathlib.Path, kept: pathlib.Path | None, program: str) -> Records:
686
+ """Both records read whole, the entries the tracked one holds beyond the local one taken,
687
+ and the chain to append to checked. Raises `RecordBrokenError` where it does not verify."""
688
+ found = Records(root, kept is not None)
689
+ here, there = found.lines["local"], found.lines["tracked"]
690
+ carried_state = found.state("tracked")
691
+ if (
692
+ kept is not None
693
+ and _prefix(here, there) == len(here) < len(there)
694
+ and carried_state is not None
695
+ and carried_state.unverifiable_from is None
696
+ ):
697
+ # A clone, or a pull: the tracked record holds entries this clone has not seen.
698
+ _take(kept, there, len(here))
699
+ found = Records(root, True)
700
+ state = found.state("local" if kept is not None else "tracked")
701
+ if state is not None and ChainStatus(state.status) not in _SOUND:
702
+ raise RecordBrokenError(state, program)
703
+ return found
704
+
705
+
706
+ def _carry(index: Index | None, kept: pathlib.Path, carried: pathlib.Path) -> bool:
707
+ """Bring the tracked record up to the local one from the index, copying the bytes of the
708
+ entries it lacks. False, having written nothing, where the index cannot say that the
709
+ tracked record is the local one's beginning with an intact end."""
710
+ if index is None or not index.current(carried):
711
+ return False
712
+ meta = index._meta()
713
+ count, head = int(meta["count"]), meta["head"]
714
+ held = index._follows(carried, count)
715
+ if held is None or held == count:
716
+ return held == count
717
+ if held and (tail_agrees(carried) is None or not _ends_a_line(carried)):
718
+ return False
719
+ start = index.start_of(held)
720
+ if start is None:
721
+ return False
722
+ with kept.open("rb") as source:
723
+ source.seek(start)
724
+ missing = source.read()
725
+ carried.parent.mkdir(parents=True, exist_ok=True)
726
+ with carried.open("ab") as handle:
727
+ handle.write(missing)
728
+ handle.flush()
729
+ os.fsync(handle.fileno())
730
+ write_anchor(carried, count, head)
731
+ return True
732
+
733
+
734
+ def _ends_a_line(path: pathlib.Path) -> bool:
735
+ """Whether a file's last byte is a line feed, read without reading the rest."""
736
+ with path.open("rb") as handle:
737
+ if not handle.seek(0, os.SEEK_END):
738
+ return False
739
+ handle.seek(-1, os.SEEK_END)
740
+ return handle.read(1) == b"\n"
741
+
413
742
 
414
- if tracked and kept is not None:
415
- with exclusive_lock(carried):
416
- here, there = _raw(kept), _raw(carried)
417
- shared = _prefix(here, there)
418
- if shared < len(there):
419
- raise RecordDivergedError(carried, shared + 1)
420
- state = _chain(carried, "tracked", there)
421
- if there and ChainStatus(state.status) not in _SOUND:
422
- raise RecordBrokenError(state, program)
423
- if len(here) > len(there):
424
- _take(carried, here, len(there))
743
+ def _carry_reading_both(kept: pathlib.Path, carried: pathlib.Path, program: str) -> None:
744
+ here, there = _raw(kept), _raw(carried)
745
+ shared = _prefix(here, there)
746
+ if shared < len(there):
747
+ raise RecordDivergedError(carried, shared + 1)
748
+ state = _chain(carried, "tracked", there)
749
+ if there and ChainStatus(state.status) not in _SOUND:
750
+ raise RecordBrokenError(state, program)
751
+ if len(here) > len(there):
752
+ _take(carried, here, len(there))
425
753
 
426
754
 
427
755
  def _move_aside(path: pathlib.Path, state: RecordState, lines: list[str]) -> RecordSetAside:
@@ -495,10 +823,12 @@ def set_aside(
495
823
 
496
824
 
497
825
  __all__ = [
826
+ "INDEX",
498
827
  "LOCAL",
499
828
  "NOT_A_REPOSITORY",
500
829
  "RECORD",
501
830
  "Identity",
831
+ "Index",
502
832
  "RecordBrokenError",
503
833
  "RecordDivergedError",
504
834
  "RecordIntactError",