Source file checks_intf.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
open! Import
type empty = |
module type Subcommand = sig
type run
val run : run
val term_internal : (unit -> unit) Cmdliner.Term.t
(** A pre-packaged [Cmdliner] term for executing {!run}. *)
val term : (unit Cmdliner.Term.t * Cmdliner.Term.info[@alert "-deprecated"])
(** [term] is {!term_internal} plus documentation and logs initialisation *)
end
module type S = sig
(** Reads basic metrics from an existing store and prints them to stdout. *)
module Stat : sig
include Subcommand with type run := root:string -> unit Lwt.t
(** Internal implementation utilities exposed for use in other integrity
checks. *)
type size = Bytes of int [@@deriving irmin]
type objects = { nb_commits : int; nb_nodes : int; nb_contents : int }
[@@deriving irmin]
val traverse_index : root:string -> int -> objects
end
module Reconstruct_index :
Subcommand
with type run :=
root:string ->
output:string option ->
?index_log_size:int ->
unit ->
unit
(** Rebuilds an index for an existing pack file *)
(** Checks the integrity of a store *)
module Integrity_check : sig
include
Subcommand
with type run :=
root:string ->
auto_repair:bool ->
always:bool ->
heads:string list option ->
unit Lwt.t
val handle_result :
?name:string ->
( [< `Fixed of int | `No_error ],
[< `Cannot_fix of string | `Corrupted of int ] )
result ->
unit
end
(** Checks the integrity of the index in a store *)
module Integrity_check_index : sig
include
Subcommand
with type run := root:string -> auto_repair:bool -> unit -> unit
end
(** Checks the integrity of inodes in a store *)
module Integrity_check_inodes : sig
include
Subcommand
with type run := root:string -> heads:string list option -> unit Lwt.t
end
(** Traverses a commit to get stats on its underlying tree. *)
module Stats_commit : sig
include
Subcommand
with type run :=
root:string ->
commit:string option ->
dump_blob_paths_to:string option ->
unit ->
unit Lwt.t
end
val cli :
?terms:
((unit Cmdliner.Term.t * Cmdliner.Term.info)[@alert "-deprecated"]) list ->
unit ->
empty
(** Run a [Cmdliner] binary containing tools for running offline checks.
[terms] defaults to the set of checks in this module. *)
end
module type Store = sig
include Irmin.S
include Store_intf.S with type repo := repo and type commit := commit
end
type integrity_error = [ `Wrong_hash | `Absent_value ]
module type Sigs = sig
type integrity_error = [ `Wrong_hash | `Absent_value ]
type nonrec empty = empty
val setup_log : unit Cmdliner.Term.t
val path : string Cmdliner.Term.t
module type Subcommand = Subcommand
module type S = S
module Make (_ : Store) : S
module Integrity_checks
(XKey : Pack_key.S)
(X : Irmin.Backend.S
with type Commit.key = XKey.t
and type Node.key = XKey.t
and type Schema.Hash.t = XKey.hash)
(Index : Pack_index.S) : sig
val check_always :
?ppf:Format.formatter ->
auto_repair:bool ->
check:
(kind:[> `Commit | `Contents | `Node ] ->
offset:int63 ->
length:int ->
Index.key ->
(unit, [< `Absent_value | `Wrong_hash ]) result) ->
Index.t ->
( [> `Fixed of int | `No_error ],
[> `Cannot_fix of string | `Corrupted of int ] )
result
val check_minimal :
?ppf:Format.formatter ->
pred:
(X.Node.value ->
(X.Node.Path.step option
* [< `Contents of XKey.t | `Inode of XKey.t | `Node of XKey.t ])
list) ->
iter:
(contents:(XKey.hash Pack_key.t -> unit Lwt.t) ->
node:(XKey.t -> unit Lwt.t) ->
pred_node:
(X.Repo.t ->
XKey.t ->
[> `Contents of XKey.t | `Node of XKey.t ] list Lwt.t) ->
pred_commit:(X.Repo.t -> XKey.t -> [> `Node of XKey.t ] list Lwt.t) ->
X.Repo.t ->
unit Lwt.t) ->
check:
(offset:int63 ->
length:int ->
XKey.hash ->
(unit, [< `Absent_value | `Wrong_hash ]) result) ->
recompute_hash:(X.Node.value -> XKey.hash) ->
X.Repo.t ->
([> `No_error ], [> `Cannot_fix of string ]) result Lwt.t
val check_inodes :
iter:
(pred_node:
(X.Repo.t ->
XKey.t ->
([> `Contents of XKey.t | `Node of XKey.t ] as 'a) list Lwt.t) ->
node:(XKey.t -> unit Lwt.t) ->
commit:(XKey.t -> unit Lwt.t) ->
X.Repo.t ->
unit Lwt.t) ->
pred:(X.Repo.t -> XKey.t -> 'a list Lwt.t) ->
check:(XKey.t -> (unit, string) result Lwt.t) ->
X.Repo.t ->
([> `No_error ], [> `Cannot_fix of string ]) result Lwt.t
end
module Stats (S : sig
type step
val step_t : step Irmin.Type.t
module Hash : Irmin.Hash.S
end) : sig
type t
val v : unit -> t
val visit_commit : t -> S.Hash.t -> unit
val visit_contents : t -> S.Hash.t -> unit
val visit_node :
t ->
S.Hash.t ->
(S.step option
* [ `Contents of S.Hash.t | `Inode of S.Hash.t | `Node of S.Hash.t ])
list ->
nb_children:int ->
width:int ->
unit
val pp_results : dump_blob_paths_to:string option -> t -> unit
end
end